Skip to content

Event listener not catching bot reply messages #307

Description

I shifted from slackeventsapi to bolt-python and was testing the functions and noticed that in bolt-python the reply messages that were sent by the bot are not being caught by event listener whereas in slackeventsapi, it was.
I want to make a function using the logs I get after storing the messages from the bot.
At first I was thinking that it is not listening to any bot messages but later while testing I found that it was listening to messages of other bots (I know this as I am logging the events in a log file). It is just not listening to it's own reply messages.
Is this made deliberately? And if yes, is there a way to disable it?

The slack_bolt version

slack-bolt==1.4.4

Python runtime version

Python 3.7.4

Steps to reproduce:

  1. Given below is the configuration of the event listener
slack_signing_secret = xxx
slack_bot_token = xxx
app = App(
    token=slack_bot_token,
    signing_secret=slack_signing_secret
)

def run():
    port = xxx
    app.start(port=port, path="/")

@ app.event("message")
def handle_message(body):
    message = body["event"]
    logger(message)
    xxx

Expected result:

The reply messages from the bot are caught by the event listener and logged

Actual result:

The reply messages from the bot are ignored by the event listener

Activity

  1. added this to the 1.6.0 milestone on Apr 27, 2021
  2. self-assigned this
    on Apr 27, 2021
  3. seratch commented on Apr 27, 2021

    @seratch
    Contributor

    Hi @Shubhanker99, thanks a lot for migrating from the old module to this one!

    Is this made deliberately?

    Yes, it is. Resulting in an infinite loop by responding to the app's own message events is a common pitfall. Thus, this a-bit-opinionated framework decided to have a built-in prevention for it.

    And if yes, is there a way to disable it?

    As of today, there is no way to disable the middleware that skips the events generated by the bot user itself. However, we've already introduced the option to disable it in Bolt for Java two months ago:

    And we are going to apply the same changes to Python and Node SDKs soon. I cannot tell the exact date we'll release a new version including this fix yet but it won't take long (say, a few days).

  4. added a commit that references this issue on Apr 29, 2021
    76158a8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions