Chapter 23. Connecting to Slack
As a business user, you can create an integration that connects to Slack. A connection to Slack can do either one of the following:
- Trigger execution of a simple integration when a Slack channel that you specify receives a message. The integration passes the message to the next step in the flow. For example, you can monitor a Slack channel for keyword instances such as product names. Upon finding messages that contain those product names, the integration can notify the appropriate contact in a Gmail connection.
- Deliver a message to a particular user or to a channel. For example, this behavior is useful when an integration downloads a file from an FTP server and processes it in some way. An integration flow can notify a Slack channel or user that the process was successful.
To connect to Slack in an integration, create a Slack connection and then add the connection to an integration flow. Details are in the following topics:
23.1. Creating a Slack connection
In an integration, a Slack connection can retrieve messages from a channel that you specify or send a message to a channel or user. You can use the same Slack connection in any number of integrations.
- You created and installed a Slack app for connecting Fuse Online to Slack.
- You can obtain the Slack webhook URL for your Slack app.
- You can obtain the Bot User OAuth Access Token that authorizes access to your Slack app.
- In Fuse Online, in the left panel, click Connections to display any available connections.
- Click Create Connection to display Fuse Online connectors.
- Click the Slack connector.
- In the Slack webhook URL field, enter the webhook URL for your Slack app.
- In the Token for accessing Slack API field, enter the Bot User OAuth Access Token, which you can obtain from the Slack app’s OAuth & Permissions page.
Optionally, enter values for additional parameters:
- In the Sending username for messages field, enter the user name that the bot has when it sends messages to Slack.
In the Message avatar emoji field, specify one emoji, which the bot uses as the message avatar when it sends a message. Examples:
Search the web for emoji cheat sheet to see some emoji codes.
- In the Message avatar icon URL field, specify the URL of the avatar that the bot uses when it sends messages to Slack.
If you specify an emoji and an icon URL, then the integration uses the icon URL. If you specify neither an emoji nor an icon URL, then the message is sent without an avatar.
- Click Validate. Fuse Online immediately tries to validate the connection and displays a message that indicates whether validation is successful. If validation fails, revise the connection configuration values and try again.
- If validation is successful, click Next.
In the Name field, enter your choice of a name that helps you distinguish this connection from any other connections. For example, enter
Slack for Tracking Company Sales.
- In the Description field, optionally enter any information that is helpful to know about this connection.
- Click Save to see the updated list of available connections, including the connection that you just created. If you entered the example name, you would see that Slack for Tracking Company Sales appears as a connection that you can choose to add to an integration. You can add this connection to any number of integrations.
23.2. Adding a Slack connection to trigger integration execution upon receiving messages
A Slack connection that starts an integration triggers execution of the integration when the connection finds messages on a Slack channel that you specify.
- You created a Slack connection.
- You are creating an integration and Fuse Online is prompting you to choose how you want to start the integration.
- Click the Slack connection that you want to use to start the integration.
- Select the Read Messages action.
- In the Channel field, specify the Slack channel from which you want to obtain messages.
- In the Delay field, accept the default of 500 milliseconds as the time that elapses between polls for messages. Or, to specify a different interval for checking for messages, enter a number and select its time unit.
In the Maximum Messages to Retrieve field, accept the default of 10 or indicate the maximum number of messages that the connection can return for each poll. If the connection finds more than this number of unread messages, then it returns the most recent messages. The connection returns a particular message only once.
For example, if you accept the default of 10 and there are 15 messages at the time of a poll then the connection returns the 10 most recent messages. At the next poll, the connection checks for messages that have a time stamp that is after the most recent message that the connection previously returned. This means that the 5 messages that were not returned in the first example poll are never returned.
When a Slack connection returns more than one message, the integration processes the messages as a batch. In other words, Fuse Online executes the integration once for the batch.
- Click Next to add the connection to the integration.
23.3. Adding a Slack connection to send a message to a Slack channel or user
In an integration, you can send a message to a Slack channel or Slack user in the middle of a flow or to finish a simple integration. To do this, add a Slack connection to the middle of a flow or as a simple integration’s finish connection.
- You created a Slack connection.
- You are creating or editing a flow and Fuse Online is prompting you to add to the integration. Or, Fuse Online is prompting you to choose a finish connection.
- On the Add to Integration page, click the plus sign where you want to add the connection. Skip this step if Fuse Online is prompting you to choose the finish connection.
- Click the Slack connection that you want to add to the flow.
Select the action that you want the connection to perform.
- Select Username to send a message to one user. To configure this action, in the User name field, specify the Slack name of the user to send the message to.
- Select Channel to publish a message on a channel. To configure this action, in the Channel field, specify the channel to publish the message to.
- Click Next to add the connection to the flow.
- Optionally, add additional connections to the flow. Whether additional connections are needed depends on what you want the flow to do. The important point is to add all connections before you continue.
- Add a data mapper step just before the Slack connection that you added in this procedure. In the mapping step, map a string from a data mapping source to the Slack message field. This string should contain the message that you want to send to the Slack user or channel. See Adding a data mapper step.