gpt4 book ai didi

botframework - 未触发自适应卡片操作

转载 作者:行者123 更新时间:2023-12-04 05:14:01 27 4
gpt4 key购买 nike

我有一个名为“表单搜索”的对话框,它有一个自适应卡片。当我单击提交按钮时,控件不会转到下一个流程,而是以错误结束。但如果使用英雄卡,按钮点击会触发下一个流程。可能是什么问题。

session.message不包含值,也不触发下一个流程。

bot.dialog("/FormSearch",[

function(session,args, next) {

var card = {
contentType: "application/vnd.microsoft.card.adaptive",
content:{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": 2,
"items": [
{
"type": "TextBlock",
"text": "Tell us about yourself",
"weight": "bolder",
"size": "medium"
},
{
"type": "TextBlock",
"text": "Your name",
"wrap": true
},
{
"type": "Input.Text",
"id": "myName",
"placeholder": "Last, First"
},
{
"type": "TextBlock",
"text": "Your email",
"wrap": true
},
{
"type": "Input.Text",
"id": "myEmail",
"placeholder": "youremail@example.com",
"style": "email"
},
{
"type": "TextBlock",
"text": "Phone Number"
},
{
"type": "Input.Text",
"id": "myTel",
"placeholder": "xxx.xxx.xxxx",
"style": "tel"
}
]
},
{
"type": "Column",
"width": 1,
"items": [
{
"type": "Image",
"url": "https://upload.wikimedia.org/wikipedia/commons/b/b2/Diver_Silhouette%2C_Great_Barrier_Reef.jpg",
"size": "auto"
}
]
}
]
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Submit"
}
]
}
}

// var card = new builder.HeroCard(session)
// .title('card title')
// .subtitle('subtitle')
// .images([builder.CardImage.create(session, 'http://oobrien.com/wordpress/wp-content/uploads/2016/07/googlemaps_july2016.jpg')])
// .buttons([
// builder.CardAction.openUrl(session, 'https://www.google.com', "Navigate"),
// builder.CardAction.postBack(session, 'select', "select")
// ]);



var msg = new builder.Message(session).addAttachment(card);
builder.Prompts.text(session, 'Fill in the below form');
session.send(msg);


},

function(session,results) {
console.log('next flow ____________');
if (session.message && session.message.value) {
console.log('A Card Submit Action obj was received');
session.send('form submitted');
}

}


]);

触发错误信息

Error message screenshot

最佳答案

请参阅文档 here关于 botbuilder-webchat 中的自适应卡 repo 。

具体来说:

The data property of the action may be a string or it may be an object. A string is passed back to your bot as a Bot Builder SDK imBack activity, and an object is passed as a postBack activity. Activities with imBack appear in the chat stream as a user-entered reply. The postBack activities are not displayed.

至于您的代码,请尝试将此代码块移动到您的对话框函数中:

    if (session.message && session.message.value) {
console.log('A Card Submit Action obj was received');
session.send('form submitted');
}

还有一个不错的node example here用于处理提交操作。

关于botframework - 未触发自适应卡片操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49632292/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com