[Question] Bot c#: How to load old conversations when user opens the chat
I've tried to implement my Bot into xamarin forms app with direct line, but I don't know how to load the old conversations when the user opens the chat again as it is in skype. I want to keep the conversation into sql db and to load it at the beginning. And also I don't know when I get the conversations from database how to organize the chat what user said to be on the users side, and the responses from bot to be on the bots side on chat.
You will have to log the conversations yourself using the user id from bot framework and load it when the user tries to open chat next time.
@alokraj68 but I don't know how, can you provide some example? I was following this link: https://github.com/Microsoft/BotBuilder-Samples/tree/master/CSharp/core-DirectLine But here it doesn't keep track of old conversations
@msBot1111 you will have to do it using IActivity log. my way is a work around.
@msBot1111 As in the link you were following, to start a new conversation you'd call:
var conversation = directLineClient.Conversations.StartConversationAsync ();
// save conversation.ConversationId somewhere locally
However, you want to cache the conversation.ConversationId locally so you can use it to reconnect to the existing conversation and get all the messages in the existing conversation - no need to save them all yourself:
var existingConversationId = // ConversationId you saved earlier
// this is the same as the existing conversation
var conversation = await directLineClient.Conversations.ReconnectToConversationAsync (existingConversationId);
// now you can get all the messages (or activities) existing conversation
var activitySet = await directLineClient.Conversations.GetActivitiesAsync (conversation.ConversationId);
But how much of the conversation will be stored in this method? And right now am experiencing restart issues in my bot. Wont that affect such storage?
On 13-May-2017 6:05 AM, "Colby Williams" [email protected] wrote:
@msBot1111 https://github.com/msbot1111 As in the link you were following, to start a new conversation you'd call:
var conversation = directLineClient.Conversations.StartConversationAsync ();// save conversation.ConversationId somewhere locally
However, you want to cache the conversation.ConversationId locally so you can use it to reconnect to the existing conversation and get all the messages in the existing conversation - no need to save them all yourself:
var existingConversationId = // ConversationId you saved earlier // this is the same as the existing conversationvar conversation = await directLineClient.Conversations.ReconnectToConversationAsync (existingConversationId); // now you can get all the messages (or activities) existing conversationvar activitySet = await directLineClient.Conversations.GetActivitiesAsync (conversation.ConversationId);
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BotBuilder/issues/2641#issuecomment-301213645, or mute the thread https://github.com/notifications/unsubscribe-auth/AIyDmwUq7hs62Nf2QkDEh1IhCCKIUTvfks5r5PrUgaJpZM4NGHmO .
I believe these will help you with what you are trying to accomplish: Documentation Source code Saving bot activities blog by @EricDahlvang Please continue the conversation by telling us how they work out for you. I am going to close this issue for now, we can always reopen it if needed
I have to maintain chat in chat window whenever I switch my web pages. I am using webchat and I have places the webchat on layout.cshtml whenever I am switching to another page my webchat gets refreshed. Is there a way in which I can persist data in my chat window
@rachita0311 You are commenting on a closed issue.
If you have a question or problem, please open a new issue.