Skip to content

feat(tools): added download file tool for onedrive, google drive, and slack; added move email tool for gmail and outlook - #1785

Merged
icecrasher321 merged 22 commits into
stagingfrom
sim-297
Nov 5, 2025
Merged

feat(tools): added download file tool for onedrive, google drive, and slack; added move email tool for gmail and outlook#1785
icecrasher321 merged 22 commits into
stagingfrom
sim-297

Conversation

@waleedlatif1

@waleedlatif1waleedlatif1 commented Nov 1, 2025

Copy link
Copy Markdown
Collaborator

Summary

  • added download file tool for onedrive, google drive, and slack
  • added move email tool for gmail and outlook
  • added missing oauth descriptions to modal
  • added a new scope for Slack OAuth integration

fixes#1786

Type of Change

  • New feature

Testing

Tested manually.

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

vercelBot commented Nov 1, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentPreviewCommentsUpdated (UTC)
docsReadyReadyPreviewCommentNov 5, 2025 9:00pm

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR adds file download capabilities for Google Drive, OneDrive, and Slack, plus email move functionality for Gmail and Outlook.

Key Changes

  • File Download Tools: Implemented download tools for Google Drive (with automatic Google Workspace file export), OneDrive, and Slack
  • Email Move Tools: Added move functionality for Gmail (using label modification) and Outlook (using folder moves)
  • API Routes: Created two new API routes (/api/tools/gmail/move and /api/tools/outlook/move) with proper authentication and validation
  • OAuth Configuration: Added files:read scope to Slack OAuth provider
  • OAuth Descriptions: Enhanced OAuth modal with missing scope descriptions for better user understanding
  • Documentation: Updated documentation for all affected tools with proper parameter and output specifications
  • Registry: Registered all 5 new tools in the tool registry

Implementation Quality

The implementation follows established patterns in the codebase:

  • Consistent error handling and logging across all tools
  • Proper OAuth scope configuration
  • Type-safe parameter validation using Zod schemas
  • Clean separation between tool definitions and API routes
  • Comprehensive documentation updates

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The code follows established patterns, includes proper error handling, authentication, and logging. All tools are well-structured with appropriate OAuth scopes. The implementation is clean and consistent with the existing codebase architecture.
  • No files require special attention

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/tools/google_drive/download.ts5/5Implements Google Drive file download with automatic export handling for Google Workspace files, proper error handling and logging
apps/sim/tools/onedrive/download.ts5/5Implements OneDrive file download using Microsoft Graph API with clean error handling
apps/sim/tools/slack/download.ts5/5Implements Slack file download supporting both OAuth and bot token authentication methods
apps/sim/tools/gmail/move.ts5/5Implements Gmail email move functionality using label modification, properly configured with OAuth scopes
apps/sim/tools/outlook/move.ts5/5Implements Outlook email move functionality using Microsoft Graph API with proper error transformation
apps/sim/app/api/tools/gmail/move/route.ts5/5API route for Gmail move with authentication, validation, and proper error handling
apps/sim/app/api/tools/outlook/move/route.ts5/5API route for Outlook move with authentication, validation, and error handling
apps/sim/lib/auth.ts5/5Added files:read scope to Slack OAuth configuration to support file download functionality

Sequence Diagram

sequenceDiagram
participant User
participant WorkflowBlock
participant ToolConfig
participant APIRoute
participant ExternalAPI
participant Storage
Note over User,Storage: File Download Flow (Google Drive/OneDrive/Slack)
User->>WorkflowBlock: Request file download
WorkflowBlock->>ToolConfig: Execute download tool
ToolConfig->>ExternalAPI: GET file metadata
ExternalAPI-->>ToolConfig: File metadata (name, mimeType, etc.)
alt Google Workspace file
ToolConfig->>ExternalAPI: Export file (convert format)
ExternalAPI-->>ToolConfig: Exported file content
else Regular file
ToolConfig->>ExternalAPI: Download file content
ExternalAPI-->>ToolConfig: File content
end
ToolConfig->>Storage: Store file buffer
ToolConfig-->>WorkflowBlock: Return file metadata
WorkflowBlock-->>User: File downloaded successfully
Note over User,Storage: Email Move Flow (Gmail/Outlook)
User->>WorkflowBlock: Request email move
WorkflowBlock->>ToolConfig: Execute move tool
ToolConfig->>APIRoute: POST move request
APIRoute->>APIRoute: Validate authentication
APIRoute->>APIRoute: Validate request data
alt Gmail
APIRoute->>ExternalAPI: POST modify labels
ExternalAPI-->>APIRoute: Updated message
else Outlook
APIRoute->>ExternalAPI: POST move to folder
ExternalAPI-->>APIRoute: Moved message
end
APIRoute-->>ToolConfig: Success response
ToolConfig-->>WorkflowBlock: Return metadata
WorkflowBlock-->>User: Email moved successfully
Loading

