当我需要要求用户填充插槽时,我正在努力创建一种Dialouge结构。
考虑以下互动。
User: What is the scientific name of Eagles?
Bot: There are 3 eagles. Choose one.
- greater spotted eagle
- tawny eagle
- indian spotted eagle
User: tawny eagle
Bot: Scientific name of Tawny Eagle is Clanga clanga
如果只有一个值,这是我的Stories.md
文件。
## Story1
* Scientific_name{'common_name': 'eagles'}
- action_sci_name
还有我的action.py
class ActionSciName(Action):
def name(self):
return "action_sci_name"
def run(self, dispatcher, tracker, domain):
# below line gives 'Eagles`
name = tracker.latest_message['entities'][0]['value']
## I fetch the value from DB for eagles if they are more than 1
## More code here
response = """There are 3 eagles. Choose one
1. greater spotted eagle
2. tawny eagle
3. indian spotted eagle"""
dispatcher.utter_message(response)
return []
上面的文件做第一部分就可以了。但接下来我要停留在用户需要在这3个之间输入值的位置。
意图:
实体:
我看过很多文章和博客,但它们非常基础。他们使用slots
,但用户在第一行本身中输入值。
感谢您的帮助。