Amazon Echo Skill EchoToEventGhost

If you have a question or need help, this is the place to be.

Re: Amazon Echo Skill EchoToEventGhost

Postby m19brandon » Sun Mar 27, 2016 2:28 am

An updated version has been added (v2.1) at post #1. Basic auth is now supported.
m19brandon
Experienced User
 
Posts: 147
Joined: Mon Feb 03, 2014 10:36 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby millsx2 » Thu Mar 31, 2016 5:33 am

I keep getting an error message when trying to get the Lambda Function to work.

{
"errorMessage": "Exception: TypeError: Cannot read property 'application' of undefined"
}

Any ideas? I have copied over the code correctly and added in the correct variables. ID, Port, App_ID.

Any help would be appreciated!
millsx2
 
Posts: 10
Joined: Thu Aug 15, 2013 5:56 am

Re: Amazon Echo Skill EchoToEventGhost

Postby m19brandon » Thu Mar 31, 2016 12:57 pm

@millsx2

Take a look at this thread, the last four post. https://forums.developer.amazon.com/for ... geID=18106

I believe it has to do with your event source. Let me know if this helps.
m19brandon
Experienced User
 
Posts: 147
Joined: Mon Feb 03, 2014 10:36 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby DanRoss » Sat Apr 02, 2016 5:07 am

I haven't had much time to play with my setup but I just noticed you added basic auth support so I had to give it a shot and am happy to say it's working perfectly.

