
Open your folder with a code editor mine is vscode your project folder should now have the have the venv folder mine is whatsappbot, go create a file bot.py in the root folder outside the venv directory.Īdd the following code in the bot.py file to make an application that prints “Hello bot” save the file and close:
#Build a whatsapp chatbot with python install#
Pip install Flask messagebird requests gunicorn jinja2 werkzeug urllib3 In your terminal navigate to the directory you created in step 2 and enter the following command replacing whatsappbot with your own name.Īctivate the virtual environment in Linux and MacOS with, replace whatsappbot with the name of the environment you created in step 2:įor Windows, activate the virtual environment with, replace whatsappbot with the name of the environment you created in step 2: If you already installed a virtual environment skip step 1.Ĭreate a directory or folder where you will create your environment use a version of python in your machine, I’m going to use python3 in this tutorial

When you send your first message to that number you will be assigned a unique channel id, but when you are verified to use your own number you will also get your own channel id which we will use to communicate with our bot. As of now, we can use the Messagebird sandbox to test our bot so let’s dive into it.Ĭonnect your phone to the sandbox from the Messagebird dashboard, click on WhatsApp then WhatsApp sandbox. The first step is to get access to use the WhatsApp API use this link to get access, once you sign up and you are in the dashboard navigate to WhatsApp and follow the instructions on setting up your own number to work with the API.

In this tutorial, I’m going to build a chatbot using the Messagebird API for WhatsApp and the Flask framework for Python.
