### Sending a Message with Python Slack SDK Source: https://docs.slack.dev/reference/block-kit/blocks/input-block Example of sending a message using the Python Slack SDK. Ensure you have the SDK installed and configured with your bot token. ```python from slack_sdk import WebClient client = WebClient(token="xoxb-your-bot-token") response = client.chat_postMessage( channel="#your-channel", text="Hello from the Python SDK!", blocks=[ { "type": "section", "text": { "type": "mrkdwn", "text": "*Hello world* :wave:" } } ] ) print(response) ``` -------------------------------- ### File Input Element Example in Modal Source: https://docs.slack.dev/reference/block-kit/block-elements/file-input-element This example shows how to integrate a file input element within a modal view. It specifies accepted file types (jpg, png) and limits the upload to 5 files. Ensure your app has the `files:read` scope to use this element. ```json { "title": { "type": "plain_text", "text": "My App", "emoji": true }, "submit": { "type": "plain_text", "text": "Submit", "emoji": true }, "type": "modal", "close": { "type": "plain_text", "text": "Cancel", "emoji": true }, "blocks": [ { "type": "input", "block_id": "input_block_id", "label": { "type": "plain_text", "text": "Upload Files" }, "element": { "type": "file_input", "action_id": "file_input_action_id_1", "filetypes": [ "jpg", "png" ], "max_files": 5 } } ] } ``` -------------------------------- ### Markdown Formatting Examples Source: https://docs.slack.dev/reference/block-kit/blocks/markdown-block Common markdown syntax supported within Slack blocks. ```markdown **this is bold** ``` ```markdown __this is bold__ ``` ```markdown *this text is italicized* ``` ```markdown _this text is italicized_ ``` ```markdown **this text is _extremely_ important** ``` ```markdown ***all of this is important*** ``` ```markdown [my text](https://www.google.com) ``` ```markdown - first item in list - second item in a list - third item in a list ``` ```markdown 1. first item in a list 2. second item in a list 3. third item in a list ``` ```markdown ~~this is strikethrough text~~ ``` ```markdown # Header 1 ``` ```markdown ## Header 2 ### Header 3 etc. ``` ```markdown `this is my code` ``` ```markdown > this is a block quote ``` ```markdown ``` this is a code block ``` ``` ```python ```python print("hello") ``` ``` ```markdown --- ``` ```markdown | Col 1 | Col 2 | | ----- | ----- | | A | B | ``` ```markdown - [ ] incomplete task - [x] completed task ``` ```markdown ![Logo](https://example.com/logo.png) ``` ```markdown \*This is special text\* ``` -------------------------------- ### Card Block Example Source: https://docs.slack.dev/reference/block-kit/blocks/card-block An example of how to structure a Card block in JSON format for Slack messages. ```APIDOC ## Example Card Block ### Request Example ```json { "blocks": [ { "type": "card", "icon": { "type": "image", "image_url": "https://picsum.photos/36/36", "alt_text": "Icon" }, "title": { "type": "mrkdwn", "text": "Lumon Industries", "verbatim": false }, "subtitle": { "type": "mrkdwn", "text": "Committed to work-life balance", "verbatim": false }, "hero_image": { "type": "image", "image_url": "https://picsum.photos/400/300", "alt_text": "Sample hero image" }, "body": { "type": "mrkdwn", "text": "Please enjoy each card equally.", "verbatim": false }, "actions": [ { "type": "button", "text": { "type": "plain_text", "text": "Action Button", "emoji": false }, "action_id": "button_action" } ] } ] } ``` ``` -------------------------------- ### Table Block Usage Example Source: https://docs.slack.dev/reference/block-kit/blocks/table-block Example of how to use a Table Block within a `chat.postMessage` request, including column settings for alignment and wrapping. ```APIDOC ## Usage Info Apps can programmatically publish messages that include a table by providing a table block in the `attachments` or `blocks` fields of a [`chat.postMessage`](/reference/methods/chat.postMessage#arguments) request. One table is allowed per message, which is appended as an attachment to the bottom of the message. Sending more than one table block will result in the error `invalid_attachments` with response metadata indicating `only_one_table_allowed`. ### Request Example (URL-encoded string in `blocks` array) ```json [ { "type": "table", "block_id": "my_table_block_id", "rows": [ { "cells": [ { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "This is a long text that should wrap." } ] } ] }, { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Right aligned text" } ] } ] } ] } ], "column_settings": [ { "align": "left", "is_wrapped": true }, { "align": "right" }, null ] } ] ``` ``` -------------------------------- ### Feedback Buttons Element Example Source: https://docs.slack.dev/reference/block-kit/block-elements/feedback-buttons-element This example shows how to use the feedback buttons element within a context actions block. Ensure the `action_id` is unique within the containing block. ```json { "blocks": [ { "type": "context_actions", "elements": [ { "type": "feedback_buttons", "action_id": "feedback_buttons_1", "positive_button": { "text": { "type": "plain_text", "text": "Good" }, "value": "positive_feedback", "accessibility_label": "Mark this response as good" }, "negative_button": { "text": { "type": "plain_text", "text": "Bad" }, "value": "negative_feedback", "accessibility_label": "Mark this response as bad" } } ] } ] } ``` -------------------------------- ### Example 1: Context Actions Block with Feedback Buttons Source: https://docs.slack.dev/reference/block-kit/blocks/context-actions-block Demonstrates how to create a context actions block containing feedback buttons. ```APIDOC ## POST /messages (Example) ### Description This example shows a context actions block with feedback buttons. ### Method POST ### Endpoint /messages ### Request Body ```json { "blocks": [ { "type": "context_actions", "elements": [ { "type": "feedback_buttons", "action_id": "feedback_buttons_1", "positive_button": { "text": { "type": "plain_text", "text": "👍" }, "value": "positive_feedback" }, "negative_button": { "text": { "type": "plain_text", "text": "👎" }, "value": "negative_feedback" } } ] } ] } ``` ### Response (Success response would typically be a confirmation of message delivery or an error message) #### Success Response (200) - **ok** (Boolean) - Indicates if the request was successful. - **channel** (String) - The channel where the message was posted. - **ts** (String) - The timestamp of the posted message. #### Response Example ```json { "ok": true, "channel": "C1234567890", "ts": "1678886400.123456" } ``` ``` -------------------------------- ### Users Select Menu Example Source: https://docs.slack.dev/reference/block-kit/block-elements/select-menu-element A select menu element configured to display a list of users within a section block. ```json { "blocks": [ { "type": "section", "block_id": "section678", "text": { "type": "mrkdwn", "text": "Pick a user from the dropdown list" }, "accessory": { "action_id": "text1234", "type": "users_select", "placeholder": { "type": "plain_text", "text": "Select an item" } } } ]} ``` -------------------------------- ### Example 2: Context Actions Block with Icon Button Source: https://docs.slack.dev/reference/block-kit/blocks/context-actions-block Demonstrates how to create a context actions block containing an icon button. ```APIDOC ## POST /messages (Example) ### Description This example shows a context actions block with an icon button. ### Method POST ### Endpoint /messages ### Request Body ```json { "blocks": [ { "type": "context_actions", "elements": [ { "type": "icon_button", "icon": "trash", "text": { "type": "plain_text", "text": "Delete" }, "action_id": "delete_button_1", "value": "delete_item" } ] } ] } ``` ### Response (Success response would typically be a confirmation of message delivery or an error message) #### Success Response (200) - **ok** (Boolean) - Indicates if the request was successful. - **channel** (String) - The channel where the message was posted. - **ts** (String) - The timestamp of the posted message. #### Response Example ```json { "ok": true, "channel": "C1234567890", "ts": "1678886400.123456" } ``` ``` -------------------------------- ### Date Element Example Source: https://docs.slack.dev/reference/block-kit/blocks/rich-text-block Example of how to use the `date` element within a `rich_text` block, demonstrating the `format` property. ```APIDOC ## POST /api/messages (Example) ### Description This endpoint demonstrates the usage of the `date` element within a `rich_text` block. ### Method POST ### Endpoint /api/messages ### Request Body - **blocks** (array) - Required - An array of Block Kit blocks. - **type** (string) - Required - The type of block, must be `rich_text`. - **elements** (array) - Required - An array of rich text elements. - **type** (string) - Required - The type of rich text element, must be `rich_text_section`. - **elements** (array) - Required - An array of rich text elements within the section. - **type** (string) - Required - The type of element, must be `date`. - **timestamp** (integer) - Required - The Unix timestamp for the date. - **format** (string) - Optional - The format string to display the date. Defaults to `{date_long_pretty}`. - **fallback** (string) - Optional - A fallback text to display if the date cannot be rendered. ### Request Example ```json { "blocks": [ { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "date", "timestamp": 1720710212, "format": "{date_num} at {time}", "fallback": "timey" } ] } ] } ] } ``` ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the request was successful. - **channel** (string) - The ID of the channel where the message was posted. - **ts** (string) - The timestamp of the message. #### Response Example ```json { "ok": true, "channel": "C1234567890", "ts": "1720710212.000001" } ``` ``` -------------------------------- ### Java Slack SDK - Divider Block Source: https://docs.slack.dev/reference/block-kit/blocks/divider-block Example of how to create a divider block using the Java Slack SDK. ```APIDOC ## POST /api/chat.postMessage (Example) ### Description This example demonstrates sending a message with a divider block using the Java Slack SDK. ### Method POST ### Endpoint /api/chat.postMessage ### Parameters #### Request Body - **blocks** (array) - Required - An array of Block Kit blocks to include in the message. ### Request Example ```json { "blocks": [ { "type": "divider" } ] } ``` ### Response #### Success Response (200) - **ts** (string) - The message's timestamp, unique identifier for the message. - **channel** (string) - The ID of the channel the message was sent to. #### Response Example ```json { "ok": true, "channel": "C1234567890", "ts": "1678886400.123456", "message": { "blocks": [ { "type": "divider" } ] } } ``` ``` -------------------------------- ### Multi-users select menu example Source: https://docs.slack.dev/reference/block-kit/block-elements/multi-select-menu-element A multi-select menu configured to display a list of workspace users within a section block. ```json { "blocks": [ { "type": "section", "block_id": "section678", "text": { "type": "mrkdwn", "text": "Pick users from the list" }, "accessory": { "action_id": "text1234", "type": "multi_users_select", "placeholder": { "type": "plain_text", "text": "Select users" } } } ]} ``` -------------------------------- ### Create a URL Source Element Source: https://docs.slack.dev/reference/block-kit/block-elements/url-source-element A basic example of a URL source element. This element can only be used within task card blocks. ```json { "type": "url", "url": "https://docs.slack.dev/", "text": "Slack API docs" } ``` -------------------------------- ### Create a Primary Styled Button Source: https://docs.slack.dev/reference/block-kit/block-elements/button-element This example shows how to create a button with a 'primary' style, making it visually distinct. Ensure the style attribute is correctly set. ```json { "type": "button", "text": { "type": "plain_text", "text": "Save" }, "style": "primary", "value": "click_me_123", "action_id": "button" } ``` -------------------------------- ### Python Slack SDK - Divider Block Source: https://docs.slack.dev/reference/block-kit/blocks/divider-block Example of how to create a divider block using the Python Slack SDK. ```APIDOC ## POST /api/chat.postMessage (Example) ### Description This example demonstrates sending a message with a divider block using the Python Slack SDK. ### Method POST ### Endpoint /api/chat.postMessage ### Parameters #### Request Body - **blocks** (array) - Required - An array of Block Kit blocks to include in the message. ### Request Example ```json { "blocks": [ { "type": "divider" } ] } ``` ### Response #### Success Response (200) - **ts** (string) - The message's timestamp, unique identifier for the message. - **channel** (string) - The ID of the channel the message was sent to. #### Response Example ```json { "ok": true, "channel": "C1234567890", "ts": "1678886400.123456", "message": { "blocks": [ { "type": "divider" } ] } } ``` ``` -------------------------------- ### Checkboxes Element Example in a Modal Source: https://docs.slack.dev/reference/block-kit/block-elements/checkboxes-element This example demonstrates how to use the checkboxes element within a modal view. It includes initial options and a description for one of the options. ```json { "type": "modal", "title": { "type": "plain_text", "text": "My App", "emoji": true }, "submit": { "type": "plain_text", "text": "Submit", "emoji": true }, "close": { "type": "plain_text", "text": "Cancel", "emoji": true }, "blocks": [ { "type": "section", "text": { "type": "plain_text", "text": "Check out these charming checkboxes" }, "accessory": { "type": "checkboxes", "action_id": "this_is_an_action_id", "initial_options": [ { "value": "A1", "text": { "type": "plain_text", "text": "Checkbox 1" } } ], "options": [ { "value": "A1", "text": { "type": "plain_text", "text": "Checkbox 1" } }, { "value": "A2", "text": { "type": "plain_text", "text": "Checkbox 2" }, "description": { "type": "mrkdwn", "text": "*A description of option two*" } } ] } } ] } ``` -------------------------------- ### Time Picker Element Example Source: https://docs.slack.dev/reference/block-kit/block-elements/time-picker-element This example demonstrates how to use a time picker element within a section block. It includes configuration for timezone, action ID, initial time, and placeholder text. The time picker is an interactive component. ```json { "blocks": [ { "type": "section", "block_id": "section1234", "text": { "type": "mrkdwn", "text": "Pick a date for the deadline." }, "accessory": { "type": "timepicker", "timezone": "America/Los_Angeles", "action_id": "timepicker123", "initial_time": "11:40", "placeholder": { "type": "plain_text", "text": "Select a time" } } } ] } ``` -------------------------------- ### Multi-external select menu example Source: https://docs.slack.dev/reference/block-kit/block-elements/multi-select-menu-element A multi-select menu configured with an external data source within a section block. ```json { "blocks": [ { "type": "section", "block_id": "section678", "text": { "type": "mrkdwn", "text": "Pick items from the list" }, "accessory": { "action_id": "text1234", "type": "multi_external_select", "placeholder": { "type": "plain_text", "text": "Select items" }, "min_query_length": 3 } } ]} ``` -------------------------------- ### Node Slack SDK - Divider Block Source: https://docs.slack.dev/reference/block-kit/blocks/divider-block Example of how to create a divider block using the Node.js Slack SDK. ```APIDOC ## POST /api/chat.postMessage (Example) ### Description This example demonstrates sending a message with a divider block using the Node.js Slack SDK. ### Method POST ### Endpoint /api/chat.postMessage ### Parameters #### Request Body - **blocks** (array) - Required - An array of Block Kit blocks to include in the message. ### Request Example ```json { "blocks": [ { "type": "divider" } ] } ``` ### Response #### Success Response (200) - **ts** (string) - The message's timestamp, unique identifier for the message. - **channel** (string) - The ID of the channel the message was sent to. #### Response Example ```json { "ok": true, "channel": "C1234567890", "ts": "1678886400.123456", "message": { "blocks": [ { "type": "divider" } ] } } ``` ``` -------------------------------- ### Task card block JSON structure Source: https://docs.slack.dev/reference/block-kit/blocks/task-card-block Example of a task_card block configuration including status, output, and URL sources. ```json { "blocks": [ { "type": "task_card", "task_id": "task_1", "title": "Fetching weather data", "status": "pending", "output": { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Found weather data for Chicago from 2 sources" } ] } ] }, "sources": [ { "type": "url", "url": "https://weather.com/", "text": "weather.com" }, { "type": "url", "url": "https://www.accuweather.com/", "text": "accuweather.com" } ] } ] } ``` -------------------------------- ### Channels Select Menu Example Source: https://docs.slack.dev/reference/block-kit/block-elements/select-menu-element A JSON representation of a section block containing a channels_select accessory. ```json { "blocks": [ { "type": "section", "block_id": "section678", "text": { "type": "mrkdwn", "text": "Pick a channel from the dropdown list" }, "accessory": { "action_id": "text1234", "type": "channels_select", "placeholder": { "type": "plain_text", "text": "Select an item" } } } ]} ``` -------------------------------- ### Create a Header Block using Python SDK Source: https://docs.slack.dev/reference/block-kit/blocks/header-block This Python code snippet shows how to generate a header block using the Python Slack SDK. Ensure the SDK is installed and configured. ```python from slack_sdk.models.blocks import Header header_block = Header(text="A Heartfelt Header") print(header_block.to_json_string()) ``` -------------------------------- ### Sending a Message with Java Slack SDK Source: https://docs.slack.dev/reference/block-kit/blocks/input-block An example of sending a Slack message using the Java Slack SDK. This requires the SDK to be added as a dependency and your bot token to be configured. ```java import com.slack.api.Slack; import com.slack.api.methods.SlackApiException; import com.slack.api.methods.request.chat.ChatPostMessageRequest; import com.slack.api.methods.response.chat.ChatPostMessageResponse; import java.io.IOException; public class SendSlackMessage { public static void main(String[] args) { String token = "xoxb-your-bot-token"; Slack slack = Slack.getInstance(); try { ChatPostMessageResponse response = slack.methods(token).chatPostMessage(ChatPostMessageRequest.builder() .channel("#your-channel") .text("Hello from the Java SDK!") .blocksAsString("[ { \"type\": \"section\", \"text\": { \"type\": \"mrkdwn\", \"text\": \"*Hello world* :wave:\" } } ]") .build()); System.out.println("Message sent: " + response.getTs()); } catch (IOException | SlackApiException e) { e.printStackTrace(); } } } ``` -------------------------------- ### Implement a date picker in a section block Source: https://docs.slack.dev/reference/block-kit/block-elements/date-picker-element This example demonstrates how to include a date picker as an accessory within a section block. ```json { "blocks": [ { "type": "section", "block_id": "section1234", "text": { "type": "mrkdwn", "text": "Pick a date for the deadline." }, "accessory": { "type": "datepicker", "action_id": "datepicker123", "initial_date": "1990-04-28", "placeholder": { "type": "plain_text", "text": "Select a date" } } } ]} ``` -------------------------------- ### Implement URL Input Element in Block Kit Source: https://docs.slack.dev/reference/block-kit/block-elements/url-input-element This example shows how to use the URL input element within an input block. Ensure the 'type' is set to 'url_text_input' and provide a unique 'action_id'. ```json { "blocks": [ { "type": "input", "element": { "type": "url_text_input", "action_id": "url_text_input-action" }, "label": { "type": "plain_text", "text": "Label", "emoji": true } } ] } ``` -------------------------------- ### Define a plain-text input element in an input block Source: https://docs.slack.dev/reference/block-kit/block-elements/plain-text-input-element This example demonstrates the structure of an input block containing a basic plain-text input element. ```json { "blocks": [ { "type": "input", "element": { "type": "plain_text_input", "action_id": "plain_text_input-action" }, "label": { "type": "plain_text", "text": "Label", "emoji": true } } ]} ``` -------------------------------- ### Define an Option Object Source: https://docs.slack.dev/reference/block-kit/composition-objects/option-object A basic example of an option object structure containing a plain text label and a unique value. ```json { "text": { "type": "plain_text", "emoji": true, "text": "Save it" }, "value": "value-2"} ``` -------------------------------- ### Static Select Menu in Section Block Source: https://docs.slack.dev/reference/block-kit/block-elements/select-menu-element This example demonstrates a static select menu within a section block. Ensure the select menu is placed inside a section, actions, or input block. ```json { "blocks": [ { "type": "section", "block_id": "section678", "text": { "type": "mrkdwn", "text": "Pick an item from the dropdown list" }, "accessory": { "action_id": "text1234", "type": "static_select", "placeholder": { "type": "plain_text", "text": "Select an item" }, "options": [ { "text": { "type": "plain_text", "text": "*this is plain_text text*" }, "value": "value-0" }, { "text": { "type": "plain_text", "text": "*this is plain_text text*" }, "value": "value-1" }, { "text": { "type": "plain_text", "text": "*this is plain_text text*" }, "value": "value-2" } ] } } ] } ``` -------------------------------- ### Plan block JSON structure Source: https://docs.slack.dev/reference/block-kit/blocks/plan-block A complete example of a plan block containing multiple task cards with varying statuses and details. ```json { "blocks": [ { "type": "plan", "title": "Thinking completed", "tasks": [ { "task_id": "call_001", "title": "Fetched user profile information", "status": "in_progress", "details": { "type": "rich_text", "block_id": "viMWO", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Searched database..." } ] } ] }, "output": { "type": "rich_text", "block_id": "viMWO", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Profile data loaded" } ] } ] } }, { "task_id": "call_002", "title": "Checked user permissions", "status": "pending" }, { "task_id": "call_003", "title": "Generated comprehensive user report", "status": "complete", "output": { "type": "rich_text", "block_id": "crsk", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "15 data points compiled" } ] } ] } } ] } ] } ``` -------------------------------- ### Conversations Select Menu Example Source: https://docs.slack.dev/reference/block-kit/block-elements/select-menu-element A select menu element configured to display a list of conversations within a section block. ```json { "blocks": [ { "type": "section", "block_id": "section678", "text": { "type": "mrkdwn", "text": "Pick a conversation from the dropdown list" }, "accessory": { "action_id": "text1234", "type": "conversations_select", "placeholder": { "type": "plain_text", "text": "Select an item" } } } ]} ``` -------------------------------- ### Implement a confirmation dialog in a button element Source: https://docs.slack.dev/reference/block-kit/composition-objects/confirmation-dialog-object This example demonstrates how to integrate a confirmation dialog object within a button element inside an actions block. ```json { "blocks": [ { "type": "actions", "elements": [ { "type": "button", "text": { "type": "plain_text", "emoji": true, "text": "Approve" }, "confirm": { "title": { "type": "plain_text", "text": "Are you sure?" }, "text": { "type": "mrkdwn", "text": "Would you not prefer a good game of _chess_?" }, "confirm": { "type": "plain_text", "text": "Do it" }, "deny": { "type": "plain_text", "text": "Stop, I changed my mind!" } }, "style": "primary", "value": "click_me_123" }, { "type": "button", "text": { "type": "plain_text", "emoji": true, "text": "Deny" }, "style": "danger", "value": "click_me_123" } ] } ]} ``` -------------------------------- ### Sending a Message with Node.js Slack SDK Source: https://docs.slack.dev/reference/block-kit/blocks/input-block This snippet demonstrates how to send a message using the Node.js Slack SDK. Make sure the SDK is installed and your bot token is set. ```javascript const { WebClient } = require('@slack/web-api'); const client = new WebClient('xoxb-your-bot-token'); async function sendMessage() { try { const response = await client.chat.postMessage({ channel: '#your-channel', text: 'Hello from the Node.js SDK!', blocks: [ { type: 'section', text: { type: 'mrkdwn', text: '*Hello world* :wave:' } } ] }); console.log('Message sent:', response.ts); } catch (error) { console.error('Error sending message:', error); } } sendMessage(); ``` -------------------------------- ### Create a Bulleted List with rich_text_list Source: https://docs.slack.dev/reference/block-kit/blocks/rich-text-block Example of a rich_text_list used to create a bulleted list of Slack features. Requires 'rich_text_section' elements for each list item. ```json { "blocks": [ { "type": "rich_text", "block_id": "block1", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "My favorite Slack features (in no particular order):" } ] }, { "type": "rich_text_list", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Huddles" } ] }, { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Canvas" } ] }, { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Developing with Block Kit" } ] } ], "style": "bullet", "indent": 0, "border": 1 } ] } ] } ``` -------------------------------- ### Radio Buttons in a Section Block Source: https://docs.slack.dev/reference/block-kit/block-elements/radio-button-group-element This example demonstrates how to include a radio button group within a section block, including an initial selection. ```json { "blocks": [ { "type": "section", "text": { "type": "plain_text", "text": "Check out these rad radio buttons" }, "accessory": { "type": "radio_buttons", "action_id": "this_is_an_action_id", "initial_option": { "value": "A1", "text": { "type": "plain_text", "text": "Radio 1" } }, "options": [ { "value": "A1", "text": { "type": "plain_text", "text": "Radio 1" } }, { "value": "A2", "text": { "type": "plain_text", "text": "Radio 2" } } ] } } ] } ``` -------------------------------- ### JSON Example: Rich Text Section Source: https://docs.slack.dev/reference/block-kit/blocks/rich-text-block Demonstrates various rich text formatting options within a rich_text_section element, including basic, bold, italic, and strikethrough text. ```json { "blocks": [ { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Hello there, I am a basic rich text block!" } ] } ] }, { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Hello there, " }, { "type": "text", "text": "I am a bold rich text block!", "style": { "bold": true } } ] } ] }, { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Hello there, " }, { "type": "text", "text": "I am an italic rich text block!", "style": { "italic": true } } ] } ] }, { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Hello there, " }, { "type": "text", "text": "I am a strikethrough rich text block!", "style": { "strike": true } } ] } ] } ] } ``` -------------------------------- ### JSON Example: Rich Text Preformatted Block Source: https://docs.slack.dev/reference/block-kit/blocks/rich-text-block Use this block to display preformatted code with optional syntax highlighting. The `language` field can be set for highlighting. ```json { "blocks": [ { "type": "rich_text", "elements": [ { "type": "rich_text_preformatted", "elements": [ { "type": "text", "text": "{\n \"object\": {\n \"description\": \"this is an example of a json object\"\n }\n}" } ], "border": 0 } ] } ] } ``` -------------------------------- ### Workflow Object Example Source: https://docs.slack.dev/reference/block-kit/composition-objects/workflow-object A workflow object must be used inside of a workflow button element. This example shows a section block with a workflow button accessory. ```json { "blocks": [ { "type": "section", "text": { "text": "A message *with some bold text* and _some italicized text_.", "type": "mrkdwn" }, "accessory": { "type": "workflow_button", "text": { "type": "plain_text", "text": "Run Workflow" }, "action_id": "workflowbutton123", "workflow": { "trigger": { "url": "https://slack.com/shortcuts/Ft0123ABC456/xyz...zyx", "customizable_input_parameters": [ { "name": "input_parameter_a", "value": "Value for input param A" }, { "name": "input_parameter_b", "value": "Value for input param B" } ] } } } } ] } ``` -------------------------------- ### Example Conversation Filter in Modal View Source: https://docs.slack.dev/reference/block-kit/composition-objects/conversation-filter-object This example demonstrates how to use the conversation filter object within a modal view to include public and MPIM conversations while excluding bot users. It is used within an input block. ```json { "title": { "type": "plain_text", "text": "My App", "emoji": true }, "submit": { "type": "plain_text", "text": "Submit", "emoji": true }, "type": "modal", "close": { "type": "plain_text", "text": "Cancel", "emoji": true }, "blocks": [ { "type": "input", "element": { "type": "conversations_select", "placeholder": { "type": "plain_text", "text": "Select a conversation", "emoji": true }, "filter": { "include": [ "public", "mpim" ], "exclude_bot_users": true } }, "label": { "type": "plain_text", "text": "Choose the conversation to publish your result to:", "emoji": true } } ] } ``` -------------------------------- ### Link element JSON structure Source: https://docs.slack.dev/reference/block-kit/blocks/rich-text-block Example of a link object used within a rich_text_section element. ```JSON { "blocks": [ { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "link", "url": "https://docs.slack.dev" } ] } ] } ] } ``` -------------------------------- ### Emoji element JSON structure Source: https://docs.slack.dev/reference/block-kit/blocks/rich-text-block Example of an emoji object used within a rich_text_section element. ```JSON { "blocks": [ { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "emoji", "name": "basketball" }, { "type": "text", "text": " " }, { "type": "emoji", "name": "snowboarder" }, { "type": "text", "text": " " }, { "type": "emoji", "name": "checkered_flag" } ] } ] } ] } ``` -------------------------------- ### Python Slack SDK: Actions Block Source: https://docs.slack.dev/reference/block-kit/blocks/actions-block Python code demonstrating how to construct an Actions Block with a static select and a button using the Python Slack SDK. ```python loading... ``` -------------------------------- ### Slack Block Kit Overview Source: https://docs.slack.dev/reference/block-kit/blocks Overview of the Block Kit framework and usage constraints for Slack messages and surfaces. ```APIDOC ## Block Kit Overview ### Description Blocks are modular components used to create visually rich and interactive messages in Slack. They can be composed to build complex layouts for messages, modals, and Home tabs. ### Usage Constraints - **Messages**: Up to 50 blocks per message. - **Modals/Home Tabs**: Up to 100 blocks per surface. ``` -------------------------------- ### Implement a Static Select Menu in a Section Block Source: https://docs.slack.dev/reference/block-kit/composition-objects/option-object A full block payload demonstrating a section block with a static select menu accessory containing multiple option objects. ```json { "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": ":mag: Search results for *Cata*" } }, { "type": "divider" }, { "type": "section", "text": { "type": "mrkdwn", "text": "**\nUse Case Catalogue for the following departments/roles..." }, "accessory": { "type": "static_select", "placeholder": { "type": "plain_text", "emoji": true, "text": "Manage" }, "options": [ { "text": { "type": "plain_text", "emoji": true, "text": "Edit it" }, "value": "value-0" }, { "text": { "type": "plain_text", "emoji": true, "text": "Read it" }, "value": "value-1" }, { "text": { "type": "plain_text", "emoji": true, "text": "Save it" }, "value": "value-2" } ] } } ]} ``` -------------------------------- ### Section block with a mrkdwn text object Source: https://docs.slack.dev/reference/block-kit/composition-objects/text-object This example demonstrates how to embed a mrkdwn-formatted text object within a section block. ```json { "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "A message *with some bold text* and _some italicized text_." } } ] } ``` -------------------------------- ### Email input element within an input block Source: https://docs.slack.dev/reference/block-kit/block-elements/email-input-element This example demonstrates how to structure an input block containing an email_text_input element. ```json { "blocks": [ { "type": "input", "block_id": "input123", "label": { "type": "plain_text", "text": "Email Address" }, "element": { "type": "email_text_input", "action_id": "email_text_input-action", "placeholder": { "type": "plain_text", "text": "Enter an email" } } } ]} ``` -------------------------------- ### Block Kit Elements Overview Source: https://docs.slack.dev/reference/block-kit/block-elements General reference for Slack Block Kit elements and their JSON payload structures. ```APIDOC ## Block Kit Elements ### Description Block Kit elements are the building blocks for interactive UI components in Slack. This documentation outlines the JSON payloads required to define these elements. ### Usage Elements are typically nested within blocks (such as section or actions blocks) to provide interactive functionality like buttons, select menus, or date pickers. ``` -------------------------------- ### Rich Text with Bold Text Source: https://docs.slack.dev/reference/block-kit/blocks/rich-text-block Example of creating a rich text block that includes bolded text. This is useful for emphasizing specific parts of a message. ```json { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Hello there, " }, { "type": "text", "text": "I am a bold rich text block!", "style": { "bold": true } } ] } ] } ``` -------------------------------- ### Create a Link Button Source: https://docs.slack.dev/reference/block-kit/block-elements/button-element Use this structure to create a button that navigates to a specified URL when clicked. The 'url' field is essential for this functionality. ```json { "type": "button", "text": { "type": "plain_text", "text": "Link Button" }, "url": "https://docs.slack.dev/block-kit" } ``` -------------------------------- ### JSON Example: Rich Text Quote Block Source: https://docs.slack.dev/reference/block-kit/blocks/rich-text-block Use this block to display quoted text within a message. It can contain other rich text elements. ```json { "blocks": [ { "type": "rich_text", "block_id": "Vrzsu", "elements": [ { "type": "rich_text_quote", "elements": [ { "type": "text", "text": "What we need is good examples in our documentation." } ] }, { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Yes - I completely agree, Luke!" } ] } ] } ] } ```