5

I am developing chatbot application based on MS Bot Framework. And I need implement functionality of long-term history for chat conversations.

After reading tons of manuals, I found out two approaches how can I do this.

  1. Use approach that was described here. This approach uses DirectLine api-endpoint https://directline.botframework.com/v3/directline/conversations/{convId}/activities.

  2. Implement custom functionality, which will:

    • process all conversation activities
    • save them to storage(MongoDB),
    • provide a possibility to request activities for a specific conversation
    • and so on and so on

Variant №1 looks good, but I have some concerns about it. I have found nowhere details about specification DirectLine cache/buffer.

  • How long DirectLine stores content (activities that were sent through it) of conversation (conversationId)? What is expiration time for conversationId?
  • Can I expect, that I can get content of specific conversation at any time?
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
CoL
  • 51
  • 4
  • `How long DirectLine stores content (activities that were sent through it) of conversation (conversationId)?` Do you want to know how long Direct Line store conversation data in temporary cache? – Fei Han May 16 '18 at 09:13
  • yeap, exactly ) Thanks – CoL May 16 '18 at 09:38
  • I do not find official documentation or blog that explain about Direct Line service temporary cache yet, but in this [github issue](https://github.com/Microsoft/BotBuilder/issues/645) willportnoy said: *DirectLine uses the same web service bot endpoint that other channels use. There is an intermediate "Direct Line" service. It stores conversation data for a short period of time (to enable queuing) in the cloud (for fault tolerance), for that short period of time. I think the "short period of time" is something less than a day, but it's subject to change over time.* – Fei Han May 21 '18 at 05:20

2 Answers2

2

in memory is temp, and will always be gone when you publish again. its best to use a database for conversation state and user sessions. and then use the watermark to get back and continue with the conversation.

Words from MS:

In-memory data storage is intended for testing only. This storage is volatile and temporary. The data is cleared each time the bot is restarted.

MS docs has lots of info on managing state data, this could expire of course at some point but Bot State Management incase that dies one day Bot state Search

provides the search link, with needed results.

Not seen a mongo one, but they have a table storage solution and cosmos db solution, both nosql

Also as a side note, even if MS are doing this on there channel for you, it will still only be temp storage, especially with the new GDPR rules, and also that MS just dont like saving the conversation data

davethecoder
  • 3,856
  • 4
  • 35
  • 66
  • Thanks for your answer, but I asked not about data storage that app use on own side. I asked about data expiration time in internal DirectLine buffer/cache. DirectLine stores all sent activities in its own storage. This is not related to BotStorage on your app side. – CoL May 16 '18 at 17:10
  • I did answer that, and also when your bot restarts, is rebuilt, its rebuilt. never mind the middleware. Laws launch in a week that say MS cant be saving all that data fro long anyway, the answer is to have your own datastore, if you want retention, even if you dont like that answer, MS will not manage all that for you for life – davethecoder May 17 '18 at 16:11
  • Thanks, I've misunderstood you before – CoL Jun 01 '18 at 14:14
1

How long DirectLine stores content (activities that were sent through it) of conversation (conversationId)? What is expiration time for conversationId?

Messages are deleted after 24 hours

Can I expect, that I can get content of specific conversation at any time?

No, if you want the history of a conversation with a user you will need to save it and retrieve it based on user Id. A while back I wrote an example of storing conversation history it was for the purpose of displaying chat history in the webchat control. If uses a branch of the webchat repository which you can find being discussed here. You may or may not be able to reporpose pieces of the code for your use depending on what exactly you are trying to accomplish.

What exactly are you trying to accomplish with historical activities/conversations? I may have some other info for you.

D4RKCIDE
  • 3,439
  • 1
  • 18
  • 34
  • `Messages are deleted after 24 hours` - Is this stated anywhere in the Directline API documentation? I am searching but cannot find it. – Mark S. Jan 03 '19 at 21:08
  • If it's not in there, it should be. It was the official policy when I was on the team. there is a chance it has changed now. Messages aren't always deleted at 24 hours, but they are only guaranteed to be there for 24 hours. – D4RKCIDE Jan 03 '19 at 23:13