Skip to content

This repository contains the details and documents on how to build a WhatsApp Chatbot

Notifications You must be signed in to change notification settings

gauravchopracg/WhatsApp-Chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WhatsApp-Chatbot

This project aims to illustrate how to build a chatbot for WhatsApp using the Twilio API for WhatsApp and the Flask framework for Python.

recognized_example.png

Requirements

The following installation has been tested on MacOSX 10.13.6 and Ubuntu 16.04.

This project requires Python 3, a smartphone with an active phone number and WhatsApp installed, a Twilio account and the following Python libraries installed(plus a few others depending on task):

  1. Clone the repo
git clone https://github.com/gauravchopracg/WhatsApp-Chatbot.git
cd WhatsApp-Chatbot/
  1. Install Dependencies
pip install -r requirements.txt
  1. Configure the Twilio WhatsApp Sandbox From your Twilio Console, select Programmable SMS and then click on WhatsApp. Now, from your smartphone send a WhatsApp message with the given code to the number assigned to your account.

recognized a3Dg7ccP5QFcnxWM6N0kmUDk7VqvuL5M538UfEg-yxMc2r.width-500.png

  1. Configuring the Chatbot
$ cd Code/
$ 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)

Open a second terminal window and run ngrok http 500 from the folder where you have downloaded ngrok. The output of ngrok should be something like this:

recognized Nxko6w14yHUPvkOMTcRokS1kt_vEMeW9v4Q9Q3rtBgSrdA.width-500.png

Now you need to copy the https:// URL from the ngrok output to Sandbox in the Twilio Console on WhatsApp and append /bot at the end of the root ngrok URL.

recognized e2z9Pv472N9CRz9516JFpnnS7GgQm0HjHPtAmJQkBh6kwg.width-500.png

Testing the Chatbot

Now you can start sending messages to the chatbot from the smartphone that you connected to the sandbox.Type any sentence with words "quote" and "cat" in them.

recognized_example.png

Deployment

To deploy a WhatsApp chatbot for production use, skip the step of using ngrok and choose a cloud server for deployment of application. The two most common production ready web servers for Python web applicaiton are gunicorn and uWSGI after that you can simply run chatbot by following:

$ gunicorn -b :5000 bot:app

Credits

The credits for this project goes to Miguel Grindberg and twilio for creating amazing tutorials on how to create web applications using Python and Flask framework integrated with Twilio API.

About

This repository contains the details and documents on how to build a WhatsApp Chatbot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages