英文:
Amazon Lex and Connect text formatting not working as intended, works fine with other platforms
问题
文本格式似乎在直接来自 Lambda 响应的消息中运行良好,但如果它是在 Lex 设计师中编写的,它看起来就不一样。
这是 Lambda 响应,以防万一:
{
        "sessionState": {
            "dialogAction": {
                "type": "ElicitSlot",
                "slotToElicit": "test_slot"
            },
            "intent": {
                "name": "test",
                "state": "InProgress"
            }
        },
        "messages": [
            {
                "contentType": "PlainText",
                "content": "测试\ntest",
            }
        ]
    }
- 我尝试使用自定义负载,但发现 Connect 不支持此功能。
 - 尝试使用 Markdown,Lex 无法处理它,而且似乎消息中的所有文本只能写成一行。
 - 还没有尝试从 Lambda 完全执行,因为这需要大量的重做工作,而且我有最后期限。
 - 我一直在谷歌搜索,但不知道是否使用了正确的关键词,因为我似乎找不到与我的具体问题相关的任何内容,所以我在这方面浪费了很多时间。
 
英文:
Text formatting appears to work fine with any message that comes directly from a Lambda response but if it was written in the Lex designer it just doesn't look the same.
Here's the lambda response just in case:
{
        "sessionState": {
            "dialogAction": {
                "type": "ElicitSlot",
                "slotToElicit": "test_slot"
            },
            "intent": {
                "name": "test",
                "state": "InProgress"
            }
        },
        "messages": [
            {
                "contentType": "PlainText",
                "content": "test \ntest",
            }
        ]
    }
- I tried using custom payloads, realized that Connect doesn't support this.
 - Tried using markdown, Lex can't handle it, plus it appears all the text in a message can only be written as a one line.
 - Haven't tried doing everything from lambda because it requires a lot a rework and I have a deadline.
 - I have been googling a lot but I don't know if I'm not using the right words because I can't seem to find anything relating to my specific problem, so I've been wasting a lot of time with this.
 
答案1
得分: 1
The Lex console seems to escape control characters which is why \n appears for intents created/updated through the designer but is interpreted correctly for responses from Lambda hooks.
一 Lex 控制台似乎会转义控制字符,这就是为什么通过设计师创建/更新的意图中会出现 \n,但对于来自 Lambda 钩子的响应会被正确解释的原因。
One thing you can try is calling the API directly; for example, if you call DescribeIntent for that intent you will see the escaped characters (Puedes preguntar sobre los siguientes temas: \\n1). You can then use UpdateIntent to update the message with the correct, unescaped characters.
您可以尝试的一件事是直接调用 API;例如,如果您调用 DescribeIntent 来查看该意图,您将看到转义字符 (Puedes preguntar sobre los siguientes temas: \\n1)。然后,您可以使用 UpdateIntent 来更新消息以包含正确的未转义字符。
英文:
The Lex console seems to escape control characters which is why \n appears for intents created/updated through the designer but is interpreted correctly for responses from Lambda hooks.
One thing you can try is calling the API directly; for example, if you call DescribeIntent for that intent you will see the escaped characters (Puedes preguntar sobre los siguientes temas: \\n1). You can then use UpdateIntent to update the message with the correct, unescaped characters.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。



评论