错误:expected_inputs [0] .input_prompt.rich_initial_prompt:' item [1]'不能为空

时间:2018-05-13 14:22:52

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

我使用下面的代码。我尝试做的是在Dialogflow上选择一个fullfillment参数,然后在响应用户时使用它。这有效,但我没有看到建议,我得到下面的错误(在模拟器中)我做错了什么?

我也遇到了这个错误:

MalformedResponse
expected_inputs[0].input_prompt.rich_initial_prompt: 'item[1]' must not be empty.

这是我的代码:

'use strict';

const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
//const {Card, Suggestion} = require('dialogflow-fulfillment');
const {
  dialogflow,
  BasicCard,
  BrowseCarousel,
  BrowseCarouselItem,
  Button,
  Carousel,
  Image,
  LinkOutSuggestion,
  List,
  MediaObject,
  Suggestions,
  SimpleResponse,
 } = require('actions-on-google');


process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  const agent = new WebhookClient({ request, response });
  console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
  console.log('Dialogflow Request body: ' + JSON.stringify(request.body));


  function emojify(agent) {
    let conv = agent.conv();


    conv.ask("Test response:" + request.body.queryResult.parameters.sentence);
    conv.ask(new Suggestions('The cat likes fish'));


    agent.add(conv);


  }

  // Run the proper function handler based on the matched Dialogflow intent name
  let intentMap = new Map();
  intentMap.set('Emojify', emojify);

  agent.handleRequest(intentMap);
});

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

问题来自你在conv.ask中调用的内容。 我认为你的展示结果是来自

conv.ask(new Suggestions('The cat likes fish'));

试试这样:

conv.ask(new Suggestions(['The cat likes fish']));

因为这是我在我的程序中使用它的方式。 它不是来自这里,而是来自

conv.ask("Test response:" + request.body.queryResult.parameters.sentence);

它不包含您的字符串...尝试打印它。