How To Create a Bot That Sends Multiple Webhook Responses Via One Trigger
In this document, we will show you how to send multiple webhook responses from one trigger action.
In this document, we will show you how to send multiple webhook responses from one trigger action. E.g. an admin presses a button and it sends out multiple messages to various users via a webhook response.
NOTES:
- This tutorial still requires an admin to trigger the action via a button but that can be sent to the admin on a daily basis through a broadcast
- It requires the FBIDs of all users to be stored within a google sheet to work
- This tutorial is only to be provided to advanced users of the platform
- The admin will receive the message to be sent to others e.g. if it is a birthday bot, they will receive the happy birthday message every day as this is the first step in the chain of webhook responses
Step 1 - The Bot
In this example, we have created a simple two message bot.
The welcome message contains the button to trigger the messages and is the one that is broadcast to the administrator on a daily basis.
The second message is the one that will be sent to multiple users. This message needs to contain a webhook to your integromat scenario, that we will set up in the next step. For example, here is our second message.
Step 2 - The Spreadsheet
We need to set up a spreadsheet that contains several columns and the FBID.
In our example, the spreadsheet has a column for Name, FBID, a variable that we are going to use to filter by (could be birth date, project participation, newsletter sign up, etc), email (optional) and a column that lets us know if the message has been sent.
Step 3 - The Integromat Scenario
We now need to set up our integromat scenario. In this example, we create a simple scenario that searches for anyone within a spreadsheet with variable x, that hasn’t already been sent a message, sends them a message and updates the row in the spreadsheet to reflect the fact that they have been sent a message.
First create your webhook and paste this into the message you want to send out to users e.g. in a birthday bot this would be the happy birthday message.
The next step is to search your google sheet for anyone with the variable X (this could also be your birth date that matches today) AND where the sent column does not exist. This looks as follows:
You need to make sure that your maximum number of returned rows is set to 1.
Next we need to add an update a row in google sheets module.
You want to update the row pulled through from your previous search row step, so use the Row number pulled through from this step. Then you want to update the sent column with the word sent. This should now look as follows:
Finally, your last step in the scenario is a webhook response.
You want to use the code:
{
"recipient": {
"id": "USER_ID"
},
"message": {
"id": "@BP:MESSAGE:4182"
}
}
Except you want to replace the USER_ID with the FBID pulled from your google sheets search rows step.
You want to use the message id of your second message (the one with the webhook in it). This will trigger the webhook again and it will continue working through your spreadsheet until everyone with variable X has been sent the message and the sent column has been updated.
This would look as follows:
Updated about 4 years ago