@ask-utils/router
v3.11.0
Published
Skill Routing library for ask-sdk v2
Downloads
27
Readme
Router
https://ask-utils.dev
Simple skill handler routing libs.
Getting started
$ npm i -S @ask-utils/router
Basic Usage
import {
RequestHandlerFactory
} from '@ask-utils/router'
const router = new RequestHandlerFactory()
router.addRoutes({
requestType: 'LaunchRequest',
handler: (input) => {
return input.responseBuilder
.speak('hello world').getResponse()
}
}, {
requestType: 'IntentRequest',
intentName: 'HelloIntent',
handler: (input, helpers) => {
helpers.stateManager.setState('step1')
return input.responseBuilder
.speak('Go to step 1').reprompt('will you go?').getResponse()
}
}, {
requestType: 'IntentRequest',
intentName: 'Step1Intent',
situation: {
state: {
current: 'step1',
next: 'step2'
}
},
handler: (input) => {
return input.responseBuilder
.speak('Go to step 2').reprompt('will you go?').getResponse()
}
}, {
requestType: 'IntentRequest',
intentName: 'Step2Intent',
situation: {
state: {
current: 'step2',
next: 'end'
}
},
handler: (input) => {
return input.responseBuilder
.speak('Finnaly').reprompt('will you go?').getResponse()
}
}, {
requestType: 'IntentRequest',
intentName: ['AMAZON.StopIntent', 'AMAZON.CancelIntent'],
situation: {
shouldEndSession: true
},
handler: (input) => {
return input.responseBuilder
.speak('Bye!').getResponse()
}
})
export const handler = CustomSkillFactory.init()
.addRequestHandlers(
...router.createHandlers()
).lambda()