Skip to content

How to сreate a WhatsApp echo bot use Green-API in Zapier#

Zapier — is an intuitive business process automation tool that allows you to connect various web applications such as Discord, Slack, and Gmail with WhatsApp

In this tutorial, we will introduce the process of creating an echo bot for WhatsApp that will automatically reply to messages received. This bot is implemented using Zapier tools and Green API.

To create an echo bot using Zapier, you will need to:

  • Create an account in Zapier and automated Zap process

  • Create an instance in your console and authorize it

  • Enable incoming notifications in instance settings

  • Setup to receiving and sending messages in Zap

Table of contents#

  1. Setup Zapier
  2. Create and configure an instance
  3. Сreate a WhatsApp echo bot
  4. Launch and test the echo bot

1. Setup Zapier#

Go to the Zapier sign-up page and enter your details to register.

Zapier sign-up

Once registered, please confirm your email address, then run the automation you created.

2. Create and configure an instance#

To start working with Green-API, you need to register and get idInstance and apiTokenInstance in your console.

An instance is an individual gateway number that allows you to send and receive messages via WhatsApp. It is created on your console and is used to work with WhatsApp API webhook.

We recommend that you pay attention to our free Developer plan. This plan takes all of your testing and development needs.

To send messages, you must first authorize the instance. To do this, go to the instance page in your console and get a QR code to link devices. Then, in the WhatsApp or WhatsApp Business mobile app, go to the "Linked devices" section and scan the received QR code. After that, your instance will be authorized.

Image with fields
The instance information is located on its page

You use the instance data later. To receive incoming messages, go to set up incoming notifications. Click the "Edit" button on the instance page, and enable the "Receive webhooks on incoming messages and files" setting. In the "Notification sending address (URL)" field, insert the address that will generated in the next step when setting up Webhook in Zapier.

3. Сreate a WhatsApp echo bot#

Automations in Zapier are written using Zap. Let's create a new Zap on the main page.

Create new Zap. Step 1 Create new Zap. Step 2

The main workspace is used to create and edit actions and automation triggers. First, set up a trigger, the event from which to launch the automation. In our case, the trigger will be triggered upon receipt of an incoming message.

In this guide, WebHook will be used to receive notifications. All ways to receive notifications in Zapier are described in the article Setup incoming notifications in Zapier.

The trigger is created as follows:

  1. Click on the trigger selection block

    Image. Create a trigger

  2. Select "WebHooks by Zapier" as the Zap script trigger in the new window

    Image. Choose "WebHooks by Zapier"

  3. Set event type to "Catch Hook"

    Image. Choose "Catch Hook"

  4. Move to the "Test" tab by double-clicking the "Continue" button

  5. Copy the link from the "Webhook URL" field

    Image. Copy the link

  6. Paste this link into the "Notification Sending Address (URL)" field on the instance page

    Image. Add link on the instance page

  7. Wait a few minutes for the settings to apply. Then send a message to the number that is linked to the instance

  8. Click on the "Test Trigger" button and select the query that appears

    Image. Choose the query

After setting up the incoming call, create an action that will suit the user with the same text. The sendMessage method and the received data from the test notification will help with this.

4. Launch and test the echo bot#

  1. Firstly, create an action with the "WebHooks by Zapier" app

    Image. Click on action block

    Image. Select WebHooks by Zapier

  2. Select POST request type

    Image. Select method action

  3. Specify URL as described in the documentation {{apiUrl}}/waInstance{{idInstance}}/sendMessage/{{apiTokenInstance}}:
    - apiUrl - API host link
    - mediaUrl - API host link for sending files
    - idInstance - instance unique number
    - apiTokenInstance - instance access key

    Image from documentation URL
    Image filled url

  4. Method sendMessage has a payload type of JSON, select it in the Payload Type field.

  5. Two fields in the request body must be filled in to send a message: message and chatId. Firstly, fill in the chatId field, which specifies the recipient's number. In our case, this number will be the sender's number. We take it from the Sender Data Chat Id field of the incoming notification.

    Image filled chatId

  6. The message field specifies the message for the recipient. Copy the text of the incoming message from the Message Data Text Message Data Text Message field.

    Image filled message

  7. You may test the method by clicking the Test Step button on the Test tab.

    Image testing

After setting up your incoming notifications and creating an action, launch the echo bot by clicking the "Publish" button in the last step of your automation, or by clicking the button at the top of the screen.

Image with button publish
Button "Publish"
Image with button place
Button at the top of the page

Now your Zap is in action and you can communicate with the echo bot in WhatsApp. To check the bot's functionality, try sending it a message in the chat, and it will respond in kind.

GIF demo of bot work