How to create response variations from a custom Action?

Hey Maria,

This is more of a Python question than a Rasa one.

random.shuffle() (try it) shuffles a list, meaning it reorganizes its items. It does not randomly take one element.

Instead, you can shuffle the list and take the first element:

dispatcher.utter_message(text = random.shuffle(response)[0])

or use random.choice() (try it) which is the method you’re looking for:

dispatcher.utter_message(text = random.choice(response))
1 Like