要求用户填写Rasa Chatbot中的位置

时间:2019-02-26 13:41:05

标签: python chatbot rasa-nlu rasa-core

当我需要要求用户填充插槽时,我正在努力创建一种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个之间输入值的位置。

意图:

  • Scientific_name
  • 公用名

实体:

  • 通用名称
  • 科学名称

我看过很多文章和博客,但它们非常基础。他们使用slots,但用户在第一行本身中输入值。

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

我认为Rasa中的forms可以为您提供帮助。使用表格,您可以验证输入并指定用户必须填充哪些插槽。