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.

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

InputDefaultNotesExample
Input
Authorize URL
string
/ Required
Default
https://slack.com/oauth/v2/authorize
Notes
The OAuth 2.0 Authorization URL for Slack. If you want to request access to the API on behalf of a user, append a 'user_scope' query parameter to the end of the Authorize URL: https://slack.com/oauth/v2/authorize?user_scope=chat:write
Example
 
Input
Client ID
string
/ Required
Default
Notes
 
Example
 
Input
Client Secret
password
/ Required
Default
Notes
 
Example
 
Input
Is User
boolean
/ Required
Default
false
Notes
Flip the flag to true if you want to access the API as a user. If flipped you must also provide a 'user_scope' query parameter to the end of the Authorize URL. Leaving the flag false will grant you a bot token instead.
Example
 
Input
Revoke URL
string
/ Required
Default
https://slack.com/api/auth.revoke
Notes
The OAuth 2.0 Revocation URL for Slack
Example
 
Input
Scopes
string
/ Required
Default
chat:write chat:write.public channels:read
Notes
A space-delimited set of one or more scopes to get the user's permission to access.
Example
chat:write chat:write.public users:read channels:read files:read files:write channels:write
Input
Signing Secret
password
/ Required
Default
Notes
 
Example
 
Input
Token URL
string
/ Required
Default
https://slack.com/api/oauth.v2.access
Notes
The OAuth 2.0 Token URL for Slack
Example
 

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
InputNotesExample
Input
Webhook URL
string
/ Required
Notes
The Slack webhook URL. Instructions for generating a Slack webhook are available on the Slack component docs page.
Example
https://hooks.slack.com/services/TXXXX/BXXXXX/XXXXXXX

Triggers#

Webhook#

Trigger for handling webhooks from Slack | key: webhook

InputNotes
Input
Connection
connection
/ Required
Notes
The connection to use

You can configure Slack to send events to a Prismatic integration. This webhook trigger uses your Slack app's signing secret to verify that messages come from Slack. If a challenge request is received, this trigger responds with the proper challenge response and this trigger follows the "URL Verify" branch. For other notifications, like a "channel create" event occurred, this trigger follows the "Notification" path.

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"  }}

Actions#

Archive Conversation#

Archive an existing conversation | key: archiveConversation

InputNotesExample
Input
Channel Name or ID
string
/ Required
Notes
The name or static ID of the Slack channel.
Example
general
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 

Close Conversation#

Close an existing conversation | key: closeConversation

InputNotesExample
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
Conversation Name
string
/ Required
Notes
The name of the Slack conversation.
Example
Book Club

Conversation Exists#

Returns true if the conversation already exists | key: conversationExists

InputNotesExample
Input
Channel Name or ID
string
/ Required
Notes
The name or static ID of the Slack channel.
Example
general
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 

Create Conversation#

Create a new conversation | key: createConversation

InputDefaultNotesExample
Input
Connection
connection
/ Required
Default
 
Notes
The connection to use
Example
 
Input
Conversation Name
string
/ Required
Default
Notes
The name of the Slack conversation.
Example
Book Club
Input
Is Private
boolean
/ Required
Default
false
Notes
This flag will determine if the Slack conversation is private.
Example
 
Input
Team Id
string
Default
Notes
The Id of the Slack team.
Example
84350944036

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

InputNotesExample
Input
Channel ID
string
/ Required
Notes
The static ID of the Slack channel.
Example
C02MS7HV6KB
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
Message Id
string
/ Required
Notes
A unique identifier of a message or thread to reply to (thread_ts)
Example
84350944036

Delete message#

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

InputNotesExample
Input
Channel ID
string
/ Required
Notes
The static ID of the Slack channel.
Example
C02MS7HV6KB
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
Message Id
string
/ Required
Notes
A unique identifier of a message or thread to reply to (thread_ts)
Example
84350944036

Get User By Email#

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

InputNotesExample
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
Email
string
/ Required
Notes
Provide a string value for the email address of the user.
Example
someone@example.com

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

InputNotesExample
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
User ID
string
/ Required
Notes
 
Example
W012A3CDE

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

