Skip to content

Latest commit

 

History

History
129 lines (65 loc) · 7.03 KB

File metadata and controls

129 lines (65 loc) · 7.03 KB

1. Blocks and Block Elements

While not explicitly in your list as a top-level category, it's crucial to understand that Actions, Messages, and Views are all composed of Blocks and Block Elements.

Blocks: These are the visual components that make up your app's UI. Think of them as containers for content or interactive elements. Examples include section (for text and accessories), image, divider, actions (specifically for interactive elements), input (for user input fields), etc.

Block Elements: These are interactive components that live inside certain blocks (like section or actions blocks). Examples include button, select menu, date picker, plain-text input, checkboxes, etc.

When to use what (Blocks and Block Elements):

Use Blocks to structure the overall layout of your message, modal, or Home tab.

Use Block Elements within appropriate blocks to add interactive components that users can engage with.

2. Actions

In the context of Block Kit, "Actions" primarily refer to the actions block and the block_actions payload.

actions block: This is a specific type of Block Kit block designed to hold multiple interactive elements like buttons, select menus, overflow menus, or date pickers.

block_actions payload: When a user interacts with an interactive Block Kit component (like clicking a button or selecting an option from a menu) within a message, modal, or Home tab, Slack sends your app a block_actions payload. This payload contains information about which component was interacted with (via block_id and action_id) and the value associated with that interaction.

When to use Actions:

Use the actions block when you need to group several interactive elements together, usually to present a set of choices or next steps to the user.

Your app will receive block_actions payloads when users interact with your interactive components. You then process these payloads to determine what action to take in response (e.g., update the message, open a modal, trigger a backend process).

3. Commands (Slash Commands)

Commands (more specifically, Slash Commands) are a way for users to invoke your app by typing a string (starting with /) into the message composer box. For example, /remind me to buy milk tomorrow.

When a user submits a slash command, Slack sends an HTTP POST request to your app's configured Request URL with a payload containing the command text and other context (user, channel, etc.).

When to use Commands:

Use slash commands when you want to enable users to quickly trigger specific actions or retrieve information from your app directly from any conversation in Slack.

They are great for initiating workflows, fetching data, or providing quick access to app functionality without needing to navigate to a specific app Home or modal.

You often respond to a slash command by posting a message (which can be Block Kit-formatted) or opening a modal.

4. Events

Events are notifications that Slack sends to your app when certain activities occur in a workspace where your app is installed. You subscribe to specific event types that are relevant to your app's functionality.

Examples of events include message.channels (a message was posted in a channel), app_home_opened (a user opened your app's Home tab), channel_created, user_changed, etc.

When an event your app is subscribed to occurs, Slack sends an HTTP POST request to your app's configured Request URL with a payload describing the event.

When to use Events:

Use events when you want your app to react to things happening in Slack in real-time or near real-time.

This is fundamental for building bots that respond to messages, apps that track user activity, or integrations that need to be aware of changes in Slack.

For example, you'd use a message.channels event to have your bot respond to keywords in a conversation, or an app_home_opened event to populate a user's App Home tab with personalized information.

5. Messages

Messages are the primary way users communicate in Slack. In the context of app creation, your app can post messages into channels, direct messages, or threads.

With Block Kit, you can compose rich and interactive messages by including an array of blocks in your message payload. This allows you to go beyond simple plain text and incorporate buttons, images, select menus, and more.

When to use Messages:

Use messages when you want your app to communicate information to users in a conversational context.

This includes:

Responding to slash commands or interactions.

Sending notifications (e.g., "Your task is complete!").

Providing updates or alerts.

Initiating workflows by presenting interactive elements to users within a conversation.

Block Kit is essential for making your app's messages visually appealing and interactive.

6. Shortcuts

Shortcuts are simple, discoverable entry points that allow users to quickly invoke your app from various prominent locations within Slack.

There are two main types:

Global Shortcuts: Available from the "Shortcuts" button in the message composer and when using search in Slack. These are for initiating workflows that don't require specific channel or message context (e.g., "Create a new task").

Message Shortcuts: Available in the context menu of non-ephemeral messages. These are for actions that relate directly to a specific message (e.g., "Save this message to a task").

When a user uses a shortcut, Slack sends an interaction payload to your app, similar to block_actions.

When to use Shortcuts:

Use shortcuts to provide quick access to your app's most important or frequently used features.

They enhance discoverability and user experience by allowing users to initiate actions without needing to remember a slash command or navigate to your app's Home tab.

Shortcuts often lead to opening a modal for further user input or confirmation.

7. Views (Modals and Home Tabs)

Views are ephemeral, interactive canvases that your app can display to users. They provide a more structured and private space for complex interactions compared to messages.

There are two main types of views:

Modals: Pop-up windows that appear on top of the Slack interface. They are excellent for multi-step forms, displaying detailed information, or confirming actions. Modals can have a "view stack," allowing you to push and pop multiple views for multi-step workflows.

Home Tabs: A dedicated, persistent space for your app within a user's Slack sidebar. It's like a mini-dashboard for your app, allowing users to interact with your app outside of conversations.

When to use Views:

Modals:

For gathering multi-part user input (e.g., filling out a form).

For complex interactions that require a focused environment, separate from the main conversation.

For confirming sensitive actions.

Often opened in response to slash commands, shortcuts, or interactive elements in messages.

Home Tabs:

To provide a personalized starting point for your app's features.

To display aggregated information or a user's specific app-related content (e.g., "My Open Tasks").

As a persistent interface for your app, providing a consistent experience regardless of the current channel or conversation.