Deploy fulfillment

Now that you've written your fulfillment, you need to deploy it using Firebase Functions with the following steps:

  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. Start the project directory where you saved your Actions project. You'll be asked to select which Firebase CLI features you want to set up for your Actions project. Choose Functions and other features you might want to use, like Firestore, then press Enter to confirm and continue:

    cd <cloud_function_dir>
    firebase init
    
  5. Associate the firebase tool with your Actions project by selecting it using the arrow keys to navigate the projects list:

  6. 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
    A functions directory will be created in your project with a Node.js package pre-configured. Functions can be deployed with firebase deploy. ? What language would you like to use to write Cloud Functions? (Use arrow keys) > JavaScript TypeScript
  7. 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)
  8. 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!
  9. Install the actions-on-google dependency:

    cd <cloud_function_dir>/functions
    npm install actions-on-google
    
  10. 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.

<pre><u>✔  Deploy complete!</u><br/>
<b>Project Console</b>: https://console.firebase.google.com/project/myprojectname-ab123/overview
<b>Function URL</b> (cloudFunctionName): https://us-central1-myprojectname-ab123.cloudfunctions.net/cloudFunctionName
</pre>

Dialogflow

In the Dialogflow Console:

  1. Click Fulfillment in the left menu.
  2. Move the ENABLED slider to the right.
  3. Enter the Function URL in the URL field.

    For example, your Dialogflow fulfillment setting might look like this screenshot:

Inline code editor

As an alternative, you can use the inline editor in Dialogflow. To deploy your code using this method, follow these steps:

  1. Navigate to the Dialogflow console.
  2. Click Fulfillment in the left menu.
  3. Enable the option for Inline Editor.
  4. Paste your fulfillment code into the editor.
  5. Click DEPLOY.