简体   繁体   English

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

[英]My Dialogflow chatbot refuses to deploy JavaScript fulfillment code

Dialogflow, and Google Cloud Console, refuses to publish my fulfillment code that I made on the Inline Editor. Dialogflow 和 Google Cloud Console 拒绝发布我在内联编辑器上创建的实现代码。

Here is a code snippet from my index.js file:这是我的 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); });

And here is my package.json file:这是我的 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" } }

Whenever I edit the code, and I try to deploy it, it says "error happened during Cloud Functions deployment".每当我编辑代码并尝试部署它时,它都会显示“在 Cloud Functions 部署期间发生错误”。 When I tried to download it, it said this:当我尝试下载它时,它说:

 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>

I can't figure out why, I have tried many times to figure out how to edit it on Google Cloud Console, and there appear to be no guides that know how to fix this problem.我不知道为什么,我多次尝试弄清楚如何在 Google Cloud Console 上对其进行编辑,并且似乎没有知道如何解决此问题的指南。

Update: Dialogflow still refuses to deploy code after more necessary updates are attempted to be installed to JavaScript fulfillment code to be able to run other functions and commands.更新:在尝试将更多必要更新安装到 JavaScript 实现代码以便能够运行其他功能和命令后,Dialogflow 仍然拒绝部署代码。

Update: I tried to get Dialogflow to integrate from Firebase using a webhook.更新:我试图让 Dialogflow 使用 webhook 从 Firebase 集成。 Firebase refuses to deploy code, will not even publish a new file under a different name and configuration. Firebase 拒绝部署代码,甚至不会以不同的名称和配置发布新文件。 Maybe it has something to do with billing issues, though I did not remove any of my billing information.也许这与计费问题有关,尽管我没有删除任何计费信息。

Update: Disabled billing information, attempted to force Firebase and Google Cloud to reinitialize billing.更新:已禁用计费信息,试图强制 Firebase 和 Google Cloud 重新初始化计费。 Still refuses to deploy code.仍然拒绝部署代码。

Update: As of now, my outlook for deploying code seems pretty hopeless.更新:截至目前,我用于部署代码的 outlook 似乎毫无希望。 I cannot make Dialogflow, Firebase, and Google Cloud Console deploy the code which allows me to manipulate the bot I am trying to make.我无法让 Dialogflow、Firebase 和 Google Cloud Console 部署允许我操纵我正在尝试制作的机器人的代码。

Update: As I cannot deploy code, I cannot do the new functions that I am trying to implement.更新:由于我无法部署代码,我无法执行我正在尝试实现的新功能。 They are necessary for a new function of the bot, and, because I cannot deploy fulfillment code, it has made it impossible to use and make that new function.它们对于机器人的新 function 是必需的,并且由于我无法部署实现代码,因此无法使用和制作新的 function。

Update: My ignorant self didn't realize that part of the problem was the execution point.更新:我无知的自己没有意识到问题的一部分是执行点。 It was not executing from the function dialgflowFirebaseFulfillment and thus refused to deploy because it was not detecting an executable function within the code.它没有从 function dialgflowFirebaseFulfillment 执行,因此拒绝部署,因为它没有在代码中检测到可执行的 function。 Problem was resolved by deleting code and creating a whole new fulfillment file.通过删除代码并创建一个全新的履行文件解决了问题。

Thanks to all those out there that helped me resolve this issue!感谢所有帮助我解决此问题的人!

This might help you from markussvensson`s answer on a similar issue.这可能会帮助您从markussvensson 对类似问题的回答中获得帮助。

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.使用 web firebase 控制台删除我的函数。
  2. Deploying normally again >firebase deploy再次正常>firebase deploy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM