SMS Bot Using Python and Twilio

I built the SMS bot using the Twilio API and Python, which allows you to send a Twilio number messages and get answers back. I got the inspiration of this project and some part of the codes from Make webpage. For this work I used Twilio API, Ngrok, Flask, Wolfram Alpha API, Wikipedia, and yWeather.

Steps:

1. Install ngrok and add the exec file in Mac:

/usr/local/bin

2. Go to twilio webpage (https://www.twilio.com/)and get free API and number (number should have sms capability)
3. Install ngrok and add the exe file here (open /usr/local/bin)
4. You need to get API from Wolfram Alpha (https://products.wolframalpha.com/api/) and add that API to getReply.py line 43.
5. Run run.py
6. Type in terminal (same path as run.py)

ngrok http port_number

You will see on you screen:

Version                                                            
Region                                                    
Web Interface                                              
Forwarding                           
Forwarding 

copy one of the Forwarding address (something like http:// …. .io)

7. Go to your Twilio dashboard and press the “#” on the left. Click on your Twilio number, scroll down and enter the http address into the space that says “A message comes in” in Messaging part. Make sure the dropdown is set to “webhook”. Now paste the Forwarding address here!
8. Open sms app on your mobile and type your question and send in to your Twilio number. (e.g., wiki Barak Obama )
9. Thanks to Sophia Smith and me, now you have working SMS chatbot 🙂

Continue reading