我正在尝试将我的 VUI 配置为在 Dialogflow 提示时重复一个句子。小背景故事,我正在帮助开发一个老年人社交机器人,所以重复一个句子是一个非常需要的功能。我刚刚开始这个项目,之前负责这个项目的开发人员已经走了,无法联系到,而且我也没有 Node.js 的经验。
我希望为此使用多声部。这些是我到目前为止所做的步骤:
- 创建了一个名为“重复”的意图。
- 为意图添加了训练短语
- 添加了“multivocal.repeat”作为动作
- 为此意图启用 webhook 调用
- 在 Node.js 中添加了 'intentMap.set('Repeat', repeat);' 到我现有的意图地图
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('Game_Rock_Paper_Scissors - Result', game_stone_paper_scissors);
intentMap.set('Game_Rock_Paper_Scissors - Result - yes', game_stone_paper_scissors_again);
intentMap.set('Conversation tree', conversation_tree);
intentMap.set('Question date', question_date);
intentMap.set('Question time', question_time);
intentMap.set('Music', music);
intentMap.set('Repeat', repeat);
接下来,在“Fulfillment”选项卡下,我想在内联编辑器“index.js”选项卡中输入函数,并确保在“package.json”中安装了多声库并且可以使用。到目前为止,我的 package.json 中有一些东西
"name": "dialogflowFirebaseFulfillment",
"description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "8"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"actions-on-google": "^2.2.0",
"firebase-admin": "^5.13.1",
"firebase-functions": "^2.0.2",
"dialogflow": "^0.6.0",
"dialogflow-fulfillment": "^0.5.0"
}
}
那么,如何安装库呢?在 Read.me 中说“您可以使用 npm install --save multivocal 安装它。” 但是我会在哪里安装呢?我是否将其放在 index.js 或 packages.js 中的某个位置?
此外,在此示例中,它显示 index.js 代码为:
const Color = require('./color.js');
Color.init();
const Multivocal = require('multivocal');
exports.webhook = Multivocal.processFirebaseWebhook;
我应该把它添加到我的 index.js 的末尾吗?还是应该将其包装在一个函数中?很抱歉在这方面没有经验,但我希望我能解释清楚。