Search code examples
alexa-skills-kitaws-sdk-nodejs

Problem with addDelegateDirective and intent


So I have a problem with building my alexa skill, I need to chain a Intent to my Launchrequest, It works with this

  return handlerInput.responseBuilder
      .addDelegateDirective({
          name: 'UserLogin',
          confirmationStatus: 'NONE',
          slots: {}
      })
      .speak("You need to login!")
      .withShouldEndSession(false)
      .getResponse();

But in my chained intent I have 2 slots required to filled, but the alexa only ask for one intent twice and then nothing, it doesn´t ask the second intent required?

This is my intent conde in lambda

const LoginUserIntent= {
   canHandle(handlerInput) {
   const request = handlerInput.requestEnvelope.request;
   return request.type === 'IntentRequest' &&
   request.intent.name === 'UserLogin' &&
   request.dialogState !== 'COMPLETED';
      },
     handle(handlerInput) {
     return handlerInput.responseBuilder
     .getResponse()
  },
}

any idea how can I make this work?


Solution

  • I know it has been a long time but in this case, what is happening is that you MUST set all slots in slots parameter of addDelegateDirective().

    Here is a sample code:

    .addDelegateDirective({
              name: 'UserLogin',
              confirmationStatus: 'NONE',
              slots: {
                  slot01: {
                             name: 'slot01',
                             confirmationStatus: 'NONE',
                             type: 'AMAZON.NUMBER',
                             source: 'USER'
                          }
              }
          })
    

    You MUST also set the slot type. There are many samples around that misses this attribute and, at least in my case, it doesn't work.

    Please let me know if it helps.