3

Hi I have been using and developing skills on Alexa since quite few months. Recently I updated to the ask sdk version 2. I find everything cool and stuck nowhere.

I couldn't find a way to emit an intent now. Like earlier we were able to call Intent from another Intent in following manner:

this.emitWithState(<intent name here>);

Anybody know how to achieve this in ask sdk V2?

Any help would be highly appreciated.

AvidDev
  • 31
  • 1
  • 6
  • I got the solution. Follow this link: https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/issues/391#issuecomment-390944091 – AvidDev May 23 '18 at 10:33

3 Answers3

5

Do it as

const FirstIntentHandler = {
  canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === 'IntentRequest'
      && handlerInput.requestEnvelope.request.intent.name === 'FirstIntentHandler';
  },
  handle(handlerInput) {

    // some code
    return SecondIntentHandler.handle(handlerinput);
  },
};
Ussama Zubair
  • 1,039
  • 1
  • 13
  • 19
1

If your skill's interaction model has a dialog model you can do the above by intent chaining. Intent chaining allows your skill code to start dialog management from any intent, including the LaunchRequest. You can Chain Intents with Dialog.Delegate as following :

.addDelegateDirective({
    name: 'OrderIntent',
    confirmationStatus: 'NONE',
    slots: {}
 })

Here is the official release blog of the intent chaining : https://developer.amazon.com/blogs/alexa/post/9ffdbddb-948a-4eff-8408-7e210282ed38/intent-chaining-for-alexa-skill

I have also written a sample implementing the same : https://github.com/akhileshAwasthi/Alexa-Intent-chaining

Akhilesh Awasthi
  • 2,688
  • 4
  • 21
  • 30
-2

Simply doing

this.emit(<intent_name>)

will work.

const handlers = {
  'LaunchRequest': function () {
    this.emit('HelloWorldIntent');
  },

  'HelloWorldIntent': function () {
    this.emit(':tell', 'Hello World!');
  }
};
Mukul Jain
  • 1,121
  • 11
  • 24