question

Matt Kruse avatar image
Matt Kruse asked

New: Alexa Apps in Node.js: alexa-app and alexa-app-server

I welcome feedback on two projects I've created: alexa-app: https://www.npmjs.com/package/alexa-app An npm module that simplifies working with the Alexa request/response json. alexa-app-server: https://github.com/matt-kruse/alexa-app-server/ A fully-working Node.js+express server supporting multiple Alexa apps and a built-in debugger! Now you can test your service without actually using the Echo, and make sure that the JSON in/out is correct. These are my initial commits, and some of my first projects that I've put up on github and npm. I hope they are useful to someone. :) Matt Kruse
alexa skills kitdebugging
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jim Hunter avatar image
Jim Hunter answered
This looks pretty cool, thanks! How do you set this to listen on a port other than 80? I need it to reside in a high port. Does your response.card support sub-titles? Thanks, Jim
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jim Hunter avatar image
Jim Hunter answered
I guess I also forgot to ask if you have used this with socket.io? I have a huge need to use it with my Echo app. Thanks, Jim
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Matt Kruse avatar image
Matt Kruse answered
The alexa-app module doesn't do any listening at all, but the alexa-app-server project defaults to listening on port 8080, or whatever process.env.port is set to. You can edit server.js to customize the port if you wish. The response.card does not support subtitles right now, but I will add that.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Matt Kruse avatar image
Matt Kruse answered
I've not used it with socket.io, no. I don't see any reason why they shouldn't work together.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Matt Kruse avatar image
Matt Kruse answered
I just published version 1.0.3 and added a third argument to response.card() to allowing setting of subtitle.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

justin avatar image
justin answered
Very cool, Matt! Looking forward to digging into this more!
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Tom avatar image
Tom answered
Hi Matt, I'm still not clear as to whether alexa-app is intended as a client (local to my laptop) that calls a lambda hosted server or is itself intended to be a lamba hosted server. If it's the last (a server) then why would I use it instead of simply going straight to alexa-app-server? Also, when I instantiate a app. using: 'var app = new alexa.app('sample');' where does alexa.request get the properties such as UserId, etc. that tie it to my particular echo and it's associated lambda server? I understand the alexa-app-server examples -- they clearly belong on the lambda server. Thanks. Best, Tom
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Matt Kruse avatar image
Matt Kruse answered
Neither of these libraries is actually built to be used with lambda. I haven't tested them there yet, and I think the code needs to be written a bit differently. I'm still trying to find time to look into that. alexa-app is just a thin wrapper around the JSON API that the Echo speaks back and forth. It can be used on any server. It includes a "bootstrap" method that connects alexa apps to the express server in Node. But if you aren't using express (using lambda, for example) then you need to map requests to the app.request method manually, and pass the request and response. I haven't had the chance to figure out how that works in lambda yet, or if I need to write alexa-app-lambda as another wrapper. alexa-app-server using alexa-app and creates a stand-alone web server that fully handles requests from the Echo. It shouldn't be used with lambda, because with lambda you don't need to run your own server.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Nick Gardner avatar image
Nick Gardner answered
Hi Thomas, There are two types of Alexa applications. You can make them either with Lambda, where you create a Lambda function, link the ARN when you create your application, and then have all the JSON passed to your Lambda function when your app is invoked, or you can simply make a HTTPS endpoint which responds to the JSON passed by the Alexa service, which can be in any language you choose, as long as it takes in the JSON, outputs the appropriate response, and is properly secured. From what I understand of this function, its meant to be the latter. It could probably be modified relatively easily for Lambda, but it was released before Lambda compatibility was announced. Alexa-app seems to be a module that makes it easier for you to develop your own app, so you don't have to implement all the JSON logic yourself, but can focus on the application logic you want to enable. The second one appears to be a full-featured server with some additional features. Thanks, Nick
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Tom avatar image
Tom answered
Understand. Thanks guys.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.