Cliq Bots - Get notifications about any action on an application with the incoming webhook handler!

Cliq Bots - Get notifications about any action on an application with the incoming webhook handler!

Webhooks can be used to get notified about events happening in other applications inside Cliq. All bots in Cliq have their own incoming webhook endpoint. This makes it simple to post messages to the bot from external applications. Unlike the send message (/message) REST API, here any data can be posted to the endpoint which is further processed in the incoming handler before notifying in Cliq.

The incoming webhook allows third-party applications to send notifications/alerts using the incoming webhook URL. These responses mostly received as a JSON can be then customized using Cliq's message card templates. The incoming webhook URL of the bot should be configured with the application's outgoing webhook. 

Incoming webhook handler workflow 

The bot's incoming webhook URL will receive the request response from the third party application's URL. The response of the request will be obtained in the body attribute. Take a look at all the attributes passed when a bot's incoming webhook handler is executed in our help page

A pictorial comparison between how Rest APIs and incoming webhooks work is shown below!
Now that we've got the concept of webhooks cleared, let's start off by creating a simple bot's webhook handler. Take a look at the sample scenario given below.

Sample Scenario 

Your support team uses Zendesk to take care of customer queries and keep track of tickets. The team also uses Cliq for internal team communication. So how can you make sure all support reps are notified in Cliq when a new ticket with a high priority has been created? Here's what you can do - create a Support Bot! 

Before we start, this is an integration by parts. Which means that you have to configure the webhook in Zendesk and format your response in Cliq. 

Cliq's part in the integration:  

Creating a bot in Cliq is just a three-step process. All you've to do is, 
  1. Click ' Settings ' in Cliq's top nav bar. 
  2. Select ' Integrations '.
  3. Once you're on the Integrations page, click ' Create Bot ' and give your bot a name, description, status, access level and image! 
Now, to set up the incoming webhook handler of your bot :
  1. Saving the bot will take you to the ' Edit Handlers ' page. Or you can navigate to the edit handlers page from the bot's preview.
  2. Click ' Edit Code ' under the bot incoming webhook handler. 
  3. Write your code in the deluge editor (once you set up the JSON body in Zendesk), click save and done! Take a look at the sample code snippet given below:
  1. // Incoming Webhook Handler Code Snippet 
  2. response = Map();
  3. title = body.get("title");
  4. priority = body.get("priority");
  5. description = body.get("description");
  6. url = body.get("url");
  7. id = body.get("id");
  8. status = body.get("status");
  9. assignee = body.get("assigned_to");
  10. response = {"text": "A new ticket has been created. The ticket details are given below: \n Ticket Name: " + title + " \n Description:" +description+   "\n Priority: `" + priority+ "` \n Ticket ID:" +id+ "\n [Ticket URL](https://" +url+ ") \n Status: " +status+ " \n Assigned To: " +assignee };
  11. return response;
To be done in Zendesk

Create a Target: 
  1. Create an extension. To do so, click 'Extensions' under 'Settings' 
  2. Click 'Add Target' under the targets tab. 
  3. Click 'HTTP target' and give a name, URL, method. 
  4. Give your bot's incoming webhook URL along with the zapikey parameter. Take a look at how to create a zapikey  here
  5. Set your HTTP method as POST. 
  6. Select 'Create Target' and click Submit. 
Sample Bot Incoming Webhook URL:

That's it! Your extension has been created.

Create a Trigger:

The next action is to create a trigger. Triggers are automated rules that work based on predefined conditions. 
  1. Navigate to the Triggers tab and click ' Add Trigger '
  2. Give the trigger a name, description and set a condition. Take a look at the sample condition used for the example shown below. 
  3. Under Actions, select ' Notify Target ' and select your target name. 
  4. The JSON body will contain the ticket details. Modify this to suit your team's requirements. Here's a sample code snippet for the JSON body.
  5. Click Save! 
Sample Trigger Code Snippet:

  1. {"title":"{{ticket.title}}", 
  2. "description" : "{{ticket.description}}", 
  3. "priority":"{{ticket.priority}}",
  4. "url": "{{ticket.url}}",
  5. "id":"{{ticket.id}}",
  6. "status":"{{ticket.status}}",
  7. "assigned_to":"{{ticket.assignee.name}}"
  8. }
Now creating a ticket with a priority set as Urgent  will notify all the support reps in Cliq via the Support Bot!

Take a look at how the Zendesk Ticket will be notified in Cliq via the Support Bot : 

Ticket in Zendesk 




Support Bot notifying in Cliq



And that's how easy it is to configure a bot's incoming webhook handler. Comments and suggestions are welcome. 

Few useful links:




Best,
Manasa
Cliq





      • Sticky Posts

      • Convert a message on Cliq into a task on Zoho Connect

        Message actions in Cliq are a great way to transform messages in a conversation into actionable work items. In this post, we'll see how to build a custom message action that'll let you add a message as a task to board on Zoho Connect. If you haven't created
      • Cliq Bots - Post message to a bot using the command line!

        If you had read our post on how to post a message to a channel in a simple one-line command, then this sure is a piece of cake for you guys! For those of you, who are reading this for the first time, don't worry! Just read on. This post is all about how
      • Cliq Bots - How to make a bot respond to your messages?

        Bots are just like your buddies with whom you can interact. They carry out your tasks, keep you notified about your to-dos and come in handy when you need constant updates from a third party application.  So, how can you make your bot respond to a message? The bot message handler is a piece of code triggered when a message is sent to the bot. Message handlers help you customise your bot responses to make it look conversational. The message input from the user can be either a string or an option selected
      • Cliq Bots - Get notifications about any action on an application with the incoming webhook handler!

        Webhooks can be used to get notified about events happening in other applications inside Cliq. All bots in Cliq have their own incoming webhook endpoint. This makes it simple to post messages to the bot from external applications. Unlike the send message
      • The Slash Command Series - Types of Command Suggestions

        Hi Everybody! I hope you guys tried the /zdocs command and now have an idea of how command suggestions with click to execute work. If you have no clue of what command suggestion is, I recommend you to take a look at all the Slash Command Series posts, especially the one on Command Suggestions ! This post is all about the different types of command suggestions.  Customise your command suggestions  Did you know you could customise your command suggestion list with a title, description, image? Well,