bots - 如何从 botpress 中的快速回复中获取有效负载
问题描述
我是 botpress 的新手,并试图用 botpress 制作简单的订单机器人。但不使用信使等只是试图制作简单的问答机器人。在 github 上的可用示例中使用 content.yml 但它给出了错误
[渲染器] 在 /Applications/MAMP/htdocs/botpress-pro-nightly-2018-12-24-darwin-x64/pizza/node_modules/botpress/src/renderers/index.js:163 未定义渲染器(#welcome): 13
index.js
module.exports = bp => {
Object.keys(renderers).forEach(name => {
bp.renderers.register(name, renderers[name])
})
bp.hear(/GET_STARTED|hello|hi|test|hey|holla/i, (event, next) => {
console.log(event);
event.reply('#welcome')
var yes=event.welcome.quick_replies[0].payload;
bp.logger.info('answer:', yes);
})
}
所以我在renderers.js中使用这种类型的代码它可以工作但无法获取回复
module.exports = {
text: data => {
return {text: data.text, typing: !!data.typing}
},
'#welcome': data => ({
typing: true,
text: 'Hey there! Would you like to order?',
quick_replies: [
{
content_type: 'text',
title: 'Yes',
payload: 'Y'
},
{
content_type: 'text',
title: 'No',
payload: 'N'
}
],
}) ,
'#askLocation': data => ({
typing: true,
text: 'Please click this button for me to know where you are!',
quick_replies: [
{
content_type: 'location',
title: 'location',
payload: 'location'
}
],
})
}
解决方案
推荐阅读
- mysql - 数据表 - 从不同的 Laravel 查询创建每一列
- firebase - 为什么firebase性能使用window对象?
- tsql - 为什么(以及如何)对 FROM 表的“隐式”引用导致此查询返回错误结果?
- angular - 如何在 Angular 项目中格式化日期字段
- android - 修复:“应用程序只安装一次,如果我卸载并再次安装,它会给出错误”
- git - 将 GIT 存储库文件导入 TFS,无需任何 GIT 包袱
- php - 使用 FPDI 时使用正确的源 URL 获取“无法打开 pdf”错误
- android - “ignoreKotlinNullability”实际上是做什么的?
- angular - Amcharts4 + Angular 多边形(国家)不出现
- excel - 在 VBA 中使用多个参数调用 Sub