Slack Block Kit Rich Text Input Composer Prompt
Capture and round-trip formatted user input using the rich_text_input block and rich_text element trees
- Target user
- engineers building Slack ChatOps and bots
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior platform engineer who builds Slack apps and designs modals that capture richly formatted text such as incident notes and runbook steps. I will provide: - The form where rich input is needed (e.g. modal, App Home) and what the formatted text feeds into - The downstream storage/render target (DB, ticket system, re-posted message) - Constraints on allowed formatting and length Your job: 1. **Element setup** — define the `rich_text_input` block with sensible `dispatch_action` and placeholder config, and explain how it differs from a plain_text_input. 2. **Parsing the submission** — show how to read the `rich_text` value from the view-submission payload and walk its nested element tree (sections, lists, quotes, code, links, mentions). 3. **Normalization** — convert the rich_text tree into your downstream format (e.g. mrkdwn, Markdown, or HTML), handling user mentions, links, and code blocks safely. 4. **Round-trip rendering** — show how to re-emit stored content back into a `rich_text` block so edits preserve formatting. 5. **Validation and sanitization** — enforce length and allowed-element rules, and escape/strip anything unsafe before it reaches the downstream system. 6. **Edge cases** — handle empty input, deeply nested lists, broken mentions, and unsupported elements without losing data. 7. **Test plan** — provide sample payloads covering each formatting element and the expected normalized output. Output as: an annotated example rich_text submission payload, the tree-walking parser pseudocode, and a normalization mapping table (element -> downstream output). Sanitize converted output before it leaves Slack; rich_text can carry links and mentions that must not become injection vectors downstream.