32 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR adds comprehensive file download capabilities for OneDrive, Google Drive, and Slack, along with email move functionality for Gmail and Outlook. It also introduces several new email management operations (mark read/unread, archive/unarchive, delete, add/remove labels) and Slack message operations (update, delete, add reaction).

Key Changes:

  • Added download file tools for OneDrive, Google Drive, and Slack with proper file handling and export support for Google Workspace files
  • Implemented email move operations for Gmail (label-based) and Outlook (folder-based)
  • Added Gmail email management: mark read/unread, archive/unarchive, delete, add/remove labels
  • Added Slack message operations: update message, delete message, add reaction
  • Updated OAuth scopes: added files:read and reactions:write to Slack provider
  • All implementations follow established patterns with proper authentication, validation, error handling, and logging
  • Updated tool registry and block configurations to expose new functionality

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • All new tools follow established patterns consistently, include proper error handling and validation, use appropriate OAuth scopes, and integrate cleanly with the existing architecture. The implementation is thorough with good logging and no security concerns.
  • No files require special attention

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/tools/gmail/move.ts5/5New Gmail move tool implementation - clean structure following existing patterns
apps/sim/tools/outlook/move.ts5/5New Outlook move tool implementation - properly structured with error handling
apps/sim/tools/slack/download.ts5/5Slack file download implementation with proper error handling and logging
apps/sim/tools/google_drive/download.ts5/5Google Drive download with Google Workspace export support - well structured
apps/sim/tools/onedrive/download.ts5/5OneDrive download implementation following established patterns
apps/sim/lib/auth.ts5/5Added files:read and reactions:write scopes to Slack OAuth configuration
apps/sim/tools/registry.ts5/5Registry updated with new download and move tools - properly exported

Sequence Diagram

sequenceDiagram
participant User
participant Frontend
participant API
participant OAuth
participant ExternalAPI as External API<br/>(Gmail/Outlook/Slack)
User->>Frontend: Configure tool<br/>(move email/download file)
Frontend->>OAuth: Request OAuth token
OAuth-->>Frontend: Return access token
Frontend->>API: POST /api/tools/{service}/{operation}
API->>API: Validate auth (checkHybridAuth)
API->>API: Validate request params (Zod)
API->>ExternalAPI: Make API call with token
ExternalAPI-->>API: Return response
API->>API: Transform response
API-->>Frontend: Return success/error
Frontend-->>User: Display result
Loading

43 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR adds comprehensive Slack thread support and additional message management capabilities to the Slack integration. The implementation includes:

Thread Support

  • Added thread_ts parameter to slack_message tool for posting replies to threads
  • Updated webhook trigger to expose thread_ts from incoming Slack events
  • Modified UI to include thread timestamp input field

New Message Management Tools

  • slack_update_message - Edit previously sent bot messages
  • slack_delete_message - Remove bot messages from channels
  • slack_add_reaction - Add emoji reactions to any message

Key Issue Found

  • File uploads with thread_ts won't post to threads correctly due to missing parameter in files.completeUploadExternal API call on line 192 of send-message/route.ts

The changes are well-structured and follow existing patterns in the codebase. Documentation has been thoroughly updated to reflect the new capabilities.

