简体   繁体   中英

Bot Transcript in Azure Bot Composer

I want to retrieve bot transcript, for bots built using composer, for conversation made till that particular point for a user and send it to an API for downstream processing.

Is there a way to retrieve the transcript

This is answered in the following github issue.

Load all of your activities from storage (maybe use the Blob REST API for this)

Pass the activities in to the createStore() method

Pass the store into the renderWebChat() method.

You can enable the bot SDK transcript logger. You'll need to configure the transcript store. Example to use the MemoryTranscriptStore (which is not recommended for production).

public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
    services.AddSingleton<ITranscriptLogger, MemoryTranscriptStore>();
    services.AddSingleton<IMiddleware, TranscriptLoggerMiddleware>();
}

You can also configure Azure blob storage via BlobsTranscriptStore as mentioned here .

To read the transcript, on the OnTurnAsync , inject the ITranscriptLogger transcriptLogger , and then you can use it:

var transcriptStore = transcriptLogger as ITranscriptStore;
var transcript = await transcriptStore?.GetTranscriptActivitiesAsync(turnContext.Activity.ChannelId, turnContext.Activity.Conversation.Id);
if (transcript?.Items != null)
{
    foreach (var iactivity in transcript.Items)
    {
        var activity = iactivity as Activity;
        if (activity != null && activity.Type == "message")
        {
            var message2 = MakeMessage(
                conversationId,
                $"{activity.From.Name}: {activity.Text}");
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM