Is there a way to suggest intents to a user that are related to their most recent intent? For example, let’s say I have intent1, intent2, intent3 and all three intents are related to building houses. The user says something that is classified as intent 1 so Rasa provides the response for intent1. Then I want Rasa to say “Can I help you with something else? Button: Intent2, Button: Intent3, Button: Other” That way I can suggest related topics but also allow the user to say something unrelated.
Hi @tatianaf,
It should be pretty straight forwawrd:
stories.md file
* greet
- utter_greet_askque
* intent1
- utter_response1
* intent2
- utter_response2
* intent3
- utter_response3
* other
- utter_response4
domain.yml file
responses:
utter_response1:
- text: Can I help you with something else?
buttons:
- title: mortgage assistance
payload: '/intent2'
- title: Materials cost
payload: '/intent3'
- title: Something else
payload: '/other'
utter_response2:
- text: We are tied up with xyz banks and can assist you in the process
utter_response3:
- text: Our sales executive will contact you at the earliest to help you out.
The title in buttons is what user will see in display and payload will be the intent it should trigger. You don’t have to mention anything about intent2 and intent3 in NLU file. Hope this will help you?
No Im trying to find an intelligent way to group intents and offer the related intents as buttons when a user chooses one of them. I’m aware of the approach you described but I think that would be a brute/manual approach and I would have to repeat the same code every intent over and over again. Like in your example you only added the buttons for response1 but I would want them for all 3 responses which would be cumbersome to maintain but thank you for your response.
I would suggest you to implement a custom action. Maybe you should try something like this:
In your domain.yml you should add:
- intent1:
triggers: action_blabla
- intent2:
triggers: action_blabla
- intent3:
triggers: action_blabla
And in your actions.py:
class ActionBlaBla(Action):
def name(self):
return "action_blabla"
async def run(
self,
dispatcher: "CollectingDispatcher",
tracker: "Tracker",
domain: Dict[Text, Any],
) -> List[EventType]:
previous_intent = [event['parse_data']['intent']['name'] for event in tracker.events if event['event'] == 'user'][-1]
text = domain["responses"]["utter_response_intent1"] + "\nCan I help you with something else?"
intents = domain["intents"]
intents = intents.pop(intents.index(previous_intent))
buttons = []
for intent in intents:
buttons.append({"title": "{}".format(intent), "payload": "/{}".format(intent)})
dispatcher.utter_message(text= text, buttons= buttons)
return [FollowupAction('action_listen')]
This is a more interesting approach, thanks!
Thank you @facureyes for your response. I don’t know about the trigger feature. It seems there are many features in RASA which i have to explore.
@tatianaf @sandilya45 your welcome
titiana, have you tried using Fallback Actions ?
The behavior Im describing is not a fallback. The idea is rasa classifies the user’s intent successfully and gives some response but after it gives the response, instead of just listening for the user to say something, Rasa will follow up with “Can I help you with something else?” and also offer some recommendations for topics of conversation related to the topic the user just asked about. But I don’t want to hardcode the recommendations, I want them to be dynamically generated based on the previous intent. The idea is to offer guidance to the user to keep the conversation going since the user might not know what to type next.