Deploy Fulfillment

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:

  1. Download and install Node.js.
  2. Set up and initialize the Firebase CLI. If the following command fails with an EACCES error, you may need to change npm permissions.

    npm install -g firebase-tools
    
  3. Authenticate the firebase tool with your Google account:

    firebase login
    
  4. Associate the firebase tool with your Actions project:

    cd <sample_dir>/functions
    firebase use PROJECT_ID
    
  5. Get the fulfillment dependencies and deploy the fulfillment:

        cd <sample_dir>/functions
        npm install
        firebase deploy --only functions
    

    The deployment takes a few minutes. 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

  6. 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, your API.AI fulfillment setting might look like this screenshot.