![]() ![]() using the combined power of Africas Talking and python you can easily handle sending one, a few or a lot of messages. Now we can Finally run python multiple-sms-csv.py and watch the output on the terminal. However, its not uncommon for messages to fail due to a variety of reasons hence I added a try block and get notified via the terminal and retry later. Py delete own message this code will send HI for 3 seconds when the user says HI discord. We then create a message variable to hold our customized message. This allows you to mass delete messages from a channel. I could ofcourse have hard-coded the date as a string,however I wanted this script to be reusable and easy make modifications going The meeting was scheduled for 5 days from the current day, using the datetime module I did quick calculations using the timedelta() function. Inorder to send messages to each member we need to iterate over each row, however the first row is just default column headers thus we need to skip them hence: if number != "Number: We then proceed to assign variables to each value. From each row we get the value of name and numbers using list unpacking, this will ofcourse change based on the layout of your csv. Inside the function we open the csv and use the reader() function from the inbult csv module to parse each row. The above code creates a function send_messages(). ![]() The message is read from a message file and sent to all contacts. Your contacts must be specified in a CSV file, where the first column is the phone number. env and enter the following replacing the placeholders with your account credentials: Simple Twilio bulk SMS client (in Python) Description This script will send mass SMS out to many people using the Twilio API. Let's add those credentials now.Ĭreate a file called. Needed to authenticate with the Africas talking API. On how to use environment variables in python.įor this use case I am using the python-dotenv package to store the credentials Our credentials in a separate file for security reasons. In this case it's the africastalking python sdk and python-dotenv module to aid keeping Line 4 and 5 uses built-in python package manager, pip to install the required modules. Recommend or pyenv-win for Windows users. You don't have to use theĭefault venv module, pyenv is a great alternative I would The main python system version as well avoid version conflicts. I'll breakdown the code above, Line 1 and 2 creates a working directory and changes into the directory.įollowing best practices, in line 3 and 4 we create and activate virtual environment to prevent cluttering Enter fullscreen mode Exit fullscreen mode ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |