Is it possible to apply formatting to bot responses that comes from custom actions?
I can’t figure out how to do things like linebreak, bold, italic, bullets, when the response comes form python code.
I’m also looking for documentation on the formatting syntax for Rasa X.
In the UI I can format the test with this markdown-like syntax:
I’m not sure what you mean by responses that come from custom actions, but i will try to answer in 2 situations:
Situation 1: Responses are constructed with Python string in custom actions
Just format the response with new line character ‘\n’ or tab character ‘\t’. You can use the format function of Python string to make it easier with variables, e.g: “This is what {} ordered:\n \t- {}\n \t-{}\n”.format(name, item1, item2) results in something like:
This is what Fuih ordered:
- Playstation 4
- Nintendo switch
Situation 2: Responses are defined as template in domain.yml
You can use the character ‘|’ to indicate that every line in the template will be append the new line character (this is yaml format).
text: |
This is what {name} ordered:
- {item1}
- {item2}
This results in:
This is what Fuih ordered:
- Playstation 4
- Nintendo switch
Unfortunately i don’t remember how can you create tab character in yaml.
That’s weird. I used Rasa X client before and the new line character ‘\n’ worked normally back then. Is it the same with the “Talk to your bot” tab ? I have never tried the share client, wonder if they are the same.
Edit: I realised that the responses are saved in a .yaml file, so thats it.
TL:DR, for new lines use \n in custom actions and the yaml markdown formatting in rasa x. But it might not work for everything.
I’m still looking for the documentation of the syntax for editing responses. Anyone?
If you are using custom actions, the sentence first line \n\n second line will be displayed in two different messages, if you wish to display them in the same message but in the different lines, do the following first line \n \n second line