rasa: Slack triggers multiple messages to rasa (does not happen with Telegram/Commandline)

Rasa Core version: 0.9.0a5

Python version: 3.6

Operating system (windows, osx, …): ubuntu 18.04

Issue: Slack triggers multiple messages to rasa and NO, this does not happen with Telegram and Commandline Interface (!) with the very same trained RASA_NLU and RASA_CORE models (!!) Please, Rasa-Team: Try to reproduce that with any kind of story!

Content of domain file (if used & relevant):


About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 38 (21 by maintainers)

Most upvoted comments

Got the issue, specific to one scenario. When the user posts a message in a channel, and not directly chatting with a bot, the channel is not being passed in. Got fix working on my local env, will add tests and raise a PR.

@akelad , I’ve posted PR. thank you for reviewing!

@naoko we actually got that same information from the slack team as well. I haven’t had time to look into it again yet, sorry! but yes, please create a PR with that fix and i’ll take a look at it

I think I see why… I was having this problem sometimes and looked around and this is what Slack is doing 😃 no wonder it doesn’t happen on other integration. This behavior is documented here: https://api.slack.com/events-api#errors Per doc, slack will re-deliver message if it meets “Failure conditions” (which also listed there). One of the condition is that if your server took longer than 3 seconds to respond. So if your server responds fast enough you won’t see this behavior. It also says, setting the header to include X-Slack-No-Retry: 1 if you don’t want the message to re-deliver. So I’ve modified the code like this

                elif self._is_user_message(output):
                    if not request.headers.environ.get('HTTP_X_SLACK_RETRY_NUM'):
                        text = output['event']['text']
                        sender_id = output.get('event').get('user')
                    else:
                        logger.warning("Received retry #{} request from slack due to {}".format(
                            request.headers.environ.get('HTTP_X_SLACK_RETRY_NUM'),
                            request.headers.environ.get('HTTP_X_SLACK_RETRY_REASON')))
                        return Response(status=201, headers={'X-Slack-No-Retry': 1})

and it seems to be successful except that Slack will still send max retry (3 times) regardless of value specified in the header.

I’m more than happy to make PR if this is an acceptable solution.