Javascript 未将数据从bot emulator获取到blob存储中?

Javascript 未将数据从bot emulator获取到blob存储中?,javascript,c#,botframework,azure-storage-blobs,direct-line-botframework,Javascript,C#,Botframework,Azure Storage Blobs,Direct Line Botframework,我在FrameworkV4中使用c#制作了一个bot。我想将bot中的对话保存到 blob商店。我已经在azure上的存储中创建了一个容器。我使用了相同的连接字符串 有了Microsoft framework提供的示例,对话就结束了 我的姓名和年龄等信息。但当我将它与我的机器人一起使用时,一个文件被创建完毕 blob没有任何对话数据。请帮我解决这个问题。 这是我正在处理的文件 {"$type":"System.Collections.Concurrent.ConcurrentDictionary

我在FrameworkV4中使用c#制作了一个bot。我想将bot中的对话保存到 blob商店。我已经在azure上的存储中创建了一个容器。我使用了相同的连接字符串 有了Microsoft framework提供的示例,对话就结束了 我的姓名和年龄等信息。但当我将它与我的机器人一起使用时,一个文件被创建完毕 blob没有任何对话数据。请帮我解决这个问题。 这是我正在处理的文件

{"$type":"System.Collections.Concurrent.ConcurrentDictionary`2[[System.String, 
System.Private.CoreLib],[System.Object, System.Private.CoreLib]], 
System.Collections.Concurrent","DialogState": 
{"$type":"Microsoft.Bot.Builder.Dialogs.DialogState, 
Microsoft.Bot.Builder.Dialogs","dialogStack": 
{"$type":"System.Collections.Generic.List`1[[Microsoft.Bot.Builder.Dialogs.DialogInstance, 
Microsoft.Bot.Builder.Dialogs]], System.Private.CoreLib","$values":[]}}}

用户消息应该是
$values
,就像

"$values":["a boy","two boys","3 boys"]
请确保已将用户消息保存到存储器中

await _myStorage.WriteAsync(changes, cancellationToken);
ActivityHandler如下所示:

using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Schema;
using Microsoft.Bot.Builder.Azure;
using System.Linq;

namespace Microsoft.BotBuilderSamples.Bots
{
    public class EchoBot : ActivityHandler
    {
        private static readonly AzureBlobStorage _myStorage = new AzureBlobStorage("XXX", "mybotuserlogs");
        // Create local Memory Storage.
        //private static readonly MemoryStorage _myStorage = new MemoryStorage();

        // Create cancellation token (used by Async Write operation).
        public CancellationToken cancellationToken { get; private set; }

        // Class for storing a log of utterances (text of messages) as a list.
        public class UtteranceLog : IStoreItem
        {
            // A list of things that users have said to the bot
            public List<string> UtteranceList { get; } = new List<string>();

            // The number of conversational turns that have occurred        
            public int TurnNumber { get; set; } = 0;

            // Create concurrency control where this is used.
            public string ETag { get; set; } = "*";
        }

        // Echo back user input.
        protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            // preserve user input.
            var utterance = turnContext.Activity.Text;
            // make empty local logitems list.
            UtteranceLog logItems = null;

            // see if there are previous messages saved in storage.
            try
            {
                string[] utteranceList = { "UtteranceLog" };
                logItems = _myStorage.ReadAsync<UtteranceLog>(utteranceList).Result?.FirstOrDefault().Value;
            }
            catch
            {
                // Inform the user an error occured.
                await turnContext.SendActivityAsync("Sorry, something went wrong reading your stored messages!");
            }

