Bot Framework-为什么Choice持有CardAction,每个角色的作用是什么? [英] Bot Framework- Why Choice hold CardAction, and what is the role of each?

查看:104
本文介绍了Bot Framework-为什么Choice持有CardAction,每个角色的作用是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Bot Framework v4 ,并且尝试使用ChoicePrompt作为菜单.

I use Bot Framework v4, and I try to use ChoicePrompt for the menu.

我正在尝试创建一个Choice对象,并且看到它包含一个CardAction对象.

I'm trying to create a Choice object, and I see that it contains a CardAction object.

因为CardAction具有更多选项,例如valueobject类型而不是string类型,所以我想使用它.

Because CardAction has more options, such as a value that is an object type rather than a string type, I want to use it.

但是,即使我为CardAction value字段分配了一个值,也会出现错误,因为Choice必须在其value中获得一个值,即获得的值最后.

But even if I assign a value to the CardAction value field, I get an error because Choice must get a value in its value, which is the value obtained at the end.

那为什么Choice包含一个CardAction对象?每个人的工作是什么?

So why does the Choice contain a CardAction object? What is everyone's job?

推荐答案

CardAction对象

实际上,没有任何文档将CardActionChoicePrompt一起使用,因为ChoicePrompts并不是真正的意味深长"的用法.有可能,但不是真正首选.

CardAction Object

There isn't really any documentation on using CardAction with a ChoicePrompt because ChoicePrompts aren't really "meant" to be used this way. It's possible, but not really preferred.

此处是CardAction类的参考:

DisplayText
获取或设置(可选)如果单击按钮,则在聊天供稿中显示的文本

DisplayText
Gets or sets (Optional) text to display in the chat feed if the button is clicked

图片
获取或设置图片网址,该网址将显示在按钮上,文字标签旁边

Image
Gets or sets image URL which will appear on the button, next to text label

文本
获取或设置此操作的文本

Text
Gets or sets text for this action

标题
获取或设置按钮上显示的文字说明

Title
Gets or sets text description which appears on the button

类型
获取或设置此按钮实现的操作类型.可能的值包括:"openUrl","imBack","postBack","playAudio","playVideo","showImage","downloadFile","signin","call","payment","messageBack". 有关ActionTypes的更多信息

Type
Gets or sets the type of action implemented by this button. Possible values include: 'openUrl', 'imBack', 'postBack', 'playAudio', 'playVideo', 'showImage', 'downloadFile', 'signin', 'call', 'payment', 'messageBack'. More on ActionTypes

注意:ChoicePrompt需要一个imBack ActivityType,因此使用其他类型可能会有一些奇怪的结果.

Note: ChoicePrompt expects a imBack ActivityType, so using other types can have some odd results.


获取或设置操作的补充参数.此属性的内容取决于ActionType

Value
Gets or sets supplementary parameter for action. Content of this property depends on the ActionType

给出CardAction:

new Choice()
    {
        Action = new CardAction()
        {
            Type = "messageBack",
            Value = "ACTION VALUE",
            Title = "TITLE",
            Text = "TEXT",
        },
        Value = "CARD VALUE",
    });

这将产生:

单击时:

因此,Title是按钮上显示的文本. Text是作为消息发送回机器人的文本.如果CardAction存在于CardAction中,它将作为活动的value发送.

So, Title is the text displayed on the button. Text is the text send back to the bot as a message. If Value is present in the CardAction, it gets sent as the activity's value.

我也看到您也已将此问题提交给GitHub .我将在这里重复答复.

I see that you submitted this question to GitHub, as well. I'll just duplicate the response here.

问题不仅仅在于您不能为空的Choice.Value,还包括当您从CardAction中提取Choice并尝试确定要为Choice显示的文本的最大长度时,ChoiceFactory错误地查看了Choice.Value而不是Choice.Action.Title,而它为空.有关修补程序,请参见 PR .

The issue isn't so much that you can't have a null Choice.Value so much as when extracting Choices from the CardAction and trying to determine the max length of the text to display for the Choice, ChoiceFactory was incorrectly looking at Choice.Value while it's null instead of looking at Choice.Action.Title. See PR for the fix, there.

这篇关于Bot Framework-为什么Choice持有CardAction,每个角色的作用是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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