Giter Club home page Giter Club logo

node-red-contrib-googlehome-actions-v2's Introduction

node-red-contrib-googlehome-actions-v2

Donate

NodeRed nodes to receive and respond Google Action's requests from Google Assistant.

It will create the webhooks you need, without any coding, or, at least, with the fewest lines of code possible. :-)

Right now it is only compatible with DialogFlow applications.

This node is a wrapper around Google's actions-on-google-nodejs client library using the Actions SDK.

It will use the Http Request and Response Nodes, responding at the same URL NodeRed is running.

Other plugins have been using Express to open another port in order to secure NodeRed. Now a days we have enough tech to protect NodeRed. We can use nginx or apache as reverse proxy or even API gateways like Kong to obfuscate the URL's we don't want to be publicly available.

NodeRed must be running with a public address and HTTPS in order to work with Google Home SDKs

The default design of a flow using this plugin will be like the image below:

node-red-contrib-googlehome-actions-v2 architecture

A Controller Node must have a Http Request Node at its input and Http Response Node at its second output. Always.

The Http Request Node must have been configured to receive a POST request at the same path you have configured your fulfillment section of dialog flow's console.

A Controller Node must have all Intent Nodes connected directly to itself. At its first output, always. You must create as much Intent Nodes as you have created at dialog flow's console.

Every Intent Node will have at least one Ask Node. It can have more. The Ask Node have a message property that will define the default answer to the intent. It can be changed later.

At Ask Node output comes the logic you need to answer the question. You can use the msg.req.params to have access to all parameters sent by Google Home and use them to process your answer. You can have access to the conv object at any time using the msg.res.conv property. So, if you want to know if an user is verified you can check the msg.res.conv.user.verification property.

After your logic you must put all answers on the msg.gh_messages. This is an array of messages that will be sent back to google home by the Send Node.

The last node is the Send Node. It will get the msg.gh_messages and finish the conversation.

The msg.gh_messages is an array of messages objects. Each item has its own format depending of the type of the answer.

Some examples below:

[{
    "type": "SimpleResponse",
    "message": "Your Message here"
},{
    "type": "link",
    "message": {
        "url": "https://example.com"    
    }
},{
    "type": "permission",
    "permission": {
        "context": "I need to know your name.",
        "permissions": ["NAME"]
    }
}]

Simple like that. You can use any NodeRed nodes you want to make your logic and assembly your messages.

Enjoy!

Installing

npm install node-red-contrib-googlehome-actions-v2

or add to your package.json

"node-red-contrib-googlehome-actions-v2": "*"

The nodes will appears at NodeRed like this:

NodeRed Google Assistant menu

Advanced

Here we have a flow asking for user permission so we can have access to his name. We are using output context to know to which timeline goes back after permission has been granted or denied.

permission flow

First we have to check if we have or not the name using a Switch Node

check name

If we don't have it, we can use the Template Node to request permissions

request permission

At Dialog Flow's Console you must create an intent to the permission's event. Than, at NodeRed, you have to create the same intent, this intent will be used when the permission has been granted or denied.

At this permission's intent you can use a Switch Node to check if the user name has already been granted or not. It will be present if it was already granted.

permission status

If user granted it, you can check the context to know to which timeline send this request. At permission's event on Dialog Flow's Console you must set an output context. This context will be at input context on NodeRed's received message.

context

Now you can connect the output from this switch to the first one we created. The user's name will be there and you can just say the name using a Template Node

say

That's it... a more complex scenario... no coding... at all!

SSML

Yes, it can be used.

It will be something like this:

[{
    "type": "SimpleResponse",
    "message": "<speak>My name is bond. <break time=\"1000ms\"/>James Bond.</speak>"
}]

Message Node

The Message Node is optional. If you don't want to assembly the response JSON by yourself. Get a look at it.

You can use a fixed value, or, send a property inside msg.payload and this node will assembly the message and add or set it to msg.gh_messages for you.

Donation

And... if this helps you to save time and money. Pay me a coffee. :-)

Donate

node-red-contrib-googlehome-actions-v2's People

Contributors

otaviojr avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

richardschembri

node-red-contrib-googlehome-actions-v2's Issues

How to use the nodes?

Hi there,

could you add/post the JSON for the example flows to get a better understanding of how to use this palette?

Thanx!

Dependency Issue with agent-base <6.0.0 and Node-RED 2.0

