Header Ads

IOT with Firebase : Home automation Light control using Google Assistant, Dialogflow and Firebase #Part 2

In this post i will finish IOT Home automation using Goggle assistant, Dialogflow and firebase which i started in previous post. Till now we are done with Hardware Setup, Connecting Arduino NodeMcu with Firebase & Setting Up/Configuring Dialogflow agent.
So, let's complete left out part i.e. Configuring Firebase Tools for Webhook and Integrating Google Assistant with Dialogflow.

Code Below Follows the Video to help:

Transcript/Cheat-sheet:

Setting Up Firebase Tools:

  • Install Node.js and npm environment. 
  • Install firebase tools using npm.

npm install -g firebase-tools

  • Start Firebase sdk for firebase functions :

=> Run firebase login to login via browser.
  • Go to firebase project directory and type command  

=> firebase init functions.
  • above command will create directory which includes whole project files here we just need to focus on index.js file .


Code :

var admin = require('firebase-admin'); const functions = require('firebase-functions');
admin.initializeApp(functions.config().firebase);
var database = admin.database();
// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
exports.hello = functions.https.onRequest((request, response) => {
let params = request.body.result.parameters;
database.ref().set(params);
response.send({
speech: "Light controlled successfully"
});
});

  • once done with writing code just need to deploy code to firebase functions. 
firebase deploy



    Integrating Google Assistant with Dialog-flow:

    Now, we are done with creating our chat bot which can control our lights, using firebase functions. Let's integrate our chatbot with google assistant so that we can easily control lights using our android device.

    Tip: Here i will suggest to use account which you are using in android device, so account google account should be same for : dialogflow, firebase, android.

    Let's start integration :
    • Navigate to integrations panel and select Google Assistant
    • In Explicit invocation select Intent you created (Lightcontrol)
    • Leave Implicit invocation blank
    • Now, click on Test button
    • You will be redirected to Actions on google, by default simulator opened
    • Navigate to Invocations tab (3rd from top) and put Display name : Light Control
    • Now do general settings as directed in video tutorial and test your app on simulator.
    So, that's end for IOT with Firebase using Google Assistant, if you face any query feel free to comment out .

     

     


    
    

    15 comments:

    1. Code is not Working!! too...

      ReplyDelete
    2. Is the code given typescript or javascript?

      ReplyDelete
    3. Code is Working, thank you ^^

      ReplyDelete
    4. Great post. Thanks for sharing it. Get the proper home automation courses of the IOT to learn the new technology in the proper way.

      ReplyDelete
    5. how to display humidity data from firebase to google assistant ...

      ReplyDelete
    6. This video is really informative on IOT technology. As, the IOT technology is emerging to provide the Smart home automation services in home to improve security in home.

      ReplyDelete
    7. How to Build an App for the Google Assistant on Android Studio , please help me!

      ReplyDelete
    8. I tried yours Project.
      BUT in actions on google test simulator
      How do I solve the problem as follows?
      Invocation Error
      You cannot use standard Google Assistant features in the Simulator. If you want to try them, use Google Assistant on your phone or other compatible devices.

      ReplyDelete
    9. Thanks for the tips guys. They were all great. I have been having issues with being fat both mentally and physically. Thanks to you guys i have been showing improvements. Do post more. CutTheWood

      ReplyDelete
    10. Error: could not handle the request

      ReplyDelete
    11. I had a power cut and had to re-set everything, but solved this by putting in 3xAAA batteries.
      Would I recommend the lamp? Yes, it works well. £30 is still hefty for an Alarm but I think it's worth it considering how expensive competitors are.
      Complete Security Alarms System

      ReplyDelete
    12. It’s my first time to visit this site & I’m really surprised to see such impressive stuff out there.locksmith Alpharetta

      ReplyDelete

    Powered by Blogger.