Skip to main content
Gainsight Inc.

Post Messages to Slack with Call External API Action Type

Gainsight NXT


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


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 > Connectors 2.0.
  2. Click Custom Connector.
  3. Click Create Connection. The Create a Connection window is displayed.


  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.


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 > External Actions
  2. Click Create Action. The Action creation page has five sections.

External Actions.png

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.



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.


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 NameARRIndustry. These three fields are created under the Fields section.


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.



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


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.


Click Create to create the action.


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.


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).

Slack Rules Engine.jpg

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

Slack Rules Engine.jpg 2023-04-25 at 3.10.40 PM.jpg

  1. (Optional) You can also choose to insert custom values instead of mapping fields from the dataset.
  2. Click Save Actions.
  3. 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.