gpt4 book ai didi

javascript - 我的 Dialogflow 聊天机器人拒绝部署 JavaScript 实现代码

转载 作者:行者123 更新时间:2023-12-03 18:48:45 25 4
gpt4 key购买 nike

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"
}
}

每当我编辑代码并尝试部署它时,它都会显示“在 Cloud Functions 部署期间发生错误”。当我尝试下载它时,它说:

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 仍然拒绝部署代码。
更新:我试图让 Dialogflow 使用 webhook 从 Firebase 集成。 Firebase 拒绝部署代码,甚至不会以不同的名称和配置发布新文件。也许这与计费问题有关,尽管我没有删除任何计费信息。
更新:已禁用计费信息,试图强制 Firebase 和 Google Cloud 重新初始化计费。仍然拒绝部署代码。
更新:截至目前,我部署代码的前景似乎很绝望。我无法让 Dialogflow、Firebase 和 Google Cloud Console 部署允许我操纵我正在尝试制作的机器人的代码。
更新:由于我无法部署代码,我无法执行我正在尝试实现的新功能。它们对于机器人的新功能是必需的,而且由于我无法部署实现代码,因此无法使用和制作新功能。
更新:我无知的自己没有意识到问题的一部分是执行点。它没有从函数 dialgflowFirebaseFulfillment 执行,因此拒绝部署,因为它没有检测到代码中的可执行函数。通过删除代码并创建一个全新的履行文件解决了问题。
感谢所有帮助我解决此问题的人!

最佳答案

这可能会对您有所帮助 markussvensson`s answer在一个类似的问题上。

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:

  1. Deleting my functions using the web firebase console.
  2. Deploying normally again >firebase deploy

关于javascript - 我的 Dialogflow 聊天机器人拒绝部署 JavaScript 实现代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67307223/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com