Microsoft Bot使用FormFlow从用户接收附件

我正在使用FormFlow设计一个Bot,其中一个输入将要求用户附加文件以继续进行。 我可以在下面看到链接地址类似的问题。 https://github.com/Microsoft/BotBuilder/issues/570

链接中提供的解决方案是使用自定义IRecognizer或如下所示

a)将其放入未暴露给FormFlow的私有字段/属性中。

b)将其作为暴露于forms流的字段的值。

c)使用private属性动态生成允许在它们之间进行选择的字段。

我对Bot框架很天真。 是否有任何示例在使用FormFlow从客户接收附件时实现此目的 。

下面是我的代码片段

enter code here [Serializable] public class DocBot { [Prompt("What's your name?")] public string Name { get; set; } [Prompt("Hey {&} , Choose the options below? {||}")] public Service? shaun; [Prompt("Attach the Document required for further processing?")] public string Document { get; set; } -- Need Suggestion on receiving documents attachment from the user here [Prompt("What is your Job Title there?")] public string JobTitle { get; set; } [Prompt("What's the best number to contact you on?")] public string Phone { get; set; } public enum Service { Consultancy, Support, ProjectDelivery, Unknown } public static IForm BuildEnquiryForm() { return new FormBuilder() .Message("Welcome to Doc BOT!!!") .Field(nameof(Name)) // .Field(nameof(Document)) -- Need Suggestion on receiving documents attachment from the user here .Build(); } } 

更新

在https://github.com/Microsoft/BotBuilder/pull/2870中添加了对FormFlow中附件的支持

这里有一个样本 ,演示了如何实现这一目标。 对于表单本身,您需要查看ImagesForm.cs

———

目前不支持此function。 在完成BotBuilder代码之后,我可以提供的唯一解决方法意味着重建BotBuilder库代码,因为您必须在FormDialog中进行一些更新才能获得附件url。

如果你想尝试解决方法(再次,是解决方法,我还没有完全测试这个,这可能有其他含义,我不知道),获取BotBuilder代码,找到FormDialog类,然后替换这两行使用以下代码:

 var message = toBot != null ? (await toBot) : null; var toBotText = message != null ? message.Text : null; var toBotAttachments = message != null ? message.Attachments : null; var stepInput = (toBotAttachments != null && toBotAttachments.Any()) ? toBotAttachments.First().ContentUrl : (toBotText == null) ? "" : toBotText.Trim(); 

此解决方法的作用是检查传入消息是否包含附件。 如果有,则丢弃文本并使用第一个附件的ContentUrl。 然后,在您的表单模型属性中,您将获得附件URL。

Interesting Posts