-
Notifications
You must be signed in to change notification settings - Fork 426
Discussion: Improvements around app.message(...) #465
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 slackapi/hubot-slack#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_messageekm_access_deniedme_messagemessage_changedmessage_deletedmessage_repliedreply_broadcastthread_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.
- Reason 1: @seratch believes developers expect to receive only new incoming messages when they use keyword matching in
text - Reason 2: It's not possible to support completely different structure in a statically-typed language (we're already aware of the same issue with TypeScript MessageEvent type definition does not match event data when subtype is 'message_changed' #311)
- The
MessageEventclass in this line is a representation ofmessagetyped event without any subtype. Other events with subtype look like this.
- The
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.