Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test my published LEX bot on a REST CLIENT

I have created my lex bot and published it. I am now trying to test it out from a rest client.

The idea is once working from rest client ,i can integrate this with my custom UI using rest calls.

enter image description here

I am using this request body from posttext as per this link http://docs.aws.amazon.com/lex/latest/dg/API_runtime_PostText.html​

When i am using this from rest client i am getting Missing Authentication Token.

enter image description here

The end point url used is https://runtime.lex.us-east-1.amazonaws.com

Should i add something in the authorization header like AWS Signature or something else to make this work.

like image 648
lost Coder Avatar asked Jul 04 '17 10:07

lost Coder


1 Answers

You need to include an AWS Signature in the Authorization tab, containing the details of an IAM user that has access to run your Lex bot.

Steps: 1. In AWS go to IAM -> Users -> Add User

enter image description here

  1. Give it a Username like "myBotUser" and select an Access Type of "Programmatic access". Hit Next:Permissions.

enter image description here

  1. Hit Create Group to create a group to give permissions to the user.

enter image description here

  1. Give it a name and then filter the policies for Lex - and select "AmazonLexReadOnly" and "AmazonLexRunBotsOnly".

enter image description here

Hit Create Group.

  1. Then hit "Next: Review".
  2. Then hit "Create User" - and your IAM user is ready. You'll see an Access key ID and a Secret Access Key.

  3. In Postman, in Authorization, select AWS Signature and enter in the Access key ID and the Secret Access Key, along with an AWS Region of "us-east-1" and a Service Name of "lex":

enter image description here

  1. Make sure you're body is as required (here I'm just sending text):

enter image description here

Hit Send and you should get a response like this:

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

Update

Note also - the POST url would be in format:

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

Also make sure the header Content-Type is application/json, as is the body.

like image 67
AndyOS Avatar answered Oct 15 '22 18:10

AndyOS