How can I "force" an entity extraction using context?

I have a form which includes a request to enter a currency (e.g., BTC) or currency pair (e.g., lrcbtc). There are thousands of these and they change, so a lookup table isn’t so great. In some cases, the “currency” intent is being recognized, but the “currency” entity isn’t being picked up so my form workflow breaks.

What is the best approach to force or give a hint so the entity is actually picked up? I thought I could do in slot_mappings but I can’t see how I can get access to the original text (if so, I could do a sanity check on text for the currency slot and then assign that). Was also thinking of a custom NLU component where I rewrite “lrcbtc” into “symbol lrcbtc” and then train on this pattern. However, I can’t see how I can see the current slot-setting context necessary to know when I should rewrite text.

Is there a sane way to solve this problem?

If you specify self.from_text() in slot_mappings, the whole text of the answer to the utter_ask_{slotname} question is extracted into the slot. Any postprocessing can be done in the validate_{slotname} method afterwards.

@IgNoRaNt23 Thanks. The goal would be to use the existing entity if one was extracted, otherwise use the text. It’s not clear how to conditionally assign in slot_mappings. e.g., if I did something like this:

[self.from_entity(entity=“symbol_entity”), self.from_text(“symbol_intent”)]

Would that work or in the case of an empty entity, simply assign None?

Nope, that didn’t work. Trying to figure out how I can access the entities extracted from within slot_mappings(). I can’t see how to get access to the Tracker which has this info.

nvm, it worked great! (typo) Thanks @IgNoRaNt23. So it looks like if the first from_*() in the list for a slot return empty value, then it keeps going until it finds one.