1

I am trying to implement Blob transcript storage(https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-howto-v4-storage?view=azure-bot-service-4.0&tabs=csharp#blob-transcript-storage-implementation). I am able to implement and see the stored transcripts in Azure blob storage under container as json files. Now the issue I am facing is how do I display them properly. If I use SendActivityasync then it displays both bot and user messages as if bot is typing it (on the bot side-left side).

  1. Is there a way to dump the transcript in one go? Just to display the whole conversation or is it supposed to be done one by one? Is there a function that allows this?

  2. Since these transcripts are saved using conversation ids, how do I use this sample to get only the user who's using the bot and not all? If the conversation ids are new for each conversation and user ids according to sample is generated using 'Guid.NewGuid()' it will be random everytime. Are these being saved to keep track of users? Is there any sample to see the whole thing?

I have seen a lot of samples mentioning this being used for debugging. Has anyone implemented this and if so what samples are you following?

Thanks

  • What do you mean by "Is there a way to dump the transcript in one go?" How exactly do you want the conversation displayed? – mdrichardson Oct 27 '20 at 20:41
  • The same way it was when the user was using the bot. For eg like I said if I pull the data from Azure Blob storage I get in and I send those activities using SendActivityAsync. This will pop all the queries from the Bot side (left side of chat). But I want to sent all bot messages from left and user messages from right. Hope that make sense. Same way then you would work with it normally. The reason I used dump is all activities will be saved separately, so is it supposed to be displayed one by one? – Sharat Gangadharan Oct 28 '20 at 07:52
  • Unfortunately, there's no way to have the bot send a message as though it were from a user. However, if you're using WebChat, [you can reload the chat history](https://stackoverflow.com/questions/56969008/is-there-a-way-to-persist-chat-history-in-ms-bot-framework-web-chat-after-a-page) – mdrichardson Oct 29 '20 at 16:49
  • Thank you, I actually have implemented that and it works great. I was trying to achieve chat history as far as 15 to 30 days. I know this persists 1 day and not intended for history but more for saving sessions if someone reloads the page. So there's no way to do that for now? Just confirming before moving on to the next thing. Maybe dump was the wrong wording. It was just a way to say that if I have transcripts saved for 15 days is there someway to just make it pop in on bot rather than sending them one by one if that makes sense. Thanks – Sharat Gangadharan Oct 30 '20 at 17:27

1 Answers1

1

This is answered in this GitHub Issue. The original issue is pretty old, but there's an updated answer in the linked comment.

Basically, you need to:

  1. Load all of your activities from storage (maybe use the Blob REST API for this)
  2. Pass the activities in to the createStore() method
  3. Pass the store into the renderWebChat() method. For example:
// This is just an example. You'll want to populate history with
// an array of activities from your storage.
const history = [
  {
          type: "message",
          id: "******************",
          timestamp: "2020-10-30T20:45:52.7120529Z",
          channelId: "webchat",
          from: {
            id: "******************",
            name: "******************",
            role: "bot",
          },
          conversation: {
            id: "******************",
          },
          locale: "en-US",
          text: "THIS IS A PREVIOUS MESSAGE",
          inputHint: "acceptingInput",
          attachments: [
          ],
          entities: [
          ],
          replyToId: "******************",
        }
]

[...]

const store = window.WebChat.createStore({ activities: history}, ({ dispatch }) => next => action => {
    return next(action);
});

window.WebChat.renderWebChat({
    directLine: window.WebChat.createDirectLine({ secret: token }),
    store
    }, 
    document.getElementById('webchat'));

[...]
mdrichardson
  • 7,141
  • 1
  • 7
  • 21
  • Thank you so much for the answer, it is working. The 2nd point is a follow up i wanted to ask as well. If the conversation id is new everytime are you keeping track of it or storing it as well with the user to pull the right conversation according to the dates? Again thank you this was really helpful. – Sharat Gangadharan Oct 31 '20 at 07:01
  • @SharatGangadharan ConversationId handling varies a bit by client but for WebChat, the ConversationId changes every time a secret is exchanged for a token, which happens every page refresh if you're passing the secret into `createDirectLine()`. If you want to pull all of a user's conversations, you might consider storing their data differently, perhaps as a map where the userId is the key and value is an array of activities. – mdrichardson Nov 02 '20 at 18:04
  • That makes sense. However the reason i asked for is to use the existing infrastructure that is made automatically by the azure blob transcript. It saves the logs under /{channel}/coversationid/activityid. So I was thinking to store the conversation ids and like you mentioned use the azure storage blob API. I will need the conversation ids to pull the logs from there. I am generating the userids with Guid.NewGuid() using the sample for token which also means the userid will be different. Is that wrong? – Sharat Gangadharan Nov 03 '20 at 09:59
  • Would you suggest storing the activities itself with the unique value separately as a map rather than accessing the activities from defaults log site? – Sharat Gangadharan Nov 03 '20 at 10:02
  • You can only rely on using the existing infrastructure, alone, if you're trying to do things that the existing infra is set up for, which this is not. I'd either, 1) store things differently, or 2) store things the same and then have the bot parse the data to do what you want. Pros and cons to each. – mdrichardson Nov 03 '20 at 18:25