botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[Question] How can I plug in my storage to store history messages?

Open bhushanvadgave opened this issue 9 years ago • 10 comments

With DirectLineJS we can get history messages using watermark. But Bot Connector does not keep the history messages of a conversation for very long time. To make sure all history messages can be fetched in webchat using watermark, is there a way to plug in my storage which stores messages (same way we can plug in storage for bot sessions)?

bhushanvadgave avatar Jun 27 '17 08:06 bhushanvadgave

@bhushanvadgave Are you using .NET or Node SDK?

nwhitmont avatar Jun 27 '17 14:06 nwhitmont

From the documentation article Manage state data:

By default, the Bot Framework SDK for .NET stores state data using the Bot Framework State service, which is intended for prototyping only and is not designed for use by bots in a production environment. For performance and security reasons in the production environment, you should either use the Bot Builder SDK Azure Extensions to store state data in your own Azure Table storage or Azure DocumentDB store or create a custom implementation of IBotDataStore to store state data in the destination that you specify.

To create your own Bot State Service, use the BotBuilder-Azure extensions library provided on GitHub.

The repository also contains sample implementations for both Azure Table Storage and DocumentDB integrations. (Note: DocumentDB implementation also supports CosmosDB, Microsoft's next generation version of DocumentDB)

nwhitmont avatar Jun 27 '17 15:06 nwhitmont

@nwhitmont I am using NodeJS SDK.

bhushanvadgave avatar Jun 28 '17 14:06 bhushanvadgave

@nwhitmont Documentation which you referred above only explains about storing sessions into persistent storage which I am able to do successfully. But how can I store history messages to enable my webchat get all history messages when it resumes the conversation using watermark.

bhushanvadgave avatar Jun 28 '17 14:06 bhushanvadgave

@bhushanvadgave Thanks for the update. What you are asking about is specific to WebChat. Please post your question on Microsoft/BotFramework-WebChat repository.

nwhitmont avatar Jun 28 '17 20:06 nwhitmont

Sorry, I know this issue has been closed, yet I have the same question as @bhushanvadgave. Did you find a solution to this? Thank you very much

zubcomandante avatar Dec 20 '17 08:12 zubcomandante

@zubcomandante No, I didn't find any solution for this.

bhushanvadgave avatar Dec 20 '17 13:12 bhushanvadgave

@zubcomandante @bhushanvadgave This project does exactly this https://github.com/JasonSowers/ChatHistoryBot-Public. I also suggest reading through this pull request on the WebChat repo https://github.com/Microsoft/BotFramework-WebChat/pull/615

JasonSowers avatar Dec 21 '17 18:12 JasonSowers

@JasonSowers thank you very much, I'm giving a look at it. Our bot is implemented in Node.js with MongoDB persistency for state data, and we are connecting from custom directline-based clients (web and mobile): so I can't use your code directly, I rather have to understand the main facts and reproduce the whole thing in our scenario.

zubcomandante avatar Dec 22 '17 10:12 zubcomandante

@zubcomandante While your implementation will be different the core functionality will be the same.

  1. Save Activity to your persistent data store
  2. Serve the activities up to the webchat control as it is rendering/before it renders.

Keep in mind the example I showed you is not a fully complete production level example. It does not, for example, have a way to handle a very high number of messages gracefully. The more messages it has to load into history the more time it will take. There are definitely ways to make it better. Good luck!

JasonSowers avatar Dec 22 '17 17:12 JasonSowers