Bias the random selection of multiple text utterences

If I have multiple text messages under utter_greet template as example hi and good morning, is there any Way I can bias these messages according to user greeting. As example if user says hi or hey, reply with hi, and if user says good morning, reply with good morning and so on.

Hi @durashi, no that is not possible. The response is selected randomly from the text messages you defined. You cannot add a bias or anything similar.

Since its a list could one not simply repeat some of the entries. That should work as a bias.

@IgNoRaNt23 True, that should also work.

Thank you @Tanja and @IgNoRaNt23 for the early replies. What I mean by bias is to give the most suitable response for the user greeting. I don’t get any idea to do that rather than splitting the greet intent to separate intents. I need to know whether there is any other method available to do that with one intent:greet

So for example if the user says ‘good morning’ you want to give ‘good morning’ back?

In that case write a custom action that is executed instead of just the utterance. Within the action you may look for keywords for example and give back a suitable message.

Yeah that is a good solution. Greet is just an example I’m getting here. I need to do that in several intents. In that case I should write custom actions for each. Is there any better way to achieve that, I mean to write a custom policy or something like that?

Custom actions should be the simplest way, would recommend to try that.

Thank you so much. I have written a custom action for greet and it’s working fine.:blush:


This post is quite old but I guessed that the random choice is here :

def random_template_for(self, utter_action: Text) -> Optional[Dict[Text, Any]]: import numpy as np

    if utter_action in self.templates:
        print("several utterance instances ! What should I choose...")
        return np.random.choice(self.templates[utter_action])
        return None

Could it be possible to change the behaviour of this funct so it learns what is the best utterance example to provide according to : intents-entities/slots/dialog history/policy selection… ? For example calling a meta-action in every story, according to previous features, that will modify the very core of the random-utterance choice so the best example is provided ?


Guess something like this could be done with the ResponseSelector