[英]Add new line (\n) in Text Response from API.ai
在使用 Node.js 模块 ( apiai
) 时,我尝试在给定查询结果的 API.ai 文本响应中添加新行 ( \\n
),但当我将响应保存在回调变量中时,它似乎不起作用像这样:
request.on('response', function (response) {
var textResponse = response.result.fulfillment.speech;
// ...
})
最后我是这样解决的:
var textResponse = response.result.fulfillment.speech;
textResponse = textResponse.replace(/\\n/g, '\n');
输入是这样的: I'm a chatbot. \\n built with ❤
I'm a chatbot. \\n built with ❤
使用 Break-line <\\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>
我在 dialogflow 内联编辑器中使用 agent.add() 方法,并希望在某些文本之间有一个换行符。 所以我使用了" \\n"
(两个空格后跟\\n
),它根据我的 dialogflow messenger 集成的要求给出了输出。
例如。
agent.add(firstName + " " + lastName + " \\n" + phoneno);
输入响应时,按 Shift + Enter 输入换行符或仅 Enter 输入另一个文本响应。
以下限制适用:
每个文本响应最多 300 个文本条目
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.