How to connect to Amazon Lex

Modified on Sun, 8 Sep at 8:55 PM

This guide steps through the specifics of the 'out of the box' Amazon Lex Skill (integration). This Skill lets you connect to content written in or generated by an AWS Lex service. Your Soul Machines Studio Project relies on connections like this to understand the User's intent and provide a response for the Digital Person to present. This Skill can be used alongside other Skills and conversation providers.

  • It does not implement any advanced state management functionality currently, but this may be expanded in the future.

  • Only bots built through the Lex V2 console are supported.

  • Refer to the AWS documentation for how to build a bot.

  • Fallbacks are triggered if an intent named “FallbackIntent” is matched.


We support Lex V2 only


Amazon Lex is supported on Digital People running on HumanOS 2.3+.


Creating AWS Role for Lex Bot Integration

  1. Log into your AWS account where the Lex Bot is provisioned.

  2. You will need to generate an External ID that our services will use to connect to your Lex Bot, the external ID is any unique string that should be a minimum of 16 characters alpha-numeric string.

  3. Go into the IAM tab in the AWS Console and click Roles > Create Role at the top right corner.

  4. In the role creation screen, click Custom trust policy entity type and copy the below code block into the policy field, make sure to replace <Your External ID> with the string generated in step 3 and click Next.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": [
          "arn:aws:iam::924390807111:role/SM_Lex_Origin_Role"
        ]
      },
      "Action": "sts:AssumeRole",
    "Condition": {
        "StringEquals": {
          "sts:ExternalId": "<Your External ID>"
        }
      }
    }
  ]
}

5. In the Add Permissions screen, find the AmazonLexRunBotsOnly policy, select it and click Next.

6. Ensure to use the below value as the Role Name otherwise, the bot will not be reachable using this Role (this is a case sensitive value), and verify that all the other values (Aside from your external ID being different) match the code provided in step 4 and click Create Role.

SM_Lex_Access_Role

7. Once the role is created, navigate to the SM_Lex_Access_Role role under the Roles tab and you will be able to copy the Role ARN.


Connecting an AWS Lex Bot to your Digital Person

Choose Amazon Lex NLP from the Manage Conversations and Skills section of Soul Machines Studio. Refer to Creating a Project | 3. Connect conversation and add skills for detailed instructions on adding an NLP and skills to your project.

Field

Type 

Description

AWS ROLE ARN

(required)

text

Enter the ARN from step 7 above.

Format arn:aws:iam::{Account_ID}:role/{Role_Name}

EXTERNAL ID

(required)

text

Is the external ID generated in step 2 above.

LEX BOT ID

(required)

text

This is used to identify which bot to connect to. See section Lex Bot ID.

LEX BOT ALIAS ID

(required)

text

This is used to specify which version of your Lex bot you want to connect to. See section Lex Bot Alias ID.

LEX BOT LOCALE

(required)

text

This is set based on the language you want your bot to use. See this page for a list of language codes.

LEX BOT SERVICE REGION

(required)

text

AWS region code based on where your Lex bot resource has been created. See this page for a list of region codes.

Note: Make sure to use the region code. For example, you should enter ap-southeast-2 rather than the region name, Asia Pacific (Sydney).


Lex Bot ID

This is used to identify which bot to connect to. 

Lex Bot Alias ID

This is used to specify which version of your Lex bot you want to connect to.

Content Cards

To make use of SM Content Cards, use @showcards(card_name) in a message. Define the card data as a Custom payload response:


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article