【问题标题】:How to give out user input error messages in rasa?如何在 rasa 中发出用户输入错误消息?
【发布时间】:2021-04-21 14:50:03
【问题描述】:

如果用户输入与任何意图不匹配,如何发出错误消息。 示例:我正在制作一家餐厅寻找 rasa 机器人,所以我正在考虑让 rasa 机器人询问用户在哪里寻找餐厅的位置,所以如果用户输入的位置没有餐厅如何返回“对不起此位置没有餐厅”消息。

【问题讨论】:

    标签: chatbot rasa


    【解决方案1】:

    您应该能够使用规则和槽创建此行为。例如:

    - rule: nothing found
      condition:
      - slot_was_set:
        - restaurant_found: false
      steps:
      - action: utter_no_restaurants_found
    

    您需要为 restaurant_found 创建一个布尔槽,并在自定义操作中将其设置为 false 或 true。

    slots:
      restaurant_found:
        type: bool
    

    custom action 看起来像这样(您需要添加“成功”条件,以及您的代码执行的任何操作来搜索餐厅。)

    class RestaurantSearchAction(Action):
    
        def name(self) -> Text:
            return "restaurant_search"
    
        async def run(
            self, dispatcher, tracker: Tracker, domain: Dict[Text, Any],
        ) -> List[Dict[Text, Any]]:
            # search for restaurant with your
            # custom code here. You can get entities
            # from the tracker like so: tracker.get_latest_entity_values
            if <successful>:
                return [SlotSet(restaurant_found, True)]
            else:
                return [SlotSet(restaurant_found, False)]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-12
      • 1970-01-01
      • 1970-01-01
      • 2019-08-26
      • 1970-01-01
      • 1970-01-01
      • 2016-12-11
      相关资源
      最近更新 更多