在 Dialogflow Essentials 中部署我的内联编辑器代码以显示网页
deploying my inline editor code in Dialogflow Essentials to show webpage
我希望我的应用在启动 AoG 时显示网页,但我不知道如何使用我的代码实现这一点。这是我的代码:
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const {dialogflow, HtmlResponse} = require('actions-on-google');
const CANVAS_URL = 'http://www.example.com';
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!`);
agent.add(new Canvas({
url: CANVAS_URL,
}));
}
function fallback(agent) {
agent.add(`Fullfillment_Fallback`);
}
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
agent.handleRequest(intentMap);
});
嘿,您似乎以一种行不通的方式将几个编程库混合在一起。让我们将其简化为仅使用 actions-on-google
。请注意,一些相似的概念有不同的命名方式。
在 actions-on-google
库中,Canvas
元素被命名为 HtmlResponse
。
'use strict';
const functions = require('firebase-functions');
const {dialogflow, HtmlResponse} = require('actions-on-google');
const CANVAS_URL = 'http://www.example.com';
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
const app = dialogflow({debug: true});
app.intent('Default Welcome Intent', conv => {
conv.ask('Welcome to my agent!');
conv.ask(new HtmlResponse({
url: CANVAS_URL,
});
});
app.intent('Default Fallback Intent', conv => {
conv.ask('Fullfillment_Fallback');
});
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);
我希望我的应用在启动 AoG 时显示网页,但我不知道如何使用我的代码实现这一点。这是我的代码:
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const {dialogflow, HtmlResponse} = require('actions-on-google');
const CANVAS_URL = 'http://www.example.com';
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!`);
agent.add(new Canvas({
url: CANVAS_URL,
}));
}
function fallback(agent) {
agent.add(`Fullfillment_Fallback`);
}
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
agent.handleRequest(intentMap);
});
嘿,您似乎以一种行不通的方式将几个编程库混合在一起。让我们将其简化为仅使用 actions-on-google
。请注意,一些相似的概念有不同的命名方式。
在 actions-on-google
库中,Canvas
元素被命名为 HtmlResponse
。
'use strict';
const functions = require('firebase-functions');
const {dialogflow, HtmlResponse} = require('actions-on-google');
const CANVAS_URL = 'http://www.example.com';
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
const app = dialogflow({debug: true});
app.intent('Default Welcome Intent', conv => {
conv.ask('Welcome to my agent!');
conv.ask(new HtmlResponse({
url: CANVAS_URL,
});
});
app.intent('Default Fallback Intent', conv => {
conv.ask('Fullfillment_Fallback');
});
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);