Dialogflow和Google控制台拒绝发布我在内联编辑器上生成的实现代码。
下面是我的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控制台上编辑它,而且似乎没有任何指南知道如何解决这个问题。
更新:在尝试将更多必要的更新安装到JavaScript实现代码以运行其他函数和命令之后,对话框流仍然拒绝部署代码。
更新:我尝试使用web钩子从Firebase获得对话框流。Firebase拒绝部署代码,甚至不会以不同的名称和配置发布新文件。也许这与计费问题有关,尽管我没有删除任何记帐信息。
更新:禁用计费信息,试图强制Firebase和Google重新初始化计费。仍然拒绝部署代码。
更新:到目前为止,我对部署代码的前景似乎相当绝望。我无法使对话框流、Firebase和Google控制台部署允许我操作正在尝试制作的机器人的代码。
更新:由于我不能部署代码,所以无法执行我正在尝试实现的新功能。它们对于机器人的新功能是必要的,而且,由于我无法部署实现代码,这使得无法使用和制作新功能。
更新:我无知的自我没有意识到问题的一部分是执行点。它不是从函数dialgflowFirebaseFulfillment执行的,因此拒绝部署,因为它没有检测到代码中的可执行函数。通过删除代码和创建一个全新的实现文件解决了问题。
感谢那些帮助我解决这个问题的人!
发布于 2021-05-10 08:05:44
这可能会在类似的问题上帮助您从markussvensson`s answer。
添加了一个提示,提示下一个灵魂遇到了这个问题。这似乎是由于还原/回滚过程中缺少/无法访问的文件造成的。
我成功地解决了这个问题,只需:
使用web防火墙console.
>firebase deploy
https://stackoverflow.com/questions/67307223
复制