How to tell Alexa to jump to a specific intent from LaunchRequest based on user input

282 Views Asked by At

I am quite new in Alexa development so please excuse my ignorance. The Alexa skill I am developing requires the following:

Users will awake the skill along with a question, e.g.

Alexa, ask marketing platform about result of last campaign

I am referring to https://developer.amazon.com/docs/custom-skills/understanding-how-users-invoke-custom-skills.html#cert-invoke-specific-request but not quite understand how to jump to a specific intent from LaunchRequest.

Where marketing platform is the skill invocation and result of last campaign is the utterance for skill intent named CampaignIntent.

There are more intents like this, which I want to call based on user's question, e.g.

Alexa, ask marketing platform to give me messaging details

I am using Lambda for the skill. At the moment it looks like the following:

exports.handler = (event, context, callback) => {
  try {
    if (event.request.type === 'LaunchRequest') {
      var welcomeMessage = '<speak>';
      welcomeMessage = welcomeMessage + 'Welcome to XYZ agency.';
      welcomeMessage = welcomeMessage + '</speak>';
      callback(null, buildResponse(welcomeMessage, false));
      //How can I tell Alexa to jump to CampaignIntent?
    }
    else if (event.request.type === 'IntentRequest') {
      const intentName = event.request.intent.name;

      if (intentName === 'CampaignIntent') {

        var ssmlConfirm = "<speak>";
        ssmlConfirm = ssmlConfirm + 'Hello Auto.';
        ssmlConfirm = ssmlConfirm + "</speak>";

        callback(null, buildResponse(ssmlConfirm, true));

      }
    }
  }
  catch (e) {
    context.fail(`Exception: ${e}`);
  }
};

function buildResponse(response, shouldEndSession) {
  return {
    version: '1.0',
    response: {
      outputSpeech: {
        type: 'SSML',
        ssml: response,
      },
      shouldEndSession: shouldEndSession,
    },
    sessionAttributes: {},
  };
}

CampaignIntent does not have any slot. It simply fetches records from a third party platform API.

I also referred https://stackoverflow.com/a/48032367/1496518 but did not understand how to achieve ...has a WHEN slot to elicit part.

1

There are 1 best solutions below

0
On

The documentation you linked say, "Users can combine your invocation name with an action, command or question. This sends the service for your skill an IntentRequest with the specific intent that corresponds to the user's request."

If a user invokes your skill in this way, the intent you find in the first request of that user's session will be CampaignIntent (the IntentRequest you've defined) instead of LaunchRequest. There isn't any "jumping" you need to do on your end. The behavior will be the same with or without slot values.