3

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

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

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

b) 将其作为向表单流公开的字段的值。

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

我对 Bot Framework 很幼稚。在使用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<DocBot> BuildEnquiryForm()
    {
        return new FormBuilder<DocBot>()
            .Message("Welcome to Doc BOT!!!")

            .Field(nameof(Name))
     //       .Field(nameof(Document))

     -- Need Suggestion on receiving documents attachment from the user here 

  .Build();
     }
     }
4

1 回答 1

4

更新

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

此处有一个示例,演示了如何完成此操作。对于表单本身,您需要查看ImagesForm.cs

---------

目前不支持此功能。在浏览完 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。然后,在您的 Form 模型属性中,您将获得附件 url。

于 2017-01-26T12:20:44.487 回答