1.0.1 • Published 7 years ago

alexa-req v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

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');
1.0.1

7 years ago

1.0.0

7 years ago