【发布时间】:2021-03-09 14:43:36
【问题描述】:
我正在尝试使用实现(内联编辑器)添加建议芯片的非常基本的代码,但它不起作用。 以下是我尝试使用的代码:
'use strict';
const functions = require('firebase-functions');
const { WebhookClient } = require('dialogflow-fulfillment');
const { Card, Suggestion } = require('dialogflow-fulfillment');
const { Suggestions } = 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 welcome(agent) {
agent.add(new Suggestion(`Quick Reply`));
agent.add(`Welcome to my agent!`);
}
function fallback(agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
function yourFunctionHandler(agent) {
agent.add(`This message is from Dialogflow's Cloud Functions for Firebase editor!`);
//the following suggestion chips are not working
agent.add(new Suggestion(`Quick Reply`));
agent.add(new Suggestion(`Suggestion`));
}
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
intentMap.set('car', yourFunctionHandler);
agent.handleRequest(intentMap);
});
以下是对话流信使的图像:
【问题讨论】:
标签: dialogflow-es dialogflow-es-fulfillment