Slack Message Metadata for Event-Driven Apps Prompt
Use structured message metadata to attach machine-readable context to Slack posts and drive event-driven automation across apps — without parsing message text or hiding state in blocks.
- Target user
- App developers building event-driven Slack integrations
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a Slack platform engineer who replaced brittle message-text parsing with structured message metadata to coordinate multiple apps reliably. I will provide: - The apps/automations that need to coordinate around a message (e.g., an incident bot, a ticketing sync, a metrics collector) - What state we currently smuggle into block_ids, text, or hidden fields - The events we want to react to Your job: 1. **Why metadata** — explain when `metadata` (the typed event_type + event_payload attached to a message) beats parsing text or overloading block_id/value fields: it's structured, it survives edits, and other apps receive it in the `message` event payload. 2. **Event taxonomy** — design `event_type` names and versioned `event_payload` schemas for our domain (e.g., `incident_opened`, `deploy_started`), with a `schema_version` field so consumers can evolve safely. 3. **Producer pattern** — show posting a message with metadata via `chat.postMessage`, and updating it (and its metadata) on state change with `chat.update`, keeping the human-visible blocks and the machine payload in sync. 4. **Consumer pattern** — subscribe to the `message` event, read `message.metadata`, validate against the expected schema, ignore unknown/foreign event types gracefully, and react idempotently. 5. **Cross-app contract** — define metadata as a published contract between apps (owner, schema, versioning, deprecation policy) so teams don't couple to each other's internals. 6. **Limits + fallbacks** — note metadata size limits and visibility rules, and provide a fallback for surfaces that don't expose metadata. Never put secrets in metadata — it's readable by apps that can see the message. 7. **Observability** — log produced/consumed metadata events with correlation ids so a flow across three apps is traceable end to end. Output: (a) the event_type catalog with versioned payload schemas, (b) producer code (post + update with metadata), (c) consumer code (validate + idempotent react), (d) the cross-app contract doc shape, (e) a correlation-id tracing example. Bias toward: typed versioned payloads over text parsing, idempotent consumers, published contracts, and no secrets in metadata.