Skip to main content
Gainsight Inc.

Post Messages to Slack with Call External API Action Type

This article explains how to post messages to Slack from Gainsight by using the Call External API action Type in Rules Engine. 

Overview

This tutorial explains how to create a rule by using the Call External API Action which posts messages to Slack when a new Company record is created. The Slack message contains three fields of the newly created company record; Name, ARR, and Industry. This tutorial has three sections:

  1. Configure Custom Connector

  2. Setup External Action

  3. Configure Call External API Action  

Configure Custom Connector

This section explains how to create a connection to the Slack channel to which you wish to post messages. 

To Create Connection to Slack:

  1. Navigate to Administration > Operations > Connectors 2.0.

  2. Click Custom Connector.

  3. Click Create Connection. The Create a Connection window is displayed.

First.GIF

  1. Enter a name for your Slack connection.

  2. Select the Authorization Type as None. Slack does not require any authorization method. 

  3. (Optional) Enter a description.

  4. Click CREATE.

 connection.GIF

Setup External Action

This section explains how to create an action for the Slack Connection created in the previous section. The action you create here can be used in Rules Engine under the Call External API action type. 

To access the External Actions page:

  1. Navigate to Administration > Operations > External Actions

  2. Click Create Action. The Action creation page has five sections.

create connection.GIF

Basic Information

In this section, you can configure the following fields:

  1. Select the Slack Connection created in the previous section from the Select a Connector drop-down menu.

  2. Enter a name for the action in the Action Name field. 

  3. Enter the POST URL of the Slack channel to which you wish to post messages from Slack. The URL shown below is for a test Slack channel and would vary for your Channel. To learn more about creating POST URL in Slack refer to the Sending Messages and Sending Messages using Incoming Webhooks articles in Slack.

PX_2.GIF

Payload

In this section, configure the fields in JSON format. These fields are displayed under the Setup Action page and you can load data from Dataset into these fields. Payload can be entered either in the JSON format or x-www-form-urlencoded format.

In the following image, the Payload fields are added in JSON format.

qw.GIF

The following API code

{"text":"  A new company is created. Below are the details: 

\n *Company Name* : {{Name}},\n *ARR*: {{ARR}},\n *Industry*: {{Industry}}"} 

creates three fields known as Name, ARR, Industry. These three fields are created under the Fields section.

ert.GIF

When you configure the Call External API action from the Rules Engine page, these three fields are displayed. You can ingest values into these fields from your Dataset and the same message is posted to Slack.

Headers Information

In this section, you can configure the Key-value pairs. By default, the Content-Type: application/JSON value is present. Do not alter this value. Click + to create additional Key-value pairs.

headers.GIF

Fields

In this section, configure the data type for the fields created in the payload section.

Fields.GIF

Advanced Configuration Information

In this section, you can configure the maximum number of times the API should try to reconnect to Slack, in case a connection is not established. By default, this value is set to 3.

re-try.GIF

Click Create to create the action.

Create.png

You can see that the new action is created under your connection.

View action.GIF

Now, Slack is the connection name (configured in first section), and Post to Slack is the Action name (configured in this section). These two fields would be used in Rules engine while configuring the Call External API action. 

You can test the action by using the Test option.

aq.GIF

Configure Call External API Action

This section explains how to leverage the Call External API action, by using the connection and action created above. 

To use the Call External API action Type: 

  1. Create a rule, and dataset, as required. 

  2. Navigate to the Setup Action screen. 

  3. Click + ACTION.

  4. Select the Call External API action type. 

  5. From the External API drop-down menu, select the action (Post to Slack in this example) created in the previous section. This action is present under the Connection name (Slack in this example).

Select action.GIF

  1. The Name, ARR, and Industry fields are populated from the configurations performed. Map these fields with appropriate fields from your dataset.

Name.GIF

  1. (Optional) You can also choose to insert custom values instead of mapping fields from the dataset.
  2. Click SAVE.

postslck.GIF

  1. Execute the rule or schedule the execution of the rule. When this rule executes, the corresponding Slack channel displays the message, with the values configured in the rule.

Slackkk.png

 

 

 

 

  • Was this article helpful?