Skip to main content

Slack Component

Send messages to Slack channels and users

Component key: slack

Description

The Slack component allows you to post messages to a Slack channel.

Connections

Slack OAuth 2.0

The vast majority of actions in this component use OAuth 2.0 for authentication. To create a Slack OAuth 2.0 connection, first create and configure a Slack App by visiting the Slack Developer App Portal:

  1. Click Create New App
  2. Choose to create the app From scratch
  3. Give your app a name and select your workspace. We'll configure it to be multi-workspace capable in a moment
  4. Select OAuth & Permissions from the sidebar
    1. Under Redirect URLs, add https://oauth2.prismatic.io/callback as a redirect URL.
    2. At the bottom, add some User Token Scopes if you plan for this integration to send messages on behalf of customers, or Bot Token Scopes if a Slack "bot" will send the messages. What scopes you need is dependent on what types of things your Slack integration will need to do (create channels, send messages, etc). If you just need to send messages to a channel as a bot, add these scopes: chat:write chat:write.public. If you want to send messages as a user, see the section below.
  5. Next, select Distribute App under Manage Distribution. Confirm that you have "removed hard coded information" and select Activate Public Distribution. Your app needs to be publicly distributed for your customers to install it in their Slack workspaces.
  6. Finally, open Basic Information. Take note of the Client ID, Client Secret and Signing Secret.

Now it's time to configure your integration to use your Slack OAuth 2.0 app. Add a Slack step to your integration - that'll create a connection config variable for you. Open up that connection config variable.

Enter Client ID, Signing Secret and Client Secret that you noted before.

The Scopes that you need to enter depends on what Slack actions your integration includes:

  • If you're just sending messages to a channel, you can enter the scopes chat:write chat:write.public and that will assign you a bot token that can write messages to public channels. See below for information on sending messages to private channels.
  • Conversation and channel-related actions require admin.conversations:write.

Enter scopes with spaces in between them (e.g. chat:write users:read users:read.email).

A list of all Slack OAuth scopes and what each does are available in their docs.

Sending messages to private channels

The chat:write.public scope allows your bot to send messages to public channels. If you would like to send messages to private channels, or would like to be more selective about what channels your bot can send messages to, your customer will need to invite the bot to specific channels.

If a bot does not have chat:write.public or tries to write to a private channel it's not a part of, you'll receive a not_in_channel error from Slack when you attempt to send a message to that channel.

Sending messages as a user

Slack applications typically send messages as bot users. If you would instead like to send messages as a user, edit the Auth URL add chat:write to a user_scope query parameter on the Authorization URL to get a User token. To manage channels, add the channels:write scope.

Your Auth URL, then, will look something like this: https://slack.com/oauth/v2/authorize?user_scope=chat:write

Dynamically changing your bot's name

Your bot's username and icon are things you set when you create your Slack app. If you would like to override your bot's username within your integration, you will need to request the chat:write.customize scope in addition to chat:write.

GovSlack

Slack offrs GovSlack for government organizations that require compliance with FIPS 140-2, FedRAMP, ITAR, etc. To use the Slack component with GovSlack, change the beginning of OAuth auth URL, token URL, and revoke URL from https://slack.com to https://slack-gov.com. The component will automatically point API requests towards the Slack Gov API endpoint.

Webhook URL

The Slack Message from Webhook and the Slack Block Message from Webhook actions are the only Slack actions that do not authenticate with OAuth. Instead, it uses Slack Incoming Webhooks. For your customers to use this authorization method, they will need to create their own Slack apps and incoming webhooks.

To generate a Slack incoming webhook URL:

  1. Navigate to https://api.slack.com/apps
  2. Click Create New App, adding an app to your workspace.
  3. Under Add features and functionality select Incoming Webhooks
  4. Activate Incoming Webhooks and then Add New Webhook to Workspace
  5. Take note of the Webhook URL. It should be of the form https://hooks.slack.com/services/foo/bar/baz

Triggers

Slack App Webhook

Trigger for handling slash command and modal webhooks from Slack | key: slashCommandWebhook


