git clone https://github.com/kitchen-assistant/api.git
This guide is the one I followed. There's also one here.
node --version
--> Ensure you have node installed
npm install -g firebase-tools
firebase --version
--> Check the version
mkdir testing-fufillment
cd testing-fufillment
firebase login
firebase init
- Only select the
Functions: Configure and deploy Cloud functions
item with the spacebar, then hit enter. - Select the
kitchen-assist
project. - Follow the rest of the prompts.
- A
/functions
folder should be created with a boilerplateindex.js
file within it along with some config files.
cd functions
npm install
npm install --save firebase-admin@^5.4.0
--> For connecting to the database
firebase deploy --only functions:dialogflowFirebaseFulfillment
The CLI should print a message to the terminal with the URL of the endpoint where the function will respond and the console.
In our case, they are:
https://console.firebase.google.com/project/kitchen-assistant-8b1db/overview
https://us-central1-kitchen-assistant-8b1db.cloudfunctions.net/dialogflowFirebaseFulfillment
Now go to DialogFlow
--> Fufillment
--> Webhook
--> update the URL to the above endpoint.
Now we just have to run firebase deploy --only functions
from now on.
Note that in our case, we didn't actually get an endpoint through the CLI because we deployed it using the inline editor and continued to use that endpoint.
firebase serve --only functions:dialogflowFirebaseFulfillment
You'll get something like this in the CLI http://localhost:5000/kitchen-assistant-8b1db/us-central1/dialogflowFirebaseFulfillment
You'll need to install ngrok to create a tunnel from the internet into your development machine.
On mac you can run brew cask install ngrok
or download it from here.
- Open a new shell and run
ngrok http 5000
. You'll now have one shell serving firebase, and the other running ngrok. - Copy the https domain you are given, i.e.:
https://<something>.ngrok.io
- Go to
https://<something>.ngrok.io/kitchen-assistant-8b1db/us-central1/dialogflowFirebaseFulfillment
. You'll get something like "Action Error: no matching intent handler for: null". If you aren't getting this, you messed something up. - Copy the
https://<something>.ngrok.io/kitchen-assistant-8b1db/us-central1/dialogflowFirebaseFulfillment
and paste it into the Dialogflow fufillment webhook. You'll have to change this back to the original webhook when you want to use your production cloud functions. - When you start executing requests (using Dialogflow), you'll see the logs appear in the console that you served firebase.
I'm still not sure the best way to do this. When setting up the project, it's probably best for Firebase to generate the /functions
and index.js
.
You should run all the above commands to get a clean install and deployment for Firebase. Then, copy whatever code you need from the git repo to it, then paste it back when you're done. But I don't think that's right.
- Google Assistant / Google Home - Actions on Google
- DialogFlow for Intents and Entities
- Storage - Firebase RealTime Database
- Server - Firebase Cloud Functions
- Language - Javascript / nodejs
You'll need to contact Jesse to add you to these portals.
- DialogFlow Console
- Actions on Google Console
- Firebase Console - Functions
- Firebase Console - Realtime Database
Follow the instructions here to get setup.