Skip to main content
Back to how-to guides Use this pattern when the customer can say one choice in many ways and the agent must store one canonical value.

Concept

An enum entity lists the allowed values. Synonyms map the customer’s own words to those values. The runtime stores the canonical value, with the spelling from VALUES, no matter which phrase the customer used. Matching is strict and has three steps:
  1. An exact match on a value.
  2. A case-insensitive match on a value.
  3. A case-insensitive match on a synonym.
There is no partial or approximate matching. A phrase that is not a value or a synonym is rejected, unless the extraction model maps it and the phrase appears in a synonym or an extraction hint. A model cannot rewrite a phrase into a value on its own. So every paraphrase you want to accept needs a synonym or an EXTRACTION_HINTS entry.

Minimal working example

A shipping assistant stores one of three delivery speeds. Customers say “overnight”, “asap”, “cheapest”, and similar words.
Variable sources:
  • speed is a GATHER field that the customer supplies.
  • The entity supplies the allowed values and the synonyms. The stored value is STANDARD, EXPRESS, or NEXT_DAY.

How it works

Write synonyms as a map. Each key is a canonical value. Each value is an inline list. Rules for the syntax: At run time:
  • The stored value is the canonical spelling from VALUES.
  • A value that matches nothing is rejected with the message Invalid value "x" for "field". Allowed: A, B. The value is left out of the message for a sensitive field.
  • The trace stage result lists each raw phrase, the value it resolved to, and whether it changed.
  • When two synonyms could match, the first one in declaration order wins. There is no clarification step.
The compiler does not warn about a missing VALUES list, orphan synonyms, or duplicates.

Common variations

Enum without an entity

A single field can list its allowed values with OPTIONS. It cannot carry synonyms. Use an entity when you need synonyms.
This is a section snippet. A field cannot combine OPTIONS with ENTITY_REF.

Synonyms in the NLU section

The NLU: section declares entities in a list form. Its synonym lists accept quotes, and keys can contain a hyphen. Use one place per entity, either ENTITIES: or NLU:.

Let the model map paraphrases

Add EXTRACTION_HINTS for phrasings that are hard to list, such as “I need it by tomorrow”. The model can map a phrase to a value only when the phrase is a synonym or a hint.

Verification

  1. Run the validator. Expect no errors and no warnings.
  2. Say “overnight please”. Expect speed to fill as NEXT_DAY.
  3. Say “the CHEAPEST one”. Expect STANDARD.
  4. Say “sometime this week”. Expect the field to stay empty and the agent to ask again.
  5. In the trace, open the extraction stage result. Check the raw phrase, the resolved value, and the changed flag.
  6. Check the rejection reason code invalid_option when a phrase is refused.

Production readiness checklist

  • VALUES is on one line, with no trailing comment.
  • Every synonym key matches a value exactly.
  • Synonyms are inline lists, and none contains a quote or a comma.
  • Customers’ real phrases come from logs or tests, and each one maps to a value.
  • Each ambiguous phrase appears under one value only.
  • Tests cover an exact value, a synonym, a different case, and an unknown phrase.

Common mistakes

Troubleshooting

Related articles: