Domain Template Variations

Hi. I recently started using Rasa. My question is about defining multiple responses for an utterance in domain template section and later on access the specific response randomly chosen in the custom actions.

While latest_action = state.get("latest_action_name") can be used to know the last triggered action, how can I extract the specific response that the bot chose and responded for the chosen utterance? Thanks!

I don’t think the specific utterance is actually stored in the tracker. The idea behind the multiple utterances per template is that they shouldn’t matter for the story logic, they’re randomly chosen to provide some variety. If your bot is going to do something different based on the utterance it chose, those utterances should not be under the same utter_{} template.

1 Like

Thanks for the response @erohmensing. I understand from your response that the random utterance message isnt stored in the tracker. I have an intent for which I need to trigger both an utternance(with multiple responses to choose from) and a custom action. I need access to the utterance response in the custom actions so that I can perform an action with it. Are there any workarounds for this?

I don’t think so – I think the work around would be splitting the “random” utterances into differently named utterances, and then moving the logic of what you do depending on which utterance earlier, to choose the correct utterance in the first place.

1 Like

@avinash1, here’s a possible work-around: as you already have an action being triggered by a story, you could opt to have the start of the action randomly choose from a pool of utterances and send that off to the user via the dispatcher. Your action handler would then know what utterance was, and you can act accordingly.

1 Like

Thanks for your response. I used a similar workaround where I had a list of utterances and randomly chose one in the custom action.

I still feel that it would be nice to have the variant utterance information in the tracker.