首页 > 解决方案 > Dialogflow - 关于未使用 NodeJS 显示的实现意图的一个非常基本的问题

问题描述

我花了一个小时搜索所以我放弃了。这个问题有点傻。

我的意图是根据收到的参数做出具体的答复。例如,如果用户说“我因为我的老板而生气”,那么回复将是“老板是最糟糕的”,但如果是关于“妻子”,那么它会说“记住你承诺永远爱她,你的错误”</p>

无论如何,根据我的阅读,我应该使用 app.intent 但我不确定如何使用它

我现在的问题是,这个履行是空的

const functions = require('firebase-functions');
const {
  dialogflow
} = require('actions-on-google');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const app = dialogflow();
 
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 angerEmotionCapture(agent) {
  let conv = agent.conv();
  conv.ask('Hello from the Actions on Google client library!');
  agent.add(conv);
  }
  
  let intentMap = new Map();
  intentMap.set('Default Welcome Intent', welcome);
  intentMap.set('Default Fallback Intent', fallback);
  intentMap.set('angerEmotionCapture', angerEmotionCapture);
  // intentMap.set('your intent name here', googleAssistantHandler);
  agent.handleRequest(intentMap);
});

标签: node.jsdialogflow-es-fulfillment

解决方案


推荐阅读