简体   繁体   English

Azure Bot Composer 中的 Bot Transcript

[英]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.我想检索机器人脚本,用于使用 Composer 构建的机器人,用于在用户特定点之前进行的对话,并将其发送到 API 以进行下游处理。

Is there a way to retrieve the transcript有没有办法找回成绩单

This is answered in the following github issue.这在以下github问题中得到了解答。

Load all of your activities from storage (maybe use the Blob REST API for this)从存储中加载所有活动(可能为此使用 Blob REST API

Pass the activities in to the createStore() method将活动传递给 createStore() 方法

Pass the store into the renderWebChat() method.将 store 传递给 renderWebChat() 方法。

You can enable the bot SDK transcript logger.您可以启用机器人 SDK 转录记录器。 You'll need to configure the transcript store.您需要配置脚本存储。 Example to use the MemoryTranscriptStore (which is not recommended for production).使用MemoryTranscriptStore的示例(不推荐用于生产)。

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 .您还可以通过此处提到的BlobsTranscriptStore配置 Azure blob 存储。

To read the transcript, on the OnTurnAsync , inject the ITranscriptLogger transcriptLogger , and then you can use it:要阅读成绩单,请在OnTurnAsync上注入ITranscriptLogger transcriptLogger ,然后您可以使用它:

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}");
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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