Make a google Fact Action with firebase cli

Hello friends!

First of all, I tell if you are beginner then follow this link before reaching here

link:- MAKE YOUR FIRST GOOGLE ACTION FOR GOOGLE ASSISTANT

Before getting start actions development using firebase cli  you need some steps to keep in mind

The following tools must be in your environment:

Familiarity with JavaScript (ES6) is strongly recommended.

We make our first google actions Fact actions. You can find the sample code below

Sample fact action code link:-  Google fact action

Now get started with Firebase CLI

Step 1: Install Firebase command line interface (CLI)

The Firebase Command Line Interface (CLI) will allow you to deploy your Actions project to Cloud Functions.

Tip:- To install the CLI you need to have installed npm which typically comes with Node.js.

To install or upgrade the CLI run the following npm command:

npm -g install firebase-tools

Tip:- Doesn't work? You may need to change npm permissions.

To verify that the CLI has been installed correctly, open a terminal and run:

firebase --version

Tip:- Make sure the version of the Firebase CLI is above 3.5.0 so that it has all the latest features required for Cloud Functions.
If not, run npm install -g firebase-tools to upgrade as shown above.

Authorize the Firebase CLI by running:

firebase login

Step 2: Setup for local development

Before setting up for local development you need to keep in mind some Key terms

Key terms:- 

  • Cloud Functions for Firebase: A service provided by Google that lets you run your webhook code in a managed environment on the cloud. You use the Firebase CLI (command-line interface) tools to deploy your webhook to Google Cloud Functions.

Why develop your Actions locally?

In contrast to using the Dialogflow inline editor, you can use a local machine, which gives you more control over your programming and deployment environment. This provides several advantages:

  • A locally-developed webhook supports a much larger suite of Actions on Google features.
  • You are not restricted to only one webhook implementation file (index.js).
  • Developing in a local environment also lets you follow software engineering best practices, such as using version control, for your Actions project.

Download your base files

Before starting development you need to download required Facts repositories

git clone https://github.com/actions-on-google/dialogflow-facts-about-google-nodejs

Important Steps:-

In order to test the Action that you’ll build for this project, you need to enable the necessary permissions.

  1. Go to the ‘Activity Controls’ page (https://myaccount.google.com/activitycontrols).
  2. Sign in with your Google account, if you have not already done so.
  3. Ensure that the following permissions are enabled:
  • Web & App Activity
  • Device Information
  • Voice & Audio Activity

Step 3: Setup your project and agent

Next, you’ll need to set up the Actions project and the Dialogflow agent for your fact action

If you’ve already completed the MAKE YOUR FIRST GOOGLE ACTION FOR GOOGLE ASSISTANT. 

Then do following

  1. Go directly to the Dialogflow console.
  2. Navigate to Fulfillment.
  3. Disable Inline Editor.
  4. Click Save.

If you’re starting from scratch, do the following:

  1. Open the Actions Console.
  2. Click on Add/import project.
  3. Type in a Project name, like “world facts”. This name is for your own internal reference; later on, you can set an external name for your project.
  4. Click Create Project.
  5. Rather than pick a category, click Skip on the upper-right corner.
  6. Click Build > Actions in the left nav.
  7. Click Add your first Action.
  8. On the Custom intent dialog, click Build to launch the Dialogflow console.
  9. Click Create.
  10. Click the gear icon on the left navigation.
  11. Click Export and Import.
  12. Click Restore From Zip.

Dialogflow

  1. Upload the FactsAboutGoogle.zip file.
  2. Type “RESTORE” and click the Restore button.
  3. Click Done

Step 4: Deploy your fulfillment

Now that your Actions project and Dialogflow agent are ready, do the following to deploy your local index.js file using the Firebase Functions CLI:

firebase use <PROJECT_ID>

for finding project id see the below picture

project id

 

Run the following command in the terminal to install dependencies.

npm install

Run the following command to deploy your webhook to firebase

firebase deploy

Note:- If you see an error message that says “An unexpected error has occurred from the CLI.”, try running the commandfirebase deploy again.

Step 5: Setup the URL in dialogflow

Now you need to update your Dialogflow agent to use your webhook for fulfillment. To do so, follow these steps:

  1. Open the Dialogflow console (you can close the Firebase console if you’d like).
  2. Navigate to Fulfillment on the left navigation.
  3. Enable Webhook.
  4. Paste the URL you copied from the Firebase dashboard if it doesn’t already appear.
  5. Click Save.

Web hook url

 

Note:- You get your webhook url after deploying your code to firebase function sucessfully.

if you finding any problem about this you can follow our video tutorial.

For any help comment , we help you

About

View all posts by

One thought on “Make a google Fact Action with firebase cli

  1. Магические услуги, на сайте вы найдете [url=http://мир-магов.рф]Приворот[/url]
    На портале размещены лучшие и проверенные Маги России.

Leave a Reply

Your email address will not be published. Required fields are marked *