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.
Surface your app's core functionality globally within Slack
Enable users to take action on a message
Improve discoverability of your app
Think about what app invocation points belong in a global context versus which belong in a message context.
For example, pretend you're building a task management app. An example of a shortcut that makes sense in a global context would be
Create a task, whereas a shortcut that belongs in a message context would be
Attach to a task, which could attach the specific message to an existing task.
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.
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.
default_to_current_conversation parameter in block kit elements to make it easy for users to send messages to the same channel your shortcut was invoked in.
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.
Some recommendations related to shortcuts:
Include user confirmation of results
Whenever a user completes an action with your app (even when it isn't associated with shortcuts), provide confirmation and details about what they just did. And for a third-party service, include relevant links out to the service.
As an example, if the user performed an action like creating a new helpdesk ticket in a third-party service, include a link to where they can view more information about that ticket.
Be clear when using paid-feature shortcuts
If your app’s core features are paid-only and you plan to expose them via shortcuts, you should make it apparent for non-paying users that the reason they can’t use the shortcut is because they must have a paid plan for your app. Rather than silently failing, we recommend opening an explanatory modal (or posting an ephemeral message) that explains why they can't use the shortcut.
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.