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

Multiple responses from Slack adapter in Bot framework Composer #533

Open
NeethithevanR opened this issue Jun 1, 2023 · 5 comments
Open

Comments

@NeethithevanR
Copy link

I use the Bot Builder community Slack adapter in my Bot service (using Bot Framework Composer v 2.1.2). And it is implemented using DOTNET(version 3.1). Currently, the issue I am facing is: when I trigger a message from my Bot channel to my Bot service, I receive multiple responses in my Bot channel. I looked at a few documents and worked around the issue using the "X-Slack-Retry-Num" request header coming along with slack API. But I feel that this is not a proper fix for the issue, as there could be genuine needs for retries later.

The workaround I made:
string slackRetry = Request.Headers["X-Slack-Retry-Num"];
if (string.IsNullOrEmpty(slackRetry)){
await adapter.ProcessAsync(Request, Response, _bot).ConfigureAwait(false);
}

Please let me know if there is a better fix for the issue above, which I believe is something to do with sending acknowledgement back to slack. This is something I am not able to figure out where and how to code. If possible, please refer some appropriate documentation to me.

@martinlarosa
Copy link

Hey! I believe it's something I ran into. This happens because the bot is not acknowledging the request in less than 3 seconds to slack.

Check this out: microsoft/botbuilder-dotnet#5405 I had a fix that was never merged but I implemented it in a custom adapter.

@NeethithevanR
Copy link
Author

@martinlarosa , Thank you for responding. I tried that fix. But its not working in my case.

@paulio
Copy link

paulio commented Jun 13, 2023

@martinlarosa , Thank you for responding. I tried that fix. But its not working in my case.

Have you tried just immediately echoing a response in your bot? As previously stated it sounds like your bot just needs to send some sort of response but has gone quiet. IMO extending the timeout isn't a great solution, people have a very low threshold to waiting for some form of response

@NeethithevanR
Copy link
Author

NeethithevanR commented Jun 15, 2023

@martinlarosa , That fix you have made in https://github.com/microsoft/botbuilder-dotnet. But that repository was no longer active. So,I am using @botbuildercommunity .

@martinlarosa
Copy link

Check the code in the commit of my PR, it's very few lines of code. They never merged it to the other repo anyway.
you can see their reasoning here: microsoft/BotFramework-Composer#6484 (comment)

There problem is that Slack needs the HTTP request to be acknowledged by the bot in less than 3 seconds. Otherwise it will start retrying. That's why you see multiple messages.
This in my experience happens in 2 ways. The most common is doing some "heavy" processing or calling an API from the bot. If this takes more than 3 seconds then you run into this situation because the ACK of the HTTP call doesn't get back to slack until everything finishes.
The other time when this happened to me was when running it locally on the first interaction, because Bot Framework took a bit of time to load up a bunch of things during the first interaction after launching it.

My solution was to not await the RunPipelineAsync call, and change the code so that it would run async. That way the bot can return the ACK to Slack, telling Slack that the message was received, while it's moving on doing it's own thing.

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

No branches or pull requests

3 participants