0

I'm creating an Action for Google Assistant with dialogflow. The tasks in background are handled in javascript in the fulfilment section. I'm a beginner, so I don't want to use my own server here.

However the fulfilment js-file is actually a firebase function. Because I need more than one js file (I want to use a library from github) I have to use another way to edit the files because in the dialogflow fulfilment section there is no availability to add more files. I installed the firebase SDK, used firebase init and choose the existing project to initialize an empty folder on my computer. I thought this might download the existing function created by dialogflow, so I can edit it an push it again. But actually a hello world js was created in the folder, so this was the wrong way.

How can I download the firebase function so can edit it on my pc and push it again with more files?

1 Answers1

2

Two things:

If you want to use a library, you don't need to use "another file". You can just edit the package.json tab using the built-in editor to add the library you need.

enter image description here

However, the built-in editor is really only good for trivial things anyway, so setting up your own Firebase Cloud Function project is a good idea.

It will not download the code for you automaticallly, firebase init just creates a set of stub files. You can certainly just copy and paste the files from the built-in editor to your local copy.

However, there is also a way to download a zip file of the project files. Clicking on the download icon will give you a zip with the files, including a README.md file with detailed instructions.

enter image description here

Once you've downloaded the files, and deployed to Cloud Functions for Firebase directly, you will no longer be using the in-line editor in Dialogflow. Instead, you'll set the Fulfillment URL, located right above the editor.

Details for the name you'll be using are in the README.md file, but in short:

  • You're use firebase deploy to install your code into Firebase
  • When this completes, it will show you a URL endpoint that will execute your code
  • This is the URL you'll use for the Webhook section on the fulfillment page.

enter image description here

Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • Hi, thank you for your answer. I'm still not sure how to upload my code. For example, if I download the code using the button you marked in the second picture I can not upload it again. Now I have three files: `index.js` `package.json` `dummy.js`. How can I upload them to firebase/dialogflow again? – Philipp Niedergesäß Mar 03 '19 at 09:21
  • I've clarified my answer a little. You don't re-upload to the inline editor. I summarize in the answer, but see the README.md file in what you downloaded for details. – Prisoner Mar 03 '19 at 11:54