Feature request - Utterance Templates

I have a chatbot (an FAQ bot) which has a lot of long utterances. Not horribly long, but still not 5 words (like 100-150 words) since answers are somewhat convoluted. I would like it if I could break it in two or three messages without messing with the bot’s logic. I remember not so long ago being able to send a message to my front-end channel in the form

“Here is the answer. \n\n The answer to your question is 42.”

and the front-end channel would have interpreted this as two messages split at the location of the \n\n, but this is not ideal if you manage multiple channels. What would be ideal is if there was a way to add in the domain’s template section a utterance format that contains a list of utterances.

Big issue with this : the current use of the list for templates is to randomly select an element of the list, not to send them all one after the other.

I am thinking of implementing this feature now, but it would sum up to a custom action that would look into a yaml file like this :slight_smile:

utter_FAQ_answer_question_number_1:
- FAQ_q1_answer_part_1
- FAQ_q1_answer_part_2
utter_FAQ_answer_question_number_2:
- FAQ_q2_answer_part_1
- FAQ_q2_answer_part_2
- FAQ_q2_answer_part_3
...
utter_FAQ_answer_question_number_5:
- Here is the answer.
- The answer to your question is 42.

and match the utterance name (say “utter_FAQ_answer_question_number_5” with a list of utterances [“FAQ_q5_answer_part_1”, “FAQ_q5_answer_part_2”]. I am not quite sure how easy it would be, but here’s my question:

What would be the “RASA-style” way of doing this with the current following versions of RASA? (i.e. a single action, templated or not, that writes multiple messages in the front-end channel)

Rasa Core : 0.13.0
Rasa Core SDK : 0.12.1
Rasa NLU : 0.14.1

You can split the utterances into multiple actions i suppose

  • Intent_FAQ_q1
  • utter_FAQ_q1_answer_part_1
  • utter_FAQ_q1_answer_part_2

I precisely said “without messing with the bot’s logic”. I am totally aware of your solution, but I am trying to avoid that. I don’t see why I should break into two parts something that is really meant to be one thing. I just want the UI to display them as two messages, that’s it. It’s really “one action”. Because what might otherwise happen is that the first half of the message gets sent, something happens in the bot’s logic in between and the second half doesn’t get sent. I definitely want to avoid that. To do so, my question describes the idea I currently have, but it feels a bit too much for something so simple as sending two messages at once…

1 Like

Ok. Not sure if there’s a Rasa way to do what you are seeking as that is what you mentioned in the end of your question. we implemented logics like this with rasa by splitting the actions and creating a delay and it worked for us. but nevertheless, I suppose you are seeking for a queque based templating system for bot responses. Not sure if it exists already.

@akelad maybe you can help.

@PatrickDS could you not have a custom action that has multiple dispatcher.utter_template(...) methods after one another?

@akelad : Yes, but wouldn’t that be a pain if it happens often? I would save a lot of time if say for instance I could implement a custom template where instead of writing utter_example_part1: text: Hi! utter_example_part2: text: How are you?

I could write

utter_example: text: part1: Hi! part2: How are you?

I know I can do it with custom actions, but it really feels like overkill to make a call to the action server just because I want to send two messages in a row… It should be simpler and easier to manage in my opinion (of course that’s my opinion). I’ve read the library quite a lot so I’m fine with doing a PR if it makes sense but I wanted to check with the community how they deal with it.

I mean one way is with the \n\n method, or adding it to the stories, or doing it in the custom actions. I’m not sure we’ll add the “part” thing to our library because we haven’t really seen this issue come up much – the existing methods seem to work fine.

Okay, I guess I’ll write something myself then. The \n\n method is not working for us in some front-ends, and I don’t want to have to edit all the front-ends I work with, I’d rather just send two (or more) messages. What I plan to do for now is to do something like

utter_example:

  • text:
    • part: Here is how we’re going to do this.
    • part: First, you’re going to read this message.
    • part: Then, you’re going to read this one.
  • text:
    • part: Here is how we’re going to do this, my friend!
    • part: First, you’re going to read this nice message!
    • part: Then, you’re going to read this other one!

So it’ll select randomly between the many options like before, but it’ll utter each of the messages one by one. I’ll put this on my to-do list at some point… maybe a future PR? who knows! Or maybe I should make a request to the repository. I’ll think about it over the weekend

@akelad wouldn’t it be useful to define a standard boundary marker for the dispatcher and have it do the message splitting? Just like Patrick, I’ve come across the same issue with front-ends displaying "\n\n" sequences differently, and it can be problematic.

@PatrickDS perhaps you could write a customised dispatcher that allows you to spit utternaces on some particular boundary (be that “\n\n” or something else) into multiple messages to the output channel.

I’ve seen a similar method, implemented at a lower level (custom output channel) as part of Scalablemind’s chatroom interface to Rasa. They split the utterance on "\n\n" boundaries into multiple messages. As far as I can tell doing the split in the dispatcher, rather than in any particular channel, should allow this to work across multiple front-ends.

Thanks @netcarver, that sounds like a reasonable approach! This way I don’t have to change the way Rasa loads my data from the domain and it’s just about how to send messages to the front-end. I will give it a try! This is also a much more reasonable edit than the one I suggested.

That’s actually a great idea :slight_smile: would you be willing to submit a PR?

1 Like

@akelad : It’s on my to-do list, I’ll definitely get in touch with Rasa (via message, the forum or a PR) if I have any progress!

Any update on this PR

Facing the same issue would love to have this feature

Hi Aditya,

I gave some thought into it to see if I could do the PR, but I think the problem to solve is that the solution is dependent of the front-end implementation of your bot. It’s definitely possible to change the response of the bot to being a list of messages instead of a single message, but your front-end has to be ready to receive a list, also in the case where one message is sent. That, or the back-end has to respond multiple times to the HTTP request asking the bot for a reply. So a discussion with Rasa would be necessary to decide what would be the best solution for the Rasa Framework.

Who should we discuss with? @akelad would you know?