slackapi / slackapi/bolt-js

Discussion: Improvements around app.message(...)

Open
#465 11 comments 0 reactions 1 assignee View on GitHub

@stevengill is already working on this.

Since May 7, 2020.

discussion semver:major
Dominant language
TypeScript
Stars
2.9k
Forks
445
Avg merge
1d 3h
Merged PRs (30d)
28

Description

Proposal

As described at #463, app.message(...)'s behavior with the latest payloads is not intuitive for developers. It's surprising for developers to receive more events than the number of messages in a channel.

I propose to change the behavior to receive only message typed events that don't have a subtype. With this, Bolt apps can receive only events telling the arrival of new messages.

Also. there is one additional thing we may need to care about in the future. As far as I know, the server-side no longer sends bot_message subtyped events. Instead, it sends no-subtype events with bot_id and bot_profile properties. If the server-side gets back to the previous behavior in the future, we may need to add bot_message events as well.

For reference: @aoberoi 's https://github.com/slackapi/hubot-slack/issues/589

What happened to the subtype: 'bot_message'? It seems to be missing on at least some, but maybe all, events where it should be.

References
The list of sutyped message events

There are a number of subtype events for messages. Some of them may have a quite different data structure compared with message typed events without a subtype.

  • bot_message
  • ekm_access_denied
  • me_message
  • message_changed
  • message_deleted
  • message_replied
  • reply_broadcast
  • thread_broadcast
Bolt for Java's approach

Bolt for Java's app.message listeners receive only message events that don't have a subtype.
https://github.com/slackapi/java-slack-sdk/blob/v1.0.3/bolt/src/main/java/com/slack/api/bolt/App.java#L509-L526

There are two reasons for that. It's technically impossible to include other events due to the Reason 2.

Regarding bot_message events, Bolt doesn't invoke listeners given to app.message due to the difference in the structure of payloads. If the server-side is changed in the future, Bolt for Java may need to consider introducing a new routing method.

What type of issue is this? (place an x in one of the [ ])
  • bug
  • enhancement (feature request)
  • question
  • documentation 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.