0

So far I've found plenty of guides online that shows how to set up a NodeJS backend, that Dialogflow can talk to. However, Dialogflow was previously API.AI and all the old guides are basically wrong now.

When I try to do this:

require('actions-on-google').ApiAiAssistant

It will tell me:

Importing the class name ApiAiAssistant is DEPRECATED, use DialogflowApp

But even changing ApiAiAssistant to DialogflowApp won't work. Here's an example of some Action: https://github.com/greenido/bitcoin-info-action/

As you can see, it has not been updated in a long time, nor does the code actually work (even if I import the intents and so on into Dialogflow).

What I basically want: Give Google Home parameters (like turn on TV which would take TV as a parameter) and handle that in my NodeJS backend. How would I do something like that? It can be with or without Dialogflow.

Also, is it even possible to say Hey Google, turn on TV? So far all examples I've seen it like Hey Google, launch MY_ACTION or Hey Google, ask MY_ACTION to INTENT which is slow and annoying.

MortenMoulder
  • 6,138
  • 11
  • 60
  • 116

1 Answers1

0

Got some updated code. Works fine with the DialogflowApp:

const fs = require("fs");
const express = require("express");
const https = require("https");
const bodyParser = require("body-parser");
const Assistant = require('actions-on-google').DialogflowApp;

const app = express();
app.use(bodyParser.json());

const options = {
    cert: fs.readFileSync("./cert.pem"),
    key: fs.readFileSync("./key.pem"),
    ca: fs.readFileSync("./chain.pem")
};

app.post("/google", (req, res) => {
    const assistant = new Assistant({ request: req, response: res });
    let device = assistant.getArgument("device");
    assistant.tell("Turning on " + device);
});

app.listen(5004);
https.createServer(options, app).listen(5005);
MortenMoulder
  • 6,138
  • 11
  • 60
  • 116