0

Recently when working with Lex in C#, I have referenced AWSCore.dll and AWSLex.dll and still trying to get a method that exposes all available Lexchatbots that I created in the Aamazon server.

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

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

used both methods to get all other information. Methods in request for bot name and alias is for setting and there is no method in response for getting available Lexchatbots in the server.

Chandy Kunhu
  • 66
  • 1
  • 8

2 Answers2

0

I don't believe that the Lex SDK supports this call directly.

Use the AWS Lex REST API to get a list of bots:

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

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

Cam Bruce
  • 5,632
  • 19
  • 34
  • You'll have to use a `HttpClient` to call the api. The site i linked shows you how to authenticate and the answer shows you what method to call. – Cam Bruce Jun 27 '18 at 13:19
  • I found the answer using another dll. Anyway thanks for the concern. I think it is unwanted to call HttpClient because AWS itself is providing the methods – Chandy Kunhu Jun 27 '18 at 15:19
0

After a long research I found the answer to my problem, It may help others.

First we need to add the AWSSDK.LexModelBuildingService through Nuget. This will add reference to the DLL.

From that all methods already exposed. We need to create both GetBotsRequest and GetBotsResponse methods.

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

Then we need to call lex model building service client

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

After that we can get the response of inbuilt method of GetBots()

botResponse = amazonmodel.GetBots(botRequest);

We will get the list of bots metadata

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

Every details about each bot created will be available in the array of list of bots There is almost all methods in getting details from Lex configuration in LexModelBuildingService dll

Note:

  1. In IAM (Identity Access Management) in AWS we need to give Access to have Lex components in Policy section. AWSLexFullAccess or atleast arn:aws:lex:region:account-id:bot:* access in policy
Chandy Kunhu
  • 66
  • 1
  • 8