Skip to content

How to run a demo chatbot locally from a docker container?#

This article is a step-by-step guide to running chatbot demo on your computer using a pre-staged Docker image.

The demo chatbot is available in the public repository docker hub and includes a fully configured launch environment.

To get started, you need to create an instance in console and then install Docker on your computer. After this, you can easily launch the image by running a few simple commands on your device's command line.

  1. Registration and creation of an instance
  2. Installing docker on your computer
  3. Downloading the image from our public docker hub repository
  4. Running a container via the console
  5. Running a container using a config file

Register and create an instance#

If you are not yet registered on our service, create an instance here.

In order to send messages or use other GREEN API methods, your WhatsApp account in the phone application must be in an authorized state. To authorize your instance, go to console, create an instance and scan the QR code using the WhatsApp application.

Installing docker on your computer#

Docker installation is required to work with images. If you already have Docker installed, you can skip this step.

To install Docker, go to the official Docker website and follow the installation instructions.

To run our image, you only need Docker Engine.

Downloading the image from our public repository docker hub#

To download the image, just open the command line and run the following command:

   docker pull greenapisupport/whatsapp-demo-chatbot-python:0.0.0

Running a container via the console#

To launch the container from the newly downloaded image, run the command below:

   docker run --name whatsapp-demo-chatbot-python -e INSTANCE={{INSTANCE}} -e TOKEN={{TOKEN}} greenapisupport/whatsapp-demo-chatbot-python:0.0.0

Where {{INSTANCE}} and {{TOKEN}} are your instance number and its token, respectively. You can find them in console.

Running a container using the config file#

An alternative way to run a container is using a configuration file. To do this, you need to create a file called config.ini. Inside the file you need to specify the following parameters:

[DEFAULT]
INSTANCE = value_of_your_INSTANCE
TOKEN = value_of_your_TOKEN

To have your instance settings automatically loaded from the file you created, run the following command:

   docker run -v {{root}}:/app/instanceData --name whatsapp-demo-chatbot-python greenapisupport/whatsapp-demo-chatbot-python:0.0.0

Instead of {{root}} specify the path to the folder with your config.ini file Now you can send messages to a number connected to the instance and test the bot.

To stop the bot, press Ctrl + C in the command line window or run the command:

   docker stop whatsapp-demo-chatbot-python