Не удалось позвонить через Webhook - PullRequest
0 голосов
/ 12 февраля 2020

Я создал нового агента и включил выполнение для Приветственного намерения по умолчанию, а также включил встроенный редактор, но когда я вызвал мое приветственное намерение в симуляторе, он дает мне ответ по умолчанию вместо ответа выполнения.

Я делаете что-то не так?

это мой код

'use strict';

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

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 welcome(agent) {
    agent.add(`Welcome to my agent!`);
  }

  function fallback(agent) {
    agent.add(`I'm sorry, can you try again?`);
  }


  let intentMap = new Map();
  intentMap.set('Default Welcome Intent', welcome);
  intentMap.set('Default Fallback Intent', fallback);
  agent.handleRequest(intentMap);

});

1 Ответ

0 голосов
/ 20 февраля 2020

Я изменил свой код и теперь он работает

это мой новый код

'use strict'; 
const functions = require('firebase-functions');
const {dialogflow} = require ('actions-on-google');
const {Suggestions} = require ('actions-on-google');
const WELCOME_INTENT = 'Default Welcome Intent';
const FALLBACK_INTENT = 'Default Fallback Intent';

const app = dialogflow();

app.intent(FALLBACK_INTENT, (conv) => {
    conv.ask("Sorry! Could you please repeat that?");
});

app.intent(WELCOME_INTENT, (conv) => {
    conv.ask("Hello!");
    conv.ask("What you would like to do?");    
});

exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);
...