JSPM

  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q60125F
  • License MIT

utility functions for ask-sdk

Package Exports

  • ask-utils

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 (ask-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ASK-Utils - Utility functions for ask-sdk

Build Status npm version logo

https://ask-utils.github.io/ask-utils/

Getting started

$ npm i -S ask-utils@next

Usage

const utils = require('ask-utils')

or

const { getRandomMessage, isLaunchRequest } = require('ask-utils')
import utils from 'ask-utils'

or

import { isLaunchRequest, getRandomMessage } from 'ask-utils'

getRandomMessage

We can easy create random response in your Alexa skill using ask-sdk.

const { getRandomMessage } = require('ask-utils')
const errorMessages = [
  'I can not here what you say, please say again.',
  'Please say again.',
  "I'm sorry, please tell me again"
]

const ErrorHandler = {
  canHandle () {
    return true
  },
  handle (handlerInput, error) {
    console.log(`Error handled: ${error.message}`)
    const message = getRandomMessage(errorMessages)
    return handlerInput.responseBuilder
      .speak(message)
      .reprompt(message)
      .getResponse()
  }
}

intentHandlers

const LaunchRequestHandler = {
  canHandle (handlerInput) {
    return isLaunchRequest(handlerInput)
  },
  handle (handlerInput) {
    const speechText = 'This is example skill'

    return handlerInput.responseBuilder
      .speak(speechText)
      .reprompt(speechText)
      .withSimpleCard(SKILL_NAME, speechText)
      .getResponse()
  }
}

const HelpIntentHandler = {
  canHandle (handlerInput) {
    return isMatchedIntent(handlerInput, 'AMAZON.HelpIntent')
  },
  handle (handlerInput) {
    const speechText = 'This is example skill'

    return handlerInput.responseBuilder
      .speak(speechText)
      .reprompt(speechText)
      .withSimpleCard(SKILL_NAME, speechText)
      .getResponse()
  }
}

development

$ git clone git@github.com:hideokamoto/ask-utils.git
$ cd ask-utils
$ npm i

test

$ npm test

Lint

$ npm run lint

or

$ npm run lint -- --fix

History

-> Release Note

Contributors

Name Version
@ArtskydJ v0.13.0