Bot Incoming Webhook Handler
The incoming webhook handler focusses on letting third party (external services) post messages in your bot. The bot's incoming webhook handler should be configured in the third party service with the authentication key or API Key. This API key is useful for authenticating the incoming webhook API's from external services.
Sample Bot Incoming Webhook Endpoint
https://cliq.zoho.com/api/v2/bots/{bot_unique_name}/incoming
Below given are the list of attributes passed when an incoming webhook handler is executed:
Attribute Name | Description |
headers | Header details from the request made to the server. |
parameters | Parameter details from the request made to the server. |
body | Request body as the type string. |
http_method | GET | POST | HEAD |
user | Details of the user who has triggered the handler. |
Example:
Let us consider the Connect Bot as an example. The Connect Bot is configured bring notifications about a new post or announcement made on Zoho Connect. Zoho Connect has an Outgoing Webhooks Module where the bot's webhook URL has to be configured. The webhooks module has a list of activities for which event updates and notifications are offered. You can choose the list of events for which you would like to be notified and proceed to configure the bot webhook URL.
Authentication
Authentication of the webhook URL should be done by passing the value of a Webhook token as the key for authentication. A sample incoming webhook URL of a bot is shown below
https://cliq.zoho.com/api/v2/bots/connectbot/incoming?zapikey=<paste_webhook_token_here>
Note: You can learn more about webhook tokens here
How to configure the bot's incoming webhook URL in Zoho Connect's Outgoing Webhook Module
- In Zoho Connect, click on the Integrations icon and select Outgoing Webhooks.
- Click Configure and select activities for which you would like to receieve updates.
For this example, we've configured the following options:
- Activity - In my network. This means, you'll be notified about any updates in your connect network.
- Activites - Conversation, Announcement, and Forum Activities.
- Action - URL
- URL - Provide your bot's incoming webhook URL with the webhook token
How to handle notification updates pushed to the bot's incoming URL
The bot incoming webhook URL is called with the corresponding JSON Object when an activity occurs in Zoho Connect. This JSON will be available either in the headers or body parameter of the incoming webhook handler. Configure the bot response based on this JSON received. A sample syntax of the Zoho Connect bot's incoming webhook handler is given below.
postdata = body.toMap();
if(postdata.get("url") != null)
{
url = "" + postdata.get("url");
ownerinfo = postdata.get("createdBy").toMap();
uname = "" + ownerinfo.get("name");
plaintextobj = postdata.get("plainContent");
if(plaintextobj != null && (plaintextobj + "").trim().length() > 0)
{
message = {"text":plaintextobj,"bot":{"name":"Connect Bot","image":""},"card":{"title":uname + " on Connect!","theme":"modern-inline"},"buttons":{{"label":"View Post","type":"+","action":{"type":"open.url","data":{"web":url}}}}};
}
}
return message;
Related Articles:
Cliq Bots - Get notifications about any action on an application with the incoming webhook handler!
Learn how to connect external applications to Cliq through your bot's incoming webhook handler