botframework 处理每个用户和对话的附件

botframework handling attachments per user and conversation

在我的机器人中,我想接受来自用户的附件。 我知道如何在 :

中接收它们
 public async Task<Message> Post([FromBody]Message message)
        {        
            if (message.Type == "Message")
            {
                if (message.Attachments.Count > 0)
                {
                    foreach (var afile in message.Attachments)
                    {
                        lstFiles.Add(afile.ContentUrl);
                    }                                  
                }       

我在这里做的是在它们到达 lstFiles 时存储它们,它是 class MessagesController : ApiController 私有的字符串列表,这样我知道我可以拥有这些文件及其 URL

当用户在 Do 事件中回答完问题(我正在使用 FormFlow)时,我将他的输入存储在 Azure 存储中 table

     internal static IDialog<VGMData> MakeRootDialog()
            {         
              return Chain.From(() => FormDialog.FromForm(VEMData.BuildForm))                
                           .Do(async (context, order) =>
                           {
    var completed = await order;                              
    StoreAndSendEmailConfirmations(completed);
    await context.PostAsync("And I am done... ..");
}

我不明白我如何才能访问 .Do 函数中的附件,以便我可以启动下载并随后将用户提交的文件及其对话中的文件存储在 azure blob 中。我似乎只有 'context' 和 'order' 是用户数据回复但没有附件文件。 我可以找到 lstFiles,但我担心它可能包含来自不同同时用户和对话的文件。

提前致谢, 罗马

您可能要考虑将附件列表存储在 PerUserPerConversation 数据包中。通过这种方式,您可以确保您将检索到与参与该对话的用户相关的数据。

Here 是关于机器人如何跟踪状态的文档。