[Deprecated] Google Assistant Relay V2.0 - Google Home Audio Notifications!

image

ASSISTANT RELAY

Version 3 has now been released: [NEEDS UPDATING] Assistant Relay V3.3 Beta

I’ve wanted to get audio notifications on my Google Home for a long time as have a number of people. There are quite a few implementations of this, however they all use the cast feature to cast TTS audio to your speaker.

Back in Autumn/Fall last year, Google announced their broadcast feature for Google Home which lets you send audio notifications to all Google Home devices.

Until recently, there hasn’t been a way to do this, until one of the Node modules I follow was updated to use the new text input feature of the Google Assistant Service API

What is this?

  • This isn’t an extension of your Google Home
  • This isn’t some fancy local API that connects directly to your Google Home
  • This is a Node.js server that uses the Assistant SDK
  • This is basically another Google Home device, but without a microphone and speaker

What can I do with this?

Assistant Relay is a Node.js server that will accept requests, and then process them. These might be broadcast requests, predefined statuses or routines. It accepts text entry and then does something with it.

As an example, open up Google Assistant on your phone and then type broadcast hello world. Your Google Home devices will now announce “hello world”.

There are lots of things you can do such as:

  • Send broadcasts, useful if you want to announce that the back door has been opened
  • Trigger routines through Google Home, useful if you don’t want to setup your Google Home routines again in SmartThings, WebCore, IFTTT or whatever other platform you might use

You can also hook this up to anything you want, it doesn’t have to be SmartThings:

  • Send broadcasts from your phone to Google Home if your phone rings using Tasker
  • Send a predefined movie announcement using WebHooks from Plex

Supported Systems

Assistant Relay relies on the Google Assistant SDK, therefore it only currently supports x64_64 or ARMv7 processors. It should work on the latest Raspberry Pi’s with an ARMv7 chip. Check the below pages for more information


Installation

What you need

  • A device capable of being always on
  • Node.js running on this device
  • A copy of Assistant Relay

I’m not going to run you through how to get Node.js running on your device as there are hundreds of guides out there on how to do this. Beginner's Guide to Installing Node.js on a Raspberry Pi | thisDaveJ

You then need to configure your Assistant Relay so that it works with your Google Account. I’ve put the configuration guide on my Github Repo. Follow that and run the relay. If the relay is running successfully, your Google Home should make an announcement to tell you its running

How To Use

You can now make a call from WebCore, Tasker, IFTTT or anything else. I’ll share some of my Postman examples below:

WebCore


Above is an example of how to call Assistant Relay and pass data to it using variables.

Postman

If you want to test the commands out in Postman first, I’ve updated the collection below:

https://www.getpostman.com/collections/42fe420662d38f74a45e


What’s New?

Sending Requests

There is a new way to send requests. Please see the Github documentation or the screenshots above

JSON Responses

V2 now responds with a JSON object that includes information about your request

Audio Responses

If you use something like cast-api, Sonos or any other network connect speaker, you can now send your Google Assistant audio responses to specific devices. It’s not the same as a broadcast, so it will interrupt whatever is happening but its the best we have at the moment.

In the below example, I am making a request to Assistant to tell me about my day. Assistant Relay saves the audio file and sends a URL to listen to it back in the response.

What you can then do is tell a speaker to play that URL from the response, and it will play the Google Assistant response.


Upgrading from V1

There is no upgrade path as it’s not really somethign required. Just keep your auth files safe, trash your existing install and then start fresh with V2.


Bugs and Requests

Could you use the Github repo to add any bugs or feature requests please. It’s too difficult to track them here:


Updates

  • 12th April
    – V2 released

  • 16th October
    – V2.1.1 released

18 Likes

Use multiple variables or put the command directly into the request

2 Likes

Great thank you! Got it! Everything but the presets. I cant get them to go. Like arrivedhome ant the like.

1 Like

I am unable to get the presets to work. I had them working in V1. Everything else in V2.0 is working great. Can someone direct me to or tell me how to get them working in V2.0. I am using webcore. Thanks in advance!

Dont know why but it just started working as expected.

It doesn’t appear to be working with Ubuntu 16.04 Server.

speaker@0.4.1 install /home/tony/SharesFOC/assistant-relay/node_modules/speaker
node-gyp rebuild

make: Entering directory ‘/home/tony/SharesFOC/assistant-relay/node_modules/speaker/build’
CC(target) Release/obj.target/output/deps/mpg123/src/output/alsa.o
…/deps/mpg123/src/output/alsa.c:19:28: fatal error: alsa/asoundlib.h: No such file or directory
compilation terminated.
deps/mpg123/output.target.mk:116: recipe for target ‘Release/obj.target/output/deps/mpg123/src/output/alsa.o’ failed
make: *** [Release/obj.target/output/deps/mpg123/src/output/alsa.o] Error 1
make: Leaving directory ‘/home/tony/SharesFOC/assistant-relay/node_modules/speaker/build’
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.4.0-134-generic
gyp ERR! command “/usr/bin/node” “/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild”
gyp ERR! cwd /home/tony/SharesFOC/assistant-relay/node_modules/speaker
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN assistant-relay@2.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! speaker@0.4.1 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the speaker@0.4.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-09-14T07_21_07_366Z-debug.log

There must be an issue with that speaker module which is only a dev dependency in the assistant module

Can you try installing with
npm i --production

speaker@0.4.1 install /home/tony/SharesFOC/assistant-relay/node_modules/speaker
node-gyp rebuild

