C# 使用AwaitableAttachment FormFlow从机器人框架检索文件?

C# 使用AwaitableAttachment FormFlow从机器人框架检索文件?,c#,azure,botframework,bots,C#,Azure,Botframework,Bots,我正在为一家公司建立一个招聘机器人。这个机器人的主要任务是从候选人那里获取信息,包括他的简历,以及通过电子邮件发送的所有信息 我使用FormFlow(basic)而不是对话框,下面是获取文件的代码 [AttachmentContentTypeValidator(ContentType = "pdf")] [Prompt("please, provide us your resume")] public AwaitableAttachment file_CV; [Prompt("Your ema

我正在为一家公司建立一个招聘机器人。这个机器人的主要任务是从候选人那里获取信息,包括他的简历,以及通过电子邮件发送的所有信息

我使用FormFlow(basic)而不是对话框,下面是获取文件的代码

[AttachmentContentTypeValidator(ContentType = "pdf")]
[Prompt("please, provide us your resume")]
public AwaitableAttachment file_CV;

[Prompt("Your email ?")]
public string email;

public static IForm<ProfileForm> BuildForm()
{
    return new FormBuilder<ProfileForm>()
                   .Message("thank you")
                   .Build();
}
[AttachmentContentTypeValidator(ContentType=“pdf”)]
[提示(“请提供您的简历”)]
公共附件文件(简历),;
[提示(“您的电子邮件?”)]
公共字符串电子邮件;
公共静态表单BuildForm()
{
返回新的FormBuilder()
.留言(“谢谢”)
.Build();
}
如果我没有记错,附件文件将在本地存储中转换为blob,但在生产中,我应该如何检索此文件以通过电子邮件将其发送给电子邮件作业公司?可能使用azure存储


谢谢。

正如您在评论中提到的,用户提供的附加pdf文件似乎作为附件存储在频道的blob存储中

如果您希望将用户提供的pdf文件存储在自定义存储中,例如Azure Blob存储,则可以基于
ContentUrl
访问附件,并在验证功能中将其上载到Azure Blob存储

代码片段:

测试结果:


我已经为此创建了一个示例bot,因为它相对来说比较复杂。 重要的代码在。 表单本身保持不变,但是在创建表单时,您需要确保包含onCompletion:

return new FormBuilder<ImagesForm>()
                    .Message("Welcome, please submit all required documents")
                    .OnCompletion(onFormCompleted)
                    .Build();
注意
这在localhost上不起作用,因为附件包含指向http localhost端点的ContentUrl,而电子邮件通道需要https端点。确保您在azure上部署以实际测试此功能。

您提供的信息不足。您应该提供一些代码,至少尝试获取附件,然后返回一个更具体的问题。@sprinter252我确实在最后的一个对象中获取了该文件,其内容URL类似于“”,我可以通过http客户端下载它来破解它,但我无法使用Azure存储资源管理器找到该文件。Bot框架在本地调试中使用Azure Storage Emulator。有几个问题需要澄清,您在Bot框架中使用哪些通道?(directline、facebook、webchat等)您是否计划在一份工作中同时发送多份简历(存储它们,然后一起发送一批),还是希望在提交时通过电子邮件发送到某个地方?@MarkB对于频道,我计划使用directline(更具体地说是webchat),对于第二个问题,正如你提到的,我想在提交申请时通过电子邮件将他们发送给电子邮件公司
return new FormBuilder<ImagesForm>()
                    .Message("Welcome, please submit all required documents")
                    .OnCompletion(onFormCompleted)
                    .Build();
var botAccount = new ChannelAccount(name: $"{ConfigurationManager.AppSettings["BotId"]}", id: $"{ConfigurationManager.AppSettings["BotEmail"]}".ToLower()); //botemail is cast to lower so that it can be recognized as valid
            var userAccount = new ChannelAccount(name: "Name", id: $"{ConfigurationManager.AppSettings["UserEmail"]}");//all of these are additional fields within application settings
            MicrosoftAppCredentials.TrustServiceUrl(@"https://email.botframework.com/", DateTime.MaxValue); //a call to TrustServiceUrl is required to send a proactive message to a channel different from the one the user is actively using.
            var connector = new ConnectorClient(new Uri("https://email.botframework.com/" ));
            var conversationId = await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount);
            IMessageActivity message = Activity.CreateMessageActivity();
            message.From = botAccount;
            message.Recipient = userAccount;
            message.Conversation = new ConversationAccount(id: conversationId.Id);
            message.Text = $"Resume recieved from {state.email.ToString()}"; //the actual body of the email
            message.Locale = "en-Us";
            

            message.Attachments = new List<Attachment>();
            message.Attachments.Add(state.file_CV.Attachment);
            try
            {
                await connector.Conversations.SendToConversationAsync((Activity)message);
            }
            catch (ErrorResponseException e)
            {
                Console.WriteLine("Error: ", e.StackTrace);
            }