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

IOT with Firebase

Code Below Follows the Video to help:


Setting Up IOT Firebase Tools:

  1. Install Node.js and npm environment.
  2. Install firebase tools using npm.
npm install -g firebase-tools

3. Start Firebase sdk for firebase functions :

=> Run firebase login to login via browser.

4. Go to firebase project directory and type command

=> firebase init functions.

5. 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’);
var database = admin.database();
// // Create and Deploy Your First Cloud Functions
// //
exports.hello = functions.https.onRequest((request, response) => {
let params = request.body.result.parameters;
speech: Light controlled successfully

6. Once done with writing code just need to deploy code to firebase functions.

firebase deploy

Integrating Google Assistant with Dialog-flow in IOT:

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 : dialog flow, firebase, android.

Let’s start integration :
  1. Firstly, Navigate to integrations panel and select Google Assistant
  2. Secondly, In Explicit invocation select Intent you created (Light Control)
  3. Thirdly, Leave Implicit invocation blank
  4. Fourthly, Now, click on Test button
  5. Fifthly, You will be redirected to Actions on google, by default simulator opened
  6. Navigate to Invocations tab (3rd from top) and put Display name : Light Control
  7. 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.