Testing

Start the chatbot by running

python bot.py

or

python3 bot.py

Make sure that the python virtual environment is activated

Your output should be something like this:

(whatsapp-bot-venv) $ python bot.py
 * Serving Flask app "bot" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Now open a second terminal window run ngrok http 5000 to allocate a temporary public domain that redirects HTTP requests to our local port 5000. 

Your output should look as follows:

Now back to the Twilio console,

  • Click on Programmable Messaging, then on Settings, and finally on WhatsApp Sandbox Settings.
  • Copy the https:// URL from the ngrok output and then paste it on the “When a message comes in” field.
  • Append /bot at the end of the URL. (Make sure to do this, otherwise, you could spend a long time debugging.)
  • Make sure the request method is set to HTTP Post. At the end, remember to click on the Save button to save all your changes.

 

               

Now you can start sending messages! 

 

 

 

 

 
Discussion

5

0