Go to Slack

An overview of message interactivity

Slack apps can use messages to do much more than just one-way communication. An injection of interactivity can invite and inspire action (and reaction). Best of all, users never have to depart from the comfort of a Slack conversation.

This overview will introduce ways to make your messages meaningfully interactive, and help guide you to the right options.


The impetus for interactivity

Interactive messages are much like other messages, but they contain extra ingredients called interactive components (more on these later).

These components allow messages to evolve in response to actions by users, services, or even just the passage of time.

With the help of interactivity, messages transform from simple information relays into powerful partners for users.

Where once your Slack app might have just pulled in data from external services, interactivity allows your app to manipulate, update, and send back data to the service with action taken.

Interactive messages even help you to build fully featured apps without needing to invest in push notification services or UI design. When you use our message composition tools and interactive components, Slack can become a notification pipeline and a consistent interface (across all platforms and devices) for your service.

The possibilities are vast - you can read some of the developer stories on our blog for inspiration - but you should start out here by reading about the different ways you can add interactivity.


The interactive message flow

Every interactive message exists as part of a flow, in a continuum of events that sum up to an interaction.

That interactive message flow has four basic parts: an origin event, a user interaction, an HTTP request from Slack telling the story of that interaction, and a response by the original service.

Here is that flow in colorful diagram form, with further explanation of each stage below:

Origin: an originating event causes your app to send a message that invites an action (like clicking a button or selecting a date) in Slack.

Interaction: A user in Slack reacts to the message by clicking that button or selecting that date.

Request: Slack sends an HTTP request to your app telling the story of how the user interacted with your message.

Response: Your app responds to the HTTP request from Slack.

Read on for an in-depth study of the four stages in the life of an interactive message.


The origins of interactive messages

Like a superhero, an interactive message needs a reason to exist, an origin story.

Something causes a message to be published, and a workflow to begin. There are several potential origins:

Timing or schedules

A message that is posted automatically to Slack because a particular time has been reached. For example, a message that is posted every Friday at 3pm to remind people to post a report of how their week went.

External services

Messages posted in reaction to something that happened on an external service. For example, a task being updated in a task tracker app, or an account being updated on a CRM platform.

Events API pushes

The Events API sends a push to Slack apps whenever one of a number of types of things occurs in Slack. The receipt of one of these event pushes could trigger a message to be posted back to Slack by the app.

For example, the app_mention event sends a push when the app is mentioned by someone in a conversation. The app could then respond with a message to continue the workflow.

User actions

A message invoked by something a user did in Slack. These kinds of user actions have to be configured by the app in order to work correctly.

Possible user actions available for Slack apps to configure are:

  • Custom message action -- adds an item to the "More Actions" menu shown when hovering on messages in Slack.
  • Slash commands -- a text command typed directly into the message box in Slack
  • Interactive messages -- this is not a typo! Interactive messages can create other interactive messages, whether as a continuation of the same workflow, or by kicking off a completely separate workflow.

Once an origin event happens, an interactive message composed by the app is published to Slack, where it sits, ready for interaction.


Interaction with message components

This is the big moment: showtime. The interactive message has attracted some user's attention, and they've seen a shiny and irresistible interactive component embedded within.

Interactive components

Interactive components initiate communication between your app and Slack users.

Some of these components can be dropped into blocks and some of them can be used as secondary content in attachments.

Once you've finished this guide, you'll want to read our guide to enabling interactivity to bring interactive components into your Slack app, and to walk you through the technical implementation of this whole interactive message flow.

Here's a quick glance at the interactive components you can add to app-published messages:

You can view our interactive element references for a full overview of the fields and options available for these components.

Buttons

Buttons provide direct paths to simple goals:

A button in a Slack message being clicked, triggering an external service to take action

View an example

Select menus

Select menus offer a list of options for interaction to pick from, and a typeahead text field to narrow down those options:

A select menu in a Slack message showing the ability to change the priority of a task

Select menus can have predetermined static options, get option lists full of relevant Slack users or conversations, or pull in data from an external source to create an option list.

View an example

Overflow menus

Overflow menus also offer a list of predefined options to pick from, but they're presented in a more compact way:

An overflow menu in a Slack message showing multiple options for action

View an example

Date pickers

Need to let a user pick a date as part of an interactive flow? You'll want a date picker:

An date picker in a Slack message showing a user selecting a date

View an example

After-action report

Meanwhile, back to our superhero's story: someone has clicked on or used a component in an app-published message, and the interactivity flow continues.


Receiving interaction requests

Once an interaction happens, a bundle of information - which we call the interactive message's request payload - is sent to the Slack app associated with the component.

In our guide to enabling interactivity, we'll outline the actual content and structure of this payload closely.

Here's a simplified summary of what the payload contains:

  • information about the acting user
  • information about the conversation in Slack where the interaction occurred
  • information about the source interactive component, including any custom or user-selected parameters which may have been passed along.

Since your app may publish many different types of interactive messages with different components, it will need to parse and process this payload in order to understand what the intention and source of the interaction was. Read our guide to enabling interactivity for more in-depth information on that.

Once your app has figured out why the payload was received, it will then make a decision on how to respond.


Responding to the interaction

An apps response to an interaction can involve two different stages:

  1. Acknowledgment response
  2. Composed responses

Acknowledgment response

This is a one-off response sent when the request payload is received, a confirmation of its arrival to your app.

This must be sent within 3 seconds of receiving the payload. If your app doesn't do that, the Slack user who interacted with the app will see an error message. So, make sure your app responds quickly.

To read more about sending acknowledgment responses, see our guide to enabling interactivity.

If you want to do more, such as reply with more messages, you'll need to use a composed response.

Composed responses

These responses are sent using a unique URL that is generated when an interaction happens, and then included in the request payload.

They can be sent up to 5 times within 30 minutes of receiving the payload. Even when sending composed responses, you must still send an acknowledgment response.

In these composed responses your app can include the JSON of a new message that will be published back to the conversation that was the source of the interaction. This message can even include more interactive components, creating a multi-step interactive flow.

The 30 minute window to send composed responses is useful because it's not possible to respond to every interaction right away.

For example, sometimes your app will have to perform some sort of operation of indeterminate length - such as if the app has to use any kind of web service (including the Slack Web API) or perform any kind of I/O function.

Let's take an earlier example for an interactive message that allows modification of tasks stored in an external task tracking service:

A select menu in a Slack message showing the ability to change the priority of a task

When the user changes the priority of the task, a request payload is sent. The app must then interface with the external service to update the details of the task there, and then receive a response from that service. Only once that's done can it send back a success message to Slack.

Again, in all cases, an acknowledgment response must still be sent to confirm the initial interaction request.

It's good practice to quickly send a composed response with a brief message right away to the user, informing them that their request is processing.

To read more about sending composed responses, see our guide to enabling interactivity.


Whew, that was a whirlwind story of a superhero known as interactive messages. You'll notice that this overview sends you toward a series of spin-offs, side-quests, and subplots as you continue to define your app's goals more clearly. That's because interactive messages are a rich, powerful feature for Slack apps, one that's worth diving deeply into.