            // If no stored messages were found, create and store a new entry.
            if (logItems is null)
            {
                // add the current utterance to a new object.
                logItems = new UtteranceLog();
                logItems.UtteranceList.Add(utterance);
                // set initial turn counter to 1.
                logItems.TurnNumber++;

                // Show user new user message.
                await turnContext.SendActivityAsync($"{logItems.TurnNumber}: The list is now: {string.Join(", ", logItems.UtteranceList)}");

                // Create Dictionary object to hold received user messages.
                var changes = new Dictionary<string, object>();
                {
                    changes.Add("UtteranceLog", logItems);
                }
                try
                {
                    // Save the user message to your Storage.
                    await _myStorage.WriteAsync(changes, cancellationToken);
                }
                catch
                {
                    // Inform the user an error occured.
                    await turnContext.SendActivityAsync("Sorry, something went wrong storing your message!");
                }
            }
            // Else, our Storage already contained saved user messages, add new one to the list.
            else
            {
                // add new message to list of messages to display.
                logItems.UtteranceList.Add(utterance);
                // increment turn counter.
                logItems.TurnNumber++;

                // show user new list of saved messages.
                await turnContext.SendActivityAsync($"{logItems.TurnNumber}: The list is now: {string.Join(", ", logItems.UtteranceList)}");

                // Create Dictionary object to hold new list of messages.
                var changes = new Dictionary<string, object>();
                {
                    changes.Add("UtteranceLog", logItems);
                };

                try
                {
                    // Save new list to your Storage.
                    await _myStorage.WriteAsync(changes, cancellationToken);
                }
                catch
                {
                    // Inform the user an error occured.
                    await turnContext.SendActivityAsync("Sorry, something went wrong storing your message!");
                }
            }

        }
    }
}
使用System.Collections.Generic;
使用系统线程;
使用System.Threading.Tasks;
使用Microsoft.Bot.Builder;
使用Microsoft.Bot.Schema;
使用Microsoft.Bot.Builder.Azure;
使用System.Linq;
命名空间Microsoft.BotBuilderSamples.Bots
{
公共类EchoBot:ActivityHandler
{
私有静态只读AzureBlobStorage _myStorage=新AzureBlobStorage(“XXX”,“mybotuserlogs”);
//创建本地内存存储。
//私有静态只读MemoryStorage _myStorage=new MemoryStorage();
//创建取消令牌(由异步写入操作使用)。
public CancellationToken CancellationToken{get;private set;}
//类,用于将话语日志(消息文本)存储为列表。
公共类话语日志:IStoreItem
{
//用户对机器人说的话的列表
公共列表语句列表{get;}=new List();
//已发生的会话回合数
公共整数整数{get;set;}=0;
//在使用它的地方创建并发控制。
公共字符串ETag{get;set;}=“*”;
}
//回显用户输入。
受保护的重写异步任务OnMessageActivityAsync(ITurnContext turnContext,CancellationToken CancellationToken)
{
//保留用户输入。
var话语=turnContext.Activity.Text;
//使本地登录项列表为空。
OuttanceLog logItems=null;
//查看存储器中是否保存了以前的消息。
尝试
{
字符串[]话语列表={“话语日志”};
logItems=\u myStorage.ReadAsync(话语列表).Result?.FirstOrDefault().Value;
}
抓住
{
//通知用户发生错误。
Wait turnContext.SendActivityAsync(“抱歉,读取存储的邮件时出错!”);
}
//如果未找到存储的邮件,请创建并存储新条目。
if(logItems为空)
{
//将当前话语添加到新对象。
logItems=新的话语日志();
logItems.话语列表.Add(话语);
//将初始转弯计数器设置为1。
logItems.TurnNumber++;
//显示用户新用户消息。
wait turnContext.SendActivityAsync($“{logItems.TurnNumber}:列表现在是:{string.Join(“,”,logItems.outtancelist)}”);
//创建Dictionary对象以保存收到的用户消息。
var changes=newdictionary();
{
添加(“话语日志”,登录项);
}
尝试
{
//将用户消息保存到存储器中。
wait_myStorage.WriteAsync(更改、取消令牌);
}
抓住
{
//通知用户发生错误。
Wait turnContext.SendActivityAsync(“对不起,存储邮件时出现了问题!”);
}
}
//否则,我们的存储已包含已保存的用户消息,请将新消息添加到列表中。
其他的
{
//将新消息添加到要显示的消息列表中。
logItems.话语列表.Add(话语);
//递增转弯计数器。
logItems.TurnNumber++;
//向用户显示已保存邮件的新列表。
wait turnContext.SendActivityAsync($“{logItems.TurnNumber}:列表现在是:{string.Join(“,”,logItems.outtancelist)}”);
//创建Dictionary对象以保存新的消息列表。
var changes=newdictionary();
{
添加(“话语日志”,登录项);
};
尝试
{
//将新列表保存到存储器中。
wait_myStorage.WriteAsync(更改、取消令牌);
}
抓住
{
//通知用户发生错误。
Wait turnContext.SendActivityAsync(“对不起,存储邮件时出现了问题!”);
}
}
}
}
}
参考:


我仍然无法将整个对话保存在blob中。只有用户日志保存在blob中。