0

最近在 C# 中使用 Lex 时,我引用了 AWSCore.dll 和 AWSLex.dll 并且仍在尝试获取一种方法来公开我在亚马逊服务器中创建的所有可用 Lexchatbots。

  var amazonPostRequest = new Amazon.Lex.Model.PostContentRequest();

  var amazonPostResponse = new Amazon.Lex.Model.PostContentResponse();

使用这两种方法来获取所有其他信息。请求机器人名称和别名的方法用于设置,没有响应方法用于在服务器中获取可用的 Lexchatbots。

4

2 回答 2

0

我不相信 Lex SDK 直接支持这个调用。

使用 AWS Lex REST API 获取机器人列表:

GET https://<your aws region endpoint>/bots/

https://docs.aws.amazon.com/lex/latest/dg/API_GetBots.html

于 2018-06-26T16:21:28.423 回答
0

经过长时间的研究,我找到了问题的答案,它可能对其他人有所帮助。

首先,我们需要通过 Nuget 添加 AWSSDK.LexModelBuildingService。这将添加对 DLL 的引用。

从那里所有的方法都已经暴露了。我们需要创建 GetBotsRequest 和 GetBotsResponse 方法。

var botRequest = new Amazon.LexModelBuildingService.Model.GetBotsRequest();
var botResponse = new Amazon.LexModelBuildingService.Model.GetBotsResponse();

然后我们需要调用lex模型构建服务客户端

var amazonmodel = new AmazonLexModelBuildingServiceClient("YourAccesKeyId","YourSecretAccessKey",Amazon.RegionEndpoint.USEast1);

之后我们可以得到 GetBots() 的内置方法的响应

botResponse = amazonmodel.GetBots(botRequest);

我们将获得机器人元数据列表

List<Amazon.LexModelBuildingService.Model.BotMetadata> bots = botResponse.Bots;

关于创建的每个机器人的每个细节都将在机器人列表的数组中可用几乎所有的方法都可以从 LexModelBuildingService dll 中的 Lex 配置中获取细节

笔记:

  1. 在 AWS 的 IAM(身份访问管理)中,我们需要授予访问权限以在策略部分拥有 Lex 组件。AWSLexFullAccess 或至少 arn:aws:lex:region:account-id:bot:* 策略中的访问
于 2018-06-27T15:32:45.923 回答