How to Create a WhatsApp Echo Bot Using the Green API in n8n#
Echo bot setup procedure:
Setup the GREEN-API application#
Setting up the GREEN-API application is described in detail in the Integration Setup section.
Create a scenario#
-
Create a workflow by clicking
Create Workflow.
-
Click
Add first step...to open thenode panel.
-
Find the
GREEN-API for WhatsAppnode.
Setup receiving incoming messages#
To receive messages in n8n, you need to set up a trigger.
Trigger is the event that starts your scenario. For example, it could be a new message in WhatsApp, a new entry in Google Sheets, or something else.
Trigger setup procedure:
-
Add the trigger
On incoming message(the scenario is run when a message is received). -
In the connection credential selection field, click
Create new credential.
-
Enter
idInstanceandapiTokenKeyfrom GREEN-API personal account. Save your connection credentials by clickingSave.
-
Go to the module settings, click
Execute step, and send a test webhook of theincomingMessageReceivedtype to your webhook'stestUrlto get sample data that will be used in the next module. Alternatively, send a test WhatsApp message to the number associated with the instance. The received data will be displayed inOutput.
Send 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.
-
Add the
Send Messagetext message sending module.
-
Use the data received in the webhook module,
senderData.chatIdandunifiedMessageText, to send a message. Drag them into the correspondingchatIdandMessagefields in theSend Messagemodule parameters.
-
Enable persistent
Workflow.
This completes the bot setup. Now, when you send a message to the number linked to the instance, you'll receive a reply with the same content.