import * as Alexa from '../src/index' ; type State = 'Started' | 'Other' ; const routes = { InitialState : 'Started' , Launch : ( ) => new Promise < Alexa . Response < State > > ( resolve => resolve ( { Say : { Text : 'Hello world' } , NewState : 'Other' , } ) ) , SessionEnded : ( ) => { console . log ( 'Session ended' ) ; } , Standard : { Help : state => ( { Say : { SSML : '<speak> try saying <emphasis>hello</emphasis> </speak>' } , } ) , Stop : state => ( { Say : { Text : 'Bye!' } , EndSession : true , } ) , } , Custom : [ [ 'MyCustomIntent' , ( state , slots ) => ( { Say : { Text : 'Something interesting' } , EndSession : true , } ) , ] , ] , } ; const auth = ( event , next ) => { if ( event . session . user . accessToken ) { return next ( event ) ; } else { return Alexa . response ( { Say : { Text : 'Please link your account to use this skill.' } , Card : { Type : 'LinkAccount' } , } ) ; } } ; const unhandled = event => Alexa . response ( { Say : { Text : "Sorry, I don't seem able to respond to that right now." } , EndSession : true , } ) ; export const handler = Alexa . Lambda . pipe ( [ Alexa . Pipe . tracer ( ) , auth , Alexa . Pipe . router ( routes ) , unhandled , ] ) ;