Slack Events API Webhook

Trigger for handling webhooks from Slack's events API | key: webhook

Output Example Payload

{
"branch": "Notification",
"payload": {
"headers": {
"accept": "*/*",
"Content-Type": "application/json",
"User-Agent": "Slackbot 1.0 (+https://api.slack.com/robots)",
"Host": "hooks.example.prismatic.io"
},
"body": {
"data": {}
},
"rawBody": {
"data": {
"type": "Buffer",
"data": [69, 120, 97, 109, 112, 108, 101]
}
},
"queryParameters": {},
"webhookUrls": {
"Flow 1": "https://hooks.example.prismatic.io/trigger/EXAMPLEGbG93Q29uZmlnOmRlNmNmNDMyLTliNWMtN0005NDMxLTRmYzA4ZjViODgxOA=="
},
"webhookApiKeys": {
"Flow 1": ["abc-123"]
},
"customer": {
"externalId": "customer-example-external-id",
"name": "John Doe"
}
},
"response": {
"statusCode": 200,
"contentType": "text/plain",
"body": "3eZbrw1aBm2rZgRNFdxV2595E9CY3gmdALWMmHkvFXO7tYXAYM8P"
}
}

Data Sources

Select Channel

Select a Slack channel from a dropdown menu (up to 10,000 channels) | key: selectChannels | type: picklist

Data Source Payload

{
"result": [
{
"key": "C123456",
"label": "#general (ID: C123456)"
},
{
"key": "C000000",
"label": "#other-channel (ID: C000000)"
},
{
"key": "C555555",
"label": "#random (ID: C555555)"
}
]
}

Actions

Archive Conversation

Archive an existing conversation | key: archiveConversation


Close Conversation

Close an existing conversation | key: closeConversation


Conversation Exists

Returns true if the conversation already exists | key: conversationExists


Create Conversation

Create a new conversation | key: createConversation

Output Example Payload

{
"data": {
"ok": true,
"channels": [
{
"id": "COZ7e3d",
"name": "example channel",
"is_channel": true,
"is_group": false,
"is_im": false,
"is_private": false,
"is_archived": false,
"created": 6426934241,
"creator": "example",
"unlinked": 0,
"name_normalized": "example channel",
"shared_team_ids": [
"TW2oP78"
],
"purpose": {
"value": "This channel was created for an example response."
}
}
]
}
}

Delete a pending scheduled message

Delete the content and metadata of a pending scheduled message from a queue | key: deletePendingMessage


Delete message

Delete the content and metadata of an existing message | key: deleteMessage


Get Conversation History

Get the history of a conversation | key: getConversationsHistory

Output Example Payload

{
"data": {
"ok": true,
"messages": [
{
"client_msg_id": "123123-123123-123123",
"type": "message",
"text": "hello world",
"user": "U01QFFSE2QK",
"ts": "166149417.178179",
"team": "TH0GJM0M8"
}
]
}
}

Get User By Email

Get a user's information by email | key: getUser

Output Example Payload

{
"data": {
"ok": true,
"user": {
"id": "example",
"color": "example",
"deleted": false,
"real_name": "Example User",
"name": "Example User",
"tz": "America/Chicago",
"profile": {
"title": "example",
"phone": "example",
"skype": "example",
"real_name": "Slackbots",
"real_name_normalized": "example",
"first_name": "example",
"email": "example",
"team": "example",
"display_name": "example"
}
}
}
}

Get User By ID

Get a user's information by ID | key: getUserById

Output Example Payload

{
"data": {
"ok": true,
"user": {
"id": "example",
"color": "example",
"deleted": false,
"real_name": "Example User",
"name": "Example User",
"tz": "America/Chicago",
"profile": {
"title": "example",
"phone": "example",
"skype": "example",
"real_name": "Slackbots",
"real_name_normalized": "example",
"always_active": true,
"first_name": "example",
"email": "example",
"team": "example",
"display_name": "example"
}
}
}
}

Invite User To Conversation

Invite a user to an existing conversation | key: inviteUserToConversation


