Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

message_replied event missing text property in typescript #2025

Open
4 of 10 tasks
stephenkalnoske-sans opened this issue Sep 1, 2022 · 1 comment
Open
4 of 10 tasks
Labels
area:typescript issues that specifically impact using the package from typescript projects bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented pkg:types applies to `@slack/types` semver:major
Milestone

Comments

@stephenkalnoske-sans
Copy link

Description

The text property does not exist on MessageRepliedEvent interface in typescript

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: 3.12.1

node version: 16.3.2

OS version(s): MacOS 12.4

Steps to reproduce:

slackApp.message(subtype("message_replied"), async ({ message }) => {
  if (message.subtype === "message_replied") {
    const messageThreadId = message.message.thread_ts;

    // Find the socket for the given thread ID
    for (const connection in openConnections) {
      const connectionProps = openConnections[connection];
      if (connectionProps.thread === messageThreadId) {
        connectionProps.socket.send(message.message.text); <---
      }
    }
  }
})

Expected result:

message.message.text is type string per event documentation:

https://api.slack.com/events/message/message_replied

Actual result:

Property 'text' does not exist on type 'MessageEvent & { thread_ts: string; reply_count: number; replies: MessageEvent[]; }'.
  Property 'text' does not exist on type 'MessageChangedEvent & { thread_ts: string; reply_count: number; replies: MessageEvent[]; }'

Attachments:

Screen Shot 2022-09-01 at 5 27 23 PM

@seratch seratch added the bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented label Sep 2, 2022
@seratch
Copy link
Member

seratch commented Sep 2, 2022

Hi @stephenkalnoske-sans, thanks for taking the time to report this issue!

Indeed, the type definition seems to be incorrect, and it should be fixed. However, as mentioned in the event data document page, the Slack Platform never sends this subtype event payload as of today:

Bug alert! This event is missing the subtype field when dispatched over the Events API. Until it is fixed, examine message events' thread_ts value. When present, it's a reply. To be doubly sure, compare a thread_ts to the top-level ts value, when they differ the latter is a reply to the former.
https://api.slack.com/events/message/message_replied

Just in case, I've verified the behavior on my end and found that the bug still exists. You will receive only GenericMessageEvent for the replies in a thread. Thus, please go ahead with the following code instead:

app.message(async ({ message }) => {
  if (message.subtype === undefined && message.thread_ts !== undefined) {
    // do the stuff here
    message.text; // this line compiles
  }
});

I hope this was helpful to you.

@filmaj filmaj mentioned this issue Jun 14, 2024
7 tasks
@filmaj filmaj transferred this issue from slackapi/bolt-js Sep 15, 2024
@filmaj filmaj added area:typescript issues that specifically impact using the package from typescript projects pkg:types applies to `@slack/types` labels Sep 15, 2024
@filmaj filmaj added this to the types@3.0.0 milestone Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:typescript issues that specifically impact using the package from typescript projects bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented pkg:types applies to `@slack/types` semver:major
Projects
None yet
Development

No branches or pull requests

3 participants