InputNotesExample
Input
Channel Name or ID
string
/ Required
Notes
The name or static ID of the Slack channel.
Example
general
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
User Id
string
/ Required
Notes
Provide a string value for the unique identifier of the user you want to send the message to.
Example
84350944036

Leave Conversations#

Leave an existing conversation | key: leaveConversation

InputNotesExample
Input
Channel Name or ID
string
/ Required
Notes
The name or static ID of the Slack channel.
Example
general
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 

List Conversation Members#

List all members of a conversation | key: listConversationMembers

InputDefaultNotesExample
Input
Channel Name or ID
string
/ Required
Default
Notes
The name or static ID of the Slack channel.
Example
general
Input
Connection
connection
/ Required
Default
 
Notes
The connection to use
Example
 
Input
Cursor
string
Default
Notes
Provide a cursor pointing to the page you would like to access
Example
3
Input
Exclude Archived
boolean
Default
false
Notes
This flag will determine if archived results will be excluded from the result set.
Example
 
Input
Limit
string
Default
Notes
Provide a numerical limit to the amount of results returned.
Example
80

List Conversations#

List all conversations | key: listConversations

InputDefaultNotesExample
Input
Connection
connection
/ Required
Default
 
Notes
The connection to use
Example
 
Input
Cursor
string
Default
Notes
Provide a cursor pointing to the page you would like to access
Example
3
Input
Exclude Archived
boolean
Default
false
Notes
This flag will determine if archived results will be excluded from the result set.
Example
 
Input
Limit
string
Default
Notes
Provide a numerical limit to the amount of results returned.
Example
80
Input
Team Id
string
Default
Notes
The Id of the Slack team.
Example
84350944036

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

InputNotesExample
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
Cursor
string
Notes
Provide a cursor pointing to the page you would like to access
Example
3

List Scheduled Messages#

List all scheduled messages | key: listScheduledMessages

InputNotes
Input
Connection
connection
/ Required
Notes
The connection to use

List Users#

List Users | key: listUsers

InputNotesExample
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
Cursor
string
Notes
Provide a cursor pointing to the page you would like to access
Example
3
Input
Limit
string
Notes
Provide a numerical limit to the amount of results returned.
Example
80
Input
Team Id
string
Notes
The Id of the Slack team.
Example
84350944036

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

InputNotesExample
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
Cursor
string
Notes
Provide a cursor pointing to the page you would like to access
Example
3
Input
Limit
string
Notes
Provide a numerical limit to the amount of results returned.
Example
80
Input
Team Id
string
Notes
The Id of the Slack team.
Example
84350944036
Input
User Id
string
/ Required
Notes
Provide a string value for the unique identifier of the user you want to send the message to.
Example
84350944036

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

InputDefaultNotesExample
Input
Blocks
code
/ Required
Default
{  "blocks": [    {      "type": "section",      "text": {        "type": "plain_text",        "text": "Hello world"      }    }  ]}
Notes
A JSON array containing blocks (objects) that make up the desired message. Use Slack's Block Kit Builder (https://app.slack.com/block-kit-builder/) to build block messages.
Example
 
Input
Channel Name or ID
string
/ Required
Default
Notes
The name or static ID of the Slack channel.
Example
general
Input
Connection
connection
/ Required
Default
 
Notes
The connection to use
Example
 
Input
Alt Message
string
/ Required
Default
Notes
This message will override if your block cannot be sent
Example
Hello from Prismatic!
Input
Message Id
string
Default
Notes
A unique identifier of a message or thread to reply to (thread_ts)
Example
84350944036
Input
Bot Username
string
Default
Notes
The username of the bot the message will be sent from. This requires the 'chat:write.customize' scope.
Example
exampleUser

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

InputNotesExample
Input
Channel Name or ID
string
/ Required
Notes
The name or static ID of the Slack channel.
Example
general
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
Message
string
/ Required
Notes
The message to send the Slack channel.
Example
Hello from Prismatic!
Input
User Id
string
/ Required
Notes
Provide a string value for the unique identifier of the user you want to send the message to.
Example
84350944036
Input
Bot Username
string
Notes
The username of the bot the message will be sent from. This requires the 'chat:write.customize' scope.
Example
exampleUser

