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.
- Target user
- Engineers building Slack ChatOps notification pipelines
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior platform engineer who builds Slack notification pipelines and has seen a timed-out chat.postMessage get retried and post the same alert three times. I will provide: - How messages are triggered (event handler, queue consumer, cron, webhook fan-in) - Our delivery path and where retries can happen (HTTP timeout, queue redelivery, Slack Events API replays) - Whether messages are unique alerts, status updates, or fan-outs to many channels Your job: 1. **Find the duplication sources** — enumerate every place a single logical message can be sent twice (client timeout-then-success, at-least-once queue, Events API retry with `X-Slack-Retry-Num`, app restart mid-send). 2. **Define an idempotency key** — derive a stable key per logical message (event id + channel, or a hash of canonical content) and explain why it's stable across retries. 3. **Dedup store** — design a keyed store (with TTL) that records "sent" with the resulting `ts`, checked-and-set atomically before each send. 4. **Treat timeouts correctly** — on an ambiguous send (timeout with no response), use the store to decide whether to retry or reconcile, rather than blindly resending. 5. **Prefer update over repost** — for status that changes, key by entity and use chat.update on the stored `ts` instead of posting again. 6. **Honor Slack's own retries** — short-circuit duplicate Events API deliveries using the retry header before doing any work. Output as: (a) the duplication-source list, (b) the idempotency-key derivation, (c) the dedup-store schema and atomic check-and-set, (d) the timeout/ambiguous-send reconciliation, (e) the update-vs-repost rule and Events API retry short-circuit. Default to not sending when in doubt; a missed duplicate suppression that drops one message is far less harmful than spamming an on-call channel.
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 Bot Blue-Green Deployment Cutover Prompt
Design a blue-green deployment for a Slack app so you can ship a new bot version with zero dropped events, no duplicate handling, and a fast rollback if interactivity breaks.
-
Slack Webhook Payload Schema Validation Prompt
Add strict schema validation to a Slack-bound webhook receiver so malformed or unexpected inbound payloads are rejected cleanly instead of crashing the handler or posting garbage into channels.
-
Slack App Cold-Start & 3-Second Ack Latency Optimization Prompt
Diagnose and fix Slack app latency that breaks the 3-second ack budget — serverless cold starts, sync work in handlers, and defer-then-followup patterns.
-
Slack App Rate-Limit Tier & Capacity Planning Prompt
Model a Slack app's request budget across method tiers, size fan-out and polling under per-workspace limits, and design a token-bucket schedule that never trips 429s.
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.