How to create an AI-powered chatbot with OpenAI in WhatsApp?#
The Make platform offers extensive opportunities for automating various processes. We have covered in previous articles how to automate messaging between WhatsApp, Discord, and Slack, as well as how to set up message broadcasting using Google Sheets. In this article, we will consider how to use Google Sheets and GREEN-API to automate mailings in WhatsApp.
To follow along, you'll need a GREEN-API account with an instance set up, as well as accounts on Make and OpenAI.
Content#
- Setting up the Make application
- 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 Make and Green-API applications#
Setting up Make and Green-API applications is described in detail in the section Integration setup
Creating a scenario#
Scenario - an automated process created in Make. Each scenario consists of a trigger and an action. When the trigger is activated in one of the Make applications, it automatically performs an action in another.
Script template
You can create a script using the instructions below or use our ready-made template.
Algorithm for creating a scenario:
- Log in or register an account on Make
-
In the sidebar menu, click on the
Scenarios
button -
On the scenarios page, click
Create a new scenario
, to create a new scenario
The scenario has been successfully created!
Setting up receiving incoming messages#
After creating the scenario, you can configure receiving incoming messages. Let's set it up using Webhooks technology.
Useful
You can find detailed configuration of the GREEN-API integration, as well as other ways to receive messages, in the article on integration setup.
-
Create a new module to receive incoming messages. In the list, select the "GREEN-API" integration
-
Select the module for receiving the incoming webhook – "New Message Webhook"
-
Select the webhook
How to create a webhook?
-
- Click the
add
button in the module window
If the webhook and instance connection do not exist yet, create them using the following steps:
- Then, select the connection to the instance or create it by clicking the
add
button in the window that appears
- Click the
-
-
To receive incoming notifications, you need to enable notifications for incoming messages in the personal account interface or by using the SetSettings method. Applying the settings may take up to 5 minutes
Before proceeding to the next step, you need to send a message to the number associated with the instance in order to continue configuring the integration
Error processing webhook
-
If the
OpenAI
module receives an error like the one below when running the scenario, you need to install a filter between theNew Message Webhook
module and theOpenAI
module. -
In the filter, set the condition where
typeWebhook
must be equal toincoming Message Received
.
Processing the request through OpenAI#
In this step, we will set up sending the user's message to the OpenAI integration to get a response from the neural network.
-
Among the integrations, find "OpenAI"
-
To generate a response for the user, select the "Create a Completion" module
-
Before proceeding with the configuration, we will need to obtain the
Api key
andOrganization ID
from the OpenAI account's personal dashboard- To get the
Api Key
, you need to sign up or log into your OpenAI -
Go to the
Api Keys
tab and click theCreate New Api Key
button
-
Enter a name for the key and select a project. In our case, it will be "Default Project." After entering all the required information, click the
Create New Key
button -
Save the generated key
-
In addition to the
Api Key
, you will also need theOrganization ID
. It can be found in theGeneral
tab
- To get the
-
Enter the account details in the module
-
Click the
Create a connection
button -
Paste the data into the
API Key
andOrganization ID
fields obtained in step 3
-
-
The next step is to choose the model that will generate the response for the user. Each model in 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 provides high-quality responses with fast generation speed and low cost
-
Let's create a query for the model. At this stage, we need to select a role and its corresponding message
In this example, we will create a request with the "System" role to pass the user's name and the dialogue format to the modelWhat are roles and what’s the difference between them?
When using the OpenAI API, you may encounter the concept of a "Role" in a request to ChatGPT. What is the difference between them? * A request with the "System" role is a direct input to the language model, setting its context and behavior. For example, you can make the tone of the model more formal or provide additional information that the model will use to generate the response * A request with the "User" role represents the user's input, to which the language model responds
-
To do this, click the
Add message
button -
Select the role. First, we will create the "System" role with additional instructions for the model
-
Fill in the message, mentioning the user's name based on the senderName
-
Then, create a second request with the "User" role, passing the user's message in the
Text Content
field
-
Before proceeding to the next step, you need to send a message to the number associated with the instance again to continue the configuration
Sending a reply message to the user#
-
Creating a new module "Send Message" from the integration of the GREEN-API
-
For the recipient, choose the sender from the first message
-
The text message will be the response from the language model. Select the "Result" variable from the "Create a Completion" module
-
Run the automation by toggling the switch in the corner of the screen
Testing the functionality.#
To test the automation, it is enough to send a message to the number associated with the instance. After a few seconds, a reply message will be sent in response, containing a response from ChatGPT, and in Make you can see the successful completion of automation.

Thus, we have set up a personal AI chatbot in WhatsApp for communication with users.
Examples of using the GREEN-API application#
How to make messaging between WhatsApp and Slack
How to make messaging between WhatsApp and Discord