Search code examples
timeoutbotframework

botbuilder-timeout for Typescript Virtual assistant


We have Microsoft Virtual Assistant built it Typescript and we are planning to add Timeout capability. What this means is VA should end the conversation with its Skill if user is not engaged for certain amount of time.

There is botbuilder-timeout module to do this in V3 SDK which says,

"Module for Microsoft Bot Framework to enable your bot to prompt the user if the bot detects inactivity and ultimately end the conversation if no user activity after a defined period of time."

Is there anything in V4 or Virtual Assistant that offers similar capability ? If yes any ideas/pointers to document is appreciated.


Solution

  • There isn't anything official for V4 bots like this. I don't believe I've seen anything unofficial, either.

    That being said, we generally recommend something like:

    1. On each message, start a synchronous timer. You can do this in the bot, but it would be better to do outside of the bot, like with Azure Functions or something. The rest of this answer will assume the timer is outside of the bot. Ensure the timer also keeps track of the conversationReference related to the timer.
    2. Restart the timer each time the user matching that conversationReference sends a message
    3. Once the timer expires, send an event to the bot with the user and conversation information (maybe through ChannelData), letting the bot know the timer has expired. You could also create a separate endpoint and monitor there, so you don't need the activity scheme; instead of /api/messages, you could use something like /api/expiredTimers.
    4. Once the expired timer event is received, send a proactive message to the user to either 1) see if they're still there, or 2) end the conversation.