A JavaScript framework for Amazon Alexa Skill development


Features

ASK SDK compatible
All API is wrapped ASK-SDK.
We can easy to add it into your ask-sdk project.
JSX(TSX) Support for SSML
We can write SSML by using JSX(TSX).
JSX helps us to markup your speech content more easily.
Generate template from CLI
TalkyJS ClI can generate any files from template.
We can easy to create handler / router / service with test.
Situational Design friendly
TalkyJS provides a route component.
It's easy to handle the request denepnds of the situation.
Build-in handler / interceptors
TalkyJS includes a commonly used Handler and interceptors
AMAZON.RepeatIntent, ErrorHandler, SessionEndedRequest, and more.

Compare from ask-sdk

Skill Handler

ASK SDK

import { CustomSkillFactory, DefaultApiClient } from 'ask-sdk-core';
import { S3PersistenceAdapter } from 'ask-sdk-s3-persistence-adapter';

export const handler = CustomSkillFactory.init()
.withPersistenceAdapter(new S3PersistenceAdapter({
    bucketName: 'name',
    pathPrefix: 'blah'
}))
.withApiClient(new DefaultApiClient())
.addErrorHandlers({
    canHandle() {
        return true
    },
    handle(handlerInput, error) {
        console.log(error)
        return handlerInput.responseBuilder
          .speak('Sorry I could not understand the meaning. Please tell me again')
          .reprompt('Could you tell me onece more?')
          .getResponse();
    }
})
.lambda()
TalkyJS

import { SkillFactory, TalkyJSSkillConfig } from '@talkyjs/core'
const config: TalkyJSSkillConfig = {
  database: {
      type: "s3",
      tableName: "name",
      s3PathPrefix: 'blah'
  },
  apiClient: {
      useDefault: true,
  },
  errorHandler: {
      usePreset: true,
  }
}

export const handler = SkillFactory.launch(config)
  .getSkill().lambda()

Request Handler

ASK SDK

import { RequestHandler, getRequest } from "ask-sdk-core";
import { IntentRequest } from "ask-sdk-model";
const StopAndCancelAndNoIntentHandler: RequestHandler = {
  canHandle(handlerInput) {
      const request = getRequest<IntentRequest>(handlerInput.requestEnvelope)
      if (request.type !== 'IntentRequest') return false;
      return ["AMAZON.StopIntent","AMAZON.CancelIntent","AMAZON.NoIntent"].includes(request.intent.name)
  },
  handle(handlerInput) {
      return handlerInput.responseBuilder
          .speak("Bye")
          .getResponse()
  }
}
TalkyJS

import { Router } from "@talkyjs/core";
export const StopAndCancelAndNoIntentRouter: Router = {
    requestType: "IntentRequest",
    intentName: ["AMAZON.StopIntent","AMAZON.CancelIntent","AMAZON.NoIntent"],
    handler: async (handlerInput) => {
      return handlerInput.responseBuilder
          .speak("Bye")
          .getResponse()
    }
}

export default StopAndCancelAndNoIntentRouter

SSML

ASK SDK


return handlerInput.responseBuilder
  .speak([
    "<p>Hello! It's a nice development. </p>",
    "<p>You can use a timer after permitted the Timer permission.</p>",
    "<p>Can I use the Timer?</p>",
  ].join(''))
  .reprompt('How are you?')
  .getResponse()
TalkyJS

/** @jsx ssml */
import {
    ssml,
    SpeechScriptJSX,
} from '@ask-utils/speech-script'

export class InitialLaunchRequestScript extends SpeechScriptJSX {
    speech() {
        return (
            <speak>
                <p>Hello! It's a nice development. </p>
                <p>You can use a timer after permitted the Timer permission.</p>
                <p>Can I use the Timer?</p>
            </speak>
        )
    }
    
    reprompt() {
        return (
            <speak>
                <p>How are you?</p>
            </speak>
        )
    }   
}