I still have quite a bit to do before I'll say I'm done with my setup (if that's even possible) but this gets me one step closer.

Thanks again for making this.
DanRoss
 
Posts: 18
Joined: Wed Mar 23, 2016 2:15 am

Re: Amazon Echo Skill EchoToEventGhost

Postby m19brandon » Sat Apr 02, 2016 12:28 pm

I have been using the basic auth for about a week now with no issue. The Alexa make a great entry and exit point but I prefer to code in EG.

Voice commands can be a bear to code but when it works it makes life easy.
m19brandon
Experienced User
 
Posts: 147
Joined: Mon Feb 03, 2014 10:36 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby DanRoss » Sat Apr 02, 2016 4:22 pm

m19brandon wrote:I have been using the basic auth for about a week now with no issue. The Alexa make a great entry and exit point but I prefer to code in EG.

Voice commands can be a bear to code but when it works it makes life easy.


I've been playing with the python scripting to run commands based off the words I get from Alexa. For instance when I tell her to set itunes volume to 22 I have a script that looks for the word itunes in the response once it sees that it looks for the command (volume in this case) based on it seeing volume it looks at the numeric value and converts that to a digit to pass along to itunes. It also sends the words back to alexa telling em the itunes volume was set to ##.

I figure if I just look for base word for things like itunes or hue I can use that to direct my scripts in the direction they need to go.

When I said if that's even possible I was referring to the fact that every time I get one small piece done a little light bulb goes off and I start thinking of ten other things I'd like to do. And for every ten things I come up with my wife throws in one or two. In the effort to keep the funding for my projects her suggestions take priority... My project list seems to grow faster than it shrinks.
DanRoss
 
Posts: 18
Joined: Wed Mar 23, 2016 2:15 am

Re: Amazon Echo Skill EchoToEventGhost

Postby guitar82 » Thu Apr 21, 2016 5:36 pm

Ok so first I wanted to thank you for providing this code. I eagerly want to get it working and I think I am hung up on something stupid. I am not sure what I am doing wrong with it. I have the amazon skill communicating with eventghost and the command is coming through. Eventghost is making communication with alexa but I can't seem to get a grasp on the jump to the python script that handles the commands. I thought it should be easy but I am constantly getting errors and at this point getting pretty frustrated. I tried editing your sample from this thread down to something simple and I can't get anywhere with that. Pretty much everything I have tried has resulted in failure at that point.

One of the errors I am getting a lot: In EG I am getting an error of AttributeError: 'Bunch' object has no attribute 'bb_get_intent'

Would anyone mind sharing an example for me so I can try to sort this all out. Also is there any plugins or requirements I need to have besides the barebones eventghost to get everything running properly? Thank you
guitar82
 
Posts: 3
Joined: Thu Apr 21, 2016 5:17 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby millsx2 » Thu Apr 21, 2016 7:48 pm

@ guitar82.

Don't worry about the python script to start. Do you have the webserver plugin installed? Has that been configured correctly in the lamda function. If everything is working correctly and you call your skill in the Echo it should relay that word or phrase to EventGhost.

For example, if I say Alexa tell "Computer" to play cable, it will come through in as an Event EventGhost like EchoToEG.playcable or EchoToEG.play cable

Based on those responses you can trigger scenes or make jump actions.
millsx2
 
Posts: 10
Joined: Thu Aug 15, 2013 5:56 am

Re: Amazon Echo Skill EchoToEventGhost

Postby millsx2 » Fri Apr 22, 2016 1:50 am

Totally forgot I am using a python code to convert the events coming from Alexa.

So initially i recieve this - HTTP.EchoToEG [u'play cable']

Then I created a script that when it receives this HTTP.EchoToEG, I run the following script. eg.TriggerEvent(eg.event.payload[0][0:55],prefix=eg.event.suffix)

EventGhost will then send me EchoToEG.play cable and I use that to trigger my scene.

Probably not the most elegant way but it works for me. Hope that helps.
millsx2
 
Posts: 10
Joined: Thu Aug 15, 2013 5:56 am

Re: Amazon Echo Skill EchoToEventGhost

Postby guitar82 » Fri Apr 22, 2016 2:59 am

Ok, I am getting the data from the echo formatted like that. I was just trying to figure out the script the way it was intended. If I just set it up the way you mean won't that mean I have to say the exact phrase to get the trigger working? I guess I am really confused as to what is the basic core script I would need so I can have specific python commands to my TV or wmc based on keywords and not the exact condition. For some reason if I trim out the example on here to remove the channels and other things I still can't get it working.
guitar82
 
Posts: 3
Joined: Thu Apr 21, 2016 5:17 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby m19brandon » Fri Apr 22, 2016 4:50 pm

I control my house with it and have about 5 root commands with dozens of secondary options like turn on the tv and then changing to the channel to ESPN.

Try something like this. Pseudo code

If eg.event.payload[0] = 'tv' then
TriggerEvent('Turn on TV')
Else if eg.event.payload[0] = 'light' then
If eg.event.payload[2] = 'familyroom' then
TriggerEvent('Turn on the familyroom lights')
m19brandon
Experienced User
 
Posts: 147
Joined: Mon Feb 03, 2014 10:36 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby guitar82 » Fri Apr 22, 2016 7:01 pm

Ok, I can get that working for now, but I would like a more elegant solutions. I am still trying to figure out your code as I am obviously not a programmer nor am I very familiar with eventghost which doesn't help. In the top section you have the following code.
Code: Select all
intent = eg.globals.bb_get_intent
conf = eg.globals.bb_get_conf
entities = eg.globals.bb_get_entities
action = ''
search_query = ''
channel = ''
msg = ''
rtn_msg = ''


I see later that you are querying the entities for channel numbers and other things like that. To do something like that do I need to have another file that this script is reading from? I am trying to figure out how to get it working similarly with windows media center channels, but I can't get the code to run like it is below and I am not sure where I am messing up. What plugins should I have installed and do I need to install python 3 or anything separate from eventghost to get this code working?

Code: Select all
intent = eg.globals.bb_get_intent
conf = eg.globals.bb_get_conf
entities = eg.globals.bb_get_entities
action = ''
search_query = ''
channel = ''
msg = ''
rtn_msg = ''
   channel_num = ''
   if query <> '':
      print 'Searching for channel ' + query
      for channel in eg.globals.family_channel_list:
         if channel[1].lower() == query.lower():
            channel_num = str(channel[0])
            print 'Channel ' + query.lower() + ' is ' + channel_num
   else:
      print 'Cannot search var, string was empty'

   return channel_num

if 'action' in entities:
    if 'value' in entities['action'][0]:
        action = entities['action'][0]['value']
        print 'Action: ' + action
    else:
        msg = msg + '\nAction Not Found'
        print 'Action Not Found'
else:
    msg = msg + '\nAction Not Found'
    print 'Action Not Found'
   
trg = ''

if action == 'off':
    trg = 'eg.plugins.SonyTVNetworkPlugin.PowerOff()'
    rtn_msg = 'turning off the family room tv'
elif action == 'computer':
    trg = 'eg.plugins.SonyTVNetworkPlugin.Hdmi2()'
    rtn_msg = 'setting living room tv to the computer'
elif action == 'reboot':
    trg = 'eg.plugins.System.Reboot(True)'
    rtn_msg = 'rebooting the computer'
   
   
   
else:
    print 'cmd is unknown: ' + action
   
if trg != '':
    eg.globals.ibl1_ttl = eg.globals.ibl1_ttl + ': ' + trg
    eg.globals.ibl1_msg = eg.globals.ibl1_msg + '\nTrigger: ' + trg
    eg.globals.ibl1_msg = eg.globals.ibl1_msg + '\nReturn Msg: ' + rtn_msg
    eg.TriggerEvent(trg)
    print trg
else:
    eg.globals.ibl1_msg = eg.globals.ibl1_msg + '\ncmd is unknown: ' + action
#Done
   
guitar82
 
Posts: 3
Joined: Thu Apr 21, 2016 5:17 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby m19brandon » Fri Apr 22, 2016 10:53 pm

I have an intent engine that I call through REST(link below), it understands language better than I can code. It return a few things.

In sample's case the intent was tv, the action would be change the channel and the channel could be ESPN.

I then use a channel list get the channel number.

This all trigger events that turn everything on and change the channel through a global cache ir blaster.

If you are interested I can say all the code, it a lot.

https://wit.ai/m19brandon/BlackBox

Python 2.x
m19brandon
Experienced User
 
Posts: 147
Joined: Mon Feb 03, 2014 10:36 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby blaher » Fri Jun 24, 2016 4:33 am

This is a simple AWS Lambda node.js script that packages up the Alexa Skills Kit Intent and will post any spoken command to your EventGhost Webserver as an Event with a payload.


Simple for some! My goodness this is hard to fathom.

https://developer.amazon.com/public/sol ... home-skill is a good starting point. It discusses the function and skill creation.

0. Extract the .zip file and make sure your EG Webserver is running.


Does it matter where, eg. plugins folder?

1. Rename "EchoToEG.js" to "index.js" follow the instructions for Creating a Lambda Function for an Alexa Skill, using the "index.js" code rather than the template code.


What runtime do I pick, as pictured? If you just copy the code to replace the 'color game demo', why do you need to rename the file, or is it uploaded? Speaking of which, there's 2 color blueprints, as you can see attached, which one do you use?

Edit: I used the middle one the nodejs, or a runtime of Node.js 4.3

Also, add the applicationId to Echo_App_ID.


Where can I find this, please?

Edit: OK, I was missing a big step, you need to create a custom skill in the alexa developer portal first to be able to use this:
https://developer.amazon.com/edw/home.html#/
Alexa Skills Kit
Get Started
Add a new skill
custom interaction model

Interaction model:
This where I presume you copy and paste the SampleUtterances & intentschema files.

Configuration:
Where you paste the Function ARN number you got from the Lambda management console function page.

5. Make sure you add the Alexa skill in the AWS Function.


The blueprint 'alexa-smart-home-skill-adapter'? It asks for an application ID. Is it the same one as above?

Edit: this blueprint seems unrelated.

6. Use the sample the two sample files for the IntentSchema and Utterances.


Where abouts to I put them?

Edit: alexa developer portal / skills / configuration

8. Add the index.html to your Webserver path. Note the {{bb_response}} in the text is for a Temporary variable that needs to be set in an EG Macro


Is this the 'HTML documents root' in the webserver config box?

Sorry for all the questions, but as you can see I'm lost. Thanks a lot.
Attachments
2Capture.PNG
2Capture.PNG (10.01 KiB) Viewed 1285 times
Capture.PNG
Capture.PNG (6.2 KiB) Viewed 1285 times
Last edited by blaher on Sun Jun 26, 2016 4:06 am, edited 1 time in total.
blaher
Experienced User
 
Posts: 394
Joined: Thu Nov 17, 2011 1:27 am

Re: Amazon Echo Skill EchoToEventGhost

Postby blaher » Sat Jun 25, 2016 4:57 am

OK, so making more progress, and have got your macro into my tree, but the 'jump to' isn't preserved with a copy and paste, so where should it jump to?

Does the rest of the macro look OK?

Cheers!
Attachments
1Capture.PNG
blaher
Experienced User
 
Posts: 394
Joined: Thu Nov 17, 2011 1:27 am

PreviousNext

Return to General Support

Who is online

Users browsing this forum: No registered users and 3 guests