The new Slack platform and the features described below are in beta and under active development.

Built-in functions

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.

Using with workflows

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,
  },
);

Built-in functions

Add pin to message

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

Add user to user group

Adds a user to a User Group. The function takes two inputs:

  • The ID of the User Group you wish to add to (e.g. S123ABC456).
  • The ID of the user you wish to add to the User Group.

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

Archive channel

Archives a channel. The function takes one input:

  • The ID of the channel (e.g. 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

Create channel

Creates a new channel. The function takes two inputs:

  • The name of the new channel, as a string. Slack will attempt to give it a name based on the existing channel naming rules, but the channel's name may end up being different than the exact string provided
  • Whether the channel should be private, as a boolean. If the channel should be private, set this to 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

Create user group

Creates a new User Group. The function takes two inputs:

  • The name of the User Group you wish to create.
  • The User Group's friendly name.

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

Delay

Delays a workflow for some amount of time. This function takes a single input:

  • A number of minutes to delay

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)

Invite user to channel

Invites a user to a channel. The function takes two inputs:

  • The ID of the user to be invited, as user_id.
  • The ID of the channel to which the user is to be invited, as 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

Open a Form

Opens a form for the user. The function takes three inputs:

  • The title of the form
  • The input fields shown on the form
  • Information about the opening of the form event

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 (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
submit_label Schema.types.string (Optional) Submit Label of 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 a user",
    input_parameters: {
        properties: {
            interactivity: {
                type: Schema.slack.types.interactivity,
            }
        },
        required: ["interactivity"]
    }
});

Remove user from user group

Removes a user or multiple users from a User Group. The function takes two inputs:

  • The ID of the User Group (e.g. S123ABC456).
  • An array of user IDs you wish to remove from the User Group (e.g., ["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)

Send direct message

Sends a direct message to a user. This function takes two required inputs:

  • The unique identifier of the user to send the message to (its user_id)
  • The test of the message you want to send (its 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

Action payload

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

Send ephemeral message

Sends an ephemeral message to a specific channel. This function takes three inputs:

  • The channel ID (channel_id) to send the message
  • The user ID (user_id) to whom the message will be shown
  • The message

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

Send message

Sends a message to a specific channel. This does not allow for direct messages to users. This function takes two required inputs:

  • The unique identifier of the channel to send the message to (its channel_id)
  • The text of the message you want to send (its 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

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,
});
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

Action payload

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

Update channel topic

Updates the topic of a channel. The function takes two inputs:

  • The ID of the channel whose topic you wish to update.
  • A string that is the channel's new topic.

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.