Deploy Fulfillment

We'll show you how to set up your environment to deploy to Cloud Functions for Firebase for production hosting.

  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 <cloud_function_dir>/functions
    firebase use PROJECT_ID
    
  5. Get the fulfillment dependencies and deploy the fulfillment:

        cd <cloud_function_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/myprojectname-ab123/overview Function URL (cloudFunctionName): https://us-central1-myprojectname-ab123.cloudfunctions.net/cloudFunctionName
  6. Create an object inside the conversations object to declare your fulfillment in your action package:

    "conversations": {
      "myFulfillmentFunction": {
        "name": "myFulfillmentFunction",
        "url": "(cloudFunctionName): https://us-central1-myprojectname-ab123.cloudfunctions.net/cloudFunctionName"
      }
    }