How to get linebreaks in the utterance?

I have some utterances with line breaks in them, which are nicely displayed in the online training, but when I am picking up the messages by using latest_bot_utterance, then those are returned without the line breaks.

Is there any way to preserve the line breaks?

So the newlines are stripped when you get it from the tracker? are you printing them to stdout? I’m looking at the BotUttered event which sets this

but can’t see any reason why newlines would be stripped. Do you have a reproducible example?

Yes, I was looking at the source code too, hoping to find where the line breaks are being lost, but couldn’t find it. Funny thing is that in online training mode the line breaks are there.

Unfortunately I don’t have a fully reproducable example, but basically I subclass the DialogueStateTracker and then use the current_state() method to pick up all earlier events and from there I pick up all the bot-events and their texts:

class MyDialogueStateTracker(DialogueStateTracker):


def get_bot_messages(self):

    events = self.current_state(should_include_events=True)['events']

    # create a list of all 'bot' events from the end of the events, but only
    # the ones after the last 'user' event, or if there was no such (eg first bot message)
    latest_bot_utterances = []
    for e in reversed(events):

        # if this is the bot's message, then it gets added to the list
        # (but only with its 'text' and 'data' attributes)
        if e['event'] == 'bot':
                'text': e['text'],
                'data': e['data']

        # if we hit a user event, then we exit
        if e['event'] == 'user':

    # we need to reverse the list, so its messages are returned in their chronological order
    return list(reversed(latest_bot_utterances))

By the time I pick up the ‘text’ attributes from the events, the line breaks are already missing.