Our future generation platform is in closed beta. Please request to participate. During the beta, expect some rough edges, broken windows overlooking blue sky vistas, and regularly scheduled changes.

Using built-in functions provided by Slack

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

Built-in functions need to be imported from the standard library built into the 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 "slack-cloud-sdk/mod.ts"

...

const createChannelStep = myWorkflow.addStep(
  Schema.slack.functions.CreateChannel,
  {
    channel_name: myWorkflow.inputs.channel_name,
    is_private: false,
  },
);

Read the full documentation for Workflows to learn how to build Workflows.

Built-in functions

Add pin to message

Pins a message to a channel.

Schema ID: Schema.slack.functions.AddPin

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. S0604QSJC).
  • The ID of the user you wish to add to the User Group.

Once completed, the function outputs the ID of the user you added and the User Group they were added to.

Schema ID: Schema.slack.functions.AddUserToUsergroup

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. C12345678)

And provides a single output, the same channel ID.

Schema ID: Schema.slack.functions.ArchiveChannel

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

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 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 outputs the created User Group's ID.

Schema ID: Schema.slack.functions.CreateUsergroup

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

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

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

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

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

Once completed, the function outputs the ID of the User Group you removed the user(s) from.

Schema ID: Schema.slack.functions.RemoveUserFromUsergroup

Input Type Description
usergroup_id Schema.slack.types.usergroup_id The ID of the User Group to remove the user(s) from
user_ids Schema.slack.types.user_id An array of user IDs 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)

Rename channel

Renames an existing channel. The function takes two inputs:

  • The ID of the chanel to rename.
  • The new name of the 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

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

Input Type Description
channel_id Schema.slack.types.channel_id The ID of the channel to rename
channel_name Schema.types.string The new name of the channel; the function will attempt to create a channel name that follows Slack's channel name guidelines
Output Type Description
channel_id Schema.slack.types.channel_id The ID of the renamed channel

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 text of the message

And returns the channel-specific unique identifier (ts) for the posted message.

Schema ID: Schema.slack.functions.SendEphemeralMessage

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
text Schema.types.string The textual message to send to channel — previously accepted as message
thread_ts Schema.slack.types.timestamp (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
ts Schema.slack.types.timestamp 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 inputs:

  • The unique identifier of the channel to send the message to, its channel_id
  • The text of the message

And returns a timestamp that the message was sent.

Schema ID: Schema.slack.functions.SendMessage

Input Type Description
channel_id Schema.slack.types.channel_id Channel ID to send the message
text Schema.types.string The textual message to send to channel — previously accepted as message
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.
Output Type Description
ts Schema.slack.types.timestamp 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

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 outputs the channel's new, updated topic as an output variable.

Schema ID: Schema.slack.functions.UpdateChannelTopic

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

Was this page helpful?