I’m developing a bot with Rasa and I have a question about the approach I’m using to change the intent during a conversation.
At a specific point of conversation (when the detected intent is intent_a), if a specific condition is not met, I’m using a custom action (action_trigger_intent) to guide the conversation to the intent_b. This action uses the UserUttered method to simulate user input with the new intention.
I need to force this intent change because it’s a condition checked within the bot, and this needs to be transparent to the user.
Here’s a snippet of my code:
# file: stories-a.yml
version: "3.1"
stories:
- story: story A
steps:
- intent: intent_a
- action: action_conditions_flow
- slot_was_set:
- conditions_flow: false
- action: action_trigger_intent
- checkpoint: checkpoint_change_intent
##################
# file: stories-b.yml
version: "3.1"
stories:
- story: story B
steps:
- intent: intent_b
- checkpoint: checkpoint_change_intent
- action: run_form
- active_loop: run_form
- active_loop: null
- slot_was_set:
- run: CORRECT
- action: action_shadow_mode
#####################
class TriggerExternalIntentAction(Action):
def name(self) -> str:
return "action_trigger_intent"
def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[str, Any]) -> List[Dict[str, Any]]:
data = { "intent": {
"name": "intent_b",
"confidence": 1.0,
}
}
return [UserUttered(text="/intent_b", parse_data=data)]
I would like to know if this is an appropriate approach or if there is a more efficient way to guide the conversation towards a specific intention in my case.