Controlling access to custom functions
Join the Developer Program and provision a sandbox with access to all Slack features for free.
To make a function available so that another user (or many users) can access workflows that reference that function, you'll use the function access
Slack CLI command. At this time, functions can be made available to:
- everyone in workspaces where the app has access,
- your app's collaborators,
- or specific users.
In order to enable the function access
command, your app must have been deployed at least once before attempting to make your function available to others.
You must also re-deploy your app after using function access
. Anytime you make permission changes to your function using the function access
command, your app must be redeployed, each time after, in order for the updates to be available in your app's workspace.
Grant access to one person
Given:
- a function with a callback ID of
get_next_song
- a user with ID
U1234567
You can make your get_next_song
function available to the user U1234567
like this:
$ slack function access --name get_next_song --users U1234567 --grant
To revoke access, replace --grant
with --revoke
.
Grant access to multiple people
Given:
- a function with a callback ID of
calculate_royalties
- users with the following IDs:
U1111111
,U2222222
, andU3333333
You can make your function calculate_royalties
available to the above users like this:
$ slack function access --name calculate_royalties --users U1111111,U2222222,U3333333 --grant
To revoke access, replace --grant
with --revoke
.
Grant access to all collaborators
Given:
- a function with a callback ID of
notify_escal_team
You can make your notify_escal_team
function available to all of your app's collaborators like this:
$ slack function access --name notify_escal_team --app_collaborators --grant
Grant access to all workspace members
Given:
- a function with a callback ID of
get_customer_profile
You can make your get_customer_profile
function available to everyone in your workspace like this:
$ slack function access --name get_customer_profile --everyone --grant
Grant access using the prompt-based approach
The prompt-based approach allows you to distribute your function to one user, to multiple people, to collaborators, or to everyone in an interactive prompt.
To activate the flow, use the following command in your terminal:
$ slack function access
Given:
- a function with a callback ID of
reverse
You will answer the first prompt in the following manner:
Choose the name of the function you'd like to distribute
> reverse (Reverse)
Choose who you'd like to to have access to your function
If going from everyone
or app_collaborators
to specific users, you should be offered the option of adding collaborators to specific users.
> specific users (current)
app collaborators only
everyone
Choose an action
> granting a user access
revoking a user's access
Provide ID(s) of one or more user in your workspace
Given:
- a user's ID in your workspace:
U0123456789
You will answer the following prompt below:
: U0123456789
You can add multiple users at the same time. To do this, separate the user IDs with a comma (e.g. U0123456789
, UA987654321
).
After you've finished this flow, you'll receive a message indicating the type of distribution you chose.
Guests and external users
Guests and external users are limited in the workflows they may run based on the scopes defined for the functions in the workflows. There is a predefined set of scopes that are considered "risky", which guest users cannot run. These scopes include the following:
channels:manage
- create and manage public channelschannels:write.invites
- invite members to public channelsgroups:write
- create and manage private channelsgroups:write.invites
- invite members to private channelsusergroups:write
- create and manage usergroups
If a guest or external user attempts to run a workflow containing a function with one of these scopes, they will receive an error.
More distribution options
For more distributions options, including how to revoke access, head to the distribute command reference.