首页 > 解决方案 > 如何从 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'
                }
            ],

    })
}

标签: bots

解决方案


推荐阅读