I’m trying to trigger a user intent from a custom action through the UserUttered event. I create this event in my custom action and in the debug logs, it appears to be present in the tracker as a valid state (its the last state in the listed states).
I also noticed that get_intent_of_latest_message returns None after this custom action is executed.
My issue is that the bot doesn’t seem to predict the next action based on this triggered intent, that’s now present on the tracker.
My requirement is to basically trigger an intent through a custom action, and ensure that the bot continues the conversation based on this injected intent, as if the user themselves had entered it.
Hi @ChrisRahme . Thanks for the prompt response, as usual! My ultimate goal is to be able to seemlessly redirect the user to another part of the conversation.
something like this:
# flow 1 going on
intent: ...
action: action_flow_1_end
# must take the user to flow 2 now after action_flow_1_end
Original approach
Currently, I make the user click on a button (basically get an intent out of them) and that helps take the user to another part of the conversation.
# flow 1 going on
intent: ...
action: action_flow_1_end
# must take the user to flow 2 now after action_flow_1_end
intent: trigger_flow_2
action: action_flow_2_start
intent:
...
What i’m currently trying
But I’m now looking at ways to avoid asking the user for this, and redirect them directly.
something like this:
# flow 1 going on
intent: ...
action: action_flow_1_end
# must take the user to flow 2 now after action_flow_1_end
# add intent trigger_flow_2 to the tracker
# bot then predicts action_flow_2_start
action: action_flow_2_start
My original question was regarding how to accomplish this. When I said I was resorting to FollowupAction, it was because the bot wasn’t using the injected intent to make the next action prediction, and was pretty much always predicting action_listen.
Regarding your suggestion
My only worry with your suggestion (directly use FollowupAction) like this:
# flow 1 going on
intent: ...
action: action_flow_1_end
# must take the user to flow 2 now after action_flow_1_end
# trigger action_flow_2_start directly
action: action_flow_2_start
is that it may hurt policy performance, since all my stories require that there be the intent trigger_flow_2 before action_flow_2_start.
TLDR
Would directly triggering the next action (not bothering with the intent in the middle at all) affect performance?
If I’m still looking for a way to manually inject an intent so that the bot considers it for the next prediction, is there a way to do it?
Using FollowupAction should not affect performance
Once you use it, just talk to your bot a bit using Rasa X and export the story to the stories.yml file - just to show your bot that this is normal, even though it has no choice but to execute it.
This is why I’m suggesting to add some new stories that were built after using FollowupAction, but again, this won’t hurt your bot’s performance since it has no choice to begin with.
I think UserUttered does not execute actions, I also failed to use it that way and had to use FollowupAction instead (which was preferable in my case anyway).
But if you really need UserUttered, maybe you can find a way to execute it from your frontend application as if the user sent the message (but without displaying it of course).
Thanks a lot for the help. I’ll look into using FollowupAction directly, or make frontend trigger it.
Last question: If there isn’t a way (with UserUttered or through an API, or otherwise) to inject an intent on to the tracker that the bot uses to predict the next action (excluding work-arounds like you suggested), shouldn’t this be a feature Rasa should provide out of the box?
Hi
I know it’s too late to reply to this post, but I think I figured out the reason why you couldn’t trigger an intent using UserUttered.
Your problem was that you forgot to add “confidence” property in your data json.
This code should work.
I have this flow (my_action followed by /affirm) defined in multiple stories and I don’t want the restrictive nature of rules… I don’t think the predictive power of the bot is the issue here, it seems to just ignore the updated intent for some reason…