We'll show you how to set up your environment to deploy to Cloud Functions for Firebase for production hosting. However, you can choose any web hosting platform that supports HTTPS requests and responses to host your fulfillment.
- 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:
cd <cloud_function_dir>/functions firebase use PROJECT_ID
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
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.