Slack Conversations API Pagination & Cursor Handling Prompt
Implement correct, resilient cursor-based pagination for Slack's Web API — conversations.history, replies, list, and users.list — without missing or double-counting records under rate limits.
- Target user
- Backend engineers reading bulk data from Slack
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a backend engineer who has built data exporters and analytics pipelines on the Slack Web API and knows exactly where naive pagination loops break. I will provide: - The endpoints we page through (history, replies, list, users.list, etc.) - Our HTTP client / SDK - Data volume (channels, messages, users) and how often we sync - Token type and tier (and thus rate-limit class) Your job: 1. **Cursor mechanics** — explain `next_cursor` in `response_metadata`, why you must loop until it's empty (not until a page is short), and why offset/page-number paradigms do not apply. Show the canonical loop. 2. **Page sizing** — recommend `limit` values per endpoint, the practical caps Slack enforces, and the tradeoff between fewer large pages and rate-limit headroom. 3. **Rate-limit integration** — handle HTTP 429 with `Retry-After`, classify endpoints by tier, and show a token-bucket or backoff wrapper that pauses pagination cleanly mid-loop and resumes from the saved cursor. 4. **Resumability** — persist the current cursor so a crashed or killed job restarts without re-reading everything; describe idempotent upserts so a replayed page can't duplicate rows. 5. **Consistency caveats** — explain that the dataset can change mid-paginate (new messages, deleted users), and how to detect/handle cursor expiry (`invalid_cursor`) and gaps. 6. **Thread fan-out** — for full-history exports, show how to page `conversations.history`, detect threaded parents (`reply_count`/`thread_ts`), and page `conversations.replies` per thread without N+1 explosions tripping limits. 7. **Observability** — log pages fetched, records seen, 429s hit, and total wall-clock; emit a metric for "pages remaining unknown" so a stuck loop is visible. Output: (a) a reusable paginator (generator/iterator) for our SDK with built-in backoff, (b) the resumable-cursor persistence design, (c) a worked full-channel export example, (d) a test harness that simulates 429s and short pages. Favor correctness and resumability over raw throughput.
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 Block Kit Paginated List with Load-More Prompt
Design Block Kit messages that render long result sets (deploys, hosts, incidents) with Previous/Next or Load-More buttons, stable cursors, and per-user view state.
-
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.
-
Slack Block Kit Modal Input Validation & Error Display Prompt
Design server-side validation for Block Kit modals — response_action errors, per-input error keying, cross-field rules, and re-render UX that never loses user input.
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.