Red Hat Training

A Red Hat training course is available for Red Hat Fuse

Chapter 15. Connecting to Slack

In an integration, you can connect to an instance of Slack and deliver a message to a particular user or to a channel. For example, this 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. You can then add that same connection to any number of integrations. Details are in the following topics:

15.1. Create a Slack connection

To create a connection to an instance of Slack:

  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 of the Slack instance to send messages to. This is the only required parameter.
  5. Optionally, enter values for additional parameters:

    1. In the Sending username for messages field, enter the user name that the bot has when it sends messages to Slack.
    2. 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 on emoji cheat sheet to see some emoji codes.

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

  6. 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.
  7. If validation is successful, click Next.
  8. 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 Company Sales.
  9. In the Description field, optionally enter any information that is helpful to know about this connection.
  10. In the upper right, click Create to see that the connection you created is now available. If you entered the example name, you would see that Slack for Company Sales appears as a connection that you can choose to add to an integration.

15.2. Add a Slack connection to an integration

In an integration, to send a message to a Slack channel or user, first create a Slack connection. You can then add that connection to any number of integrations as a finish connection or as a middle connection. It does not make sense to add a Slack connection that starts an integration because you must map the message content from a previous step to a Slack connection field. In other words, a data mapping step must be in the integration just before the Slack connection.

To add a Slack connection to an integration, you must be 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.

To add a Slack connection:

  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 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. The integration sends the integration data in a message to that channel.
  3. Click Done to add the connection to the integration.
  4. After you add all connections to the integration, add a data mapping step just before the Slack connection. In the mapping step, map a string from a previous step 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.