如何在REST CLIENT上测试我发布的LEX机器人

问题描述 投票:13回答:1

我创建了我的lex bot并发布了它。我现在正试图从其他客户端测试它。

这个想法一旦从休息客户端工作,我可以使用其他调用将其与我的自定义UI集成。

enter image description here

我正在使用来自posttext的请求正文,根据此链接http://docs.aws.amazon.com/lex/latest/dg/API_runtime_PostText.html

当我从休息客户端使用此功能时,我将收到Missing Authentication Token。

enter image description here

使用的终点网址是https://runtime.lex.us-east-1.amazonaws.com

我是否应该在AWS Signature等授权标头中添加一些内容以使其工作。

rest amazon-web-services amazon-lex
1个回答
10
投票

您需要在“授权”选项卡中包含AWS签名,其中包含有权运行Lex bot的IAM用户的详细信息。

步骤:1。在AWS中转到IAM - >用户 - >添加用户

enter image description here

  1. 给它一个像“myBotUser”这样的用户名,并选择“程序访问”的访问类型。点击下一步:权限。

enter image description here

  1. 点击“创建组”以创建一个组以向用户授予权限。

enter image description here

  1. 给它命名,然后过滤Lex的策略 - 并选择“AmazonLexReadOnly”和“AmazonLexRunBotsOnly”。

enter image description here

点击创建组。

  1. 然后点击“下一个:评论”。
  2. 然后点击“创建用户” - 您的IAM用户已准备就绪。您将看到Access密钥ID和秘密访问密钥。
  3. 在邮递员的授权中,选择AWS签名并输入访问密钥ID和秘密访问密钥,以及AWS地区“us-east-1”和服务名称“lex”:

enter image description here

  1. 确保你的身体是必需的(这里我只是发送文字):

enter image description here

点击发送,您应该得到这样的回复:

{
    "dialogState": "Fulfilled",
    "intentName": "yourIntentName",
    "message": "A response for that intent",
    "responseCard": null,
    "sessionAttributes": {},
    "slotToElicit": null,
    "slots": {}
}

更新

另请注意 - POST网址格式为:

https://runtime.lex.us-east-1.amazonaws.com/bot/MyBotName/alias/myMyAlias/user/aUniqueUserID/text and it should be a POST

还要确保标题Content-Type是application / json,身体也是如此。

© www.soinside.com 2019 - 2024. All rights reserved.