Hi,

We've detected that your node has a dependency on an old version of agent-base (<6.0.0) ,
These old versions were patching a core node.js function in a way that could break other libraries - including one we started using in Node-RED 2.0 for the HTTP Request node.
Therefore any users that upgrade to Node-RED 2.0 and have your node installed (or later try to install it) will get errors when using the http-request node.

Could you please take a look at your dependencies and see if you can update the versions so that you are no longer dependent on agent-base before version 6.0.0

Note this could be a module that you are using has a dependency on agent-base so you might need to check for updates to that module, to help you we've attached your nodes dependency tree below

More details on this issue and the warning message that is now displayed in Node-RED 2.0.2 are on the forum at link https://discourse.nodered.org/t/node-red-2-0-2-released/48767

└─ [email protected]
   ├─ [email protected]
   ├─ [email protected]
   │  └─ [email protected]
   └─ [email protected]
      ├─ @types&#x2F;[email protected]
      ├─ [email protected]
      │  └─ [email protected]
      ├─ @types&#x2F;[email protected]
      ├─ @types&#x2F;[email protected]
      │  ├─ @types&#x2F;[email protected]
      │  │  ├─ @types&#x2F;[email protected]
      │  │  │  └─ @types&#x2F;[email protected]
      │  │  └─ @types&#x2F;[email protected]
      │  ├─ @types&#x2F;[email protected]
      │  │  ├─ @types&#x2F;[email protected]
      │  │  └─ @types&#x2F;[email protected]
      │  ├─ @types&#x2F;[email protected]
      │  └─ @types&#x2F;[email protected]
      │     ├─ @types&#x2F;[email protected]
      │     ├─ @types&#x2F;[email protected]
      │     └─ @types&#x2F;[email protected]
      ├─ [email protected]
      │  ├─ [email protected]
      │  │  ├─ [email protected]
      │  │  │  ├─ [email protected]
      │  │  │  └─ [email protected]
      │  │  ├─ [email protected]
      │  │  ├─ [email protected]
      │  │  ├─ [email protected]
      │  │  └─ [email protected]
      │  │     ├─ [email protected]
      │  │     ├─ [email protected]
      │  │     │  └─ [email protected]
      │  │     ├─ [email protected]
      │  │     └─ [email protected]
      │  ├─ [email protected]
      │  │  ├─ [email protected]
      │  │  └─ [email protected]
      │  │     └─ [email protected]
      │  │        └─ [email protected]
      │  ├─ [email protected]
      │  │  ├─ [email protected]
      │  │  │  ├─ [email protected]
      │  │  │  ├─ [email protected]
      │  │  │  └─ [email protected]
      │  │  │     └─ [email protected]
      │  │  └─ [email protected]
      │  ├─ [email protected]
      │  ├─ [email protected]
      │  ├─ [email protected]
      │  │  ├─ [email protected]
      │  │  ├─ [email protected]
      │  │  └─ [email protected]
      │  └─ [email protected]
      │     ├─ [email protected]
      │     └─ [email protected]
      └─ [email protected]
         ├─ [email protected]
         │  ├─ [email protected]
         │  ├─ [email protected]
         │  ├─ [email protected]
         │  ├─ [email protected]
         │  │  ├─ [email protected]
         │  │  └─ [email protected]
         │  │     └─ [email protected]
         │  ├─ [email protected]
         │  ├─ [email protected]
         │  │  ├─ [email protected]
         │  │  └─ [email protected]
         │  │     └─ [email protected]
         │  │        └─ [email protected]
         │  ├─ [email protected]
         │  ├─ [email protected]
         │  │  └─ [email protected]
         │  └─ [email protected]
         └─ [email protected]
            ├─ [email protected]
            ├─ [email protected]
            ├─ [email protected]
            │  └─ [email protected]
            │     ├─ [email protected]
            │     │  ├─ [email protected]
            │     │  ├─ [email protected]
            │     │  └─ [email protected]
            │     │     └─ [email protected]
            │     ├─ [email protected]
            │     └─ [email protected]
            │        ├─ [email protected]
            │        └─ [email protected]
            ├─ [email protected]
            ├─ [email protected]
            └─ [email protected]


Thanks in advance for looking into this.

Sam

PS Sorry for the templated issue but we've got a number of nodes with the issue so I'm automating the issue creation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.