Slack Events API Retry & Idempotency Prompt
Build a reliable Slack Events API consumer — URL verification, fast ack, dedup of Slack's retry storms, idempotent processing, and a queue-backed worker pattern.
- Target user
- Engineers building event-driven Slack integrations at scale
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a distributed-systems engineer who has run a high-traffic Slack Events API consumer and learned the hard way that Slack retries aggressively and will disable your subscription if you're slow. I will provide: - The events we subscribe to (message.channels, reaction_added, app_mention, etc.) - Our infra (web tier, queue, workers, datastore) - Symptoms (duplicate processing, "your app is being rate limited", disabled subscriptions) Your job: 1. **URL verification** — handle the `url_verification` challenge correctly and only once; explain why it must be a synchronous echo. 2. **The 3-second ack** — return 200 immediately after signature verification; NEVER do real work inline. Explain Slack's retry policy: it resends on non-2xx or slow responses with `X-Slack-Retry-Num` and `X-Slack-Retry-Reason`, up to 3 times with backoff. 3. **Dedup / idempotency** — events can arrive multiple times. Design a dedup key (`event_id`, or `client_msg_id` for messages) with a TTL store (e.g. Redis SETNX, 1h). Show the check-and-skip path and how to honor `X-Slack-Retry-Num`. 4. **Queue handoff** — push the verified event to a durable queue; workers process with their own retries and dead-letter. Explain at-least-once semantics and why handlers must be idempotent regardless. 5. **Bot-loop prevention** — drop events where `bot_id` is your own app or `subtype` is `bot_message`, to avoid infinite reaction/message loops. 6. **Ordering** — Slack does not guarantee order. Show how to tolerate out-of-order edits/deletes (message_changed, message_deleted) using `event_ts`. 7. **Backpressure & rate limits** — respect Tier limits and `Retry-After` on outbound calls; shed or buffer inbound during spikes rather than 500-ing (which triggers more retries). 8. **Observability** — metrics for ack latency, dedup hit rate, retry-num distribution, and worker lag; alert before Slack auto-disables the subscription. Output as: (a) the HTTP handler (verify → ack → enqueue), (b) the dedup store interface + TTL choice, (c) the worker with idempotent handler contract, (d) the bot-loop and out-of-order guards, (e) a runbook for "subscription disabled". Bias toward: idempotency everywhere, ack-before-work always, and treating every event as possibly-duplicated and possibly-out-of-order.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Slack Legacy Outgoing Webhook → Events API Migration Prompt
Plan and execute migration off deprecated Slack outgoing webhooks and legacy custom integrations to a modern Events API app with signing-secret verification.
-
Slack Link Unfurling for App-Owned Domains Prompt
Design and implement custom link unfurls so internal tool URLs render as rich Block Kit attachments in Slack
-
Slack postMessage Idempotency & Safe Retry Prompt
Make chat.postMessage delivery idempotent so retries after timeouts or crashes never double-post alerts, and a redelivered event never spams a channel twice.
-
Production-Grade Slack API Client Design Prompt
Design a hardened Slack API client library — token rotation, rate limiting, retries, dedup, audit logging, and Block Kit composition — for services that post to Slack at scale.
More Slack prompts & error guides
Browse every Slack prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.