Imagine if there were absolutely no line breaks in this post. It would make for very hard reading, wouldn’t it? Unfortunately, Dialogflow’s built in web demo doesn’t allow line breaks. As a result, it is very hard to show multi-line responses nicely in the integration.
In this post, I will explain briefly how you can add line breaks in your website chatbot.
You need to understand and implement the system explained in the Rich Webchat article.
The process for adding line breaks is simple. Just add the line break into your Dialogflow text response.
If you didn’t know how, you just need to use SHIFT + ENTER and you will notice that Dialogflow automatically creates those line breaks for you.
When you get the corresponding response JSON, you see the line breaks inside the JSON. (These are not visible in the test console or the web demo integration though).
And best of all, most of the Markdown parser can automatically handle the “\n” as a line break, so there is nothing more for you to do!