I test the forms, then get an error: “failed to extract slot …” What are the possible reasons, Looking forward to your reply, thanks
Your problem is very generic. Give us some code or details of your work to answer.
Slot extraction can fail for a number of reason. User may have not given the correct message. The NLU and Story data may not be supporting extraction of that particular slot. The slots definition may be missing auto_fill: true in domain.yml file. The spelling of slot name and entity name maybe mismatching.
There can be many reasons for which a slot extraction can fail. We can guide you once we get a little bit more detail.
hi,
You are so kind . I paste my intent/domain/story and form-action code as follows:
intent: greet
- 你好
- 你好啊
intent: phonetoll_search
intent: goodbye
- 再见
- byebye
============================================
intents:
- greet
- phonetoll_search
- goodbye
actions:
- utter_greet
- utter_goodbye
- action_search_phonetoll
- utter_result
- utter_ask_item1
- utter_ask_datetime1
slots:
datetime1:
type: unfeaturized
auto_fill: true
item1:
type: unfeaturized
auto_fill: true
cost1:
type: text
initial_value: “”
requested_slot:
type: unfeaturized
forms:
- phonetoll_form
templates:
utter_greet:
- text: “你好阿”
utter_goodbye:
- text: “再见了哦”
utter_result:
- text: “您{datetime1}的{item1}是{cost1}”
utter_ask_item1:
- text: “您要查话费还是流量费呢?”
utter_ask_datetime1:
- text: “您要查上个月的还是本月的?”
================================
story1
- greet
- utter_greet
- phonetoll_search
- phonetoll_form
- form{“name”: “phonetoll_form”}
- utter_result
- goodbye
- utter_goodbye
- action_restart
==============================
class PhoneTollForm(FormAction):
def name(self): return “phonetoll_form”
@staticmethod def required_slots(tracker): return [“item1”,“datetime1”]
def submit( self, dispatcher, tracker, domain ):
datetime1 = tracker.get_slot('datetime1')
if datetime1 == '上个月':
#dispatcher.utter_message("上个月话费是100")
return [SlotSet("cost1", "100")]
elif datetime1 == '本月':
return [SlotSet("cost1", "200")]
else:
return [SlotSet("cost1", "")]
"""dispatcher.utter_template("utter_submit", tracker)"""
return []
I’m looking forward to your reply
Where is your slot_mappings
method in the FormAction class? That method is used to fill the slots from the user messages.
hi, I sloved the problem by adding slot_mappings
method, thanks a lot.
but I have a new question, I fill the slots by from_text mode,like this:
def slot_mappings(self):
return {
“item1”: self.from_text(),
“datetime1”: self.from_text(),
}
when I run the bot,the slot filled,but the slot value have a prefix “/”,
for example:
I input: 话费
the slot filled by : /话费
is that right? or some error?
Please go through the documentation of Form. You can use other methods like from_entity
and from_intent
in a chained manner. For reference please read rasa blog.
ok, thank you.