The Facts about Google sample comes with fulfillment that returns responses to users when an intent in the API.AI agent is triggered. We'll show you how to deploy fulfillment to Cloud Functions for Firebase. When an intent is triggered, API.AI sends your app's fulfillment a request and the fulfillment sends back a response to present to the user.
To deploy the Facts About Google fulfillment to Cloud Functions for Firebase:
- Download and install Node.js.
Set up and initialize the Firebase CLI. If the following command fails with an
EACCESerror, you may need to change npm permissions.
npm install -g firebase-tools
Authenticate the firebase tool with your Google account:
Associate the firebase tool with your Actions project:
firebase use PROJECT_ID
Get the fulfillment dependencies and deploy the fulfillment:
cd <sample_dir>/functions npm install firebase deploy --only functions
The deployment takes a few minites. Once completed, you'll see output similar to the following. You'll need the Function URL to enter in API.AI.
✔ Deploy complete!
Project Console: https://console.firebase.google.com/project/factsapp-abb1d/overview Function URL (factsAboutGoogle): https://us-central1-factsapp-abb1d.cloudfunctions.net/factsAboutGoogle
In API.AI's left navigation, click Fulfillment, move the ENABLED slider to the right, and enter the Function URL in the URL field. For example, if your project ID is
factsapp-abb1d, your API.AI fulfillment setting might look like this screenshot.