1

I am calling a third party REST API in MS Teams Bot on a particular input form user in the chat bot. Sometimes, the third party REST API response time is slower than usual. In such cases. MS Teams show the following message to the user with a Red color warning icon - "Unable to reach app. Please try again." Within few seconds of the Red color warning, the Teams however shows the correct data returned by the API successfully in the chat windows.

How do I handle such scenarios ("red warning") gracefully in the Teams Chat Bot caused by delay caused by calls to external REST APIs. Is there any time-out value in Microsoft Teams App that I have to modify to eliminate this kind of Warnings ?

Thanks!

Gags
  • 827
  • 2
  • 13
  • 29

1 Answers1

3

There is a 10 or 15 second timeout that can occur, and if it does then I think that would cause what you're seeing. See more at https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-howto-long-operations-guidance?view=azure-bot-service-4.0 where it states:

If the bot does not complete the operation within 10 to 15 seconds, depending on the channel, the Azure Bot Service will timeout and report back to the client a 504:GatewayTimeout, as described in How bots work.

In a nutshell, a simple approach could be:

  1. have your bot send a message back instantly
  2. queue the long-running operation on a queue somewhere (e.g. Azure), with a background processor to deal with it (e.g. Azure Function)
  3. when the operation completes, have the background processor send a pro-active message

The example in the article gives some guidance a sample to handle a long-running operation like this, using another approach with dialogs etc.

Update: This might actually give some useful background on the conversation, so see how the proactive messaging would fit in: https://hilton.giesenow.com/how-bot-calls-actually-work

Update 2: Here's a relatively recent sample for proactive messaging, hopefully it's useful: https://github.com/pnp/teams-dev-samples/tree/master/samples/bot-proactive-messaging

Hilton Giesenow
  • 9,809
  • 2
  • 10
  • 24
  • Thanks for your reply. I did try the approach in the article "Long Operations Guidance". However, I could not get the background processor send the pro-active message in MS Teams Bot. Please see my previous 2 posts on stackoverflow regarding the issue. https://stackoverflow.com/questions/65353154/manage-a-long-running-operation-in-ms-teams-bot/65354939#65354939 and https://stackoverflow.com/questions/65409285/ms-teams-dialog-bot-event-not-fired-when-message-is-sent-from-outside-the-teams?noredirect=1#comment115667421_65409285 – Gags Mar 01 '21 at 10:58
  • yeah I thought I recognized your name! See update above – Hilton Giesenow Mar 01 '21 at 11:58
  • Thanks ! I will check the proactive messaging sample. – Gags Mar 01 '21 at 12:48