0

I was trying to deploy function in dialogflow but it shows an error. Code:-

'use strict';
 
const functions = require('firebase-functions');
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 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?`);
  }

 
  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);
});

Error:- Error happened during Cloud Functions Deployment

Can you please tell me how to solve this problem.

Akvo
  • 3
  • 2

1 Answers1

0

I think there is trouble with creating Cloud Functions Environment.

Cloud you please follow these steps below?

  1. Enable Cloud Build API
    Go to your project connected your Dialogflow ES in Google Cloud. ( The way is here. Select gear mark next to agent name in Dialogflow console. At "General" tab you can see "GOOGLE PROJECT". Click the Project ID link then you can move to Google Cloud.)
    Search "Cloud Build API" at the search bar. Move to Cloud Build API page. "Enable" Cloud Build API.
    If the page shows "API Enabled", then this finished.

  2. Redeploy the Cloud Functions.
    At Dialogflow Console, redeploy the source.

I hope this works for you.

Peter
  • 393
  • 1
  • 3
  • 15