首页 > 解决方案 > 在自动驾驶仪的收集操作中添加新行

问题描述

我问我的机器人用户一系列问题,其中一些要求他们回答李克特式的问题。当我提供答案选项时,将项目放在新行上会很有帮助。

{
    "actions": [
        {
            "collect": {
                "name": "q1",
                "questions": [
                    {
                        "question": "How much does this bother you?\\n\\n1 = not at all\\n2 = somewhat\\n3 = moderately\\n4 = quite a bit",
                        "name": "q1_score",
                        "type": "Twilio.NUMBER"
                    }
                ],
                "on_complete": {
                    "redirect": "task://question_2"
                }
            }
        }
    ]
}

理想情况下,这将返回一条短信,上面写着:

How much does this bother you?
1 = not at all
2 = somewhat
3 = moderately
4 = quite a bit

但它实际返回的是:

How much does this bother you?\n\n1 = not at all\n2 = somewhat\n3 = moderately\n4 = quite a bit

我是否转义\都没关系(即既不\n也不\\n返回所需的结果)。尝试使用 URL 编码版本%0a也不起作用。

提前感谢您提供的任何见解。

标签: twilio

解决方案


Twilio 开发人员布道者在这里。

你在用模拟器吗?我相信模拟器不会显示新行,但使用\n如下所示应该生成您希望的文本:

"questions": [
                    {
                        "question": {
                            "say": "How much does this bother you? \n 1 = not at all \n 2 = somewhat \n3 = moderately \n4 = quite a bit"
                        },
                        "name": "num",
                        "type": "Twilio.NUMBER"
                    },
...

并得到

这条短信

让我知道这是否有帮助!


推荐阅读