【发布时间】:2020-03-18 00:52:10
【问题描述】:
我正在尝试使用 Microsoft 机器人框架创建一个信使机器人
我正在使用瀑布对话框来创建结构流。
在此,我有多个步骤,在一个特定步骤中,我需要发送一个由四张英雄卡组成的轮播,每张都有按钮。
我使用了 steven 的答案, Handling HeroCards responses In Microsoft Bot Framework v4 for NodeJS
我在机器人模拟器和网络聊天中进行测试时工作正常 但是在 Messenger bot 中测试时会产生错误
谁能帮我纠正这个错误,在此先感谢
async locationStep(step) {
// WaterfallStep always finishes with the end of the Waterfall or with another dialog; here it is a Prompt Dialog.
// Running a prompt here means the next WaterfallStep will be run when the user's response is received.
await this.sendIntroCard(step)
await step.context.sendActivity("How often do you use surface on the move?")
let acard =CardFactory.heroCard(
" ",
[`https://scontent.fmaa1-4.fna.fbcdn.net/v/t1.0-9/89121134_2372258766207358_5255590702309441536_n.jpg?_nc_cat=109&_nc_sid=8024bb&_nc_ohc=1cHak5WO_yoAX-VdtfO&_nc_ht=scontent.fmaa1-4.fna&oh=fd002544bc74bf53ae0185f4c192efe6&oe=5E82E09B`],
[{ type: ActionTypes.PostBack,
title: 'Never',
value: 'Never'}]
);
let bcard =CardFactory.heroCard(
" ",
['https://i.imgur.com/m2DWB7m.jpg'],
[{ type: ActionTypes.PostBack,
title: 'Once in a while',
value: 'Once in a while'}]
);
let ccard =CardFactory.heroCard(
" ",
['https://i.imgur.com/Kwn0FBn.jpg'],
[{ type: ActionTypes.PostBack,
title: 'A few days a week',
value: 'A few days a week'}]
);
let dcard =CardFactory.heroCard(
" ",
['https://i.imgur.com/mAlW0Bv.jpg'],
[{ type: ActionTypes.PostBack,
title: 'Every day',
value: 'Every day'}]
);
await step.context.sendActivity( {attachments:[acard,bcard,ccard,dcard],attachmentLayout: AttachmentLayoutTypes.Carousel
});
return await { status: DialogTurnStatus.waiting };
}
【问题讨论】:
-
产生了什么错误?
-
我发现错误是英雄卡中的title字段为空发送的,有什么方法可以发送没有任何标题
-
标题为什么要加空格?
-
我的回答可以接受吗?
-
凯尔回答得很好,非常感谢
标签: node.js botframework facebook-messenger