Bot Incoming Webhook Handler

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 NameDescription
headersHeader details from the request made to the server.
parametersParameter details from the request made to the server.
bodyRequest body as the type string.
http_methodGET | PUT | POST | DELETE
userDetails 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 an authentication token as a value to the key authtoken. A sample incoming webhook URL of a bot is shown below


https://cliq.zoho.com/api/v2/bots/connectbot/incoming?authtoken=<active_authtoken>

 

Note:

In this example, token based authentication method has been used to generate an authtoken. In scenarios where the bot is bundled into an extension, you can pass the extension's ZAPI Key as a value for the authtoken.

How to configure the bot's incoming webhook URL in Zoho Connect's Outgoing Webhook Module

  1. In Zoho Connect, click on the Integrations icon and select Outgoing Webhooks. 
  2. Click Configure and select activities for which you would like to receieve updates. 

Configure outgoing webhook is Connect

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 authtoken

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;

Connect bot notification

View card to read connect post from the bot

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

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohocliq.com