Slack provides built-in functions you can use alongside your custom functions in a workflow. Built-in functions are essentially Slack-native actions, like creating a channel or sending a message, that work hand-in-hand with your functions.
Please note that some built-in functions may be restricted due to Workspace permission settings. Reach out to a Workspace owner if these aren't available to you.
You can familiarize yourself with workflows via our workflows guide.
Built-in functions need to be imported from the standard library built into the Slack SDK — all built-in functions are children of the Schema.slack.functions
object. Just like custom functions, built-ins are then added to steps in a workflow using the addStep
method. That's it!
Built-in functions define their own inputs and outputs, as detailed for each built-in below.
Here's an example of a workflow that creates a new Slack channel using the CreateChannel
built-in function:
import { DefineWorkflow, Schema } from "deno-slack-sdk/mod.ts"
// ...
const createChannelStep = myWorkflow.addStep(
Schema.slack.functions.CreateChannel,
{
channel_name: myWorkflow.inputs.channel_name,
is_private: false,
},
);
Pins a message to a channel.
Schema ID: Schema.slack.functions.AddPin
Required Scope: pins:write
Input | Type | Description |
---|---|---|
channel_id |
Schema.slack.types.channel_id |
The ID of the Channel the message will be pinned to |
message |
Schema.types.string |
The URL or timestamp of the message that will be pinned |
Adds a user to a User Group. The function takes two inputs:
S123ABC456
).Once completed, the function returns the ID of the user you added and the User Group they were added to.
Schema ID: Schema.slack.functions.AddUserToUsergroup
Required Scope: usergroups:write
Input | Type | Description |
---|---|---|
usergroup_id |
Schema.slack.types.usergroup_id |
The ID of the User Group the user will be added to |
user_id |
Schema.slack.types.user_id |
The ID of the user to add to the User Group |
Output | Type | Description |
---|---|---|
usergroup_id |
Schema.slack.types.usergroup_id |
The ID of the User Group, now with the added user |
Archives a channel. The function takes one input:
C123ABC456
)And provides a single output, the same channel ID.
Schema ID: Schema.slack.functions.ArchiveChannel
Required Scope: channels:write
, im:write
, groups:write
, mpim:write
Input | Type | Description |
---|---|---|
channel__id |
Schema.slack.types.channel_id |
The ID of the channel to archive |
Output | Type | Description |
---|---|---|
channel_id |
Schema.slack.types.channel_id |
The ID of the archived channel |
Creates a new channel. The function takes two inputs:
true
; if the channel should be public, set to false
.If the channel is successfully created, the ID of the channel will be returned as an output of the function.
Schema ID: Schema.slack.functions.CreateChannel
Required Scope: channels:manage
, groups:write
Input | Type | Description |
---|---|---|
channel_name |
Schema.types.string |
The name of the channel; the function will attempt to create a channel name that follows Slack's channel name guidelines |
is_private |
Schema.types.boolean |
(Optional) Set to true if the channel should be private |
Output | Type | Description |
---|---|---|
channel_id |
Schema.slack.types.channel_id |
The ID of the created channel |
Creates a new User Group. The function takes two inputs:
Once completed, the function returns the created User Group's ID.
Schema ID: Schema.slack.functions.CreateUsergroup
Required Scope: usergroups:write
Input | Type | Description |
---|---|---|
usergroup_name |
Schema.types.string |
The name of the User Group to be created |
usergroup_handle |
Schema.types.string |
The @usergroup handle |
Output | Type | Description |
---|---|---|
usergroup_id |
Schema.slack.types.usergroup_id |
The ID of the new User Group |
Delays a workflow for some amount of time. This function takes a single input:
And returns a timestamp that the function completed.
Schema ID: Schema.slack.functions.Delay
No additional required scopes.
Input | Type | Description |
---|---|---|
minutes_to_delay |
Schema.types.integer |
Length of time (in minutes) |
Invites a user to a channel. The function takes two inputs:
user_id
.channel_id
.If the user is successfully invited to the channel, the ID of the user will be returned as an output of the function.
Schema ID: Schema.slack.functions.InviteUserToChannel
Required Scope: channels:manage
, groups:write
Input | Type | Description |
---|---|---|
channel_id |
Schema.slack.types.channel_id |
The ID of the channel to invite the user into |
user_id |
Schema.slack.types.user_id |
The ID of the user to invite into the channel |
Output | Type | Description |
---|---|---|
user_id |
Schema.slack.types.user_id |
The ID of the user invited to the channel |
Opens a form for the user to interact with. The function takes three inputs:
Learn how to use this function in a workflow to collect information from a user for use in later steps!
Schema ID: Schema.slack.functions.OpenForm
No additional required scopes.
Input | Type | Description |
---|---|---|
title |
Schema.types.string |
Title of the form shown to the user (24 characters max) |
fields |
See Using forms for schema | Input fields to be shown on the form |
interactivity |
Schema.slack.types.interactivity |
Context about the interactive event that led to opening of the form |
description |
Schema.types.string |
(Optional) Description of the form shown to the user |
submit_label |
Schema.types.string |
(Optional) Label of the submit button that the user will click to submit the form |
Output | Type | Description |
---|---|---|
fields |
Schema.types.object |
Values of the input fields filled by the user. See Using forms for details. |
interactivity |
Schema.slack.types.interactivity |
Context about the form submit action interactive event |
Additional requirements: When creating a workflow that will have a step to open a form, your workflow needs to include a required interactivity
input parameter, and the call to OpenForm
must be the first step in the workflow.
Here's an example of a basic workflow definition using interactivity
:
export const SayHelloWorkflow = DefineWorkflow({
callback_id: "say_hello_workflow",
title: "Say Hello to another user",
input_parameters: {
properties: {
interactivity: {
type: Schema.slack.types.interactivity,
}
},
required: ["interactivity"]
}
});
Removes a user or multiple users from a User Group. The function takes two inputs:
S123ABC456
).["U123ABC456"]
)Once completed, the function returns the ID of the User Group you removed the user(s) from.
Schema ID: Schema.slack.functions.RemoveUserFromUsergroup
Required Scope: usergroups:write
Input | Type | Description |
---|---|---|
usergroup_id |
Schema.slack.types.usergroup_id |
The ID of the User Group to remove the user(s) from |
user_id |
Schema.slack.types.user_id |
An single user ID to be removed from the User Group |
Output | Type | Description |
---|---|---|
usergroup_id |
Schema.slack.types.usergroup_id |
The ID of the User Group, which no longer contains the user(s) |
Sends a direct message to a user. This function takes two required inputs:
user_id
)message
)And returns the channel-specific unique identifier (ts
) for the posted message. Timestamp of the message that was sent.
Schema ID Schema.slack.functions.SendDm
Required Scopes:
Input | Type | Description |
---|---|---|
user_id |
Schema.slack.types.user_id |
User ID to send the message |
message |
Schema.slack.types.rich_text |
The private textual message to send to the recipient |
thread_ts |
Schema.types.string |
(Optional) The ts identifier of an existing message to send this message to as a reply. Do not use ts values of messages that themselves are replies |
interactive_blocks |
Schema.slack.types.blocks |
(Optional) Buttons to send with the message |
Output | Type | Description |
---|---|---|
message_ts |
Schema.types.string |
The channel-specific unique identifier for this message. Doubles as a timestamp for when the message was posted in seconds from the epoch |
action |
Schema.types.object |
If interactive_blocks was provided, the action object contains the button properties (see action payload below) |
interactivity |
Schema.slack.types.interactivity |
If interactive_blocks is provided, the interactivity context |
Example action
payload:
{
"action_id": "WaXA",
"block_id": "=qXel",
"text": {
"type": "plain_text",
"text": "View",
"emoji": true
},
"value": "click_me_123",
"type": "button",
"action_ts": "1548426417.840180"
}
Sends an ephemeral message to a specific channel. This function takes three inputs:
channel_id
) to send the messageuser_id
) to whom the message will be shownmessage
And returns the channel-specific unique identifier (ts
) for the posted message.
Schema ID: Schema.slack.functions.SendEphemeralMessage
No additional required scopes.
Input | Type | Description |
---|---|---|
channel_id |
Schema.slack.types.channel_id |
The ID of the Channel to send the message |
user_id |
Schema.slack.types.user_id |
The ID of the user that will be able to see the ephemeral message |
message |
Schema.slack.types.rich_text |
The textual message to send to channel |
thread_ts |
Schema.types.string |
(Optional) The ts identifier of an existing message to send this ephemeral message to as a reply. Do not use ts values of messages that themselves are replies. |
Output | Type | Description |
---|---|---|
message_ts |
Schema.types.string |
The channel-specific unique identifier for this message. With some wrangling, doubles as a partial timestamp for when the message was posted in seconds from the epoch |
Sends a message to a specific channel. This does not allow for direct messages to users. This function takes two required inputs:
channel_id
)message
)This function returns a timestamp of the new message, which also serves as a confirmation that the message was sent.
Schema ID: Schema.slack.functions.SendMessage
No additional required scopes.
Input | Type | Description |
---|---|---|
channel_id |
Schema.slack.types.channel_id |
Channel ID to send the message |
message |
Schema.slack.types.rich_text |
The textual message to send to channel — previously accepted as text |
thread_ts |
Schema.slack.types.timestamp |
(Optional) The ts identifier of an existing message to send this message to as a reply. Do not use ts values of messages that themselves are replies |
metadata |
Schema.slack.types.object |
(Optional) Additional data about the message |
interactive_blocks |
Schema.slack.types.blocks |
(Optional) Buttons to send with the message. Must be wrapped in a block. |
For example, if you want to collect a formatted message (using rich_text
) from your end users and send it as is, you can use a form to collect the formatted text, and a built-in function to send it:
const inputForm = RichTextWorkflow.addStep(
Schema.slack.functions.OpenForm,
{
title: "Send formatted message",
interactivity: RichTextWorkflow.inputs.interactivity,
submit_label: "Send formatted message",
fields: {
elements: [{
name: "formattedInput",
title: "Formatted input",
type: Schema.slack.types.rich_text,
},
{
name: "channel",
title: "Post in:",
type: Schema.slack.types.channel_id,
default: RichTextWorkflow.inputs.channel,
},]
required: ["channel", "formattedInput"],
},
},
);
RichTextWorkflow.addStep(Schema.slack.functions.SendMessage, {
channel_id: inputForm.outputs.fields.channel,
message: inputForm.outputs.fields.formattedInput,
interactive_blocks: [{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Approve",
},
"style": "primary",
"value": "approve",
"action_id": "approve_button",
},
],
}],
});
Here's a simpler example with just regular ol' text.
const sendPreview = createAnnouncement.addStep(
Schema.slack.functions.SendMessage,
{
channel_id: "CTLC2K3JS",
message: "Good to see you here!",
},
);
Output | Type | Description |
---|---|---|
message_ts |
Schema.types.string |
The channel-specific unique identifier for this message. With some wrangling, doubles as a partial timestamp for when the message was posted in seconds from the epoch |
message_link |
Schema.types.string |
Permalink URL of the message that was sent |
action |
Schema.types.object |
If interactive_blocks was provided, the action object contains the button properties (see action payload below) |
interactivity |
Schema.slack.types.interactivity |
If interactive_blocks is provided as an input parameter, the interactivity context becomes available |
Example action
payload:
{
"action_id": "WaXA",
"block_id": "=qXel",
"text": {
"type": "plain_text",
"text": "View",
"emoji": true
},
"value": "click_me_123",
"type": "button",
"action_ts": "1548426417.840180"
}
Updates the topic of a channel. The function takes two inputs:
Once complete, the function returns the channel's new, updated topic as an output variable.
Schema ID: Schema.slack.functions.UpdateChannelTopic
Required Scopes: channels:manage
, groups:write
Input | Type | Description |
---|---|---|
channel_id |
Schema.slack.types.channel_id |
The ID of the channel to have its topic changed |
topic |
Schema.types.string |
The topic to change to |
Output | Type | Description |
---|---|---|
topic |
Schema.types.string |
The new topic |
Have 2 minutes to provide some feedback?
We'd love to hear about your experience with the new Slack platform. Please complete our short survey so we can use your feedback to improve.