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 🙏

© 2026 – Pkg Stats / Ryan Hefner

simple-alexa-skill

v1.0.4

Published

A simple way to build Alexa skills with Express

Readme

simple-alexa-skill

A generic framework for handling simple Alexa skills. It works well with Express, but could work with other Node web servers without a ton of effort.


var express = require('express');
var router = express.Router();
let skillId = process.env.appId || '123456789';

const BOOK_LIST = [
    {
        'title': 'The Adventures of Huckleberry Finn',
        'author': 'Mark Twain'
    },
	{
		'title': 'Hamlet',
		'author': 'William Shakespeare'
	},
	{
		'title': 'Moby Dick',
		'author': 'Herman Melville'
	},
	{
		'title': 'The Odyssey',
		'author': 'Homer'
	},
	{
		'title': 'Invisible Man',
		'author': 'Ralph Ellison'
	}
];
const SimpleAlexaSkill = require('simple-alexa-skill');

const messages = {
	'launch': {
		'output': 'Random Books. Please request a book.'
	},
	'help': {
		'output': `Here are some things you can say: give me a random book, give me a book to read, or what book I should read. You can also say, stop, if you're done. So, how can I help?`
	},
	'cancel': {
		'output': 'Good-bye'
	},
	'stop': {
		'output': 'Good-bye'
	},
	'error': {
		'output': 'An error occurred retrieving your request. Please request a random book.',
		'reprompt': 'Try asking for a random book.'
	},
	'found': {
		'reprompt': 'If you would like a new random book, please request a new book.'
	}
};

const intents = {
	'GetRandomBook': getRandomBookIntentHandler,
	'AMAZON.HelpIntent': helpIntentHandler,
	'AMAZON.StopIntent': stopIntentHandler,
	'AMAZON.CancelIntent': cancelIntentHandler
};

let skill = new SimpleAlexaSkill(skillId, messages, intents);

function getRandomBook(resolve) {
	const book = BOOK_LIST[Math.floor(Math.random() * BOOK_LIST.length)];
	let message = `If you're looking for a random book to read, check out ${book.title} by ${book.author}`;

	resolve(skill.formatResponse(`${message}! ${skill.messages.found.reprompt}`, messages.found.reprompt));
}

function getRandomBookIntentHandler(requestBody, res) {
	let deferred = new Promise((resolve, reject) => {
		return getRandomBook(resolve, reject);
	});

	deferred.then((data) => {
		res.send(data);
	});
}

function helpIntentHandler(requestBody, res) {
	res.send(skill.formatResponse(skill.messages.help.output, skill.messages.help.reprompt));
}

function stopIntentHandler(requestBody, res) {
	res.send(skill.formatResponse(skill.messages.stop.output, 	skill.messages.stop.reprompt, true));
}

function cancelIntentHandler(requestBody, res) {
	res.send(skill.formatResponse(skill.messages.cancel.output, skill.messages.cancel.reprompt, true));
}

router.post('/', (req, res) => skill.handleAll('POST', req, res));