make: Entering directory ‘/home/tony/SharesFOC/assistant-relay/node_modules/speaker/build’
CC(target) Release/obj.target/output/deps/mpg123/src/output/alsa.o
…/deps/mpg123/src/output/alsa.c:19:28: fatal error: alsa/asoundlib.h: No such file or directory
compilation terminated.
deps/mpg123/output.target.mk:116: recipe for target ‘Release/obj.target/output/deps/mpg123/src/output/alsa.o’ failed
make: *** [Release/obj.target/output/deps/mpg123/src/output/alsa.o] Error 1
make: Leaving directory ‘/home/tony/SharesFOC/assistant-relay/node_modules/speaker/build’
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.4.0-134-generic
gyp ERR! command “/usr/bin/node” “/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild”
gyp ERR! cwd /home/tony/SharesFOC/assistant-relay/node_modules/speaker
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN assistant-relay@2.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! speaker@0.4.1 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the speaker@0.4.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Ah sorry, my mistake.
Can you redownload it from github and try again

Sure!
Doing it now

grpc@1.8.0 install /home/tony/SharesFOC/assistant-relay/node_modules/grpc
node-pre-gyp install --fallback-to-build --library=static_library

[grpc] Success: “/home/tony/SharesFOC/assistant-relay/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc/grpc_node.node” is installed via remote
npm WARN assistant-relay@2.0.0 No repository field.

added 382 packages from 264 contributors and audited 910 packages in 9.384s
found 32 vulnerabilities (3 low, 26 moderate, 3 high)
run npm audit fix to fix them, or npm audit for details

And it seems to start with your fixes, get a ANSI graphic Lots of errors though

assistant-relay@2.0.0 start /home/tony/SharesFOC/assistant-relay
node server/app.js

Received command broadcast Assistant Relay is now setup and running

No user specified, using undefined

(node:19008) UnhandledPromiseRejectionWarning: TypeError: Cannot read property ‘start’ of undefined
at Promise (/home/tony/SharesFOC/assistant-relay/server/assistant.js:64:18)
at new Promise ()
at Object.sendTextInput (/home/tony/SharesFOC/assistant-relay/server/assistant.js:57:12)
at /home/tony/SharesFOC/assistant-relay/server/assistant.js:50:14
at /home/tony/SharesFOC/assistant-relay/node_modules/async/dist/async.js:473:16
at replenish (/home/tony/SharesFOC/assistant-relay/node_modules/async/dist/async.js:1006:25)
at /home/tony/SharesFOC/assistant-relay/node_modules/async/dist/async.js:1016:9
at Object.eachOfLimit (/home/tony/SharesFOC/assistant-relay/node_modules/async/dist/async.js:1041:24)
at Promise (/home/tony/SharesFOC/assistant-relay/server/assistant.js:33:13)
at new Promise ()
(node:19008) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:19008) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Also, remember this is a server. I have no way to authenticate with the second step that would open a browser on my machine.

I tried a post. It didn’t work.

Not sure what you mean by this?

The server is command line only. No way to get a browser.

"Now that the Assistant Relay is configured, start the relay with the command npm run start

This should open a web browser asking you to sign in to your Google account. Make sure you use the account linked to you Google Home/Assistant."

It outputs a URL in the console as well. Copy that into any browser and paste the code back into the console

Unfortunately, it didn’t. I posted the error log before it started up.

@ghesp also getting a bit of an error on startup.

root@3f2ec31d1665:/assistant-relay# npm run start
npm info it worked if it ends with ok
npm info using npm@4.2.0
npm info using node@v7.10.1
npm info lifecycle assistant-relay@2.0.0~prestart: assistant-relay@2.0.0
npm info lifecycle assistant-relay@2.0.0~start: assistant-relay@2.0.0

assistant-relay@2.0.0 start /assistant-relay
node server/app.js

/assistant-relay/node_modules/terminal-image/index.js:9
const readFile = util.promisify(fs.readFile);
^

TypeError: util.promisify is not a function
at Object. (/assistant-relay/node_modules/terminal-image/index.js:9:23)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/assistant-relay/server/assistant.js:8:23)
at Module._compile (module.js:571:32)

npm info lifecycle assistant-relay@2.0.0~start: Failed to exec start script
npm ERR! Linux 4.4.0-130-generic
npm ERR! argv “/usr/local/bin/node” “/usr/local/bin/npm” “run” “start”
npm ERR! node v7.10.1
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! assistant-relay@2.0.0 start: node server/app.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the assistant-relay@2.0.0 start script ‘node server/app.js’.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the assistant-relay package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node server/app.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs assistant-relay
npm ERR! Or if that isn’t available, you can get their info via:
npm ERR! npm owner ls assistant-relay
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /root/.npm/_logs/2018-09-14T17_24_45_733Z-debug.log
root@3f2ec31d1665:/assistant-relay#

When attempting to run the app.js I am getting the following:

root@3f2ec31d1665:/assistant-relay# node server/app.js
/assistant-relay/node_modules/terminal-image/index.js:9
const readFile = util.promisify(fs.readFile);
^

TypeError: util.promisify is not a function
at Object. (/assistant-relay/node_modules/terminal-image/index.js:9:23)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/assistant-relay/server/assistant.js:8:23)
at Module._compile (module.js:571:32)
root@3f2ec31d1665:/assistant-relay#

Possibly, I didn’t configure the API properly. What are the return URLs supposed to be for this project?

Do I need to forward a port and make an ‘A’ record for my server? This is a key piece of info left out of the setup instructions.

I fixed it. Didn’t do “Other” for the API key. Got the message “Assistant Relay is Now Set up and Running.”

Next question.

How do make this run at boot? Also, Is there a way to kill the introduction? I reboot this server at late evening times and I don’t want to wake up the whole house.