Created
September 14, 2018 02:46
-
-
Save isann/6a6092af57653bc1125effc346c76646 to your computer and use it in GitHub Desktop.
ask-sdk で非同期処理してからレスポンス ref: https://qiita.com/isann_tech/items/2cfbff4a336d0389d2db
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface RequestHandler { | |
canHandle(handlerInput: HandlerInput): Promise<boolean> | boolean; | |
handle(handlerInput: HandlerInput): Promise<Response> | Response; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function execute(msg) { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
resolve(); | |
}, 1000); | |
}); | |
} | |
const MyIntentHandler = { | |
canHandle(handlerInput) { | |
return handlerInput.requestEnvelope.request.type === 'IntentRequest' | |
&& handlerInput.requestEnvelope.request.intent.name === 'MyIntent'; | |
}, | |
async handle(handlerInput) { | |
await execute('なんか非同期処理'); | |
return handlerInput.responseBuilder | |
.speak('Hello My Intent') | |
.reprompt('Hello') | |
.getResponse(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment