How to Create WhatsApp Echo Bot Using GREEN-API in Make#
How to create an echo bot:
- Setting up the Green-API application
- Creating a scenario
- Setting up receiving incoming messages
- Sending a message
- Launching and testing the bot
Setting up the Green-API application#
Setting up the Green-API application is described in detail in the section Integration setup
Creating a scenario#
A Scenario is an automated process created in Make.
Each scenario consists of a trigger and an action. When a trigger is fired in one application, 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.
Steps to create a scenario:
- Log in or register an account in Make
-
Click the
Scenariosbutton in the sidebar
-
On the scenarios page, click
Create a new scenarioto create a new scenario
-
Scenario successfully created!
After creating the scenario, a plus sign (adding a module) will appear on the Make page.
Setting up receiving incoming messages#
To receive messages in Make, you need to set up a trigger:
Setting up an instance
When using the Watch Incoming Webhooks trigger, instance setup: is automatically installed
"webhookUrl": "https://hook.eu2.make.com/xxxxxxxxxxxxxxxxxxxx",
"incomingWebhook": "yes"
- Create a new scenario
-
Click on the
+sign, in the list of applications find GREEN-API for WhatsApp
-
Select the Watch Incoming Webhooks trigger at the top of the list

-
Click on the added module to open its settings
-
Click
Create a webhookto add a webhook
-
Click
Create a connectionto add a connection to the instance
- Specify the values of your
idInstanceandapiTokenInstance
(The script will receive messages from the number linked to this instance)

The Connection name field can be used to name the instance being added (for example, "work number" or "sales").
This will allow you to easily find the required account in the list of available integrations when creating. - Specify the values of your
Filter messages by sender number
By default, the script activates when a message is received from any number.
To run the script when a message is received from a specific number (or several specific numbers), use the chatIds parameter.

-
The number can be selected from the contact list by clicking on the drop-down list icon:

-
The number can be added manually by entering it in the
ChatIdfield:
When filling in the number manually, enter it in international format + postfix c@us - phoneNumber@c.us.
For example: 79876543210@c.us.
To add multiple numbers, add the required number of fields by clicking Add item

- Click
Saveto save your settings
- Test by clicking
Run once.
If the selected chat has incoming messages and the test is successful, click the magnifer to see what fields will be available when configuring the action.

Done! The trigger is set up, ready to use!
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.
To do this, find GREEN-API for WhatsApp in the list of applications

-
Select
Send a Messagemodule
-
From the
Connectionlist, select a ready-made connection or add a new connection by clicking theaddbutton.When adding a new connection, specify your instance values
idInstanceandapiTokenInstanceThen click
Saveto save.
-
As a recipient, select the sender from the
incomingMessageReceivednotification received in the Watch Incoming Webhooks module- Click on the
Chat Idinput field. - A window will open on the right with data received via the trigger.
- Specify the
chatIdvariable from thesenderDataobject as theChat Id.

- Click on the
-
In the
Messagefield, specify the variable with the message text.Since the message text can be transmitted in different fields depending on the message type, it is recommended to specify the condition: "
extendedTextMessageData.textshould only be used iftextMessageData: textmessageis empty"
-
Click
Saveto save the settings -
Run a test by clicking the
Run oncebutton. If the test is successful, click on themagnifying glassto see the action result details
Done! Echobot is ready to run
How to configure the bot to respond only to certain messages?
In some situations, it may be useful for the bot to respond only 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 linking the webhook and sending the message.

As an example, we will check the incoming message for the phrase !green-bot.
- In the
Conditionparameter, we specify a variable with the message text.
Since the message text can be transmitted in different fields depending on the message type, it is recommended to specify the condition:
"iftextMessageData: textmessageis not empty, then use it; otherwise, useextendedTextMessageData.text"
- In the
Text operators: Equal toparameter, specify the text that the bot will respond to

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

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 request, we will use the Replace module from the built-in Text parser application.
Create a module between the webhook and sending a message

Select the Replace module

In the Pattern field, enter the phrase that we will delete. In our case, !green-bot (with a space at the end)

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

As the text for processing, select textMessage

In the Send a Message module, replace the text of the response message with output of the Replace module

After this setup, 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 that the echo bot works continuously, you need to run automation by activating the switch.

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

This completes the bot setup.