Skip to content

Conversation

@sudhanshug16
Copy link

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

  • New feature
  • 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

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

@vercel
Copy link

vercel bot commented Nov 13, 2025

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

A member of the Team first needs to authorize it.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 13, 2025

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"
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

11 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +82 to +83
const limit = params.limit ? Number(params.limit) : 20
url.searchParams.append('limit', String(Math.min(limit, 15)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Inconsistent limit handling - parameter description says max: 100 but implementation caps at 15

Suggested change
const limit = params.limit ? Number(params.limit) : 20
url.searchParams.append('limit', String(Math.min(limit, 15)))
const limit = params.limit ? Number(params.limit) : 20
url.searchParams.append('limit', String(Math.min(limit, 100)))

Should the maximum limit be 100 as documented or 15 as implemented?

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/tools/slack/thread_reader.ts
Line: 82:83

Comment:
**logic:** Inconsistent limit handling - parameter description says max: 100 but implementation caps at 15

```suggestion
      const limit = params.limit ? Number(params.limit) : 20
      url.searchParams.append('limit', String(Math.min(limit, 100)))
```

 Should the maximum limit be 100 as documented or 15 as implemented?

How can I resolve this? If you propose a fix, please make it concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant