Customize response for each user in Rasa

Hello,

I’m trying to use Rasa for my hobby project and I’ve some basic queries.

Let us say the bot is being used by 100 users. Can I use Rasa to send a custom responses to each user? I know how to customize responses in terms of NLU, but my question is handling the flow. For example if John sends 'Hi' to the bot, it should respond with 'Hi John', for Ram it should be 'Hi Ram'. I expect conversation with each user to be personalized.

One way I could think of is I will detect user inside **Custom Actions** by **sender_id** and respond accordingly through a function. But this approach will direct every conversation through custom actions rendering intents wasted as all logic resides in Custom Actions.

  1. Is Rasa only meant for those bots that give same response to every user irrespective of user?
  2. If someone designed a bot that gives personalized responses, could you please throw some light on how to approach this?

Thanks

1 Like

Yes, Rasa is designed with this type of natural conversation in mind. In your example, you would save the users name in a slot which can be used in responses throughout the conversation. There’s a blog post on forms which also discuss this and the Rasa Masterclass videos.

1 Like

Hi Stephens,

Thanks for the response!

Yes, as you pointed out, I could get user name through a slot and greet the user by name. I feel slot-filling serves the purpose to some extent. Going beyond the slots, if I wanted to make responses personalized to each user based on historical conversations, how can I achieve this in Rasa?

Let’s say one user wants to chat about Biology(which is her/his interest) and other user want to chat about physics.

So when Physics user pings the bot, bot should dig up historical conversations of this user and respond accordingly(not through slot filling). Same should happen when when Biology user pings.

As far as I know, sender_id is the only way to detect which user pinged. So, based on sender_id, I should respond to user. This is where I'm not sure how the flow should work.

Since multiple users will be chatting with the bot anytime, I need to check 'sender_id' for every message to personalize the response to each user, is my assumption correct? Is there a better way to do this, where I'll know the user identity only once at the beginning of conversation and bot responds through personalized messages for rest of the conversation, without checking 'sender_id' for very message?

Thanks

Yes, the sender_id would typically be used for this along with a data store to persist user information.

Hi @stephens, I also have the same issue. Is it possible for rasa to send different response based on the user persona? For example, suppose I have 3 age groups of user, can I respond to each age group with different responses?

Yes, the age group would typically be stored in a slot. You could then use a custom action to determine the correct response or you could make the age_group slot a featurized slot and use a story or rule to select the response.

There’s a discussion of how to do this with featurized slots and a story on the Contextual Conversations page. In that example, there’s a slot called likes_music and the response is based on that. In your case, you would create an age_group slot as a categorical slot which is discussed here.

1 Like

Hi @stephens. Thanks a lot for your reply. Just a guess, is there possibility that I can use different domain.yml which contain utterances for each group users? And when I retrieve the group index, the bot responds using utterances from the corresponding domain.yml. Besides, can response be organized in a hierarchical way, e.g. utter_response/group_1, utter_response/group_2? since I saw chitchat/ and faq/ functions in rasa before.

You could do this with utterances:

- utter_group_1
  text: xxxx
- utter_group_2
  text: yyyy

and a custom action that calls: dispatcher.utter_message(f"utter_{slot_age_group}")

Greg

1 Like