我的 Dialogflow 聊天机器人拒绝部署 JavaScript 实现代码
My Dialogflow chatbot refuses to deploy JavaScript fulfillment code
Dialogflow 和 Google Cloud Console 拒绝发布我在内联编辑器上创建的实现代码。
这是我的 index.js 文件中的代码片段:
'use strict';
const functions = require('firebase-functions');
const {google} = require('googleapis');
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 Weather(agent) {
const state = agent.parameters['geo-state-us'];
const city = agent.parameters['geo-city-us'];
agent.add(`The weather in ${city}, ${state} is fine and mild.`);
}
let intentMap = new Map();
intentMap.set('AskCity', Weather);
agent.handleRequest(intentMap);
});
function welcome(agent) {
agent.add(`Welcome to my agent!`);
}
function fallback(agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
// // Uncomment and edit to make your own intent handler
// // uncomment `intentMap.set('your intent name here', yourFunctionHandler);`
// // below to get this function to be run when a Dialogflow intent is matched
// function yourFunctionHandler(agent) {
// agent.add(`This message is from Dialogflow's Cloud Functions for Firebase editor!`);
// agent.add(new Card({
// title: `Title: this is a card title`,
// imageUrl: 'https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png',
// text: `This is the body text of a card. You can even use line\n breaks and emoji! `,
// buttonText: 'This is a button',
// buttonUrl: 'https://assistant.google.com/'
// })
// );
// agent.add(new Suggestion(`Quick Reply`));
// agent.add(new Suggestion(`Suggestion`));
// agent.setContext({ name: 'weather', lifespan: 2, parameters: { city: 'Rome' }});
// }
// // Uncomment and edit to make your own Google Assistant intent handler
// // uncomment `intentMap.set('your intent name here', googleAssistantHandler);`
// // below to get this function to be run when a Dialogflow intent is matched
// function googleAssistantHandler(agent) {
// let conv = agent.conv(); // Get Actions on Google library conv instance
// conv.ask('Hello from the Actions on Google client library!') // Use Actions on Google library
// agent.add(conv); // Add Actions on Google library responses to your agent's response
// }
// // See https://github.com/dialogflow/fulfillment-actions-library-nodejs
// // for a complete Dialogflow fulfillment library Actions on Google client library v2 integration sample
// 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);
// intentMap.set('your intent name here', yourFunctionHandler);
// intentMap.set('your intent name here', googleAssistantHandler);
agent.handleRequest(intentMap);
});
这是我的 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": "10"
},
"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"
}
}
每当我编辑代码并尝试部署它时,它都会显示“云函数部署期间发生错误”。当我试图下载它时,它说:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Details>No such object: gcf-sources-647212949737-us-central1/dialogflowFirebaseFulfillment-37ed71f1-69e0-4830-8ada-26d947fa10b3/version-10/function-source.zip</Details>
</Error>
我不明白为什么,我试了很多次想弄清楚如何在 Google Cloud Console 上编辑它,但似乎没有指南知道如何解决这个问题。
更新:在尝试将更多必要的更新安装到 JavaScript 实现代码以便能够 运行 其他功能和命令后,Dialogflow 仍然拒绝部署代码。
更新:我尝试使用 Webhook 从 Firebase 集成 Dialogflow。 Firebase 拒绝部署代码,甚至不会以不同的名称和配置发布新文件。也许它与帐单问题有关,但我没有删除我的任何帐单信息。
更新:禁用账单信息,试图强制 Firebase 和 Google Cloud 重新初始化账单。仍然拒绝部署代码。
更新:到目前为止,我对部署代码的前景似乎很绝望。我无法让 Dialogflow、Firebase 和 Google Cloud Console 部署允许我操作我尝试创建的机器人的代码。
更新:因为我无法部署代码,所以我无法执行我正在尝试实现的新功能。它们对于机器人的新功能是必需的,并且由于我无法部署实现代码,因此无法使用和制作该新功能。
更新:无知的我没有意识到部分问题是执行点。它不是从函数 diagflowFirebaseFulfillment 执行的,因此拒绝部署,因为它没有检测到代码中的可执行函数。通过删除代码并创建一个全新的执行文件解决了问题。
感谢所有帮助我解决此问题的人!
这可能会对您 类似的问题有所帮助。
Adding a hint for the next soul running into this problem. It seems to be caused by missing/inaccessible file in the restore/rollback process.
I was successfully removing the problem by simply:
- Deleting my functions using the web firebase console.
- Deploying normally again
>firebase deploy
Dialogflow 和 Google Cloud Console 拒绝发布我在内联编辑器上创建的实现代码。
这是我的 index.js 文件中的代码片段:
'use strict';
const functions = require('firebase-functions');
const {google} = require('googleapis');
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 Weather(agent) {
const state = agent.parameters['geo-state-us'];
const city = agent.parameters['geo-city-us'];
agent.add(`The weather in ${city}, ${state} is fine and mild.`);
}
let intentMap = new Map();
intentMap.set('AskCity', Weather);
agent.handleRequest(intentMap);
});
function welcome(agent) {
agent.add(`Welcome to my agent!`);
}
function fallback(agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
// // Uncomment and edit to make your own intent handler
// // uncomment `intentMap.set('your intent name here', yourFunctionHandler);`
// // below to get this function to be run when a Dialogflow intent is matched
// function yourFunctionHandler(agent) {
// agent.add(`This message is from Dialogflow's Cloud Functions for Firebase editor!`);
// agent.add(new Card({
// title: `Title: this is a card title`,
// imageUrl: 'https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png',
// text: `This is the body text of a card. You can even use line\n breaks and emoji! `,
// buttonText: 'This is a button',
// buttonUrl: 'https://assistant.google.com/'
// })
// );
// agent.add(new Suggestion(`Quick Reply`));
// agent.add(new Suggestion(`Suggestion`));
// agent.setContext({ name: 'weather', lifespan: 2, parameters: { city: 'Rome' }});
// }
// // Uncomment and edit to make your own Google Assistant intent handler
// // uncomment `intentMap.set('your intent name here', googleAssistantHandler);`
// // below to get this function to be run when a Dialogflow intent is matched
// function googleAssistantHandler(agent) {
// let conv = agent.conv(); // Get Actions on Google library conv instance
// conv.ask('Hello from the Actions on Google client library!') // Use Actions on Google library
// agent.add(conv); // Add Actions on Google library responses to your agent's response
// }
// // See https://github.com/dialogflow/fulfillment-actions-library-nodejs
// // for a complete Dialogflow fulfillment library Actions on Google client library v2 integration sample
// 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);
// intentMap.set('your intent name here', yourFunctionHandler);
// intentMap.set('your intent name here', googleAssistantHandler);
agent.handleRequest(intentMap);
});
这是我的 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": "10"
},
"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"
}
}
每当我编辑代码并尝试部署它时,它都会显示“云函数部署期间发生错误”。当我试图下载它时,它说:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Details>No such object: gcf-sources-647212949737-us-central1/dialogflowFirebaseFulfillment-37ed71f1-69e0-4830-8ada-26d947fa10b3/version-10/function-source.zip</Details>
</Error>
我不明白为什么,我试了很多次想弄清楚如何在 Google Cloud Console 上编辑它,但似乎没有指南知道如何解决这个问题。
更新:在尝试将更多必要的更新安装到 JavaScript 实现代码以便能够 运行 其他功能和命令后,Dialogflow 仍然拒绝部署代码。
更新:我尝试使用 Webhook 从 Firebase 集成 Dialogflow。 Firebase 拒绝部署代码,甚至不会以不同的名称和配置发布新文件。也许它与帐单问题有关,但我没有删除我的任何帐单信息。
更新:禁用账单信息,试图强制 Firebase 和 Google Cloud 重新初始化账单。仍然拒绝部署代码。
更新:到目前为止,我对部署代码的前景似乎很绝望。我无法让 Dialogflow、Firebase 和 Google Cloud Console 部署允许我操作我尝试创建的机器人的代码。
更新:因为我无法部署代码,所以我无法执行我正在尝试实现的新功能。它们对于机器人的新功能是必需的,并且由于我无法部署实现代码,因此无法使用和制作该新功能。
更新:无知的我没有意识到部分问题是执行点。它不是从函数 diagflowFirebaseFulfillment 执行的,因此拒绝部署,因为它没有检测到代码中的可执行函数。通过删除代码并创建一个全新的执行文件解决了问题。
感谢所有帮助我解决此问题的人!
这可能会对您
Adding a hint for the next soul running into this problem. It seems to be caused by missing/inaccessible file in the restore/rollback process.
I was successfully removing the problem by simply:
- Deleting my functions using the web firebase console.
- Deploying normally again
>firebase deploy