Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

Here is a code snippet from my index.js file:

'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:

{
  "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". 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.

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.

Update: I tried to get Dialogflow to integrate from Firebase using a webhook. Firebase refuses to deploy code, will not even publish a new file under a different name and configuration. 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. Still refuses to deploy code.

Update: As of now, my outlook for deploying code seems pretty hopeless. I cannot make Dialogflow, Firebase, and Google Cloud Console deploy the code which allows me to manipulate the bot I am trying to make.

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.

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. 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!

like image 433
Jeff Avatar asked Oct 26 '22 12:10

Jeff


1 Answers

This might help you from markussvensson`s answer on a similar issue.

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
like image 50
crg Avatar answered Oct 29 '22 14:10

crg