How to create a buddy bot using Make(formerly Integromat)
Knowledge Level: Advanced
Purpose
In this tutorial, we will setup a buddy bot that will let users matchup for meetings with colleagues randomly.
We will setup a bot to trigger webhooks to Make(formerly Integromat), Make(formerly Integromat) will use connections to Google Sheet for randomly matching users with each other.
Prerequisite
- A bot
- An Make(formerly Integromat) account
- A Google Sheet which acts as a staff directory (You need name and email as columns)
- Your favorite beverage
Setting up the bot
To setup the bot, we will need two message parts:
- A welcome message asking the user if they would like to buddy up with someone
- A confirmation message letting the user know that a buddy is being searched, this message part will also contain the webhook to trigger our Make(formerly Integromat) scenario
Setting up Make(formerly Integromat)
We will be using the following modules in our scenario:
- Custom webhook
- Google Sheet (Search Rows)
- Array Aggregator
- Set Variable
- Create JSON
- Webhook Response
Setup Webhook
First add a custom webhook module. Add a new webhook and give it a suitable name. Now you need to copy the webhook URL generated and paste it into the webhook message within the thank you message on the Bot Platform.
Now click the 'Run once' button on your Make(formerly Integromat) scenario and test your bot by going through the message flow and triggering the webhook.
Once the webhook data is received, we should be able to continue building the rest of our Make(formerly Integromat) scenario.
Setup Google Sheet module
In the next step, add a new module and look for Google Sheets 'Search Row' module.
In the configuration of this Google Sheet module, select your Google sheet containing the name and email addresses of your employees. You can use an existing staff directory Spreadsheet for this purpose.
The configuration should look as follows:
In the above screenshot, we have configured a search filter condition to ensure the requester is not matched with themself!
Setup array aggregator
In the next step, we will add an array aggregator module. Since the search rows module from Google Sheets is going to produce possible matches in bundles, we need to be able to summarize the list and then be able to only pick one match to return to the user, randomly. For more information on how to use an array aggregator module, please click here
In the 'aggregated fields' configuration section, we will use the following fields from the Google Sheet module:
- Name
- email address
It should look like as follows:
Setup a 'set variable' module
Via the array aggregator, we have been able to summarize all the attendees we found in the Google Sheet. In this step, we will shuffle the list to randomly find a buddy for our bot user. Let's start by adding a 'set variable' module
In the settings, name the variable as you would like. In the variable value section, add a 'Shuffle' operator from the array functions module in Make(formerly Integromat) (see example below):
Setup JSON module
We are almost done with our scenario. After shuffling and finding a random buddy, it's now time to present the randomly selected buddy to our bot user. For our use case, we have gone with using a carousel format to present the buddy to bot user in a card format.
In the first step, add a new 'Create JSON' module to your scenario:
In the configuration of this module, click on 'Add' and click 'Generator' button. Paste the Carousel JSON example from our dev docs in the text box that appears after clicking on 'Generator' button. The code can be found below:
{
"message":{
"raw":{
"attachment":{
"type":"template",
"payload":{
"elements":[
{
"title":"A ticket to the theatre",
"buttons":[
{
"type":"postback",
"title":"View this lot",
"payload":"@BP:MESSAGE:83510"
},
{
"type":"postback",
"title":"Place a bid",
"payload":"@BP:MESSAGE:83510"
}
],
"subtitle":"Did you want to bid?"
},
{
"title":"A £100 voucher",
"buttons":[
{
"type":"postback",
"title":"View this lot",
"payload":"@BP:MESSAGE:83510"
},
{
"type":"postback",
"title":"Place a Bid",
"payload":"@BP:MESSAGE:83510"
}
],
"subtitle":"Did you want to bid?"
}
],
"template_type":"generic"
}
}
}
},
"recipient":{
"id":"{{1.fbuser.fbid}}"
}
}
After the above step, the JSON module should look as below:
This is the step where we will configure the details of the card. We will use the outputs from our Google Sheet search rows module which we shuffled in the earlier step to compose our card. We are also adding two buttons to get confirmation from user if they have been previously matched with this buddy in which case the search will be triggered again to find a new buddy.
Let's start by editing the 'Create JSON' module and editing the 'Element' section of the module as following:
In the title section, we inform the user with the name of the individual they have been matched with using the output from the 'Set Variable' module. In the 'buttons' section, add the first item and set the following:
- type:postback
- title:Yes
- payload:@BP:MESSAGE:{messageid from The Bot Platform}
Do this again by adding another button replace the title with 'No'. For the message-id in both buttons, copy the message id from The Bot Platform pointing the user to messages in the bot based on their responses.
For the 'subtitle', we have configured it to say 'Do you already know this person?'. You can modify this to your own liking.
Press save on this screen and return to the main configuration of the 'Create JSON' module, for the rest of the module, use the settings from the below screenshot:
Setup webhook response module
In the last step of our tutorial, add a 'Webhook response' module:
In the body of the webhook response module, add the output from the 'Create JSON' module which will be labeled as 'JSON string'.
Now, save your scenario and make sure it's turned on. It's time to match up with a buddy!
Go through the bot flow and if everything has been configured properly, you should receive a response from the bot with a random buddy.
Happy buddy-ing!!
Updated over 1 year ago