Skip to content

add `enqueueProgressiveResponseDirective()`

Compare
Choose a tag to compare
@hideokamoto hideokamoto released this 22 Aug 07:11
· 198 commits to master since this release
bdefc20

enqueueProgressiveResponseDirective() will helps you to easy add progressive response into your Alexa Skill.

example

const { enqueueProgressiveResponseDirective } = require('ask-utils') 
const GetFirstEventHandler = {
  canHandle (handlerInput) {
    const request = handlerInput.requestEnvelope.request
    return request.type === 'IntentRequest' && request.intent.name === 'GetFirstEventIntent'
  },
  async handle (handlerInput) {
    try {
      await enqueueProgressiveResponseDirective(handlerInput, 'Please wait for a while')
    } catch (err) {
      // if it failed we can continue, just the user will wait longer for first response
      console.log(err)
    }
    // call some api
    const content = await get()
    return responseBuilder
        .speak(content)
        .getResponse()
  }
}