微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

需要提供带有日期时间提示的额外建议以在机器人框架中使用

如何解决需要提供带有日期时间提示的额外建议以在机器人框架中使用

随着日期时间提示,我试图传递额外的建议,但提示对象中的选择不起作用。任何人都可以提出一种方法来传递额外的建议以及日期时间提示

尝试的解决方案:

async flightBookingDate(step) {
    if (destinationProvidedForFlightBooking) {
        step.values.destination = "Delhi";
    } else {
        step.values.destination = step.result;
    }

    if (!step.values.flightBookingDate) {
        await step.context.sendActivity("Below are the suggested date options?")
        var reply = MessageFactory.suggestedActions(['Today','Tomorrow']);
        await step.context.sendActivity(reply);

        let prompData = {
            prompt: "For when you want to book flight?",retryPrompt: "No flights avaliable for today. Please enter different date"
        }

        return await step.prompt(DATETIME_PROMPT,prompData)
    } else {
        return await step.continueDialog()
    }
}

执行下面的bot后是输出

enter image description here

有人可以帮我解决吗?

解决方法

首先要理解的是 Teams does not support suggested actions

建议操作的常见替代方法是卡片。您可以将动作放在 the cards Teams supports 中的任何一个中,但如果您只需要动作而不需要其他功能,那么我建议使用英雄卡,因为它们是最简单的。您可以参考sample 6了解如何使用卡片。创建包含您的卡片的活动的代码可能如下所示:

var reply = MessageFactory.attachment(CardFactory.heroCard(null,null,['Today','Tomorrow']));

如果您想让按钮在 Teams 中显示为卡片,但在模拟器中显示为建议的操作,那么您可以使用 ChoiceFactory.forChannel,但您仍然需要一种方法来防止建议的操作在下一次出现时消失消息被发送。这样做的方法是将建议的操作作为提示的一部分,而不是在提示之前发送的活动。

if (!step.values.flightBookingDate) {
    let promptData = {
        prompt: ChoiceFactory.forChannel(step.context,'Tomorrow'],"For what day do you want to book the flight? Below are the suggested date options:"),retryPrompt: ChoiceFactory.forChannel(step.context,"No flights avaliable for that day. Please enter a different date. Below are the suggested date options:")
    };
    
    return await step.prompt(DATETIME_PROMPT,promptData);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?