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:
Start the project directory where you saved your Actions project. You'll be asked to select which Firebase CLI features you want to setup for your Actions project. Choose
Functionsand other features you might want to use, like Firestore, then press Enter to confirm and continue:
cd <cloud_function_dir> firebase init
Associate the firebase tool with your Actions project by selecting it using the arrow keys to navigate the projects list:
After choosing the project, the firebase tool will start the Functions setup asking you what language you want to use. Select using the arrow keys and press Enter to continue.
=== Functions Setup
Choose if you want to use ESLint to catch probable bugs and enforce style typing Y or N:
? Do you want to use ESLint to catch probable bugs and enforce style? (Y/n)
Get the project dependencies by typing Y to the prompt:
? Do you want to install dependencies with npm now? (Y/n)
Once the setup is completed, you'll see an output similar to the following:
✔ Firebase initialization complete!
Install the actions-on-google dependency
cd <cloud_function_dir>/functions npm install actions-on-google
Get the fulfillment dependencies and deploy the fulfillment function:
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 Dialogflow.
✔ 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 the Dialogflow Console, click Fulfillment, move the ENABLED slider to the right, and enter the Function URL in the URL field. For example, your Dialogflow fulfillment setting might look like this screenshot.