Search code examples
amazon-lexaws-lex

Precedence of slot utterances over intent utterances


In our bot we have several intents. In one of the intents we have the following sample utterance:

I {injuryType} my {bodyPart}

So it matches things like I broke my leg.

Then, in another intent, we have a slot for bodyPart with the following sample utterance:

I broke my {bodyPart}

The problem we are having is that when the user is prompted by the bodyPart and he says I broke my leg, instead of just filling the slot, it is switching to the other intent.

Is there a way to indicate that the slot utterances should have precedence over the intent utterances?


Solution

  • Unfortunately, we don't have a way to explicitly force Lex to remain within slot value matching and not try to match at the intent level.

    From my experience with this issue (it happens a lot, so this is a constant balancing act), the slot values do take priority over intent utterances when you are in an intent. With a good bot structure ("intent schema") the intent utterances seem to only be checked when the slot value does not find a perfect match. However, Lex might check both every time and simply provide the best match, which in your case would be the intent utterance because of one less variable.

    We really only have one form of control over this, how we set up intents, utterances, slotTypes, and slotType values.

    Here are some suggestions:

    1. Reconsider the set up of the intents and look for possibilities where two intents are too similar and could be merged into a single intent.
    2. Assess the similarity between utterances and slotType values, and simply remove one in favor of the other.
    3. Try to strengthen the slotType values list such as: "break", "broke", "broken", "braked", etc. (even misspellings)

    I have been least successful with #3, and most successful with #1 and #2.

    Like I said, it has been a constant balancing act considering the structuring of intents, possible slotType values within different intents, any overlap of input matching at all, and natural language user experience. You will have to sacrifice some freedom/structure in one to give more freedom/structure to another.