8000 GitHub - psayre23/alexa-app: A framework for Alexa (Amazon Echo) apps using Node.js
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

psayre23/alexa-app

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alexa-app

A Node module to simplify development of Alexa apps using Node.js

Installation

	npm install alexa-app --save

Example App

The alexa-app-server project is a fully working example of using alexa-app to build an Alexa application using Node.js.

Summary

alexa-app does the dirty work of interpretting the JSON request from Amazon and building the JSON response. It provides convenience methods to more easily build the response, handle session objects, and add cards. It also makes it easy to run multiple endpoints (apps) on one Node.js server instance.

Usage

var alexa = require('alexa-app');
var app = new alexa.app('sample');

app.intent('number',function(request,response) {
  var number = request.slot('number');
  response.say("You asked for the number "+number);
});

express.post('/sample',app.request);

Examples

LaunchRequest

app.launch(function(request,response) {
  response.say("Hello World");
  response.card("Hello World","This is an example card");
});

IntentRequest

Define the handler for multiple intents using multiple calls to intent().

app.intent('buy', function(request,response) {
	response.say("You bought a "+request.slot("item"));
});
app.intent('sell', function(request,response) {
	response.say("You sold your items!");
});

SessionEndRequest

app.sessionEnded(function(request,response) {
	logout( request.userId );
	// No response necessary
});

Keep a session open

By default the session is closed after each request.

app.intent('guess', function(request,response) {
	response.say("Guess again!");
	response.shouldEndSession(false);
});

Read/write session data

app.launch(function(request,response) {
	response.session('number',42);
	response.say("Would you like to know the number?");
	response.shouldEndSession(false);
});
app.intent('tellme', function(request,response) {
	response.say("The number is "+request.session('number'));
});

Access the raw http request/response

app.launch(function(request,response,http_req,http_res) {
	log( http_req.ip );
});

Attach multiple apps to express

var server = express();
var alexa = require('alexa-app');

var app1 = new alexa.app('hello');
app1.launch(function(request,response) {
  response.say("Hello");
});

var app2 = new alexa.app('world');
app2.launch(function(request,response) {
  response.say("World");
});

// Prefix all apps with /alexa/ => ex: /alexa/hello
alexa.bootstrap(server,"/alexa/");

Define a custom endpoint name for an app

var app = new alexa.app('hello','myEndpointName');

About

A framework for Alexa (Amazon Echo) apps using Node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%
0