Lex logo

Amazon Lex NLU activator

Allows using Amazon Lex V2 NLU engine as a states activator in JAICF.

Built on top of Amazon Lex V2 API Client for Java .

How Lex works

You can read how Lex works here

How to use

1. Include Lex dependency to your build.gradle

implementation("com.just-ai.jaicf:lex:$jaicfVersion")

Replace $jaicfVersion with the latest version

2. Use Lex activator in your scenario actions

state("launch") {
    activators {
        intent("BookHotel")
    }

    action(lex) {
        // Recognised named entities
        val slots = activator.slots

        // Data of recognized intent 
        val recognizedIntent = activator.recognizedIntentData
    }
}

3. Sign up in the AWS Management Console

To create an AWS account, open Aws Management sign up page and follow the online instructions.

Part of the sign-up procedure involves receiving a phone call and entering a verification code on the phone keypad.

4. Sign in Lex console

Open Lex Console and sign in. Select the second version of the console.

5. Create a bot

You can create a bot using examples or create your bot from empty. For better understanding, you can read this topic.

6. Configure Lex activator

A bot ID can be found on the main page of your bot in the “Bot Details” block. Also, to use the bot, you need to create an alias and associate it with the version of the bot. The region argument must equal the region of your bot. The locale is the language for which you are creating the bot.

To find your credentials, you need to click on your username in the upper right corner and select “My Security Credentials.” On the page that opens, select “Access keys” and click “Create new access key.” In the form that opens, select “Show access key,” then save the access key ID and secret access key.

val lexActivator = LexIntentActivator.Factory(
    LexConnector(
        LexBotConfig(
            "<bot_id>",
            "<bot_alias_id>",
            Region.EU_WEST_2,
            Locale.US
        ),
        AwsBasicCredentials.create(
            "<access_key_id>",
            "<secret_access_key>"
        )
    )
)

Slot filling

Lex provides a slot filling feature that allows your JAICF scenario to resolve the intent after all the necessary intent parameters (slots) have been received from the user. You don’t need to make special changes in your scenarios to use this feature - JAICF handles all slot filling-related logic for you.

Please note that Lex may cancel the slot fill process if the confirmation has been canceled. In this case, the decline response configured in the Lex Console will be sent and no state will be selected.