Alexa Notifications - Override/Reroute Speech Commands

Ask questions about integrating other services (internet and otherwise) and applications with Indigo.
ckeyes888
Posts: 2438
Joined: Thu Nov 26, 2009 2:41 pm
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by ckeyes888 »

James wrote:You may have to install the Xcode Command Line Tools.

I believe this method still works:

http://osxdaily.com/2014/02/12/install- ... -mac-os-x/


Sent from my iPhone using Tapatalk
Thanks. I had installed Xcode some time ago. I’ll try your link to reinstall.
This would be an awesome thing to get working.

edit: Ran the link above and it seemed to install the Xcode tools without issue...but still get the same errors I posted above
when running:

cd ~/Desktop/Alexa && npm install github:Apollon77/alexa-remote.git && node ./send-alexa-command.js

Carl
Last edited by ckeyes888 on Tue Oct 01, 2019 6:38 pm, edited 1 time in total.
ckeyes888
Posts: 2438
Joined: Thu Nov 26, 2009 2:41 pm
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by ckeyes888 »

indigobo wrote:I'm a newb myself, but I did have success with using the above instructions. Did you download Node.js?
Yes, thanks. I was able to get that installed and download and rename the send-alexa-command file.
Just stuck on step 2.

Carl
ckeyes888
Posts: 2438
Joined: Thu Nov 26, 2009 2:41 pm
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by ckeyes888 »

Finally got it installed but am missing how to execute the scripts in Indigo.
Also, I’m hoping it’s possible to send the contents of a variable to speak?
Any help appreciated!

Thanks,

Carl
Attachments
4DD0C250-391C-4EE8-B956-F5EADC346C9B.jpeg
4DD0C250-391C-4EE8-B956-F5EADC346C9B.jpeg (120.37 KiB) Viewed 5364 times
James
Posts: 22
Joined: Tue Aug 16, 2011 6:37 pm

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by James »

The steps I posted above were just to provide an example. The scripts do not integrate at all with Indigo. Although, my original purpose for this thread was to see if I could override Indigo’s speech function in an effort to create such an integration.

I don’t think overriding the function in Python will work, so maybe I’ll come up with another method when I have time.

Right now I’m just setting an Indigo variable with the text I want spoken, and a trigger runs a script when that variable changes to send the command to Alexa (then sets the variable back to empty).
ckeyes888
Posts: 2438
Joined: Thu Nov 26, 2009 2:41 pm
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by ckeyes888 »

James wrote:Right now I’m just setting an Indigo variable with the text I want spoken, and a trigger runs a script when that variable changes to send the command to Alexa (then sets the variable back to empty).
That’s exactly how I’ve been handling announcements in Indigo...without Alexa.
Love to hear how you’ve done it with Alexa...or maybe how you might get it to work in the future.

Thanks,

Carl
User avatar
indigobo
Posts: 22
Joined: Fri Jan 04, 2019 11:45 am
Location: Raleigh, NC

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by indigobo »

James, I can't tell you how much fun I've had with this... Thank you, thank you, thank you!

I do however have a question. Is there a way to send multiple commands at the same time so that a first command would complete before performing the second command? For example, have Alexa read out today's calendar events and she is finished, then start reading out tomorrow's calendar events. I've kind of got this working now but am using two different scripts to accomplish it. The problem (other than me :wink:) is that some days are busier than others so I can't set a specific amount of pause between the commands to make it work out right. On that note, if I had to use a hard pause, can it be placed in your script directly.

Sorry for the questions. Man this would make an awesome plug-in!!

All the best!
ckeyes888
Posts: 2438
Joined: Thu Nov 26, 2009 2:41 pm
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by ckeyes888 »

indigobo wrote:James, ....Man this would make an awesome plug-in!!
+20 on that!

For now maybe share how you’re sending these commands to Alexa?

Thanks,

Carl
jens
Posts: 265
Joined: Sun May 03, 2015 11:45 am
Location: Sweden

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by jens »

Yes please, test message work but I can not get some other spetch:)

//Jens


Skickat från min iPhone med Tapatalk Pro
User avatar
indigobo
Posts: 22
Joined: Fri Jan 04, 2019 11:45 am
Location: Raleigh, NC

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by indigobo »

@Carl I can tell you how I'm doing it, but I have no way of knowing if it is the "correct" way since I have very little coding knowledge. That being said here goes.

Step 1

Follow the directions at the beginning of this thread.

Step 2

Open the send-alexa-command.js file located in the Alexa folder on your Desktop.

Change the part under // Change the sendCommand call below to send a command to one or more of your Alexa devices. to the following:

