How to set an attribute value for a user via Slack Bot

In this tutorial, we will utilize a webhook trigger and our webhook response code to set an attribute value for a user in The Bot Platform.

Purpose

In this tutorial, we will set an attribute value for a user by trigger a webhook and pulling the attribute value from an external system or database. This webhook response can be used across a variety of use cases, especially when you want to apply values from an external system and utilize it in your bot for broadcast filtering, etc.

For this example, let's see we have a spreadsheet dividing a list of users in four different groups. We will use the webhook trigger in our platform to trigger a webhook on Make.com, search through the list in a spreadsheet and assign a group number to the user in the platform.

Prerequisite

  • A bot
  • A Make account
  • A spreadsheet with a list of items
  • Your favorite beverage (I replenished some essential minerals through a Berocca drink!)

Demo

Here's the bot in action:

Setting up the webhook

For our first step in the Make please follow this guide for process of setting up a webhook trigger in Make -> Setting up webhook and response in a Slack bot.

🚧

Paste webhook url to your bot

After creating the webhook module. Please make sure to copy and paste the url into your bot as a 'Webhook' message part.

Setting up Google Sheet module

In this use case, we are assigning the results from a Goggle Sheet, to the bot user in the form of an attribute. Hence, setup a new module after the webhook trigger and look for Google Sheets:

Select your desired spreadsheet and setup the search filter. The search filter will allow you to pull the group name.

Add webhook response

The last step is to add a webhook response module.

For the webhook response code, use the code below:

{
  "recipient": {
    "id": "USER_ID"
  },
  "message": {
    "text": "Group assigned!"
  },
  "set": {
    "$group": "value_spreadsheet"
  }
}

Replace the 'USER_ID' value with the 'FBID' value from your webhook trigger. For "value_spreadsheet", use the result obtained from the Google Sheet module.

The final configuration of the webhook will look something like this:

Once done, click 'Ok' to save the changes to the module. At the end, save your scenario and make sure it's switched on. If everything was setup correctly, your bot user should receive a response message confirming a group has been assigned.

👍

Happy attributing!