如何进行聊天机器人对话

时间:2019-01-18 08:16:00

标签: c# botframework azure-bot-service transcription

我正在使用azure bot服务,Bot工作正常。聊天完成后,我需要将整个聊天对话以笔录或形式发送至电子邮件。如何实现呢?

1 个答案:

答案 0 :(得分:1)

Bot Framework Service不保留任何脚本,这是您必须在bot中实现的功能。不过,您很幸运,因为Bot Builder SDK附带了一个中间件appropriately named TranscriptLoggerMiddleware,它将为您完成此任务,并且可以配置您选择的后备存储。

A storage implementation that ships in the box is the AzureBlobTranscriptStore,它将在整个对话过程中附加到一个Blob。但是,如果您想使用另一种存储机制来存储脚本,则可以自己实现ITranscriptLogger(只是一种方法),然后将其传递给中间件。

要设置中间件,请在启动逻辑中执行以下操作:

public void ConfigureServices(IServiceCollection services)
{
    // Load the settings from config however you like
    var myAzureBlobTranscriptSettings = LoadMySettingsFromConfig();

    services.AddBot<MyBot>(options =>
    {
        // Register the middleware
        options.Middleware.Add(
           new TranscriptLogger(
               new AzureBlobTranscriptStore(
                 myAzureBlobTranscriptSettings.ConnectionString,
                 myAzureBlobTranscriptSettings.ContainerName)));
    });
}