Skip to content

Comments

fix(trigger): handle Slack reaction_added/reaction_removed event payloads#3280

Merged
waleedlatif1 merged 4 commits intostagingfrom
fix/slack-trigger
Feb 21, 2026
Merged

fix(trigger): handle Slack reaction_added/reaction_removed event payloads#3280
waleedlatif1 merged 4 commits intostagingfrom
fix/slack-trigger

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Extract channel from event.item.channel and timestamp from event.item.ts for reaction events
  • Fetch original message text via conversations.history when bot token is available
  • Extract reaction (emoji name) and item_user (original message author) fields
  • Gracefully handle missing permissions — returns empty string instead of erroring
  • Add reaction and item_user to trigger output schema
  • Update setup instructions with reaction scopes and event subscriptions

Type of Change

  • Bug fix

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
Copy link

vercel bot commented Feb 21, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 21, 2026 1:14am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 21, 2026

Greptile Summary

This PR adds support for handling Slack reaction_added and reaction_removed events in the webhook trigger. The implementation extracts channel and timestamp from event.item.channel and event.item.ts (where reaction events nest this data), and fetches the original message text using Slack's reactions.get API rather than conversations.history. This is a better approach because reactions.get works for both top-level messages and thread replies by looking up items directly via channel + timestamp, whereas conversations.history cannot fetch thread replies without additional context.

Key changes:

  • Added fetchSlackMessageText helper using reactions.get API with proper error handling
  • Conditionally extracts channel and timestamp from event.item for reaction events
  • Added reaction (emoji name) and item_user (original message author) to output schema
  • Updated setup instructions to include reactions:read scope and event subscription steps
  • Gracefully handles missing permissions by returning empty string instead of throwing errors

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation correctly handles Slack reaction events by using the appropriate reactions.get API which works for both top-level messages and thread replies. The code includes proper error handling with graceful degradation (returns empty string on failure), correctly extracts nested fields from reaction event payloads, and updates the schema documentation appropriately. The switch from conversations.history to reactions.get is technically sound since reaction events need to fetch message text for items that may be thread replies.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/lib/webhooks/utils.server.ts Added fetchSlackMessageText using reactions.get API to fetch message text for reaction events; extracts channel/timestamp from event.item for reaction events; adds reaction and item_user fields to output
apps/sim/triggers/slack/webhook.ts Updated setup instructions with reactions:read scope and event subscriptions; added reaction and item_user properties to output schema

Sequence Diagram

sequenceDiagram
    participant Slack
    participant Webhook
    participant formatWebhookInput
    participant fetchSlackMessageText
    participant SlackAPI

    Slack->>Webhook: reaction_added/reaction_removed event
    Webhook->>formatWebhookInput: process event payload
    formatWebhookInput->>formatWebhookInput: detect reaction event type
    formatWebhookInput->>formatWebhookInput: extract channel from event.item.channel
    formatWebhookInput->>formatWebhookInput: extract timestamp from event.item.ts
    
    alt botToken available
        formatWebhookInput->>fetchSlackMessageText: fetch original message text
        fetchSlackMessageText->>SlackAPI: GET reactions.get(channel, timestamp)
        
        alt API success
            SlackAPI-->>fetchSlackMessageText: return message data
            fetchSlackMessageText-->>formatWebhookInput: return message.text
        else API failure
            SlackAPI-->>fetchSlackMessageText: error response
            fetchSlackMessageText-->>formatWebhookInput: return empty string (graceful degradation)
        end
    else no botToken
        formatWebhookInput->>formatWebhookInput: use empty string for text
    end
    
    formatWebhookInput->>formatWebhookInput: build event object with reaction & item_user
    formatWebhookInput-->>Webhook: return formatted event data
Loading

Last reviewed commit: ebbc42a

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.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Collaborator Author

@greptile

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.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

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.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@waleedlatif1 waleedlatif1 merged commit 765a481 into staging Feb 21, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/slack-trigger branch February 21, 2026 01:23
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