Skip to content

How to Create a WhatsApp Echo Bot Using the Green API in n8n#

Echo bot setup procedure:

  1. Setup the GREEN-API application
  2. Create a scenario
  3. Setup receiving incoming messages
  4. Send a message

Setup the GREEN-API application#

Setting up the GREEN-API application is described in detail in the Integration Setup section.

Create a scenario#

  1. Create a workflow by clicking Create Workflow.

    workflow

  2. Click Add first step... to open the node panel.

    app

  3. Find the GREEN-API for WhatsApp node.


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:

  1. Add the trigger On incoming message (the scenario is run when a message is received).

  2. In the connection credential selection field, click Create new credential.

    credential

  3. Enter idInstance and apiTokenKey from GREEN-API personal account. Save your connection credentials by clicking Save.

    console

  4. Go to the module settings, click Execute step, and send a test webhook of the incomingMessageReceived type to your webhook's testUrl to 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 in Output.

    app


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.

  1. Add the Send Message text message sending module.

    empty-action

  2. Use the data received in the webhook module, senderData.chatId and unifiedMessageText, to send a message. Drag them into the corresponding chatId and Message fields in the Send Message module parameters.

    send-message

  3. Enable persistent Workflow.

    connection-action

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.