npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

alexa-nodekit

v1.0.2

Published

Amazon Echo Alexa's App Kit NodeJS Implementation

Downloads

7

Readme

alexa-nodekit

Amazon Echo Alexa's App Kit NodeJS Implementation

Build Status

Usage

// Require module.
var alexa = require('alexa-nodekit');

/**
 * Store values from Echo Request.
 *
 * @param {Object} req.body The request body object coming from the Echo.
 *
 * @return {undefined} No Response.
 */
alexa.launchRequest(req.body);
alexa.intentRequest(req.body);
alexa.sessionEndedRequest(req.body);

/**
 * Respond to the Echo requests. The Content-Length header must be included in each response.
 *
 * @param {String} speech The string that Alexa should state to the user. Up to 8000 characters and no more than 24 kb.
 * @param {Object} card The card object to generate for echo.amazon.com.
 * @param {String} card.title The card title.
 * @param {String} card.subtitle The card subtitle.
 * @param {String} card.content The card content.
 * @param {Boolean} endSession Wether this response should end the session or not.
 * @param {Function} callback The callback function.
 *
 * @return {Function} The callback function.
 */
// Launch or Intent Response.
alexa.response('Welcome to my app, you can say things like <action> or <action>.', {
  title: 'Launch Card Title',
  subtitle: 'Launch Card Subtitle',
  content: 'Launch Card Content'
}, false, function (error, response) {
  if(error) {
    return console.log(error);
  }
  console.log(response);
});

// Session Ended Response.
alexa.response(function (error, response) {
  if(error) {
    return console.log(error);
  }
  console.log(response);
});

Examples

Example of Launch Request/Response using ExpressJS.

var alexa = require('alexa-nodekit');

// Route request and response ends up here.
exports.route = function (req, res) {
   // Grab the necessary values from the Echo request.
   alexa.launchRequest(req.body);
   // Store the session and/or user data

   // Respond to the Echo
   alexa.response('Welcome to my app, you can say things like <action> or <action>.', {
     title: 'Launch Card Title',
     subtitle: 'Launch Card Subtitle',
     content: 'Launch Card Content'
   }, false, function (error, response) {
     if(error) {
       return res.status(400).jsonp({message: error});
     }
     return res.jsonp(response);
   });
};

Example of Intent Request/Response using ExpressJS.

var alexa = require('alexa-nodekit');

// Same route used as launch, request and response ends up here.
exports.route = function (req, res) {
   // Grab the necessary values from the Echo request.
   alexa.intentRequest(req.body);
   // Check session and/or user data
   // Check the Intent Name and Intent Slots to decide on what logic to kick off.

   // Respond to the Echo
   alexa.response('I am an Echo response based on your intent.', {
     title: 'Intent Card Title',
     subtitle: 'Intent Card Subtitle',
     content: 'Intent Card Content'
   }, true, function (error, response) {
     if(error) {
       return res.status(400).jsonp({message: error});
     }
     return res.jsonp(response);
   });
};

Example of Session Ended Request/Response using ExpressJS.

var alexa = require('alexa-nodekit');

// Same route used as launch and intent, request and response ends up here.
exports.route = function (req, res) {
   // Grab the necessary values from the Echo request.
   alexa.sessionEndedRequest(req.body);
   // Check session and delete it.

   // Respond to the Echo
   alexa.response(function (error, response) {
     if(error) {
       return res.status(400).jsonp({message: error});
     }
     return res.jsonp(response);
   });
};

Testing

$ npm test

Contributions

  • Fork it (https://github.com/YOUR_USERNAME/alexa-nodekit/fork).
  • Create your feature branch (git checkout -b my-new-feature).
  • Commit your changes (git commit -am 'Added some feature.').
  • Push to the branch (git push origin my-new-feature).
  • Create a new pull request.

License