A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.slack.dev/interactivity/implementing-shortcuts below:

Implementing shortcuts | Slack Developer Docs

Implementing shortcuts

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.

Use cases Shortcut types Global shortcuts

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

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.

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.

Getting started with shortcuts

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.

Preparing for payloads

Ensure your app is ready to receive interaction payloads by providing a Request URL, as described in our guide to handling user interactions.

Adding the right permissions

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:

  1. From your app's dashboard, click the menu item OAuth & Permissions.

  2. 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 Slack Marketplace, the changes will be reflected only after the app is reviewed and approved.

Creating a shortcut

Now that your app is ready, it's time to create some potential interaction energy:

  1. Open your app's dashboard

  2. Click on Interactivity & Shortcuts in the sidebar

  3. Click the Create New Shortcut button under Shortcuts

  4. Select from the Global and On messages options, depending on which type of shortcut you want and click Next

  5. Fill in the following:

  1. Click the green Create button, and you'll be sent back to the Interactivity & Shortcuts page.

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

Handling the use of shortcuts in your app

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.

Processing the 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.

Responding to shortcuts

There are a few things to consider about responding to interaction payloads:

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:

Limitations Next steps

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.

Related references Interaction payloads Modal and messages

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4