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#
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.
Algorithm for creating 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:
Setting up an instance
When using the Watch webhooks trigger, instance setup is automatically installed:
"webhookUrl": "webhookserver make",
"incomingWebhook": "yes"
The order of setting up a trigger:
- Create a new scenario
- Click on the
+
sign, find GREEN-API for WhatsApp in the list of applications

- Select the Watch webhooks trigger at the beginning 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 your instance's
idInstance
andapiTokenInstance
values(Script will receive messages from the number associated with this instance)

The
Connection name
field can be used to name the instance being added (e.g. "work number" or "sales").This will allow you to easily find the desired account in the list of available integrations when creating.
- Click
Save
to save the values.
- Test by clicking the
Run once
button.
If the selected instance has incoming messages and the test is successful, click themagnifying glass
to see which fields will be available when configuring the action.

Done! The trigger is set up and 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#
-
Create a new "Send Message" module from the Green-API integration
-
As a recipient, select the sender from the
incomingMessageReceived
notification received in the Watch webhooks module -
The text message will be the response from the language model. Select the
Result
variable from the Create a Completion module -
Launch automation by clicking the switch in the corner of the screen
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 make messaging between WhatsApp and Discord