slackapi / deno-slack-sdk

SDK for building Run on Slack apps using Deno
https://api.slack.com/automation
MIT License
158 stars 27 forks source link

[BUG] A `MessagePosted` trigger is not reliably calling the workflow. #348

Open phil-kremidas-unitedmasters opened 1 month ago

phil-kremidas-unitedmasters commented 1 month ago

The deno-slack versions

phil@phils-mbp slack % cat import_map.json | grep deno-slack
    "deno-slack-sdk/": "https://deno.land/x/deno_slack_sdk@2.14.0/",
    "deno-slack-api/": "https://deno.land/x/deno_slack_api@2.7.0/"

Deno runtime version

phil@phils-mbp slack % deno --version 
deno 1.45.2 (release, x86_64-apple-darwin)
v8 12.7.224.12
typescript 5.5.2

OS info

phil@phils-mbp slack % sw_vers && uname -v
ProductName:            macOS
ProductVersion:         13.6
BuildVersion:           22G120
Darwin Kernel Version 22.6.0: Fri Sep 15 13:41:28 PDT 2023; root:xnu-8796.141.3.700.8~1/RELEASE_ARM64_T6000

Describe the bug

I have the following trigger:

const respondWithGoLinksTrigger: Trigger<typeof RespondWithGoLinksWorkflow.definition> = {
  type: TriggerTypes.Event,
  name: "Golink Response",
  description: "Responds to messages that contain short links with clickable links.",
  workflow: `#/workflows/${RespondWithGoLinksWorkflow.definition.callback_id}`,
  event: {
    event_type: TriggerEventTypes.MessagePosted,
    all_resources: true,
    filter: {
      version: 1,
      root: {
        statement: "{{data.text}} CONTAINS um/",
      },
    }
  },
  inputs: {
    message: {value: "{{data.text}}"},
    channel: {value: "{{data.channel_id}}"},
    user: {value: "{{data.user_id}}"},
  },
};

This trigger sometimes gets called for new messages that contain the string "um/" and sometimes doesn't. When it does, the workflow behaves as expected. I would expect it to always get called for such messages. Here's an example interaction:

image

Steps to reproduce

  1. Write a workflow with the trigger above.
  2. Run or deploy it.
  3. Invite the bot user to a channel.
  4. Send a message containing the string "um/".

Expected result

The workflow should run.

Actual result

The workflow may or may not run.

filmaj commented 1 month ago

Hello @phil-kremidas-unitedmasters 👋

What kind of workspace do you experience this issue in? Standalone or as part of an enterprise grid? And you experience the issue in both deployed (slack deploy) and local run (slack run) environments? If so, would you say the rate of this issue occurring is roughly equal regardless of execution environment?

phil-kremidas-unitedmasters commented 1 month ago

Hi @filmaj.

I think I'm in a standalone workspace, though I'm not totally sure how to check that. um-t.slack.com is the url if that helps.

This does happen both locally and deployed. At about the same rate.

filmaj commented 1 month ago

Thanks for sharing that, yes indeed confirmed, a standalone workspace. Let me see if I can reproduce this...

filmaj commented 1 month ago

So I couldn't reproduce this on my production standalone workspace. Both local run and deployed ran and the trigger ran every time, and I tried 50 times for each of local run and deployed. Some screens:

Screenshot 2024-08-01 at 12 20 10 PM Screenshot 2024-08-01 at 12 20 26 PM

As much as I hate to give you the runaround, I would suggest emailing our customer support team at feedback@slack.com and ask them to look into the issue from your specific workspace's perspective. It may due to a particular setting for your workspace. It may be a rare workspace-specific bug. Customer support also is authorized to look into production customer data such as workflow execution logs to help debug the problem. Feel free to link to this issue along in your e-mail and mention that the SDK team (me) wasn't able to easily reproduce.

phil-kremidas-unitedmasters commented 1 month ago

Yeah. I have another thread going with them. Thanks.

rabraham-Cornerstone commented 3 weeks ago

I'm surprised your code works. Whenever I try to get the the actual text of the posted message it's blank. I tried like you: message: {value: "{{data.text}}"}, and it's always an empty string.

My trigger always happens but the data.text isn't passed.