alexa-req

1.0.1 • Public • Published

Alexa Request

npm version NPM Status CircleCI

This library is meant to parse an incoming Alexa request and return a function version all the request so that you can easily access the data you need.

Installation

 $ npm install --save alexa-req

Usage

import AlexaRequest from 'alexa-req';
 
// get the body from your request
const body = request.body;
 
// create a new AlexaRequest object
const alexa = new AlexaRequest(body);

Functions

getSessionId

Returns the sessionId from the request

const alexa = new AlexaRequest(body);
const sessionId = alexa.getSessionId();

getUserId

Returns the user alexa userId

const alexa = new AlexaRequest(body);
const userId = alexa.getUserId();

getRequestType

Returns the request type

const alexa = new AlexaRequest(body);
const requestType = alexa.getRequestType();

getIntentName

Returns the name of the alexa intent

const alexa = new AlexaRequest(body);
const intent = alexa.getIntentName();

getSlotValue

Returns the value from a given slot. Will return an error if the slot does not exist.

const alexa = new AlexaRequest(body);
const value = alexa.getSlotValue('myslot');

verifyAppId

Verifies if the request has the correct api id

const alexa = new AlexaRequest(body);
const isValid = alexa.verifyAppId('myAppId');

Package Sidebar

Install

npm i alexa-req

Weekly Downloads

7

Version

1.0.1

License

MIT

Last publish

Collaborators

  • patrickml