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 fromVALUES, no matter which phrase the customer used.
Matching is strict and has three steps:
- An exact match on a value.
- A case-insensitive match on a value.
- A case-insensitive match on a synonym.
EXTRACTION_HINTS entry.
Minimal working example
A shipping assistant stores one of three delivery speeds. Customers say “overnight”, “asap”, “cheapest”, and similar words.speedis aGATHERfield that the customer supplies.- The entity supplies the allowed values and the synonyms. The stored value is
STANDARD,EXPRESS, orNEXT_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.
VALUES list, orphan synonyms, or duplicates.
Common variations
Enum without an entity
A single field can list its allowed values withOPTIONS. It cannot carry synonyms. Use an entity when you need synonyms.
OPTIONS with ENTITY_REF.
Synonyms in the NLU section
TheNLU: 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
AddEXTRACTION_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
- Run the validator. Expect no errors and no warnings.
- Say “overnight please”. Expect
speedto fill asNEXT_DAY. - Say “the CHEAPEST one”. Expect
STANDARD. - Say “sometime this week”. Expect the field to stay empty and the agent to ask again.
- In the trace, open the extraction stage result. Check the raw phrase, the resolved value, and the
changedflag. - Check the rejection reason code
invalid_optionwhen a phrase is refused.
Production readiness checklist
VALUESis 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: