Skip to content

API and back-end for DialogFlow, Google Actions, WebHooks, and Firebase.

Notifications You must be signed in to change notification settings

kitchen-assistant/api

Repository files navigation

api

Required Software Installed

Cloning the git repo

git clone https://github.com/kitchen-assistant/api.git

Installing Firebase

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

  1. Only select the Functions: Configure and deploy Cloud functions item with the spacebar, then hit enter.
  2. Select the kitchen-assist project.
  3. Follow the rest of the prompts.
  4. A /functions folder should be created with a boilerplate index.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

Deploying Fufillment

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.

Running the project locally

Serving the firebase project locally

firebase serve --only functions:dialogflowFirebaseFulfillment

You'll get something like this in the CLI http://localhost:5000/kitchen-assistant-8b1db/us-central1/dialogflowFirebaseFulfillment

Install ngrok

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.

Starting ngrok

  1. Open a new shell and run ngrok http 5000. You'll now have one shell serving firebase, and the other running ngrok.
  2. Copy the https domain you are given, i.e.: https://<something>.ngrok.io
  3. 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.
  4. 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.
  5. When you start executing requests (using Dialogflow), you'll see the logs appear in the console that you served firebase.

Deploying after cloning this repo for the first time

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.

Stack

Work Management and Issue Tracking

Console Portals

You'll need to contact Jesse to add you to these portals.

Communication

Helpful tools

Follow the instructions here to get setup.

About

API and back-end for DialogFlow, Google Actions, WebHooks, and Firebase.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published