AWS Lex Lambda使用Python返回多行

AWS Lex Lambda使用Python返回多行

问题描述:

我一直在阅读AWS Lex/Lambda文档并查看示例. 我看不到返回多行的方法.

I've been reading the AWS Lex / Lambda docs and looking at the examples. I don't see a way to return multiple lines.

我想创建一个意图,当用户键入帮助"时,它会为我提供如下输出.

I want to create an intent that when a user types 'Help' It gives me an output like below.

Options:
  Deploy new instance.
  Undeploy instance.
  List instances.

我已经尝试过了:

def lambda_handler(event, context):
    logger.debug('event.bot.name={}'.format(event['bot']['name']))
    a = {
        "dialogAction": {
        "type": "Close",
        "fulfillmentState": "Fulfilled",
        "message": {
            "contentType": "PlainText",
            "content": "Options: \nDeploy instance.\nUndeploy instance."
        }
      }
    }
    return a

如何向用户显示消息完全取决于您使用的输出通道.

How a message is displayed to the user completely depends on the output Channel you are using.

\n在我所知道的Facebook和Slack中都能很好地工作.

\n works well in Facebook and Slack that I know of.

Lex控制台测试聊天具有用于显示Lex输出的独特格式,因此它对于测试消息的格式不是很可靠.它仅对快速测试有效,以确保您的机器人能够正确响应.并一窥Lex JSON响应.

The Lex Console Test Chat has its own unique formatting for displaying the Lex output, so its not very reliable for testing the formatting of a message. Its really only good for quick tests to make sure your bot responds without errors. And for a glimpse at the Lex JSON response.

每个输出Channel将接收Lex JSON响应并以其自己的方式显示,因此测试消息格式,链接,图像和响应卡的唯一可靠方法是在实际Channel中对其进行测试.

Each output Channel will receive the Lex JSON response and display it in its own way, so the only reliable way to test message formatting, links, images, and response cards is to test it in the actual Channel.