gpt4 book ai didi

rest - 如何在 REST 客户端上测试我发布的 LEX 机器人

转载 作者:行者123 更新时间:2023-12-03 23:50:40 26 4
gpt4 key购买 nike

我已经创建了我的 lex bot 并发布了它。我现在正在尝试从休息客户端对其进行测试。

这个想法曾经在rest客户端上工作,我可以使用rest调用将其与我的自定义UI集成。

enter image description here

我正在按照此链接使用 posttext 中的此请求正文
http://docs.aws.amazon.com/lex/latest/dg/API_runtime_PostText.html

当我从其余客户端使用它时,我收到了缺少身份验证 token 。

enter image description here

使用的端点 url 是 https://runtime.lex.us-east-1.amazonaws.com

我应该在授权 header 中添加一些东西,比如 AWS 签名或其他东西来完成这项工作。

最佳答案

您需要在授权选项卡中包含一个 AWS 签名,其中包含有权运行您的 Lex 自动程序的 IAM 用户的详细信息。

脚步:
1. 在 AWS 中转到 IAM -> 用户 -> 添加用户

enter image description here

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

  • enter image description here
  • 点击创建组创建一个组来授予用户权限。

  • enter image description here
  • 为其命名,然后过滤 Lex 的策略 - 并选择“AmazonLexReadOnly”和“AmazonLexRunBotsOnly”。

  • enter image description here

    点击创建组。
  • 然后点击“下一步:回顾”。
  • 然后点击“创建用户” - 您的 IAM 用户已准备就绪。您将看到一个访问 key ID 和一个 secret 访问 key 。
  • 在 Postman 的授权中,选择 AWS 签名并输入访问 key ID 和 secret 访问 key ,以及“us-east-1”的 AWS 区域和“lex”的服务名称:

  • enter image description here
  • 确保您的 body 符合要求(这里我只是发送文本):

  • 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,就像正文一样。

    关于rest - 如何在 REST 客户端上测试我发布的 LEX 机器人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44903626/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com