The Slack component allows you to send messages, notifications, and alerts to Slack channels or users directly from your integration flows.
URI Syntax: slack:channel
Path parameters
Name | Description | Default | Type |
|---|---|---|---|
channel (common) | (required) The channel name (syntax #name) or slack username (syntax userName) to send a message directly to a user. | — | String |
Query parameters
Name | Description | Default | Type |
|---|---|---|---|
token (common) | The token to access Slack. This app needs to have permissions channels:history, groups:history, im:history, mpim:history, channels:read, groups:read, im:read and mpim:read. The type of token needed is User OAuth Token. | — | String |
conversationType (consumer) | Type of the conversation. Possible values: PUBLIC_CHANNEL, PRIVATE_CHANNEL, etc. | PUBLIC_CHANNEL | ConversationType |
The flow below receives messages sent in a public group and demonstrates two ways to access the message content: through Java methods and through conversion to Map via JSON.
The flow starts when a message is sent in the outros-assuntos channel on Slack. The parameters indicate the conversation type (public channel) and the authentication token.
Then, the body of the received message is logged as ${body}.
The second log shows the class type of the received object with ${body.class}, which will be com.slack.api.model.Message.
Since the message is a Java object, the getText() method is used to get the text: ${body.getText()}.
Next, the message is converted to JSON with the marshal EIP.
Then, the message is converted to Map with the unmarshal EIP, making it easier to access the data.
Finally, after conversion to Map, the text field is accessed directly using index notation: ${body[text]}.

We use cookies to enhance your experience on our site. By continuing to browse, you agree to our use of cookies.Learn more