在FormFlow(Bot Framework)中显示Datepicker [英] Showing Datepicker in FormFlow (Bot Framework)

查看:116
本文介绍了在FormFlow(Bot Framework)中显示Datepicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的一个bot项目中开发bot框架的FormFlow功能.该漫游器需要从用户那里获取有关日期范围(从和到)的输入.表单流有效,但是漫游器需要在字符串中输入DateTime.为了避免人为错误,我希望它是一个日期选择器(如自适应卡中的那个),而不是用户输入的字符串.

I am working on a FormFlow feature of a bot framework in one of my bot projects. The bot is required to get input from user about the date range (From and To). The form flow works, however the bot requires to enter DateTime in string. To avoid human errors, I would like it to be a Date picker (like the one in Adaptive Cards) instead of string input from user.

我尝试显式设置字段类型,但是由于某些原因它没有起作用.请参见下面的代码.

I tried setting type of field explicitly but it didn't work for some reason. See the code below.

    [Serializable]
    public class Leave
    {
        [Prompt("Select type of leave you want to apply.")]
        public LeaveTypeEnum LeaveType;

        [Prompt("Vacations from date")]
        public DateTime? From;

        [Prompt("To date")]
        public DateTime? To;



        public static IForm<Leave> BuildForm()
        {
            return new FormBuilder<Leave>().Message
            ("Fill in the form.")
                .Field(new FieldReflector<Leave>(nameof(From)).SetType(typeof(DateTime)))
                .Field(nameof(From))
                .Field(nameof(To))
                .Build();
        }
    }

我们可以改为显示日期选择器吗?

Can we show datepicker instead?

推荐答案

简短的回答是否",botframework中没有DatePicker组件.

The short answer is no, there is no DatePicker component in botframework.

例如,您应该能够使用Microsoft的Recognizers-Text GitHub项目通过用户的文本获取日期时间并处理多种格式,例如: https://github.com/Microsoft/Recognizers-Text

You should instead be able to get a datetime by text from your user and handle many formats, by using Microsoft's Recognizers-Text GitHub project for example: https://github.com/Microsoft/Recognizers-Text

它用于解析几种类型的文本输入,DateTime是提供的类型之一.在 NuGet 包中可用.

It is made for parsing text inputs in several types, and DateTime is one of the provided types. It is available in NuGet packages.

这篇关于在FormFlow(Bot Framework)中显示Datepicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