About ASK Utils

Make Alexa skill more easily

We want to make Alexa Skill more emotional and useful.
And we make various utility functions, handler, and some Builder or Factory class. We think these utilities should be more open, so we publish our utility function as ASK Utils.

Easy to use

ASK Utils has a lots of helper functions.

Before ASK Utils

function randomPhrase(myData) {
  // the argument is an array [] of words or phrases
  var i = 0;
  i = Math.floor(Math.random() * myData.length);
const confirmations = ['ok','got it','roger that', 'sounds good', 'great'];
const message = "Here’s your random confirmation message, " + randomPhrase(confirmations))

After ASK Utils

import { getRandomMessage } from 'ask-utils'
const message = "Here’s your random confirmation message, " + getRandomMessage([
    'got it',
    'roger that',
    'sounds good',

TypeScript support

When we create some utility function, we have to make or take care of TypeScript.
ASK Utils packages are almost made by TypeScript.
So we don't have to make type definition, just import and use it.

Amazon Pay & Proactive Event support

We provide packages for Amazon Pay and Proactive Events. We can easy to make the payload and call the proactive event API.

Amazon Pay

const AMAZONPay = require('@ask-utils/amazon-pay')
// Make Order
const SellerOrderAttributes = AMAZONPay.Setup.BillingAgreementBuilder
  .setPlatFormId('My id')
  .setSellerNote('my note')
  .setSellerBillingAgreementId('agreement id')
  .setSellerNote('My store')
  .setCustomInformation('custom info')

// Make Payload
const setupPayload = AMAZONPay.Setup.PayloadBuilder
  .setSellerId('my seller id')
  .setLedgerCurrency('ledger currency')
  .setCheckoutLanguage('checkout lang')
const payload = setupPayload.getPayload()

Proactive Event

import { Client, MediaContent } from '@ask-utils/proactive-event'

// setup client
const clientSecret = 'XXXXXXXXXXXXXX'
const client = new Client({
  clientId: 'amzn1.application-oa2-client.XXXXXXXXX',
  clientSecret: 'XXXXXXXXXXXXXX',
  apiRegion: 'FE' // default: US
// configure event information
const PayloadBuilder = MediaContent.Available.PayloadFactory.init()
const parameters = PayloadBuilder
// configure localizedAttributes
const localizedAttributes = LocalizedAttributes.Factory.init()
  .putLocalizedAttribute('en-US', 'contentName', 'New CD')
  .putLocalizedAttribute('ja-JP', 'contentName', 'あたらしいCD')

// Call proactive event API
  .then(result => console.log(result))
  .catch(result => console.log(result))