通过node.js进行对话流的Caraousel视图

时间:2019-04-18 11:36:14

标签: carousel dialogflow

我将使用dialogflow,并将dialogflow bot集成到andriod和ios应用程序中,而iam则不会使用google上的操作。但是,如何通过对话框流控制台和iam获取caraousel视图来显示它们并进行iam测试没有得到输出。这是我的基本代码。

 const agent = new WebhookClient({request: req, response: res});
 function welcome(agent) {
    agent.add('Welcome to the LTA Find Bus!');
    agent.add('I can help you to find the suitable bus stop, bus service, and arriving time. Where are you want to go?');
    agent.add(new Suggestion('Bedok'));
     agent.add(new Suggestion('Cancel'));
        }
  function getDestination(agent) {
              // Get parameters from Dialogflow to convert
  const Destination = req.body.queryResult.parameters.hello;;

           let conv=agent.conv();
         conv.ask(`User would like to go to ${Destination}. `);
         conv.ask('Please choose an bus stop:');
         conv.ask(new List({
          title: 'List of Bus Stops',
          items: {
          // Add the first item to the list
          '1': {
           title: 'Opp Our Tampines Hub - 76059',
             },
           // Add the second item to the list
           '2': {
            title: 'Blk 945 - 76111',
            }}}));

            agent.setContext({
               name: 'Destination',
               lifespan: 5,
               parameters:{Destination: Destination}
                `});
               agent.add(conv);}`

});
}
   let intentMap = new Map(); // Map functions to Dialogflow intent 
   names
      intentMap.set('Default Welcome Intent', welcome);
      intentMap.set('Goods', getDestination);
     // intentMap.set('actions.intent.OPTION', getOption);
      agent.handleRequest(intentMap);

我在这里遇到错误,原因是“ TypeError:无法读取null的属性“询问”” 请帮帮我 thnx

0 个答案:

没有答案