Chapter 17. Connect 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 the integration when a Slack channel that you specify receives a message. The integration passes the message to the next step in the integration. 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. You can finish an integration by notifying 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. Details are in the following topics:

17.1. Create 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.

Prerequisites

  • You created a Slack app for connecting Fuse Online to Slack.
  • You can obtain the Slack webhook URL for your Slack app.
  • You can obtain a legacy token that authorizes access to your Slack app.

Procedure

  1. In Fuse Online, in the left panel, click Connections to display any available connections.
  2. In the upper right, click Create Connection to display Fuse Online connectors.
  3. Click the Slack connector.
  4. In the Slack webhook URL field, enter the webhook URL for your Slack app.
  5. In the Token for accessing Slack API field, enter the Slack-provided token, which you can obtain from Slack.
  6. 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: :smile:, :wave:, :question:.

      Tip

      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.

  7. 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.
  8. If validation is successful, click Next.
  9. In the Connection 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.
  10. In the Description field, optionally enter any information that is helpful to know about this connection.
  11. In the upper right, click Create 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.

17.2. Add a Slack connection to trigger 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.

Prerequisites

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

Procedure

  1. Click the Slack connection that you want to use to start the integration.
  2. Click the Read Messages action.
  3. In the Channel field, specify the Slack channel from which you want to obtain messages.
  4. 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.
  5. 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.

  6. Click Done to add the connection to the integration.

17.3. Add 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 to finish an integration or in the middle of an integration.

Prerequisites

  • You created a Slack connection.
  • You are creating or editing an integration. If you are creating an integration, then Fuse Online might be prompting you to choose a finish connection. To add a middle connection, hover over the plus sign in the left panel in the location where you want to add the connection and select Add a connection.

Procedure

  1. Click the Slack connection that you want to add to the integration.
  2. Select the action that you want the connection to perform.

    • Click 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.
    • Click Channel to publish a message on a channel. To configure this action, in the Channel field, specify the channel to publish the message to.
  3. Click Done to add the connection to the integration.
  4. Optionally, add additional connections to the integration. Whether additional connections are needed depends on what you want the integration to do. The important point is to add all connections before you continue.
  5. Add a data mapping 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 Add data mapping step.