Leave Conversations

Leave an existing conversation | key: leaveConversation


List Conversation Members

List all members of a conversation | key: listConversationMembers


List Conversations

List all conversations | key: listConversations

Output Example Payload

{
"data": {
"ok": true,
"channels": [
{
"id": "COZ7e3d",
"name": "example channel",
"is_channel": true,
"is_group": false,
"is_im": false,
"is_private": false,
"is_archived": false,
"created": 6426934241,
"creator": "example",
"unlinked": 0,
"name_normalized": "example channel",
"shared_team_ids": [
"TW2oP78"
],
"purpose": {
"value": "This channel was created for an example response."
}
}
]
}
}

List Files

List all available files | key: listFiles


List Scheduled Messages

List all scheduled messages | key: listScheduledMessages


List Users

List Users | key: listUsers

Output Example Payload

{
"data": {
"ok": true,
"members": [
{
"id": "Exmple",
"team_id": "34700c09vs0zx",
"name": "Example",
"deleted": false,
"color": "37373",
"profile": {
"title": "example",
"phone": "example",
"skype": "example",
"real_name": "Slackbots",
"real_name_normalized": "example",
"always_active": true,
"first_name": "example",
"email": "example",
"team": "example",
"display_name": "example"
}
}
],
"response_metadata": {
"next_cursor": "",
"scopes": [
"admin",
"idetify",
"channels:read"
]
}
}
}

List Users Conversations

List Users Conversations | key: listUsersConversations

Output Example Payload

{
"data": {
"ok": true,
"channels": [
{
"id": "COZ7e3d",
"name": "example channel",
"is_channel": true,
"is_group": false,
"is_im": false,
"is_private": false,
"is_archived": false,
"created": 6426934241,
"creator": "example",
"unlinked": 0,
"name_normalized": "example channel",
"shared_team_ids": [
"TW2oP78"
],
"purpose": {
"value": "This channel was created for an example response."
}
}
]
}
}

Post Block Message

Post a message to a slack channel | key: postBlockMessage

Output Example Payload

{
"data": {
"ok": true,
"channel": "C011B7U3R9U",
"ts": "1646951430.367539",
"message": {
"type": "message",
"subtype": "bot_message",
"text": "The message I sent",
"ts": "1646951430.367539",
"username": "My Slack App",
"bot_id": "B036D2DCT54"
},
"response_metadata": {
"scopes": [
"identify",
"chat:write",
"chat:write.public",
"chat:write.customize"
],
"acceptedScopes": [
"chat:write"
]
}
}
}

Post Ephemeral Message

Post an ephemeral message to a user or channel | key: postEphemeralMessage


Post Message

Post a message to a slack channel | key: postMessage

Output Example Payload

{
"data": {
"ok": true,
"channel": "C011B7U3R9U",
"ts": "1646951430.367539",
"message": {
"type": "message",
"subtype": "bot_message",
"text": "The message I sent",
"ts": "1646951430.367539",
"username": "My Slack App",
"bot_id": "B036D2DCT54"
},
"response_metadata": {
"scopes": [
"identify",
"chat:write",
"chat:write.public",
"chat.write.customize"
],
"acceptedScopes": [
"chat:write"
]
}
}
}

Raw Request

Send a raw HTTP request to Slack API | key: rawRequest


Rename Conversation

Rename an existing conversation | key: renameConversation


Set Conversation Purpose

Set the purpose of an existing conversation | key: setConversationPurpose


Set Conversation Topic

Set the purpose of an existing conversation | key: setConversationTopic


Slack Block Message From Webhook

Post a block formatted message to a Slack channel from a webhook URL | key: postWebhookBlockMessage

Output Example Payload

{
"data": {
"text": "ok"
}
}

Slack Message From Webhook

Post a message to a Slack channel from a webhook URL | key: postSlackMessage

Output Example Payload

{
"data": {
"text": "ok"
}
}

Update Message

Update the contents of an existing message | key: updateMessage


Upload File

Upload a new file to a slack conversation | key: uploadFile