Type: NLP Worker
A Lex worker takes user input and sends it to a lex bot for natural language processing. A lex worker can be created through the CLI or through the Add Resource
button on a bot’s detail page.
An AWS cross-account role is required in order to access Lex. Please see cross-account roles for more information.
Save this json to a file and create a worker using the cli command sb-cli worker create file.json
{
"Data": {
"lexConfig": "srn:vault::organization:aws-cross-account-role:secretalias",
"region": "eu-west-1",
"botAlias": "exampleLexWorker",
"botName": "exampleLexWorker"
},
"Organization": "Organization",
"Config": {
"Avatar": "default-bot"
},
"Enabled": true,
"Description": "An amazing Lex Worker",
"Type": "r2-lex-worker",
"Name": "exampleLexWorker",
"Status": "published",
}
Once you have created the worker using the CLI, it will return an ID for you. You need to then update/create a bot and place the filter worker at the top with the id and the type of r2-lex-worker
If you’re using sb-intents and want to sync the responses with lex you need to set the Data.syncResponsesToNLP to true. A sample worker config is below.
{
"Data":{
"syncResponsesToNLP":true,
"lexConfig": "srn:vault::organization:aws-cross-account-role:secretalias",
"region": "eu-west-1",
"botAlias": "exampleLexWorker",
"botName": "exampleLexWorker"
},
"Organization": "Organization",
"Config": {
"Avatar": "default-bot"
},
"Enabled": true,
"Description": "An amazing Lex Worker",
"Type": "r2-lex-worker",
"Name": "exampleLexWorker",
"Status": "published",
}
If you want to set a custom confidence threshold you can use the below payload. Whats required here is the Data.nluIntentConfidenceThreshold, this needs to be set to a value between 0 and 1. If you want to test the confidence score of your utterance you can do this via the CLI using the dry run command.
sb-cli nlu dr --bot <YOUR_BOT_NAME> -u "<YOUR_UTTERANCE>" -d
{
"Data":{
"nluIntentConfidenceThreshold": 0.7,
"lexConfig": "srn:vault::organization:aws-cross-account-role:secretalias",
"region": "eu-west-1",
"botAlias": "exampleLexWorker",
"botName": "exampleLexWorker"
},
"Organization": "Organization",
"Config": {
"Avatar": "default-bot"
},
"Enabled": true,
"Description": "An amazing Lex Worker",
"Type": "r2-lex-worker",
"Name": "exampleLexWorker",
"Status": "published",
}