Post Message#

Post a message to a slack channel | key: postMessage

InputNotesExample
Input
Channel Name or ID
string
/ Required
Notes
The name or static ID of the Slack channel.
Example
general
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
Message
string
/ Required
Notes
The message to send the Slack channel.
Example
Hello from Prismatic!
Input
Message Id
string
Notes
A unique identifier of a message or thread to reply to (thread_ts)
Example
84350944036
Input
Bot Username
string
Notes
The username of the bot the message will be sent from. This requires the 'chat:write.customize' scope.
Example
exampleUser

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"      ]    }  }}

Rename Conversation#

Rename an existing conversation | key: renameConversation

InputNotesExample
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
Conversation Name
string
/ Required
Notes
The name of the Slack conversation.
Example
Book Club
Input
New Conversation Name
string
/ Required
Notes
The name of the Slack conversation.
Example
Book Club

Set Conversation Purpose#

Set the purpose of an existing conversation | key: setConversationPurpose

InputNotesExample
Input
Channel Name or ID
string
/ Required
Notes
The name or static ID of the Slack channel.
Example
general
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
Conversation Purpose
string
Notes
Provide a string value for the purpose of the given conversation.
Example
Engineering
Input
User Id
string
/ Required
Notes
Provide a string value for the unique identifier of the user you want to send the message to.
Example
84350944036

Set Conversation Topic#

Set the purpose of an existing conversation | key: setConversationTopic

InputNotesExample
Input
Channel Name or ID
string
/ Required
Notes
The name or static ID of the Slack channel.
Example
general
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
Conversation Topic
string
Notes
Provide a string value for the topic of the given conversation.
Example
Engineering
Input
User Id
string
/ Required
Notes
Provide a string value for the unique identifier of the user you want to send the message to.
Example
84350944036

Slack Block Message From Webhook#

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

InputDefaultNotesExample
Input
Blocks
code
/ Required
Default
{  "blocks": [    {      "type": "section",      "text": {        "type": "plain_text",        "text": "Hello world"      }    }  ]}
Notes
A JSON array containing blocks (objects) that make up the desired message. Use Slack's Block Kit Builder (https://app.slack.com/block-kit-builder/) to build block messages.
Example
 
Input
Connection
connection
/ Required
Default
 
Notes
The connection to use
Example
 
Input
Alt Message
string
/ Required
Default
Notes
This message will override if your block cannot be sent
Example
Hello from Prismatic!

Output Example Payload#

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

Slack Message From Webhook#

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

InputNotesExample
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
Message
string
/ Required
Notes
The message to send the Slack channel.
Example
Hello from Prismatic!

Output Example Payload#

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

Update Message#

Update the contents of an existing message | key: updateMessage

InputNotesExample
Input
Channel ID
string
/ Required
Notes
The static ID of the Slack channel.
Example
C02MS7HV6KB
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
Message
string
/ Required
Notes
The message to send the Slack channel.
Example
Hello from Prismatic!
Input
Message Id
string
/ Required
Notes
A unique identifier of a message or thread to reply to (thread_ts)
Example
84350944036

Upload File#

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

InputNotesExample
Input
Channels
string
Notes
Provide a comma separated list of channel names, or ids that the file will be shared in.
Example
general,marketing
Input
Connection
connection
/ Required
Notes
The connection to use
Example
 
Input
Cursor
string
Notes
Provide a cursor pointing to the page you would like to access
Example
3
Input
File Content
data
/ Required
Notes
Provide the data for a file to be uploaded
Example
 
Input
File Name
string
/ Required
Notes
Provide a name for the file.
Example
reports.csv
Input
File Name
string
/ Required
Notes
A full list of supported file types can be found here: https://api.slack.com/types/file#file_types
Example
csv
Input
Initial Comment
string
Notes
The message text introducing the file in the specified channels when uploaded
Example
Example message
Input
Thread Reply
string
Notes
Provide another message's ts value to upload this file as a reply. Never use a reply's ts value, use the parent instead.
Example
u830hd230
Input
File Title
string
Notes
The title of the file as it will appear in the channel
Example
Monthly Reports