Shortcuts let users quickly trigger workflows from various prominent locations within Slack.
Shortcuts can trigger modals and other app interactions. When someone uses one of your shortcuts, your app will receive some context about what happened in an interaction payload. They are gateways to powerful, productive workflows.
Apps can create global shortcuts that are available from anywhere in Slack, and message shortcuts that are shown only in message context menus.
Read on to find out about the two types of shortcuts, and how to create one.
Global shortcuts are available to users via the shortcuts button in the message composer, and when using search in Slack.
These type of shortcuts are intended to trigger workflows that can operate without the context of a channel or message.
For example, users might trigger a global shortcut to create a calendar event or view their upcoming on-call shifts.
Message shortcuts are shown to users in the context menus of non-ephemeral messages within Slack.
Message shortcuts will retain the context of the source message from which they were initiated. This makes them ideal when you have a workflow that relies on that context to work.
For example, users might quickly generate tasks from a posted message, or send messages to external services.
If you don't have a Slack app yet, follow our quick guide to create one.
In order to start using shortcuts with your app, there are a few preparation steps you'll need to go through.
Ensure your app is ready to receive interaction payloads by providing a Request URL, as described in our guide to handling user interactions.
To make shortcuts available in Slack, your app must have the
commands permission scope. You can either request this scope during the OAuth flow or add it to your app OAuth settings:
From your app's dashboard, click the menu item OAuth & Permissions.
Under Scopes, type
commands into the text field, select the correct permission to add it, then click Save Changes.
If your app isn't already requesting
commands at installation, it will need to be reinstalled before shortcuts can be used. If your app is published in the App Directory, the changes will be reflected only after the app is reviewed and approved.
Now that your app is ready, it's time to create some potential interaction energy:
Open your app's dashboard
Click on Interactivity & Shortcuts in the sidebar
Click the Create New Shortcut button under Shortcuts
Select from the Global and On messages options, depending on which type of shortcut you want and click Next
Fill in the following:
Click the green Create button, and you'll be sent back to the Interactivity & Shortcuts page.
On that page you'll need to click the Save Changes button.
That's it—you've created your first shortcut! You can create some more—each app can have up to 5 global shortcuts, and separately, 5 message shortcuts. Shortcuts will appear in shortcuts menus in the order in which they were created.
Now let's make sure you are ready to receive interaction payloads and do something in response.
You've created a shortcut, and at some point it will be used by someone in Slack. Your app has to handle that eventuality.
We explain the process in-depth in our guide to handling user interactions in apps, including how to prepare your app with a request URL. In short, your app will receive an interaction payload after someone uses one of your shortcuts. Your app must process that payload and then send a response.
First, let's learn more about that interaction payload.
Take a shortcut to a solution with Bolt
When a shortcut is invoked, a request will be sent to the app's configured Request URL. The request body will contain a
payload parameter that your app should parse for JSON.
Inside you'll discover an interaction payload containing lots of useful context — consult our reference guide to see the full structure of the fields included.
Payloads for global shortcuts will contain different info from payloads for message shortcuts. For example, a payload for a message shortcut will include channel and message context, and a
response_url for publishing message responses. If you want to publish a message in response to a global shortcut, use our alternative approach.
There are a few things to consider about responding to interaction payloads:
Always send an acknowledgment response.
As soon as your app receives the interaction payload, a countdown begins, because this message will self-destruct in 3 seconds. If your app doesn't respond with an HTTP status
200 OK within 3000ms of receiving the payload, the person who used the shortcut will see a generic error message letting them know that something went wrong.
Your app must follow up with a modal to confirm any action that will occur.
This will allow the user to feel much more confident using any shortcut, as they can trust that they won't immediately publish a message or modify data.
Beyond these essential actions, your app also has a range of more complex responses to take.
You can use a field supplied in the interaction payload to publish messages, or another payload field to pop a modal that can collect or present more info. Shortcuts can also be a trigger for your app to make calls to APIs or external services.
A note about global shortcuts and sending messages
If you're using global shortcuts, and want to publish messages as a response, you can do so by triggering a modal containing a special conversation selector.
Apps should use this approach to ensure that users know that they can use any shortcut without an unexpected message being published on their behalf.
Global shortcuts are not visible (and therefore usable) for all types of guest user. Please see our Help Center for an up-to-date breakdown of the availability of shortcuts for these users.
When an app is submitted (or re-submitted) to the App Directory, the confirmation modal does not indicate any changes regarding global shortcuts. Despite the discrepancy, global shortcut changes will be submitted upon confirmation.
An app responding to a shortcut initiated from a threaded message cannot currently publish a message back to that thread. They can publish back to the parent conversation. We are working on a comprehensive solution that will make this possible.
You've now learned how to create a shortcut, and what your app has to do to handle their use. That's a great start!
Read our guide to responding to interactions to understand the vast range of possibilities open to your app at this point.