sim icon indicating copy to clipboard operation
sim copied to clipboard

add slack thread reader tool

Open sudhanshug16 opened this issue 3 months ago • 2 comments

Summary

Adds a tool for slack to read a thread given the thread_ts. Useful when the slack bot is mentioned in a thread and we want the context of the thread.

Fixes #(issue)

Type of Change

  • [x] New feature
  • [x] Documentation

Testing

Manually tested the tool using a thread in our company slack. Output showed the parent plus every reply and has_more:false, confirming the code paths and response mapping.

Checklist

  • [x] Code follows project style guidelines
  • [x] Self-reviewed my changes
  • [ ] Tests added/updated and passing
  • [x] No new warnings introduced
  • [x] I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

sudhanshug16 avatar Nov 13 '25 08:11 sudhanshug16

@sudhanshug16 is attempting to deploy a commit to the Sim Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Nov 13 '25 08:11 vercel[bot]

Greptile Overview

Greptile Summary

This PR adds a new Slack thread reader tool that fetches complete thread context when a Slack bot is mentioned in a thread. The implementation introduces the slack_thread_reader tool that uses Slack's conversations.replies API to retrieve both root messages and all replies from a specific thread using the thread_ts parameter.

The changes include: creating the core tool implementation (thread_reader.ts), adding TypeScript interfaces for request/response handling, registering the tool in the central registry, integrating it with the Slack block UI configuration, and providing comprehensive multilingual documentation across English, German, French, Spanish, Japanese, and Chinese versions. The tool supports pagination with cursor-based navigation and filtering options, following the established architectural patterns used by other Slack tools in the codebase.

Important Files Changed

Filename Score Overview
apps/sim/tools/slack/thread_reader.ts 3/5 New tool implementation with limit inconsistency between docs (max: 100) and code (hardcoded max: 15)
apps/sim/tools/slack/types.ts 5/5 Added TypeScript interfaces for thread reader parameters and responses
apps/sim/tools/registry.ts 5/5 Registered the new tool in the central tools registry
apps/sim/blocks/blocks/slack.ts 4/5 Extended Slack block configuration with thread reading operation and UI fields
apps/sim/tools/slack/index.ts 5/5 Added import and export for the new thread reader tool
apps/docs/content/docs/en/tools/slack.mdx 5/5 Added English documentation for the new slack_thread_reader tool
apps/docs/content/docs/de/tools/slack.mdx 5/5 Added German documentation for the new slack_thread_reader tool
apps/docs/content/docs/fr/tools/slack.mdx 5/5 Added French documentation for the new slack_thread_reader tool
apps/docs/content/docs/es/tools/slack.mdx 5/5 Added Spanish documentation for the new slack_thread_reader tool
apps/docs/content/docs/ja/tools/slack.mdx 5/5 Added Japanese documentation for the new slack_thread_reader tool
apps/docs/content/docs/zh/tools/slack.mdx 5/5 Added Chinese documentation for the new slack_thread_reader tool

Confidence score: 3/5

  • This PR requires careful review due to inconsistent limit handling in the core tool implementation
  • Score lowered due to hardcoded limit mismatch (docs state max: 100, code enforces max: 15) and potential missing error handling for malformed API responses
  • Pay close attention to apps/sim/tools/slack/thread_reader.ts for the limit inconsistency and apps/sim/blocks/blocks/slack.ts for the new operation integration

Sequence Diagram

sequenceDiagram
    participant User
    participant SlackBlock
    participant SlackThreadReaderTool
    participant SlackAPI
    
    User->>SlackBlock: "Configure thread reader with channel and thread_ts"
    SlackBlock->>SlackBlock: "Validate authentication method (OAuth/Bot Token)"
    SlackBlock->>SlackBlock: "Set operation to 'read_thread'"
    SlackBlock->>SlackThreadReaderTool: "Execute with parameters"
    
    SlackThreadReaderTool->>SlackThreadReaderTool: "Build URL with channel, thread_ts, limit, cursor"
    SlackThreadReaderTool->>SlackAPI: "GET /api/conversations.replies"
    
    SlackAPI-->>SlackThreadReaderTool: "Return thread messages (root + replies)"
    
    SlackThreadReaderTool->>SlackThreadReaderTool: "Transform response: map messages with ts, text, user, files"
    SlackThreadReaderTool->>SlackThreadReaderTool: "Extract pagination info (has_more, next_cursor)"
    
    SlackThreadReaderTool-->>SlackBlock: "Return thread data with messages array"
    SlackBlock-->>User: "Provide thread_ts, messages, has_more, next_cursor"

greptile-apps[bot] avatar Nov 13 '25 08:11 greptile-apps[bot]