Search code examples
botframeworkdirect-line-botframeworkweb-chat

How should a botframework webchat conversation be maintained for over an hour?


I have looked through the documentation for botframework-webchat and have not been able to find any documentation on how conversations over 1 hour should be handled properly. This situation is most likely to occur if a web page is left idle in the background for an extended period of time.

The directline connection is maintained as long as the webchat remains active on a web page. The problem occurs after a page refresh.

The initial short term solution is to store the relevant conversation information in session storage, such as a token. The problem is that the token for the conversation is refreshed every 15 minutes. The refreshed token must be retrieved in order to maintain the conversation upon a page refresh.

I am sure a hacky work around exists for retrieving the refreshed token from the directline client object using an event callback.

Ideally, I am looking for a clean framework designed approach for handling this situation.

Though a working solution is better than no solution.

Relevant Link: https://github.com/microsoft/BotFramework-WebChat

Thanks.


Solution

  • The solution involved storing the conversation id in session storage instead of the token. Upon a page refresh a new token will be retrieved.

    https://github.com/microsoft/BotFramework-WebChat/issues/2899

    https://github.com/microsoft/BotFramework-WebChat/issues/2396#issuecomment-530931579

    This solution works but it is not optimal. A better solution would be to retrieve the active token in the directline object and store it in session storage. The problem is that a way to cleanly way to retrieve a refreshed token from a directline object does not exist at this point.