Tutorial: Post Message to Slack when External Event Occurs using Real-Time Rules
Gainsight NXT
This article explains how to post in Slack when an external event occurs using Gainsight data.
Introduction
Using the Call External API action type in Real-Time Rules, configure a rule to post a message in the Slack channel immediately when an urgent ticket is created in FreshdeskTM (which is an external system) for high revenue customers. For more information on the Real-Time Rules feature, refer to the Real-Time Rules article.
This tutorial has four sections:
Configure External Events
From FreshdeskTM, configure a rule using Webhook such that when a ticket status is updated to Urgent call Gainsight. For more information on how to configure external events, refer to the Events Framework article.
To capture the ticket status update to Urgent in Events Framework:
- Navigate to the Administration > Events page.
- In the TOPICS tab, click +Create New Topic.
- Create a topic with the name FreshDeskTM Demo (sample). For more information, refer to the Create a Topic section in the Events Framework article.
- In the EVENTS tab, create an event with the name Urgent Priority under the FreshdeskTM demo topic.
- In the Structure section, click + Add New and add the same fields used in creating a webhook in FreshdeskTM. Refer to the video below:
- Select the Resolve event fields checkbox to view all the Company fields in Real-Time Rules.
- From the Resolve to drop-down, select Company and map the Company Name event field to the Name object field.
- Click Save.
Configure Custom Connector
You must first configure a connection with Slack. For more information on how to configure a custom connector in Gainsight, refer to the Configure Custom Connectors article.
Setup External Action
This section explains how to create an action for the external connection created in the previous section.
To access the External Actions page:
- Navigate to Administration > External Actions.
- Click Create Action. The Create Action page appears.
- In the Basic Information section:
- From the Select a Connector drop-down, select the Slack Connection created in the previous section
- In the Action Name field, enter a name (Post to Slack Tutorial) for the action
- Enter the POST URL of the Slack Channel to which you wish to post a message. The URL shown below is for a test FreshdeskTM account and this would vary for your instance. For more about creating POST URLs in Slack refer to the Sending Messages and Sending Messages using Incoming Webhooks articles in Slack.
-
In the Payload section, enter the following API code:
{"text": "*An urgent ticket has been created for the Company:{{Company}}* \n _Subject:_ {{subject}}\n _Agent Name:_ {{Agent}}\n _Priority:_ {{priority}}\n _CSM:_ {{CSM}}, *Status:* {{Status}}" }
The above example API code posts messages in Slack with Company Name, Subject, Agent, Priority, CSM, and Status fields.
IMPORTANT: Ensure that the fields provided in the above API are the same as in the Events Framework configuration.
- In the Headers Information section, by default, the Content-Type: application/JSON value is auto-populated.
- In the Fields section, configure the data type for the fields created in the payload section.
- In the Advanced Configuration Information section, set the value to 3.
- Click Create.
Configure Call External API Action
This section explains how to configure a Real-Time rule to sync post a slack message when an external event occurs.
To configure the Real-Time rule:
- Navigate to Administration > Rules Engine > Real-Time Rules tab.
- Click New Rule. A new page appears, where you can view the following three tabs:
- Details
- Configure
- Actions
Details Tab
Enter the following information in the Details tab.
- Rule Name: Post to Slack when External Event Occur.
- Select Folder: Select the folder in which you want to add this rule (or) by default, the rule is saved to the Uncategorized folder.
- (Optional) Description: Provide a brief description of the rule.
- Click Configure to update the rule details, and navigate to the Configure tab.
Configure Tab
To configure a Rule for high revenue customers:
-
In the Select an Event section:
- From the Event Topic drop-down, select the FreshdeskTM Demo event configured in the Configure External Events section.
- From the Event drop-down, select Urgent Priority(1).
Note: All the Company lookup fields are displayed since the company is resolved in Events Framework.
- In the Apply Filters section, drag and drop the ARR field and set the value greater than 100000.
- Click Actions to update the rule details, and navigate to the Actions tab.
Actions Tab
To create an Action:
- Click Create Action.
- Select Call External API action type.
- From the Connector drop-down, select Slack.
- From the External API drop-down, select Post to Slack - Tutorial.
- In the Field Mappings section, map the following External Action Fields to Event Fields:
- Company - Company Name
- Subject - Subject
- Agent - Agent Name
- Priority - Priority
- CSM Name - Custom Field
- Status - Status
- Click Save Rule.
- Click Close.
- Turn on the Status toggle switch to execute the rule.
When an urgent ticket is created in the external system, External Framework receives an event that triggers the rule. If the rule is successful, a message is posted in the selected Slack channel.