如果枚举,则LUIS ActionBinding Param库不显示

时间:2017-05-11 19:22:34

标签: botframework luis

如果我指定为enum,则它不会显示在对话框中。任何人都可以帮忙指出我是否遗漏了一些东西?

        [LuisActionBinding("CollPay", FriendlyName = "Reminder")]
        public class CollPayAction : BaseLuisAction
        {

            public enum PaymentAmtOptions
            {
                [Terms(new string[] { "Full Payment", "Entire Amount", "Full Due Amount" })]
                FullPayment = 1,

                [Terms(new string[] { "Clubbed Payment", "Combined Payment" })]
                CombinedPayment
            };

            [Required(ErrorMessage = "Are you planning to make a separate payment or combined one?")]
            [LuisActionBindingParam(CustomType = "BOPYMTOPTION", Order = 2)]
            [Template(TemplateUsage.EnumSelectOne, "Are you planning to make a separate payment or combined one? {||}",
                              "How would you like to make the payment - separate for each Invoice(or) clubbed with other pending dues? {||}")]
            public PaymentAmtOptions PaymentAmount { get; set; }


            public override Task<object> FulfillAsync()
            {
                var result = string.Format("Hello! You have reached the CollPay intent");

                return Task.FromResult((object)result);
            }
        }

1 个答案:

答案 0 :(得分:0)

感谢您报告此事,这肯定是一个问题。好消息是已经创建了PR with a patch

PR获得批准后,您必须更新代码:

- 使用更新的库   - 验证枚举值。您将在下面找到代码的外观:

[LuisActionBinding("CollPay", FriendlyName = "Reminder")]
public class CollPayAction : BaseLuisAction
{
    public enum PaymentAmtOptions
    { 
        None = 0,   // default - no option selected
        FullPayment = 1,
        CombinedPayment = 2
    };

    // custom validator for my enum value
    public class ValidPaymentAttribute : ValidationAttribute
    {
        public override bool IsValid(object value)
        {
            return value is PaymentAmtOptions &&  ((PaymentAmtOptions)value) != PaymentAmtOptions.None;
        }
    }

    [ValidPayment(ErrorMessage = "Are you planning to make a separate payment [FullPayment] or combined one [CombinedPayment]?")]
    [LuisActionBindingParam(CustomType = "BOPYMTOPTION", Order = 2)]
    public PaymentAmtOptions PaymentAmount { get; set; }

    public override Task<object> FulfillAsync()
    {
        var result = string.Format("Hello! You have reached the CollPay intent");

        return Task.FromResult((object)result);
    }
}