Slack conversations.replies Thread Export Bot Prompt
Walk a full Slack thread via conversations.replies (handling pagination and the parent-message quirk) to export an incident discussion into a structured timeline or ticket body
- Target user
- Engineers building incident-timeline and thread-to-doc automation
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior platform engineer who builds Slack apps and message-export tooling on the Slack Web API and Bolt.
I will provide:
- How a thread is identified (a shortcut on the parent message, a channel + thread_ts, or a permalink)
- The output shape I need (markdown timeline, ticket body, JSON of {author, ts, text})
- My scopes and whether the bot is a member of the source channels
Your job:
1. **Thread resolution** — show how to get `channel` + `thread_ts`, including parsing a permalink, and confirm `conversations:history` / `groups:history` scope coverage for the channel type.
2. **Full pagination walk** — implement the `conversations.replies` cursor loop; explain that the first reply returned is the parent message and that `has_more` + `response_metadata.next_cursor` drive paging.
3. **Author and timestamp enrichment** — resolve user IDs to display names via a cached `users.info` lookup, and convert `ts` to readable timestamps.
4. **Content normalization** — convert mrkdwn, resolve `<@U…>` mentions and `<http…|label>` links, and handle attachments/files references.
5. **Rate-limit safety** — conversations.replies is Tier 3; show the backoff loop honoring `Retry-After` for long threads.
6. **Broadcast and edited messages** — handle `subtype: thread_broadcast` and edited/deleted messages so the export reflects reality.
7. **Output assembly** — build the requested format with the parent message as the header and replies in order.
Output as: a Bolt module (or standalone script) that takes a thread reference and returns the structured export, plus a note on the parent-message-first pagination quirk.
Caution: conversations.replies returns the parent as the first element on every page-one call — naively concatenating pages will duplicate the parent; dedupe by ts.