How do I skip entity nodes if user already provided the info in the original utterance?

Hi All,

Let’s say I have an intent called “Get flight times”. This dialog task needs 3 bits of info in order to return some results:

  • from-city
  • to-city
  • date of travel

To collect these info, I create the following entities:

So to trigger this flow, the customer has to utter: “Get Flight Times”

However another valid utterance could be: “Get Flight Times from London to Paris for tomorrow.”

This utterance has all three entities within a single utterance. Also I can inspect the context object for this info using: {{context.userInputs.originalInput.sentence}}

In this scenario, is it possible to skip one or more entities if the information is already provided by the user?

One way I tried to achieve this is to insert a bot action node that extracts all the available information and used it to populate the context.entities section, e.g.:

But that didn’t work I’m afraid. Does anyone have any suggestions on how to achieve this?

Thanks,
Sher

The default behavior is to extract entity values from the initial utterance and to only prompt if a value is not found.

But peering through the mists of the screenshot I see that you have defined those city entities of type String rather than Airport.

String entities are not extracted from the initial utterance because there is no limit to what to match. They are greedy and will, by default, grab the entire sentence. (There is a way to have a string entity extract from the initial utterance through entity patterns, but care must be taken).

An Airport entity is capable of extracting airport codes (ORD) as well as airport names (O’Hare) and cities (Chicago). The value for an Airport entity is JSON with all the appropriate data. Note there may be an ambiguity with a prompt with cities that have several equally major airports:

But otherwise it will pick the main one. It will also use additional data to help qualify a city.

Now because you have two entities of the same type, then I would recommend using entity patterns for them, (from *) and (to *) so that the platform knows which one is which. The patterns are an indication of where to start looking and what words to protect from earlier entities, but if the pattern words are not present then the platform will work start to end in the sentence.

One a side note, using script to parse the user’s utterance is never the right solution. There are so many things to consider (tokenization, spell correction, appropriate values, etc.) :wink:

Thanks for your pointers about avoiding use of generic strings entities, and use of entity patterns. I think those 2 combined is what I’m looking for :slightly_smiling_face:. I’ll give that a try.