Search code examples
amazon-web-servicesaws-lambdaamazon-lex

One intent for Multiple Questions - Amazon Lex


Can i use a single intent to give response to different question.

For eg :

Suppose i have a intent reports, now for reports there can be multiple questions like

Q1 . How to download report?

Q2 . Where can i see my reports?

Do i have to make separate intent for download reports and show reports and call a single lambda function for fulfillment? I can have nested if else for intents to give a suitable response.

Is there any other way i can minimize my no of intents ? I am using JavaScript for lambda function.


Solution

  • (In Alexa and Lex lingo: "Utterance" = user questions or statements.)

    General Tip when deciding to group or separate intents:
    Use multiple intents when the utterances differ greatly.
    Use a single intent when you have similar utterances and only a few words differ between them.

    If the utterances are similar then you can use slots to determine the keyword differences.

    Here's how to set it up using your example:

    Create a single intent called Records.
    Then create a custom slotType called actionTypes and list the values as: (download, see, view, etc)
    Then add a slot to Records called action using actionTypes as the slotType.

    Your utterances then become:

     how do I {action} reports  
     how do I {action} a report  
     where can I {action} my reports
    

    Then in your Lambda and within your Records handling logic, you can detect the action slot and respond accordingly.

    This is much better in your case than parsing inputTranscript yourself. Let Lex do that as much as possible, it's what Lex is meant for.