Skip to content

Fix #197 by supporting classic bot messages in app.message constraints - #198

Merged
seratch merged 1 commit into
slackapi:mainfrom
seratch:issue-197-classic-bot-message-events
Jan 12, 2021
Merged

seratch merged 1 commit into
slackapi:mainfrom
seratch:issue-197-classic-bot-message-events

Conversation

@seratch

@seratch seratch commented Jan 10, 2021

Copy link
Copy Markdown
Contributor

This pull request fixes #197 by adding support for classic app's bot messages in app.message listener constraints.

When an app with the current permission model posts a message in a channel, Events API sends the following payload (Payload A) to your app. On the other hand, if a message is posted by a classic app, the Event API payload (Payload B) can be a bit different. The notable difference is the existence of "bot_message" subtype. Bolt for Python had not been including this pattern for the events that can be handled by app.message listeners. This pull request resolves this issue.

Payload A

current_bot_message_event_payload = {
    "team_id": "T111",
    "enterprise_id": "E111",
    "api_app_id": "A111",
    "event": {
        "type": "message",
        "team": "T111",
        "channel": "C111",
        "channel_type": "channel",
        "ts": "1610261539.000900",
        "text": "Hi there! Thanks for sharing the info!",
        "user": "UB111",
        "bot_id": "B999",
        "bot_profile": {},
        "event_ts": "1610261539.000900",
    },
    "type": "event_callback",
    "event_id": "Ev222",
    "event_time": 1610261539,
    "authorizations": [],
    "is_ext_shared_channel": False,
    "event_context": "1-message-T111-C111",
}

Payload B

classic_bot_message_event_payload = {
    "team_id": "T111",
    "enterprise_id": "E111",
    "api_app_id": "A111",
    "event": {
        "type": "message",
        "subtype": "bot_message",
        "channel": "C111",
        "channel_type": "channel",
        "ts": "1610262363.001600",
        "text": "Hi there! Thanks for sharing the info!",
        "username": "classic-bot",
        "bot_id": "B888",
        "event_ts": "1610262363.001600",
    },
    "type": "event_callback",
    "event_id": "Ev333",
    "event_time": 1610262363,
    "authorizations": [],
    "is_ext_shared_channel": False,
    "event_context": "1-message-T111-C111",
}

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

  • slack_bolt.App and/or its core components
  • slack_bolt.async_app.AsyncApp and/or its core components
  • Adapters in slack_bolt.adapter
  • Document pages under /docs
  • Others

Requirements (place an x in each [ ])

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

  • 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 run ./scripts/install_all_and_run_tests.sh after making the changes.

@seratch seratch added bug Something isn't working area:async area:sync labels Jan 10, 2021
@seratch seratch added this to the 1.2.0 milestone Jan 10, 2021
@seratch seratch self-assigned this Jan 10, 2021
@codecov

codecov Bot commented Jan 10, 2021

Copy link
Copy Markdown

Codecov Report

Merging #198 (6da54bc) into main (512a53c) will decrease coverage by 0.02%.
The diff coverage is 93.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #198      +/-   ##
==========================================
- Coverage   92.14%   92.12%   -0.03%     
==========================================
  Files         149      149              
  Lines        4496     4508      +12     
==========================================
+ Hits         4143     4153      +10     
- Misses        353      355       +2     
Impacted Files Coverage Δ
slack_bolt/listener_matcher/builtins.py 93.53% <91.66%> (-0.71%) ⬇️
slack_bolt/app/app.py 86.78% <100.00%> (+0.03%) ⬆️
slack_bolt/app/async_app.py 94.39% <100.00%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 512a53c...6da54bc. Read the comment docs.

@seratch

seratch commented Jan 12, 2021

Copy link
Copy Markdown
Contributor Author

It seems no one has concerns on this change. Let me merge this now.

@seratch
seratch merged commit 47063fa into slackapi:main Jan 12, 2021
@seratch
seratch deleted the issue-197-classic-bot-message-events branch January 12, 2021 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:async area:sync bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle message event from incomming webhook

1 participant