Confidence Score: 3/5

  • Safe to merge after fixing the thread_ts issue in file uploads
  • The PR implements valuable features with clean code architecture, but contains a logic bug where file uploads won't be posted to threads because the thread_ts parameter is missing from the files.completeUploadExternal API call. This means files will always post to the channel root instead of the specified thread. Once this is fixed, the implementation should work correctly.
  • Pay special attention to apps/sim/app/api/tools/slack/send-message/route.ts - the file upload path needs thread_ts parameter added to line 192-196

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/app/api/tools/slack/send-message/route.ts3/5Added thread_ts support for posting messages to Slack threads, but file uploads to threads may not work correctly due to missing thread_ts in files.completeUploadExternal call
apps/sim/tools/slack/message.ts5/5Added thread_ts parameter definition to Slack message tool configuration for thread reply support
apps/sim/blocks/blocks/slack.ts5/5Added UI fields for thread timestamp input and updated block configuration to support new Slack operations (update, delete, react)
apps/sim/lib/webhooks/utils.ts5/5Added thread_ts field to Slack webhook formatting to expose parent thread timestamp in webhook payloads
apps/sim/tools/slack/add_reaction.ts5/5New tool configuration for adding emoji reactions to Slack messages
apps/sim/tools/slack/delete_message.ts5/5New tool configuration for deleting Slack messages sent by the bot
apps/sim/tools/slack/update_message.ts5/5New tool configuration for updating Slack messages sent by the bot
apps/sim/triggers/slack/webhook.ts5/5Updated webhook trigger configuration to expose thread_ts in sample payload and output schema
apps/docs/content/docs/en/tools/slack.mdx5/5Updated documentation to reflect new Slack capabilities including thread support, message management, and reactions

Sequence Diagram

sequenceDiagram
participant User
participant SlackBlock as Slack Block UI
participant MessageTool as slack_message Tool
participant SendAPI as /api/tools/slack/send-message
participant SlackAPI as Slack API
participant Webhook as Slack Webhook
participant WebhookUtils as Webhook Utils
Note over User,WebhookUtils: Thread Support Flow
User->>SlackBlock: Configure Slack message with thread_ts
SlackBlock->>MessageTool: Pass thread_ts parameter
MessageTool->>SendAPI: POST with channel, text, thread_ts
alt No files attached
SendAPI->>SlackAPI: POST /chat.postMessage
Note right of SendAPI: Includes thread_ts in body
SlackAPI-->>SendAPI: Returns message timestamp
else Files attached
SendAPI->>SlackAPI: POST /files.getUploadURLExternal
SlackAPI-->>SendAPI: Upload URL + file_id
SendAPI->>SlackAPI: Upload file data
SendAPI->>SlackAPI: POST /files.completeUploadExternal
Note right of SendAPI: Missing thread_ts parameter!
SlackAPI-->>SendAPI: File uploaded
end
SendAPI-->>User: Success response with ts
Note over User,WebhookUtils: Webhook Trigger Flow
SlackAPI->>Webhook: Event callback with thread_ts
Webhook->>WebhookUtils: Process Slack event
WebhookUtils->>WebhookUtils: Extract thread_ts from event
WebhookUtils-->>Webhook: Formatted event data
Webhook-->>User: Trigger workflow with thread_ts
Loading

Additional Comments (1)

  1. apps/sim/app/api/tools/slack/send-message/route.ts, line 192-196 (link)

    logic: missing thread_ts parameter - file uploads won't be posted to threads

9 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@icecrasher321
icecrasher321 merged commit cf023e4 into stagingNov 5, 2025
9 checks passed
@waleedlatif1waleedlatif1 mentioned this pull request Nov 5, 2025
10 tasks
@waleedlatif1
waleedlatif1 deleted the sim-297 branch November 6, 2025 01:24
waleedlatif1 added a commit that referenced this pull request Nov 12, 2025
… slack; added move email tool for gmail and outlook (#1785)
* feat(tools): added download file tool for onedrive, google drive, and slack
* added gmail & outlook move tools, added missing credentials descriptions to modal
* added slack delete/update message, add reaction; added gmail read/unread/label/unarchive; added outlook copy/delete/read/unread
* added threads to slack operations
* added timestamp for slack webhook trigger since api uses timestamp for updating/reacting/deleting
* cleanup
* added file info to slack read messages
* updated slack desc
* fixed downloading for onedrive, slack, and drive
* fix type check
* fix build failure
* cleanup files, fix triggers with attachments, fix integration blocks with include attachment to parse to user files, remove unused code
* fix move files tools
* fix tests
* fix build errors
* fix type error
* fix tests
* remove redundant code and filter out unecessary user file fields
* fix lint error
* remove fields from tag dropdown
* fix file upload via API
* fix pdf parse issue
---------
Co-authored-by: waleed <waleed>
Co-authored-by: Adam Gough <adamgough@Adams-MacBook-Pro.local>
Co-authored-by: Vikhyath Mondreti <vikhyath@simstudio.ai>
@waleedlatif1waleedlatif1 mentioned this pull request Nov 12, 2025
10 tasks
Sign up for freeto 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.

2 participants

@waleedlatif1@icecrasher321