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

Event listener not catching bot reply messages #307

Closed
ghost opened this issue Apr 27, 2021 · 2 comments · Fixed by #310
Closed

Event listener not catching bot reply messages #307

ghost opened this issue Apr 27, 2021 · 2 comments · Fixed by #310
Assignees
Milestone

Comments

@ghost
Copy link

ghost commented Apr 27, 2021

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

@seratch seratch added this to the 1.6.0 milestone Apr 27, 2021
@seratch seratch self-assigned this Apr 27, 2021
@seratch
Copy link
Member

seratch commented Apr 27, 2021

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).

@ghost
Copy link
Author

ghost commented Apr 27, 2021

@seratch Thank you for the reply. Looking forward to the next release date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant