Jump to content

Emby with Amazon Alexa


chef

Recommended Posts

PenkethBoy

OH THE HUMANITY!!!

 

After learning all about node.js, completing several tutorials! Made an AWS Amazon account specifically to get good at writing Lambda functions! Built the Lambda function and deployed it!

BUT!!

There are no Amazons Servers close enough to my little frozen part of the world to actually use it!

 

That just takes the cake! Why is Canada so behinde the times??? Our brains are frozen half the year... That's why.

 

I admit defeat... Until the echo is released in Canada. :(

So are you saying Alexa does not work in Canada or that you cant program in Canada?

Link to comment
Share on other sites

This is why I believe it could be possible to setup a web service which handles communication with Emby on your computer.

 

1. Alexa's voice commands can be uploaded to Amazon in a ZIP file (these commands are lists of Movie Titles etc, and their respective Emby IDs in a particular JSON format that the Alexa engine understands)

 

You don't need to do that.  We don't want to be trying to upload everyone's complete library definition to some central server.  Instead, just think of sending commands to your server and having it interpret what to do with them.

Link to comment
Share on other sites

I thought Alexa worked with the Philips Hue lights "out of the box" ??

It does, but I'm not using Phillip hue lights, I'm using Vera lite, which isn't supported.

  • Like 1
Link to comment
Share on other sites

So are you saying Alexa does not work in Canada or that you cant program in Canada?

You can host functions on various Amazon servers, but they are all too far away for Canadians to access at runtime.

Link to comment
Share on other sites

PenkethBoy

sorry dont understand the distance thing - a more distant server would have more latency is that what you mean - does Alexa need low latency to work?

Link to comment
Share on other sites

nxenos83

I started to look into this over the weekend, and got a simple intent setup. ("Alexa ask emby what's up next?" responds with a list of TV series that have episodes in the Next Up section.)

I have a skill that point to an amz hosted lamba function that handles the intents and makes web calls to a plugin created end point, which returns the results of the query for next up episodes.

 

To extend to all users, this would be bit of work on each user's part (right now I've hard-coded the domain name of my emby server into a lamda function), but have been thinking how this could be seamless.

 

If the skill is set up to require account linking, when enabling the skill, the user can be presented with emby connect login page. After providing credentials, emby connect would need to store the alexa provided amazon userId (Alexa creates a unique user ID for each amazon account for each skill). All requests will contain this id and can be used to authenticate the user. To support multiple servers, emby connect would need to provide a way to select the server to be used with each unique amazon id.

 

Alexa skill would send json request to an emby connect end point that would look for an account with the userid, and redirect to a plugin created API end point at the user's IP. Plugin endpoint would return alexa formatted json. Big questions is if this would create a strain on the emby connect servers.

 

Plugin on users server would parse the Alexa request. Plugin would require configuration that allowed for amazon userid to be white-listed and linked to local server account.

  • Like 2
Link to comment
Share on other sites

sorry dont understand the distance thing - a more distant server would have more latency is that what you mean - does Alexa need low latency to work?

When I try to load the uri for the lambda function into the new skill, it gives an error that says I have to choose an Amazon server closer to my location.

 

They have serveral servers in the east and west coast. None of the servers are close enough to Toronto Canada and the error says it would take to long to process causing a latent response.

Link to comment
Share on other sites

I started to look into this over the weekend, and got a simple intent setup. ("Alexa ask emby what's up next?" responds with a list of TV series that have episodes in the Next Up section.)

I have a skill that point to an amz hosted lamba function that handles the intents and makes web calls to a plugin created end point, which returns the results of the query for next up episodes.

 

To extend to all users, this would be bit of work on each user's part (right now I've hard-coded the domain name of my emby server into a lamda function), but have been thinking how this could be seamless.

 

If the skill is set up to require account linking, when enabling the skill, the user can be presented with emby connect login page. After providing credentials, emby connect would need to store the alexa provided amazon userId (Alexa creates a unique user ID for each amazon account for each skill). All requests will contain this id and can be used to authenticate the user. To support multiple servers, emby connect would need to provide a way to select the server to be used with each unique amazon id.

 

Alexa skill would send json request to an emby connect end point that would look for an account with the userid, and redirect to a plugin created API end point at the user's IP. Plugin endpoint would return alexa formatted json. Big questions is if this would create a strain on the emby connect servers.

 

Plugin on users server would parse the Alexa request. Plugin would require configuration that allowed for amazon userid to be white-listed and linked to local server account.

it would be great to see the endpoint plugin code you wrote.

Link to comment
Share on other sites

Jdiesel

Honest question as I really don't know much about any of the voice control systems out there but wouldn't it make more sense to have voice control on the player end rather then the server? What benefit is there to running something like Amazon Echo through the server versus integrating through the FireTV or in the case of other platforms Google Now, Cortana, Siri, or the Roku's? 

  • Like 2
Link to comment
Share on other sites

Honest question as I really don't know much about any of the voice control systems out there but wouldn't it make more sense to have voice control on the player end rather then the server? What benefit is there to running something like Amazon Echo through the server versus integrating through the FireTV or in the case of other platforms Google Now, Cortana, Siri, or the Roku's?

Yes, and I believe fire tv already has Alexa integrated, Xbox has Cortona, etc.

 

Having one Speech Bot in the house seems a little more streamlined to me.

Currently I have three... Cortona, Alexa and a Home Brew Speech Bot of my own design...Lol!

 

There is a remote control portion of the emby API.

 

I suppose that one way of controlling your clients, would be to attach the speech assistant (which ever one) to those remote control function emby has. Have emby control the clients.

 

That would happen by connecting to the server API.

 

Otherwise each device/client would have to have its own speech contol integrated.

Link to comment
Share on other sites

Guest asrequested

Honest question as I really don't know much about any of the voice control systems out there but wouldn't it make more sense to have voice control on the player end rather then the server? What benefit is there to running something like Amazon Echo through the server versus integrating through the FireTV or in the case of other platforms Google Now, Cortana, Siri, or the Roku's?

There was a brief flirtation with that. Carter, is the name that was chosen, I believe. But I couldn't make it work.

Link to comment
Share on other sites

Honest question as I really don't know much about any of the voice control systems out there but wouldn't it make more sense to have voice control on the player end rather then the server? What benefit is there to running something like Amazon Echo through the server versus integrating through the FireTV or in the case of other platforms Google Now, Cortana, Siri, or the Roku's? 

 

The reason is that every single app would have to have custom code to handle this.  We already have a remote control API in the server that can communicate with the apps so having Alexa talk to the server makes the most sense and provides the broadest possible support for apps/devices.

 

 

I started to look into this over the weekend, and got a simple intent setup. ("Alexa ask emby what's up next?" responds with a list of TV series that have episodes in the Next Up section.)

I have a skill that point to an amz hosted lamba function that handles the intents and makes web calls to a plugin created end point, which returns the results of the query for next up episodes.

 

To extend to all users, this would be bit of work on each user's part (right now I've hard-coded the domain name of my emby server into a lamda function), but have been thinking how this could be seamless.

 

If the skill is set up to require account linking, when enabling the skill, the user can be presented with emby connect login page. After providing credentials, emby connect would need to store the alexa provided amazon userId (Alexa creates a unique user ID for each amazon account for each skill). All requests will contain this id and can be used to authenticate the user. To support multiple servers, emby connect would need to provide a way to select the server to be used with each unique amazon id.

 

Alexa skill would send json request to an emby connect end point that would look for an account with the userid, and redirect to a plugin created API end point at the user's IP. Plugin endpoint would return alexa formatted json. Big questions is if this would create a strain on the emby connect servers.

 

Plugin on users server would parse the Alexa request. Plugin would require configuration that allowed for amazon userid to be white-listed and linked to local server account.

 

But you are still only talking to the server there.  The next step is to be able to tell a specific app to do something.

 

It can be done.  It just isn't trivial.

Link to comment
Share on other sites

PenkethBoy

When I try to load the uri for the lambda function into the new skill, it gives an error that says I have to choose an Amazon server closer to my location.

 

They have serveral servers in the east and west coast. None of the servers are close enough to Toronto Canada and the error says it would take to long to process causing a latent response.

wow some limitation that - or i wonder if its a "feature" to limit echo's getting off the reservation

Link to comment
Share on other sites

 or i wonder if its a "feature" to limit echo's getting off the reservation

 

That is probably exactly what it is.  Didn't Chef say the Echo is not yet available in Canada?

  • Like 1
Link to comment
Share on other sites

I started to build my own service in C#

 

I figure as long as the service returns a format that the echo can understand in JSON, it should work.

 

The only thing is learning how to create a certificate for it, which is either: self signed and await confirmation from Amazon that they'll accept it, or buy one.

 

Then I have to figure out how to deploy the service online.

 

I'm reading about IIS, but... Meh, learning new coding stuff is hard work.

Link to comment
Share on other sites

nxenos83

I started to build my own service in C#

 

I figure as long as the service returns a format that the echo can understand in JSON, it should work.

 

The only thing is learning how to create a certificate for it, which is either: self signed and await confirmation from Amazon that they'll accept it, or buy one.

 

Then I have to figure out how to deploy the service online.

 

I'm reading about IIS, but... Meh, learning new coding stuff is hard work.

I'm on a business trip, but can share what I have so far.

 

I'll do some work in parrell, but let me share a few things that I've found.

 

1. For certificate, you will only need this for testing. We would want to have the skill point to connect.emby for release, and there is already a trusted certificate

 

2. Make sure emby is listening on port 443 for https traffic

 

3. To generate a signed certificate, use let's encrypt. There is a powershell cmd let that helps with this process(can't remember the name)

 

4. Have emby serve up the pfx that you create through era encrypt, and set your domain name in emby settings

 

5. When moving to full release, the amazon required timezone and app id verification from the web service. I think this will have to done on the emby connect server, but I'm not sure.

 

 

6. I came across a .net library for Alexa, but haven't had a chance to look into it. Might be a shorter route for parsing Alexa requests.

 

Let me know if you create a GitHub for your work, I'm not a programmer by trade, but enjoy trying.

  • Like 1
Link to comment
Share on other sites

I'm guessing everybody has seen this?

 

http://www.droid-life.com/2017/02/02/plex-can-now-controlled-amazon-alexa/

 

Also I've been controlling my Roku via Alexa with this skill/setup quite well: https://github.com/chris1642/alexaroku

 

Would love to be able to stop using my own node.js server on my desktop and be able to run this through Emby.

Link to comment
Share on other sites

AH HA! I finally have a node JS server running on my machine. Took me a while. I don;t know if this is right or not, but I'm going to try and use it as an intermediary between emby and Alexa.

 

I'm not sure what it is I'm doing is right. I'm in unexplored territory.

 

I know people have mentioned that I should have my skill talk directly to connect.emby, but... and seriously... I haven't the foggiest idea what I'm doing yet... I thought I would try this :)

Edited by chef
Link to comment
Share on other sites

Guest asrequested

AH HA! I finally have a node JS server running on my machine. Took me a while. I don;t know if this is right or not, but I'm going to try and use it as an intermediary between emby and Alexa.

 

I'm not sure what it is I'm doing is right. I'm in unexplored territory.

 

I know people have mentioned that I should have my skill talk directly to connect.emby, but... and seriously... I haven't the foggiest idea what I'm doing yet... I thought I would try this :)

 

LOL...I appreciate the effort :D

Link to comment
Share on other sites

nxenos83

AH HA! I finally have a node JS server running on my machine. Took me a while. I don;t know if this is right or not, but I'm going to try and use it as an intermediary between emby and Alexa.

 

I'm not sure what it is I'm doing is right. I'm in unexplored territory.

 

I know people have mentioned that I should have my skill talk directly to connect.emby, but... and seriously... I haven't the foggiest idea what I'm doing yet... I thought I would try this :)

 

Probably a wise idea using node JS, since Amazon offers a SDK and many examples of how to handle requests. Are you using the Emby JavaScript API to communicate to Emby?

Ultimately, I still think a plugin for Emby, or adding the Alexa handling as a service to the server code, is the only way to make setup easy for all users.

 

I've made some (slow progress) handling the request through an Emby plugin. I can now send playstate (pause, resume, skip, etc) commands to active emby clients from Alexa, and can start a movie on DLNA devices that have an active session (using ISessionManager). "Play Aliens on Xbox One" will start Aliens on Xbox One. I haven't figured out how to start a session with Chromecast.

 

I'm thinking of shrinking my scope, and just focus on using Emby as a music service for Alexa to play music. That way I don't have to manage and start Emby sessions.

 

To search for media I am using the GetItemsResult class in ILibraryManager. Anyone know of limitations of using this?

  • Like 1
Link to comment
Share on other sites

@nxenos83

 

 

I tryied your method to see if I could get my WAN access point to return json string data that Alexa would understand, by creating and Endpoint Plugin.

 

My plugin returned this JSON  string data which Alexa should undertsand:

{"version": "1.0","response": {"shouldEndSession": true,"outputSpeech": {"type": "SSML","ssml": "<speak>Looks like a great day!</speak>"}}

But, whenever I test it on the developer portal I get this error from the test.

 

The remote endpoint could not be called, or the response it returned was invalid.

 

 

Any suggestions?

Edited by chef
Link to comment
Share on other sites

nxenos83

@nxenos83

 

 

I tryied your method to see if I could get my WAN access point to return json string data that Alexa would understand, by creating and Endpoint Plugin.

 

My plugin returned this JSON  string data which Alexa should undertsand:

{"version": "1.0","response": {"shouldEndSession": true,"outputSpeech": {"type": "SSML","ssml": "<speak>Looks like a great day!</speak>"}}

But, whenever I test it on the developer portal I get this error from the test.

 

The remote endpoint could not be called, or the response it returned was invalid.

 

 

Any suggestions?

 

Your missing a closing '}' on the string.

Also, have the class just return the string representation of the json.  Check what it is returning at http://resttesttest.com/. Make sure that your json isn't wrapped in anything.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...