you may need to cover cases like the user clarifying without saying the words “am” or “pm”
The other way to solve this could be to just give your users am
and pm
buttons so they can select the correct one.
you may need to cover cases like the user clarifying without saying the words “am” or “pm”
The other way to solve this could be to just give your users am
and pm
buttons so they can select the correct one.
@fkoerner Thanks for the detailed answer but what if we want to use the slot mapping of the time
slot given in the domain for clarify_time
slot as well.
@noman sorry, I’m not quite sure I understand your question. Are you saying you want to use the same extraction method? Or the same type of slot?
I want to extract clarify_time
using the same slot mapping as for time
slot, which is defined in the domain file.
You’d have to define both of them in the domain file. They can have the same definition, but you need to write it out once for each slot:
slots:
clarify_time:
type: text
time:
type: text
This is not what i am asking
Could you clarify, please? I wouldn’t list clarify_time
as part of the form, because you only want to require the slot if the time
slot is not clear. Because clarify_time
is not part of the form, slot mapping doesn’t really apply here.
@fkoerner if my requested slot is clarify_time
that what will be its slot mapping?
The slot mapping for clarify_time
that I suggested is not one of the predefined slot mappings, but rather the custom one I outlined earlier. I don’t think it makes sense for clarify_time
and time
to share a slot mapping. Reason being that I think time
can probably be covered with Duckling and from_entity
. clarify_time
should be handled with a custom slot mapping.
A custom slot mapping prefixed with "extract_<name of slot>"
will be recognized by the form action as that slot’s extraction method. Read more about custom actions here. Here is the extraction method I suggested as a starting point:
Bear in mind that there are many other ways to extract the slots, or handle them. You could use a text slot, or a categorical slot. In addition, you may need to cover cases like the user clarifying without saying the words “am” or “pm”, for example if they say “I meant in the morning”. The best way to figure this out is to practice CDD to find out what real people would say in response to your bot’s question
And the usual disclaimer, I haven’t actually run this code, it’s very possible there are typos, it’s meant more as a suggestion than for you to copy it verbatim.
async def extract_clarify_time(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> Dict[Text, Any]:
text_of_last_user_message = tracker.latest_message.get("text")
time_clarification = "am" if "am" in text_of_last_user_message.lower() else "pm"
unclear_time = tracker.get_slot("time")
clear_time = f"{unclear_time} {time_clarification}" # or however else you want to adjust the time with the new info
return {"clarify_time": time, "time": clear_time}
using bot utterance for validation message doesn’t stop form for asking same slot required message