IOT also know as Internet of Things is in boom nowday’s and automating IOT devices with a chat bot and google assistant is a next level tech. Nowday’s You can easily purchase a prebuilt IOT home automation products with chat bot and google assistant control on online sites like: Google Home Mini, Echo Dot. Me as a DIY guy don’t like prebuilt stuff’s as they limited to features and not customizable. Till this post we have already come a very long way, We started from simple led control switch program using custom android app and firebase realtime database, till controlling led using google assistant by creating our custom chat bot

Problem Statement

In previous post of IOT with Google Assistant, we have checked how to setup by dialog flow webhook url . Using webhook url we triggered the values in firebase database using  using google assistant. Last post on this topic was created around 2 years before, where diaglowflow supports Api V1 option for webhook integration. But, now there is no option available for configuring API v1 option. So let’s see how to migrate the webhook url code for firebase functions according to API V2.

IOT with Google Assistant Resolution

Check out this video, code below follows the video to help: 

If you like videos like this consider donating $1, or simply turn off AdBlocker. Either helps me to continue making tutorials.

So, by following the above video we can come to problem resolution for API V2 update in dialogflow. Please use the below code and paste it in firebase function project.

const functions = require('firebase-functions');

// // Create and Deploy Your First Cloud Functions
// //
var admin = require('firebase-admin');
var database=admin.database();
exports.helloWorld = functions.https.onRequest(async(request, response) => {
    let params = request.body.queryResult.parameters;
    console.log("params are ", params)
   await database.ref().update(params)
    response.send("Hello from Firebase!");

Once you are done with pasting the code in firebase project, just use firebase deploy command to deploy the firebase function. So now successful deployment you should get the firebase function url in your console.
Here we come to final point to test the flow by pasting the firebase function url in Dialogflow v2 webhook settings.

Categorized in: