Botframework-sdk: Conversation doesn't end/expire automatically in MS teams

Created on 15 May 2018  Â·  11Comments  Â·  Source: microsoft/botframework-sdk

Bot Info

  • SDK Platform: Node.js
  • SDK Version: v3
  • Active Channels: MS Teams, Cortana
  • Deployment Environment: Azure Bot Service, Azure App Service, local development with Emulator

Issue Description

My bot in MS teams works fine as of now but there is one corner case. If user finishes conversation flow gracefully (by finishing task ex:- Room booking) I am calling session.endConversation at the end so technically session data, bags, state will be cleared. But, there is a possibility that user might leave the 1:1 conversation with Bot in the middle. ex:- trying to book a room > got room suggestion > user never booked it.
If user tries to pickup the same conversation later let's say after 2 days user might have stale state data/results. To avoid this I implemented global command like (quit,bye) which can be used to get out of the conversation at any time. But, still there are some users who aren't using it.

To avoid this I wanted something like which will enable 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.

I came across https://www.npmjs.com/package/botbuilder-timeout but it doesn't work as expected. Looks like it has some bug. I implemented botbuilder-timeout in my code but even if conversation is ended gracefully & session.endConversation() is called, botbuilder-timeout again asks user "Hey are you there?". Looks like it is not checking is endConversation() was called in Bot and it was ended already.

Reproduction Steps

Try to chat with Bot in teams, and leave the conversation in the middle.

Expected Behavior

Conversation data, state data and data bags should be cleared in MS teams, Cortana chat , Skype if bot detects inactivity from user after a defined period of time.

Update:

All 11 comments

Any update on this please ?

Hi @rjgmail88, there is a bug in the botbuilder-timeout module. A pull request has already been submitted against the repository by the community. However, if you implement the changes locally this should fix the issue.

To implement, you will need to change the code located at https://github.com/User1m/botbuilder-timeout/blob/master/dist/timeout.js#L37.

The code should be changed from

_this.clearTimeoutHandlers(event);

to

_this.clearTimeoutHandlers(convoId);

I have tested the timeout module post-code change and it appears to work as expected.
Once the PR is approved you can update the module.

I'm closing as this should resolve the problem. Please reopen if further help is needed.

@stevkan , If I want to make thee changes then I believe I need to go under .../node_modules/botbuilder-timeout and change the file. I did so but changes arent reflecting. Do you think after doing 'npm install' my changes will be overridden ?

Do I need to overlay a file in nodejs.

@stevkan Any update ?

Hi @rjgmail88, apologies for the lack of response. I missed your having responded. Were you able to get this working?

No. This issue still persist. I have implemented the change you mentioned on May 21 but still that didn't fix it.

Hi @rjgmail88,

To answer your question about npm install possibly overriding customized modules the answer is, yes. At least, that is what I'm seeing online. A solution is to point the install for that package to a locally stored module rather than pulling from online. You can read about that here. Another option would be to save a copy of the changed folder and copy it back in after an install. It's less elegant, but certainly doable.

What do you mean by "Do I need to overlay a file in node.js"?

Can you also share the code changes so I can look over for possible errors?

@stevkan ,

I forked the botbuilder-timeout and made the change you suggested. Please check the following file in my repo.

https://github.com/rjgmail88/botbuilder-timeout/blob/master/src/timeout.ts

then i changed the respective dependency to point to pull from above repo.

"devDependencies": {
    "botbuilder-timeout": "git+https://github.com/rjgmail88/botbuilder-timeout.git"

this method insures npm install doesn't override & pulls correct copy.

Note:- The real issue is suggested changes aren't working as expected. Are you sure the fix you mentioned works ?

Hi @rjgmail88,

Unfortunately, I don't have another answer for you. The provided solution does work. Perhaps delete the timeout module from your node_modules folder, do another npm install, and try making the changes a second time. It's possible that something got upset.

Beyond that, you are going to have to reach out to the developer of the botbuilder-timeout repo. That repo isn't an official Microsoft repo and I've helped about as much as I am able to.

I am closing the issue. For future consideration, the Microsoft Bot Framework team prefers that how to questions be submitted on Stack Overflow. The official Bot Framework Github repo  is the preferred platform for submitting bug fixes and feature requests related specifically to Microsoft/BotBuilder.

Hi @rjgmail88, there is a bug in the botbuilder-timeout module. A pull request has already been submitted against the repository by the community. However, if you implement the changes locally this should fix the issue.

To implement, you will need to change the code located at https://github.com/User1m/botbuilder-timeout/blob/master/dist/timeout.js#L37.

The code should be changed from

_this.clearTimeoutHandlers(event);

to

_this.clearTimeoutHandlers(convoId);

I have tested the timeout module post-code change and it appears to work as expected.
Once the PR is approved you can update the module.

I'm closing as this should resolve the problem. Please reopen if further help is needed.

Hi stevkan,
Thanks for your solution its working fine in the normal scenarios
but if the reconnect to the previous conversion on page refresh as i need to something to the support tickets if user refreshes the html page in between then i did the loadsession passing the address of previous conversation then this issue started coming again.

Any ideas how to solve it or have you also faced something like this.

@stevkan I am developing a bot using BF v4 and C#/.Net Core.
Can you please point me how to get the similiar behaviour in C#. Timers approach and its management is not something I am real fan of. Please comment.

Was this page helpful?
0 / 5 - 0 ratings