Rule with different action depending on condition

Hello there!

When the user asks for the price, I want the chatbot to reply with the price, if it is set. If not, I want it to start the price_form.

This is what I thought would work:

  - rule: start form on asked price
    condition:
      - slot_was_set:
          - fetched_travel_price: None
    steps:
      - intent: ask_info_price
      - action: price_form
      - active_loop: price_form

  - rule: question path price
    condition:
      - slot_was_set:
          - fetched_travel_price: True
    steps:
      - intent: ask_info_price
      - action: utter_info_price

However, when I run the training, it says the two rules are conflicting each other.

Is it possible to have two rules, where different actions follow after an intent depending on if a slot is set or not?

Thank you, Zaya

For anyone else wondering, I solved this by using a custom action that fetches the slot value, and if the slot value equals None, it starts the form, otherwise it gives a response instead.

  - rule: question path price
    steps:
      - intent: ask_info_price
      - action: action_handle_requests
class ActionHandleRequests(Action):
    def name(self) -> Text:
        return "action_handle_requests"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

            slot_value = tracker.get_slot('price')
            if slot_value is None:
                return [FollowupAction("price_form")]
            else:
                dispatcher.utter_message(response="utter_info_price")

If this is possible to do without a custom action, please feel free to explain it!

1 Like