在来自API.ai的文本响应中添加新行(\ n)

在使用Node.js模块( apiai )时,我尝试在给API查询结果的API.ai文本响应中添加新行( \n ),但是当我将响应保存在callbackvariables中时似乎不起作用喜欢这个:

 request.on('response', function (response) { var textResponse = response.result.fulfillment.speech; // ... }) 

最后我解决了这个问题:

 var textResponse = response.result.fulfillment.speech; textResponse = textResponse.replace(/\\n/g, '\n'); 

input是这样的: I'm a chatbot. \n built with ❤ I'm a chatbot. \n built with ❤

使用折线<\br>而不是\n

例如:

 <div>This is with break line<br>this is after break line</div> <div>This is with break line \n this is after new line</div>