Code: Select all

sendCommand("speak", 70, "This is a test. Hello World!");
Then save the file. MAKE SURE THAT THE FILE IS SAVED AS PLAIN TEXT NOT RTF!

Step 3

Create a script by simply creating an empty TextEdit document and insert the following:

Code: Select all

#!/bin/bash
cd Desktop/Alexa
node ./send-alexa-command.js
Save the file as test.sh inside the Alexa folder. (MAKE SURE THAT THE FILE IS SAVED AS PLAIN TEXT NOT RTF)

Step 4

In indigo create a new action in Action Groups.
Under Type select Server Actions >> Script and File Actions >> Run Shell Script.
In the popup window delete what's inside the field Full path to file on server.
Locate the test.sh file you just created and drag it on top of the empty Full path to file on server field.

Save the action.

You can then try the action by selecting Execute Actions Only located at the bottom right of the Indigo Home Screen.

The reason I'm doing it this way is because it does things in the background and doesn't require me to open the Terminal app. Initially, I wanted a way to call the node ./send-alexa-command.js directly from within Indigo but couldn't figure out how to do it. Hope this helps, but remember that you get what you pay for :D .
ckeyes888
Posts: 2438
Joined: Thu Nov 26, 2009 2:41 pm
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by ckeyes888 »

Great, thanks. I’ll give it a try

Carl
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by whmoorejr »

I'm stuck on Step2. I am getting an error, but not the same one.

Code: Select all

WHM-Server:~ williammoore$ cd ~/Desktop/Alexa && npm install github:Apollon77/alexa-remote.git && node ./send-alexa-command.js
npm WARN engine [email protected]: wanted: {"node":">=6.0.0"} (current: {"node":"4.8.0","npm":"2.15.11"})
[email protected] ../../node_modules/alexa-remote2
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected])
/Users/williammoore/Desktop/Alexa/send-alexa-command.js:2
let Alexa = require('alexa-remote2');
^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:140:18)
    at node.js:1043:3
Anything to point me in the right direction would be great.
Bill
My Plugin: My People
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by whmoorejr »

whmoorejr wrote:I'm stuck on Step2.
I'm now unstuck. It was a Node.js thing. So I installed the newer version of Node.js, but the old version was still the active one being accessed. When looking up how to force an update or remove and start from scratch, I had to do some sudo command wizardry. That sorta worked..... at least to the point where

Code: Select all

node --version
and

Code: Select all

npm --version
were showing the update.... but when I ran Step 2, it was looking for node in /opt/local/bin/node instead of where it installed at /usr/local/bin/node. Since I couldn't figure out how to tell it to look in the correct place, I just copied node and npm into the opt/local/bin folder. Got the cookie error, provided the German page with my amazon credentials and poof.... all my echo devices announced the test.
Bill
My Plugin: My People
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by whmoorejr »

indigobo wrote:

Code: Select all

#!/bin/bash
cd Desktop/Alexa
node ./send-alexa-command.js
.
had to add "~/" to the script before "Desktop" to work for me. (working like a charm now)

Code: Select all

#!/bin/bash
cd ~/Desktop/Alexa
node ./send-alexa-command.js
or

Code: Select all

#!/bin/bash
cd ~/Desktop/Alexa && node ./send-alexa-command.js
Thank your for all your work on this, I'm really looking forward to implementing this in with my stuff.
Bill
My Plugin: My People
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by whmoorejr »

James wrote: There are actually! Here is a list of commands you can use using my previous example:
  • weather
    traffic
    flashbriefing
    goodmorning
    singasong
    tellstory
    calendarToday
    calendarTomorrow
    calendarNext
    volume*
    deviceStop
    speak*
    notification*
    announcement*
    ssml*
* Requires additional value

There is MUCH more you can do if you are familiar with programming. See the source file for all the functions you can perform:

[
Thank you again for posting all of this and your examples. Do you know of a way to send a string of commands in one shot? weather + ssml + calendarTomorrow?
Bill
My Plugin: My People
ar26pt2
Posts: 25
Joined: Thu Jan 23, 2014 3:52 pm
Contact:

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by ar26pt2 »

This tool seems great and powerful, thank you so much for sharing!

Small caution for n00bs: I was using TextEdit to modify the .js file. It was inserting "smart quotes" in place of standard quotations which messes up the file encoding/reading by node.js creating many errors. Before editing code with textedit, turn off smart quotes, smart dashes and everything else smart and rich in the TextEdit preferences... :roll: :roll:
Thanks again!
aaron
Post Reply

Return to “Integrating Services/Applications”