Skip to content

How to Create WhatsApp Echo Bot Using GREEN-API in Make#

In the Make service, the GREEN-API platform has its own application (alternative link to the application), with which you can send messages to WhatsApp.

What should I do if an installation error occurs?

If an error occurs when installing the application using the specified links in Make, we recommend that you specify in the link the subdomain in which you were authorized on the site.
The subdomain determines the availability of the site via a link.
Examples of available domains: eu1, eu2, us1, us2.

EU1

In this tutorial, we'll walk through the process of creating an echo bot for WhatsApp that will automatically reply to received messages. The bot is implemented using the GREEN-API application for the Make platform.

Contents#

  1. Setting up the Make application
  2. Setting up the GREEN-API application
  3. Creating a scenario
  4. Setting up receiving incoming messages
  5. Sending a message
  6. Launching and testing the bot

Setting up Make and Green-API applications#

Setting up Make and Green-API applications is described in detail in the section Integration setup

Creating a scenario#

Scenario (scenario) - an automated process created in Make. Each scenario consists of a trigger and an action. When a trigger is fired in one of the applications, Make automatically performs the action in the other.

Scenario template

You can create a scenario according to the instructions or use our ready-made template.

You can create a scenario from the "Scenarios" section of the side menu by clicking the "Create a new scenario" button.

Image with transition to the tab

After that, the scenario workspace will appear, in which you can make further adjustments.


Setting up receiving incoming messages#

To start using the application in Make, you need to get the instance data. Information on how to create an instance and retrieve its data can be found at link.

The instance must also be authorized. This action links the WhatsApp account on your phone to the instance, allowing you to send and receive messages. Detailed instructions on authorizing the instance are provided in the article "Quick Start" в нашей документации.

The scenario should be run after the echo bot receives an incoming message. In this tutorial, we will look at the process of receiving notifications via WebHook.

Other ways to set up notifications can be found at link.

To receive incoming notifications via WebHook, use the "New Message Webhook" trigger from the GREEN-API integration. Let’s set it up as follows.

  1. Click on the plus sign and find "GREEN-API" in the list of applications

    Image with scenario creation Image with application search

  2. Select the "New Message Webhook" module

    Image with scenario creation Image with trigger selection

  3. Click on Add to add a webhook to the instance from which notifications will be received

    Image with scenario creation Image with new WebHook added

  4. In the window that opens, click Add to add a connection to the instance

    Image with scenario creation Image with new instance added

  5. Enter a value from the authorized instance, where:

    • Connection name - arbitrary name of the connection to the instance (not to be confused with the instance name)
    • ID Instance and Api Token Instance - your instance authorization data
      Image with scenario creation Image with instance data input
What should I do if an error occurs when trying to connect an instance?

When trying to connect an unauthorized instance, a notification with the error Unexpected status notAuthorized. Should be "authorized" will appear. This error can be removed by authorizing the instance, linking the WhatsApp account to the instance

Image with scenario creation Image with error when connecting instance

  1. Save the webhook data by first clicking on the "Save" button, and then on the "OK" button

Before further configuration, you will need to send a test message to the phone number associated with the instance.

  • To do this, temporarily run the automation by clicking on the "Run Once" button

    Image with scenario creation Image with the scenario launch button

  • Send a text message to the phone number associated with the instance. In a few seconds, you should receive an incoming notification, the data from which will be required for further configuration

    Image with scenario creation Image with received notification

How to receive notifications only from a specific chat or group?

In the "Create a webhook" window, in the "Only From Specify Chat" section, select "Yes".
You can specify a chat manually by selecting the "Manual" type in the Chat ID source, or through the contact list by selecting "From Contact List".
When filling in the number manually, you need to enter the number in the format phoneNumber@c.us. For example: 0100123456789@c.us.

You must enter the full phone number in international format. Do not use plus signs, zeros, brackets or hyphens when entering a phone number in international format.

Image with scenario creation specify-chat-yes-manual

When selecting a number from the contact list, you must select the desired chat in the drop-down menu in the Chat Id section.

Image with scenario creation specify-chat-yes-contactlist


Sending a message#

After setting up the receipt of incoming messages, you need to create an action that will respond to the user with the same text. The sendMessage method will help with this.

To send messages in Make, you need to add and configure the "Send Message" module.

  1. To add an action, click on the semicircle next to the trigger. An empty gray circle with a plus sign will appear (add app)

    Image with scenario creation add-action

  2. Select an application to perform the action, to do this, find GREEN-API in the application list

    Image with scenario creation empty-action

  3. Select the SendMessage method

    Image with scenario creation send-message

  4. From the Connection list, select a ready-made connection or add a connection by clicking the Add button

    Image with scenario creation connection-action

  5. In the Chat ID source field, select Manual

    Image with scenario creation Image with Chat ID Source selection

  6. To reply to a user who wrote to the bot, you need to define them as a recipient. To do this, in the Chat Id field, you need to specify the value of the chatId variable, which is located in the senderData section of the incoming notification

    Image with scenario creation Image with chatId selection

  7. In the Message field, paste the textMessage variable from the messageData section. Then click OK
    Image with scenario creation Image with textMessage selection
  8. Make a test by clicking the Run once button. If the test is successful, click on the zoom in icon to see details of the action result
    Image with scenario creation test-action

Done! Echo Bot is ready to launch

How can I configure the bot to only respond to certain messages?

In some situations it may be useful for the bot to only respond to certain messages from the chat, for example when the bot is in a group. Let's configure our bot to respond to messages with the text !green-bot. To do this, we will use filters. You can configure them by clicking on the dots that connect the webhook and sending the message.

Image with scenario creation Image with click on the connection between receiving and sending a message

After this, a window with filter settings will open, in which Label is an arbitrary filter name, and the presented text fields use comparisons with each other according to the condition selected in the Text operators menu.
In our case, we will check the incoming message for the phrase !green-bot. To do this, insert the variable textMessage from the messageData section into the first field.

Image with scenario creation Image with textMessage variable selected

In the second field we write the phrase to which the bot will react

Image with scenario creation Image with the phrase entered in the second field

We set the check condition to Starts with to check for the presence of the phrase at the beginning of the message

Image with scenario creation Image with operator selection

Now the bot will only respond to messages starting with !green-bot. To remove this part of the message and get only the user's text query, we will use the Replace module from the built-in Text parser application.
Create a module between the webhook and sending a message

Image with scenario creation Image showing module creation between webhook and message sending

Select the Replace module

Image with scenario creation Image with Replace module selected

Enter the phrase we will be deleting in the Pattern field. In our case, !green-bot (with a space at the end)

Image with scenario creation Image with input phrase for replacement

In the New Value field, insert the emptyString variable to replace the phrase with an empty string

Image with scenario creation Image with empty string selection for replacement

As the text to be processed, select textMessage

Image with scenario creation Image with text selection for processing

Replace the text of the response message in the SendMessage module with the output of the Replace module

Image with scenario creation Image with selection of processed line in SendMessage module
After this setting, the bot will only respond if the phrase !green-bot is entered at the beginning of the message


Launching and testing the bot#

To ensure continuous operation of the echo bot, you need to start automation by activating the switch.

Image with scenario creation Image with scenario running

Now the bot is running and ready to work. You can check its functionality by writing to the number linked to the instance. The bot will respond with the same message in response.

GIF showing the bot in action

This completes the bot setup.