How to create an AI-powered chatbot with OpenAI in WhatsApp?#
To create a chatbot using generative AI and integrate OpenAI into Make, we will need a Green-API account with an instance configured, as well as Make and OpenAI accounts.
Table of Contents#
- Setting up the GREEN-API application
- Creating a scenario
- Setting up receiving incoming messages
- Processing the request through OpenAI
- Sending the response message to the user
- Testing the functionality
Setting up the Green-API application#
Setting up the Green-API application is described in detail in the section Configuring Integration
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 triggered in one of the applications, Make automatically performs an action in the other.
Scenario template
You can create a scenario according to the instructions below or use our ready-made template.
Steps to create a scenario:
- Log in or register an account in Make
- Click the
Scenarios
button in the sidebar menu

- On the scenarios page, click
Create a new scenario
to 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:
Trigger is an event that activates your scenario. For example, it could be a new message in WhatsApp, a new entry in Google Sheets, or something else.
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"
The order of setting up a trigger:
- 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 webhook
to add a webhook -
Click
Create a connection
to add a connection to the instance- Specify the values of your
idInstance
andapiTokenInstance
(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
ChatId
field:
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
Save
to 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!
Error processing webhook
- If the
OpenAI
module receives an error like the one below when running the script, you need to set a filter between theWatch webhooks
modules and theOpenAI
module

- In the filter, set a condition where
type Webhook
must be equal toincomingMessageReceived
.


Processing a request via OpenAI#
This step configures sending a user message to the OpenAI integration to receive a response from the neural network.
-
Find OpenAI among integrations
-
To generate a response to the user, select the Create a Completion (Prompt) module
-
Before further configuration, get the
Api key
andOrganization ID
from your OpenAI account- Register or log in to your OpenAI account
- Go to the
Api Keys
tab and click theCreate new secret key
button
- Enter the name of the key and click the
Create secret key
button
- Save the received key
- In addition to the
Api Key
, you need theOrganization ID
. It is located on theGeneral
tab
-
Enter account data in the module
- Click the
Create a connection
button
- Paste the data into the
API Key
andOrganization ID
fields obtained in step 3
- Click the
-
The next step is to select a model that will generate a response to the user. Each model from the list has its own advantages and disadvantages, which can be found in the official documentation.
For our purposes, the "gpt-4o-mini" model is suitable, as it offers high quality answers with fast generation speed and low cost
-
Create a request to the model. At this stage, you need to select a role and its message
In this example, we will create a request with the Developer / System role to pass the username and dialogue format to the model.
What are roles and what is the difference between them?
When using the OpenAI API, you may encounter the fact that when forming a request to ChatGPT, the request has a "Role". What is the difference between them?
-
A request with the Developer / System role is a request directly to the language model, setting its context and behavior. For example, you can make the model's tone more formal or provide additional information on the basis of which the model will form a response
-
A request with the User role passes a user request to which the language model responds
-
To do this, click on the
Add message
button -
Choose a role. First, let's create a Developer / System role with additional instructions for the model
-
Fill in the message by mentioning the username based on the senderName
-
Create a second request from the User role, passing the variable with the user message in the
Text Content
fieldSince the message text can be passed in different fields depending on the message type, it is recommended to specify the condition:
"iftextMessageData: textmessage
is not empty, then use it; otherwise, useextendedTextMessageData.text
"
-
Before moving on to the next step, you need to send a message again to the number linked to the instance for further configuration
Sending a response message to the user#
-
Select an application to perform the action.
To do this, find GREEN-API for WhatsApp in the list of applications -
Select
Send a Message
module -
From the
Connection
list, select a ready-made connection or add a new connection by clicking theadd
button.When adding a new connection, specify your instance values
idInstance
andapiTokenInstance
Then click
Save
to save. -
As a recipient, select
chatId
from theincomingMessageReceived
notification received in the Watch Incoming Webhooks module- Click on the
Chat Id
input field. - A window will open on the right with data received via the trigger.
- Specify the
chatId
variable from theSender Data
object as theChat Id
.The number is formatted automatically.
- Click on the
-
Enter the text of the message in the
message
field. Select theResult
variable from the Create a Completion module
How to quote an incoming message in a response?
To add a quote in the message you send, fill in the quotedMessageId
field with the ID Message
variable

- Click
Save
to save the values.
Testing the work#
To test the automation, it is enough to send a message to the number linked to the instance. In a few seconds, a response message will be sent in response, containing a response from ChatGPT, and in Make you will be able to see the successful execution of the automation.

The personal AI chatbot for WhatsApp to communicate with users is set up and ready to go.
Examples of using the GREEN-API application#
How to make messaging between WhatsApp and Slack
How to Set Up Messaging Between WhatsApp and Discord