Terry
Terry

Reputation: 317

Is it logical to invoke other intent from the custom intent in an Alexa app

My interaction has to be executed in two steps. in first step. Alexa will get some information to the user. On the basis of published information, Alexa will ask to take another action from the user's answer (Which is yes/no).

So is it possible to invoke one intent and on the basis of previous intent's reply through reprompt, i would be able to call another intent of alexa app.

if so, then how can i do that through akexa node js SDK v2.

Use Case:
My app is connecting with third party API which needs alexa to use Account Linking. Scenario is, when my account is linked and i have valid access token. Here's how conversation will go:

User: Alexa, ask "a" to get me overdue invoices.
Alexa: You have "x" number of invoices. Do you want to send payment reminders?
User: Yes.
Alexa: Your request to send reminders has been registered. Anything else I can help?
User: No Thanks.

So for this, I have to communicate with an external API two times. One, while getting overdue invoices, and two, while sending reminders.

Upvotes: 1

Views: 1082

Answers (1)

Jay A. Little
Jay A. Little

Reputation: 3287

From your example, I'm guessing you have invoices as one intent, then reminders as another intent. If reminders is only ever used immediately after invoices, then I'd make them a single intent. But if you want users to create reminders at any point, or if you have multiple intents that could flow into the reminders intent, then separate intents can work.

Check out: How to Pass a new Intent

Each of the Dialog directives includes an updatedIntent property that can take an Intent object. Use this to:

  • Trigger a dialog on a completely different intent. For example, after completing the dialog for a BookFlight intent, you could return Dialog.Delegate with updatedIntent set to BookRentalCar to start new dialog.

...
When you use updatedIntent to change to a different intent, the directive acts against the new intent instead of the original:

...
When you use updatedIntent to set or change data on the original intent, make sure that the intent name and full set of slots matches the intent sent to your skill.

So to use your example, this is what you would do:

  1. User: Alexa, ask SkillName to get me overdue invoices.

    • Trigger invoices intent.
    • Make API call, get # invoices.
    • Return Dialog.Delegate or Dialog.ElicitSlot or Dialog.ConfirmIntent with updatedIntent set to reminders intent. (include any and all slots, must be a full intent object)
    • Set the outputSpeech to "You have X number of invoices. Do you want to send payment reminders?"
  2. Alexa: You have X number of invoices. Do you want to send payment reminders?

  3. User: Yes.

    • Depending on which Dialog Directive you've chosen to use, it will return the user's answer differently. Either filling a slot you've prepared, or in a confirmationStatus, or AMAZON.YesIntent.
    • Check for the correct one of those, and make your reminders API call if confirmed.
    • Return fulfilled intent with output message:
  4. Alexa: Your request to send reminders has been registered. Anything else I can help?

Upvotes: 1

Related Questions