Ошибка неверного ответа: пустой речевой ответ при создании моего агента - PullRequest
0 голосов
/ 19 мая 2019

Я делал приложение dialogflow, которое связывает пользователя с каждой ссылкой на число, которое говорит пользователь.

Я получил код выполнения google codelab и отредактировал его, чтобы сделать его.

Но когдаЯ пытаюсь использовать Card и другие вещи для создания кликабельных URL-ссылок: «MalformedResponse: не удалось проанализировать ответ Dialogflow в AppResponse из-за пустого речевого ответа».

Я использую Dialogflow InlineEditor для этого.

Попытка app.buildRichResponse, но это также не удается

Это мой код node.js.

'use strict';

// Import the Dialogflow module from the Actions on Google client library.
const {dialogflow} = require('actions-on-google');

// Import the firebase-functions package for deployment.
const functions = require('firebase-functions');

// Instantiate the Dialogflow client.
const app = dialogflow({debug: true});

const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');

// Handle the Dialogflow intent named 'favorite color'.
// The intent collects a parameter named 'color'.
app.intent('getJobs', (conv, {number}) => {
    const jobNum = number;
    // Respond with the user's lucky number and end the conversation.
    if (number == 1) {
      conv.ask(new Card({
           title: `Title: this is a card title`,
           imageUrl: 'https://dialogflow.com/images/api_home_laptop.svg',
           text: `This is the body text of a card.  You can even use line\n  
    breaks and emoji! ?`,
           buttonText: 'This is a button',
           buttonUrl: 'https://docs.dialogflow.com/'
          }));

    } else if (number == 2) {
      conv.close('camera on');
    } else {
      conv.close('unknown number');
    }
});

//Set the DialogflowApp object to handle the HTTPS POST request.
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);

1 Ответ

0 голосов
/ 19 мая 2019

Я думаю, проблема в том, что вы используете только расширенный ответ, когда число равно 1, и это может привести к ошибке «MalformedResponse: Не удалось проанализировать ответ Dialogflow в AppResponse из-за пустого речевого ответа», поскольку помощник не может ответить голосом. Вы не можете использовать богатый ответ без простого ответа.

Также вы пытаетесь использовать библиотеки actions-on-google и dialogflow-fulfillment. Это также может вызвать проблему. Вы можете попробовать:

   function getJobs(agent) {
     agent.add(`This message is from Dialogflow's Cloud Functions for Firebase editor!`);
     agent.add(new Card({
         title: `Title: this is a card title`,
         imageUrl: 'https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png',
         text: `This is the body text of a card.  You can even use line\n  breaks and emoji! ?`,
         buttonText: 'This is a button',
         buttonUrl: 'https://assistant.google.com/'
       })
     ); 
intentMap.set('getJobs', getJobs);

или

const { dialogflow, BasicCard, Image, Button } = require('actions-on-google');
app.intent('getJobs', (conv, {number}) => {
conv.ask('This is simple response...',new BasicCard({
  text: `This is a basic card.`
  subtitle: 'This is a subtitle',
  title: 'Title: this is a title',
  buttons: new Button({
    title: 'This is a button',
    url: 'https://assistant.google.com/',
  }),
  image: new Image({
    url: 'https://example.com/image.png',
    alt: 'Image alternate text',
  }),
  display: 'CROPPED',
}));
});
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...