JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 23
  • Score
    100M100P100Q47500F
  • License MIT

Simple library to manage alexa responses and some helpers to improve data transformation.

Package Exports

  • alexa-helpers

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (alexa-helpers) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Alexa Helpers

Simple library to manage alexa responses and some helpers to improve data transformation.

Responses can include variables escaping them into curly brackets {variable}.

Example Usage

To manage alexa's responses.

var messageRenderer = require('alexa-helpers').messageRenderer
  , Reply = require('alexa-helpers').reply;
...
var responses = {
  "Generic": {
    "Say": { say: "I want {a} {drink}" },
    "Tell": { tell: "I want {a} {drink}" },
    "Ask": { 
      ask: "Do you want a {drink}?",
      reprompt: "Please answer if you want a {drink}.",
      card: {
        type: 'Simple',
        title: 'Blah',
        content: "I want {a} {drink}"
      }
    }
  }
};

var data = {
  drink: 'water'
};

var variables = {
  a: function a(data) {
    return Promise.resolve('a');
  },
  drink: function drink(data) {
    return Promise.resolve(data.drink);
  }
};

var sut = messageRenderer(responses, variables);
sut('Generic.Ask', data).then(function(msg) {
  var reply = new Reply(msg);
  // Send the message/text to alexa
  reply.write(response);
})