必须设置final_response

时间:2018-08-12 17:37:29

标签: javascript node.js actions-on-google

我正在尝试实现列表响应,这只是示例代码,但不起作用,已启用webhook,部署完成,请查看此代码并为此推荐好的解决方案。我不知道这个问题的确切答案。尝试尝试。错误为

格式错误的响应

必须设置“ final_response”。

:(

'use strict'

const {dialogflow, List ,Image}=require('actions-on-google');
const functions = require('firebase-functions');
//const d=require('date-and-time');
const app=dialogflow({debug : true });
let date = new Date();

app.intent('what is',(conv,{menu})=>{
//conv.ask('This is today menu ');
conv.ask(new List({
      title : "Today's Menu",
      items : {
        'one':{
          synonyms:[
          'show me Chinese',
          'Chinese',
        ],
        title : 'Chinese menu',
        description : 'chow(30/-), manchurian(50/-),hakka chow(80/-)',
        image : new Image({
          url : 'https://image.ibb.co/fBNYT9/image.png',
          alt : 'chinese food',
        }),
      },
      'two' : {
        synonyms:[
        'show me Veg',
        'Veg',
      ],
      title : 'Veg menu',
      description : 'chow(30/-), manchurian(50/-),hakka chow(80/-)',
      image : new Image({
        url : 'https://image.ibb.co/fBNYT9/image.png',
        alt : 'chinese food',
      }),
    },
    'three' : {
      synonyms:[
        'show me non Veg',
        'non Veg',
        ],
    title : 'non Veg menu',
    description : 'fake description',
    image : new Image({
              url : 'https://image.ibb.co/fBNYT9/image.png',
              alt : 'chinese food',
          }),
      },
    },
  }));
});


//response from upper layer.

const SELECTION_KEY_ONE='one',SELECTION_KEY_TWO='two',SELECTION_KEY_THREE='three';



// );

const selected_item_response ={
  [SELECTION_KEY_ONE]: 'You choose to eat chinese',
  [SELECTION_KEY_TWO] : 'Hey Its Veg Time',
  [SELECTION_KEY_THREE] :'NON veg timeeeeee',
}
app.intent('action.intent.OPTION',(conv,params,option)=>{
  let response='you did not selected any option';
  if(option && selected_item_response.hasOwnProperty(option)){
    response=selected_item_response[option];
  }
  conv.close(response);
});
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);

0 个答案:

没有答案