How to send a WhatsApp chatbot message triggered by an event via Make
The Integromat service has changed its website address, design and name to Make. The integration options remain the same, but the design may differ from the screenshots shown in the article.
With connector services, you can track events in one system and transfer data to another. For example, you can track orders, payments, abandoned carts, customer registration, incoming messages, and other information and then continue your communication with the customer with SendPulse.
This article will show you how to create a scenario with event tracking in Make, send order data to SendPulse and a message to WhatsApp, or add a contact to an audience with additional data.
Set up the trigger
The first element is a trigger that launches your scenario.
We selected WIX and the Watch Orders trigger for our example.
You can also select other events that start with the word "Watch" as the start trigger. Check the complete list of available triggers in WIX:
Watch Carts | Tracks events when the user adds an item to a cart, completes checkout, drops, or returns to cart in the online store. |
Watch Contacts | Tracks events when a contact is created, or contact details are updated. |
Watch Fulfillments | Tracks events of creating, updating, or deleting orders in the order fulfillment service. |
Watch Orders | Tracks events when orders are created, paid for, canceled, or refunded. |
Watch Collections | Tracks events when product collections are created, updated, or deleted. |
Watch Form Submissions | Tracks events when a form is filled out on the site. |
Watch Messages | Tracks events of incoming and outgoing messages in WIX chat. |
Watch Products | Tracks events when an item is created, updated, or deleted in the store. |
Create a webhook to connect to WIX
If you have not previously connected an app in Make, you need to create a webhook to add a connection to your selected app (in our example, it is WIX).
To do this, click Add in the element next to the Webhooks field. In the window next to the Connections field, click Add.
How to create a Wix connection with Make:
- Go to the developers page in WIX, and create an app for your site in WIX.
- Go to the "Permissions" tab in the left panel, and click +Add Permission. Add permissions to the desired services: Wix Developers, Wix CRM, Wix Coupons,Wix Chat, Wix Stores, and Wix Payments
- Go back to the Oath tab, and paste the following URL into the Redirect URL and App URL fields: https://www.integromat.com/oauth/cb/wix
- In the upper right corner, click Test your app, and select App Market Website. In the dialog box, click Test app.
- In the next window, add your app to the site.
- Go back to the Oath tab, and copy the values from the App ID and App Secret fields.
Read more: How to connect WIX
Go back to the Make scenario builder, enter the copied ID and Secret, and click Connect.
In the next window, select the site and the app you created, and provide an Make permission to retrieve the information.
After a successful connection, copy the resulting webhook URL.
Add a webhook trigger to the WIX app
Go to the developer’s page in WIX, and click +Add Webhook under the Webhooks tab.
Select a category corresponding to the trigger from the API Category list. In our example, it is Wix Stores.
Select the events you want to track, and insert a webhook.
Click Save.
Each time you make changes to the WIX Developers settings, make sure you click Save in the upper right corner to accept the settings.
Read more about configuring the "Watch Orders" and other triggers in the WIX documentation.
Test the trigger
To configure the correspondence of the information received in WIX to the fields written in the Action element, you need to test the data and get the data structure.
Right-click on the start trigger item, and select Run this module only. Run the tracked event in Wix.
Read also: Setting Up Your Store and How to Create Your Online Store.
When you have more items in the scenario, you can click Run once and test the whole bundle.
After a successful test, you will receive the structure of the variables you will receive with this element that you can use later in the scenario.
Set up the action
You can send a message to the users via WhatsApp by phone number or add them to the audience and start the flow.
Action "Send Template Message to Phone"
Click Add another module next to the Wix box.
Add a new SendPulse element, and select the Send a WhatsApp Bot Template message action.
If the user does not initiate the conversation first, you can only send templated messages.
After the user responds and starts the session, you can send free messages through the chatbot.
At the Connection field, you need to click Add and enter the ID and Secret from the API account settings in SendPulse.
Click Continue.
Select the method of user identification — by number or contact ID.
Select the phone variable.
Note that you need to enter the number in the international format. You can add an error handler to continue your scenario in case your message is sent unsuccessfully.
You can also add the Phone element to write the phone number in the international format. You can select only 1 country per item to convert the number. To add more countries, use the Router and multiple Phone elements.
Choose a WhatsApp chatbot.
Read also: How to create a WhatsApp chatbot
Select an approved template.
Read also: How to add a template for WhatsApp campaigns.
To add variables to the message, click Add item under the Components field.
Select the Body type.
Under the Parameters field, click Add item, and select the type of variable.
Select the variable, and click Add.
Note that the SendPulse WhatsApp API does not specify the name of the variables — the variables are substituted in the order in which you add them.
For example, let’s take the following template:
“Hello {{1}} Your order {{2}} is in progress. You can track the status of your order in your personal account. Have a nice day!"
The first variable from WIX should be with the name, and the second variable should be with the order status.
You can keep adding as many variables as your template requires.
To test your scenario, click Run once. To view the data received and sent by the element, click on the number to the right of the element. Apart from that, don’t forget to check the messenger you sent the message to or the chat in your account.
Action "Create a Contact in SendPulse"
Click Add another module next to the "Wix" element, and add a new "SendPulse" element. Select the "Make API call" action.
Note that you can only transfer your contact data once with the "Create Contact" method. To update existing variables, use the "Set Variable" method, but remember to get the contact_id
in other methods first
In the Connection field, select the created connection to SendPulse.
In the URL field, insert the endpoint of the Create a new contact in the WhatsApp chatbot audience request:
/whatsapp/contacts
Select the POST method.
Enter the body of the request in the field:
{
"phone":"string",
"name":"string",
"bot_id":"string"
}
Where:
phone |
The user's phone number in the international format. It is specified in the data received from the client in the previous element.
For variables from the "WIX Watch Order" you can use the |
name |
User name. For variables from the "WIX Watch Order" you can use the Buyer Info: First name variable with a space and Buyer Info: Second name . |
bot_id |
The bot ID of the audience you are adding a contact to You can get it from the address bar on the bot page after bots/whatsapp.
Or you can add the "SendPulse" element with the "Make API call" action, send a request using the "Get list of connected bots" method, and use the |
Note: if you don't have the 1.Buyer Info: Phone
, 1.Buyer Info: First name
and other variables (1
is the element number in Make in which you received this variable. For the starting element, it will always be 1
. If you receive information from several elements, the desired element number may be different), click Run once, and run the flow in the chatbot in which you set up the webhook.
To test the scenario, click Run once. To view the data received and sent by the element, click on the number to the right of the element.
You can also view your bot's audience to check the contact you've added.
Action "Add Tag"
You can add a tag to any contact to filter and segment your contacts by a certain attribute. This way, you can find contacts easier and work with each of them individually.
Click Add another module, and select the SendPulse element with the Set tags to a contact action.
In the Connection field, select the created connection to SendPulse.
Select the messenger you want to send your message to.
Select the contact_id
variable obtained in the previous element.
Enter the tag value.
Additional features
You can also add additional elements and automate the information processing.
Variable filter
You can add a filter between the elements that receive and transmit data to trigger the element only if the transmitted contact has certain information.
For example, you can use a filter when a customer has placed a special order, and you need to share specific information when communicating with them.
To branch scenarios depending on the result of filtering received data and send different messages, add Router between the elements. Next, from the Router element, set up the number of branches that corresponds with your number of filters. Then click on the line, and set the filter conditions. Read more about working with filters: How to filter data using variables.
Error handler
You can also add an error handler so that the scenario will continue even if the element ends with an error.
To add an error handler, right-click on the element, click Add error handler, select the rule, or execute the next element.
For example, if the user has changed the number, entered an invalid number, or stopped using the messenger, which makes the sendout to the number unsuccessful, you can add a sending element to another messenger. For your regular customers, you can set up sending messages to their messenger using contact_id
.
You can check the difference between a scenario branch that is executed if the previous element was executed successfully and a scenario branch that is executed if the previous element was executed with an error by the color of the line. The line between the elements, one of which is added through the "Error handler" element, will consist of empty circles.
Last Updated: 07.10.2024
or