Resume conversation
See original GitHub issuePer https://github.com/Microsoft/BotFramework-WebChat/issues/353, it would be useful to resume a conversation in progress. Let’s talk about how this could happen.
First of all we’d need the conversationId
of the previous conversation. @dandriscoll can we depend on this remaining valid?
Instead of calling /conversation
we call /conversations/{conversationId}
, which would give us a current streamUrl
. I guess if this call fails we know the conversationId
is no longer valid.
We could also optionally supply a watermark
. If we don’t we’d get all the cached messages Direct Line might still be holding, which would sometimes be desirable.
Then business would resume as normal.
From an API perspective we’d just need to add conversationId?: string
and watermark?: string
to DirectLineOptions
.
You might ask, how do we get the conversationId/watermark from the previous conversation? Well it’s inside the DirectLine object. So the hosting page could create a DirectLine object, e.g.
const dl = new DirectLine({
secret: your_direct_line_secret // or token: your_direct_line_token
});
and then save dl.conversationId
and dl.watermark
to a cookie, or local storage, or its server, etc. Then when reconstituting it, it would do:
const dl = new DirectLine({
secret: your_direct_line_secret, // or token: your_direct_line_token
conversationId: from_previous_conversation,
watermark: from_previous_converation
})
Am I missing anything?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:40 (15 by maintainers)
Top GitHub Comments
You can get it from directline object
You then pass it to webchat
and then when connection is established
That code is used when initializing webchat object in HTML refer to : Advanced Web Chat chapter here https://github.com/Microsoft/BotFramework-WebChat/blob/master/README.md
Sent from my Windows 10 device
From: Kostas Setzas notifications@github.com Sent: Wednesday, October 17, 2018 5:03:20 PM To: Microsoft/BotFramework-DirectLineJS Cc: baki32; Mention Subject: Re: [Microsoft/BotFramework-DirectLineJS] Resume conversation (#9)
@baki32https://github.com/baki32 @sevetseh28https://github.com/sevetseh28 I still cannot get it. Do you put the lines above into the same script?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Microsoft/BotFramework-DirectLineJS/issues/9#issuecomment-430665177, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AVyIloHj_Q5a7GEVh4WHFsr-4s65oGx5ks5ul0aegaJpZM4MPwXk.