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.


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


2. Go to twilio webpage ( 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 ( and add that API to line 43.
5. Run
6. Type in terminal (same path as

ngrok http port_number

You will see on you screen:

Web Interface                                              

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