Skip to content

feat(slack): ability to have DM channels as destination for slack tools - #2388

Merged
icecrasher321 merged 13 commits into
stagingfrom
feat/slack-dm
Dec 16, 2025
Merged

feat(slack): ability to have DM channels as destination for slack tools#2388
icecrasher321 merged 13 commits into
stagingfrom
feat/slack-dm

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

Surface DM channels correctly.

Type of Change

  • New feature

Testing

Tested with @aadamgough

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 Dec 15, 2025

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentReviewUpdated (UTC)
docsSkippedSkippedDec 16, 2025 1:30am

@greptile-apps

greptile-appsBot commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR adds support for Slack direct messages (DMs) as a destination type alongside channels. The implementation introduces a destinationType dropdown with "Channel" and "Direct Message" options, and adds a new user selector that fetches and displays Slack users.

Key Changes:

  • Created /api/tools/slack/utils.ts to consolidate message sending logic with DM support via openDMChannel() and sendSlackMessage() functions
  • Added /api/tools/slack/users endpoint to fetch Slack users for the selector
  • Enhanced serializer/index.ts with evaluateCondition() function to support nested AND conditions for conditional field visibility
  • Introduced user-selector sub-block type and unified SlackSelectorInput component that handles both channel and user selection
  • Updated Slack OAuth scopes to include im:write, im:history, and im:read for DM permissions
  • Modified block configuration to conditionally show channel fields when destinationType=channel and user fields when destinationType=dm
  • Refactored message_reader.ts to proxy through new /api/tools/slack/read-messages endpoint for consistent DM handling

Architecture:
The implementation uses conditional field visibility based on destinationType, ensuring users only see relevant fields (either channel selector or user selector). The serializer correctly evaluates these conditions when building request parameters, excluding hidden fields from serialization.

Confidence Score: 5/5

  • This PR is safe to merge with no critical issues found
  • The implementation is well-architected with proper separation of concerns, comprehensive error handling, correct conditional logic for field visibility, and appropriate OAuth scope additions. Code refactoring improves maintainability by extracting shared logic into utils. All changes follow existing patterns and the feature was tested by the team.
  • No files require special attention

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/app/api/tools/slack/utils.ts5/5New utility module extracting Slack message/DM logic with clean separation of concerns
apps/sim/blocks/blocks/slack.ts5/5Added DM support with destinationType dropdown and user selector fields, proper conditional logic
apps/sim/serializer/index.ts5/5Refactored condition evaluation logic to support nested AND conditions for field visibility
apps/sim/app/api/tools/slack/send-message/route.ts5/5Refactored to use utils module, added userId support with proper schema validation
apps/sim/app/api/tools/slack/read-messages/route.ts5/5New endpoint for reading Slack messages with DM support via userId parameter
apps/sim/app/api/tools/slack/users/route.ts5/5New endpoint for fetching Slack users, filters out deleted and bot accounts
apps/sim/hooks/selectors/registry.ts5/5Added slack.users selector definition for user selection in UI
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/slack-selector/slack-selector-input.tsx5/5New unified component for both channel and user selection with shared selector logic

Sequence Diagram

sequenceDiagram
participant User
participant UI as Slack Block UI
participant Serializer
participant SendAPI as /api/tools/slack/send-message
participant UsersAPI as /api/tools/slack/users
participant Utils as slack/utils.ts
participant Slack as Slack API
Note over User,Slack: DM Channel Selection Flow
User->>UI: Select "Direct Message" destination
UI->>UsersAPI: POST /api/tools/slack/users
UsersAPI->>Slack: GET users.list
Slack-->>UsersAPI: User list
UsersAPI-->>UI: Filtered users (non-bot, non-deleted)
User->>UI: Select user from dropdown
Note over User,Slack: Send DM Flow
User->>UI: Click Send
UI->>Serializer: Serialize block params
Serializer->>Serializer: Evaluate conditions (destinationType=dm)
Serializer->>Serializer: Include dmUserId, exclude channel
Serializer->>SendAPI: POST with userId
SendAPI->>Utils: sendSlackMessage({userId, text})
Utils->>Slack: POST conversations.open
Slack-->>Utils: DM channel ID
Utils->>Slack: POST chat.postMessage
Slack-->>Utils: Message response
Utils-->>SendAPI: Success
SendAPI-->>UI: Message sent
Note over User,Slack: Read DM Flow
User->>SendAPI: Read messages with userId
SendAPI->>Utils: openDMChannel(userId)
Utils->>Slack: POST conversations.open
Slack-->>Utils: DM channel ID
Utils->>Slack: GET conversations.history
Slack-->>Utils: Messages
Utils-->>SendAPI: Messages
SendAPI-->>User: DM messages
Loading

@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.

21 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@icecrasher321

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.

23 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@icecrasher321
icecrasher321 merged commit 300aaa5 into stagingDec 16, 2025
10 checks passed
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.

1 participant

@icecrasher321