Plugin Documentation

LexBot
Amazon Lex V2 conversations for Blueprints and C++

Conversational NPCs, companions and voice commands: send what the player types or says to an Amazon Lex V2 bot and get messages, intents, slots, sentiment and spoken replies back — built on the official AWS SDK for C++.

v1.0
UE 4.27 & 5.8
Win64, Linux & Android
90 Blueprint nodes
Category Networking
Alpha XP

Overview

LexBot connects Unreal Engine 4.27 and 5.8 to the Amazon Lex V2 runtime. Design the conversation in the Lex console (intents, slots, prompts, Lambda fulfillment), then let players talk to it with typed text or the microphone. Requests run on background worker threads with automatic retries; every result arrives on the game thread.

  • Recognize Text: text in — messages, intent with slots, interpretations with NLU confidence, sentiment, session state and dialog action out.
  • Recognize Utterance: 16-bit PCM speech in (any rate, converted to 16 kHz mono), what Lex heard plus an optional spoken reply as a playable sound wave.
  • Put / Get / Delete Session: start at an intent, pre-fill slots, set attributes, read or end a session.
  • LexBot Conversation component: session id per NPC, turn queue, microphone with voice-activity detection (Win64, Android), automatic reply playback, events for messages, intent changes, filled slots and the end of a conversation.
  • Session-state builders, response helpers (card buttons, message text, SSML stripping), locale mapping from the game culture, WAV and PCM helpers.
Request / response onlyLexBot uses RecognizeText, RecognizeUtterance and the session operations. They work over HTTP/1.1 on every platform, including Linux and Android where the engine's libcurl has no HTTP/2. The streaming StartConversation operation is not used.

Requirements

RequirementDetails
Unreal Engine4.27 and 5.8
PlatformsWin64, Linux and Android. Microphone capture: Win64 and Android (Linux: send audio with Send Audio / Recognize Utterance).
ModulesLexBot (Runtime), LexBotSdk (prebuilt AWS SDK for C++ 1.11.916 in Source/ThirdParty)
DependenciesThe engine's AndroidPermission plugin (enabled by default) for the Android microphone permission. On Linux and Android the SDK uses the engine's libcurl, OpenSSL and certificate store.
AWSAn AWS account and an Amazon Lex V2 bot with a built locale and an alias. Lex and Cognito usage is billed by AWS.

Installation

  1. Install LexBot from Fab into your engine, or copy the LexBot folder into your project's Plugins folder.
  2. Enable LexBot in Edit > Plugins and restart the editor.
  3. Open Project Settings > Plugins > LexBot and set Region, Identity Pool Id, Default Bot Id, Default Bot Alias Id and Default Locale Id.
  4. C++ only: add PublicDependencyModuleNames.Add("LexBot"); to your Build.cs.
Several AWS plugins in one projectEach Alpha XP cloud plugin carries its own copy of the SDK under a plugin-specific name, so they install side by side without conflicts.

Setting up AWS

  1. In the Amazon Lex V2 console create a bot, add your intents and slots, and Build the locale. Note the Bot ID (10 characters) and the region.
  2. Create an alias for the version you ship (Bots > Aliases). For testing, the built-in draft alias TSTALIASID works.
  3. Optional: enable sentiment analysis on the alias to fill Interpretation.Sentiment, and set a Polly voice on the locale for spoken replies.
  4. In Amazon Cognito create an identity pool (guest access if players talk to the bot before signing in) and give its role permission to talk to your bot alias only:
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": [
      "lex:RecognizeText",
      "lex:RecognizeUtterance",
      "lex:PutSession",
      "lex:GetSession",
      "lex:DeleteSession"
    ],
    "Resource": "arn:aws:lex:us-east-1:123456789012:bot-alias/ABCDEFGHIJ/TSTALIASID"
  }]
}

List one ARN per alias (bot-alias/<bot id>/<alias id>). Drop lex:PutSession if players must not change the session state themselves.

Never ship access keysStatic keys in the settings end up in DefaultGame.ini and in packaged games. Use them only for development and dedicated servers; players should always use the identity pool. Shipping builds refuse settings keys unless Allow Static Keys In Shipping is enabled.

Quick start

Typed chat with an NPC

  1. Add the LexBot Conversation component to the NPC actor (leave Bot Id empty to use the settings).
  2. When the player submits text, call Send Text on the component.
  3. Bind On Bot Message: show Get Message Text in the dialogue widget. For cards (Is Response Card), make buttons from Get Card Buttons and send the button's Value with Send Text.
  4. Bind On Conversation Ended: when Reason is Fulfilled, read the slots of Intent (Get Slot Value) and run the game action — open a shop, give a quest, spawn a vehicle.

Voice commands

  1. Android: call Request Microphone Permission once.
  2. Set the component's Response Audio to PCM 16 kHz (sound wave) if the NPC should answer out loud.
  3. On a key press call Start Microphone. The recording is sent when the player stops speaking; On Transcript shows what Lex heard and the reply plays automatically.

Without the component

Use Generate Session Id once per conversation and call Recognize Text with it on every turn. Response > Session State > Intent holds the slots; Is Conversation Ended tells you when the bot closed the intent.

Conversation component

ULexBotConversationComponent keeps one conversation: the session id (a new GUID per component, Reset Conversation starts over), the current intent and its slots, session attributes (sent with the next turn after you change them) and request attributes (sent with every turn). Turns sent while the bot is answering are queued.

EventParametersWhen
On Bot Message EventMessage, IndexOnce per message of a turn: plain text, SSML, custom payload or image response card.
On Intent Changed EventIntent, Previous Intent NameThe bot recognized another intent.
On Slot Filled EventSlot Name, SlotA slot of the current intent got a new value.
On Conversation Ended EventReason (Fulfilled / Failed / Closed), IntentThe dialog action is Close.
On Response EventResponseAfter the other events of every turn.
On Transcript EventTextWhat Lex heard (speech) or the text sent.
On Error EventErrorAWS errors, NoSpeech, MicrophonePermission, Unsupported, CaptureFailed.
On Speech Started / Ended Event—Voice-activity detection of the microphone.
On Response Audio Finished Event—A reply played by the component finished.

Microphone settings on the component: Silence Threshold (RMS), Silence Timeout Seconds, Max Utterance Seconds, No Speech Timeout Seconds, Microphone Gain, Auto Send On Silence and Stop Audio When Listening (barge-in). Audio is converted to 16 kHz mono (or 8 kHz with the Microphone Sample Rate setting); half a second before speech starts is kept so the first syllable is not cut.

Node reference (90 nodes)

Latent nodes run in the background, can be stopped with Cancel on their return value and fire exactly one final pin on the game thread. Empty Bot Id / Bot Alias Id / Locale Id inputs use the project settings.

Conversation (latent)

NodeInputsOutputsPurpose
Recognize Text LatentInput Text, Session Id, Bot Id, Bot Alias Id, Locale Id, Send State, State, Request AttributesOn Success / On Failure (Response, Error)One text turn (RecognizeText).
Recognize Utterance LatentPcm Audio, Sample Rate, Session Id, Response Audio, Num Channels, Bot ids, Send State, State, Request AttributesOn Success / On Failure (Response, Error)One spoken turn (RecognizeUtterance); Response.Sound is the spoken reply with Response Audio = PCM.
Recognize Text With Voice Reply LatentInput Text, Session Id, Response Audio, Bot ids, Send State, State, Request AttributesOn Success / On FailureText in, spoken reply out (RecognizeUtterance with text input).
Recognize WAV File LatentWav File Path, Session Id, Response Audio, Bot idsOn Success / On FailureSends a 16-bit PCM WAV file as speech.

Session (latent and helpers)

NodeInputsOutputsPurpose
Put Session LatentSession Id, State, Bot Messages, Response Audio, Bot ids, Request AttributesOn Success / On Failure (Response, Error)Sets intent, slots, attributes and dialog action; optionally makes the bot say Bot Messages.
Get Session LatentSession Id, Bot idsOn Success / On FailureReads the session: intent, slots, attributes, last messages and interpretations.
Delete Session LatentSession Id, Bot idsOn Success / On FailureEnds the session on the bot.
Make Session State PureIntent Name, Slots (name -> value), Session Attributes, Dialog Action, Slot To ElicitSession StateQuick builder for Put Session or the State inputs.
Make Slot Value PureValue, Original Value, Resolved ValuesSlotA filled scalar slot.
Make List Slot Value PureValuesSlotA filled List slot.
Make Intent PureName, Slots, State, Confirmation StateIntentAn intent with typed slots.
Set Intent Slot PureIntent, Slot Name, SlotIntentCopy of an intent with one slot set.
Make Dialog Action PureType, Slot To Elicit, Elicitation StyleDialog ActionWhat Lex does next.
Make Active Context PureName, Attributes, Time To Live Seconds, Turns To LiveActive ContextEnables follow-up intents.
Make Runtime Hint PureIntent Name, Slot Name, PhrasesRuntime HintPhrases that improve recognition of one slot (item or character names).
Session State To JSON PureStateReturn ValueLex V2 JSON of a session state (save, log).
Session State From JSON PureJsonState, Return ValueReads a session state from Lex V2 JSON.
Generate Session Id Callable—Return ValueNew random session id (lower-case GUID).
Decode Lex Header PureEncodedReturn ValueBase64 + gzip decoding of utterance headers.
Encode Lex Header PureTextReturn ValueGzip + base64 encoding Lex expects in utterance headers.

Response helpers

NodeInputsOutputsPurpose
Get Message Text PureMessageReturn ValuePlain text, SSML without tags, card title + subtitle or the custom payload.
Join Messages PureMessages, SeparatorReturn ValueReadable text of all messages.
Is Response Card PureMessageReturn ValueTrue for image response cards.
Get Card Buttons PureMessageButtonsButtons of a card (Text + Value).
Get Messages Of Type PureMessages, TypeMessagesFilters messages, for example Custom Payload only.
Intent State To Text PureStateReturn Value"InProgress", "Fulfilled"...
Dialog Action Type To Text PureTypeReturn Value"ElicitSlot", "Close"...
Get Slot Value PureIntent, Slot NameValue, Return ValueInterpreted value of a slot.
Get Filled Slot Names PureIntentReturn ValueNames of the slots with a value.
Get Top Interpretation PureResponseInterpretation, Return ValueThe interpretation Lex chose, with NLU confidence and sentiment.
Find Interpretation PureResponse, Intent NameInterpretation, Return ValueThe interpretation of one intent.
Is Conversation Ended PureResponseReason, Return ValueTrue when the dialog action is Close; Reason Fulfilled / Failed / Closed.
Strip SSML PureSsmlReturn ValueRemoves tags, decodes entities.

Locale

NodeInputsOutputsPurpose
Locale From Culture PureCulture (empty = current)Return Valueen-US -> en_US, de -> de_DE, es-MX -> es_419, zh-Hant -> zh_HK.
Get Supported Locales Pure—Return ValueLex V2 locale ids.
Is Supported Locale PureLocaleReturn ValueTrue for a listed locale id.

Conversation component

NodeInputsOutputsPurpose
Send Text CallableTextReturn ValueQueues a text turn.
Send Audio CallablePcm, Sample Rate, Num ChannelsReturn ValueQueues a spoken turn.
Is Waiting For Response Pure—Return ValueA turn is on its way or queued.
Reset Conversation CallableDelete On Server—New session id, no intent; attributes are re-sent.
Sync Session From Server Callable—(On Response / On Error)Get Session into the component's state.
Get Session Id Pure—Return ValueThe current session id.
Set Session Id CallableNew Session Id—Continues another session.
Set Bot CallableNew Bot Id, New Bot Alias Id, New Locale Id—Switches the bot.
Get Current Intent Pure—Return ValueIntent with slots.
Get Slot Value PureSlot NameValue, Return ValueSlot of the current intent.
Get All Slots Pure—Return ValueAll slots of the current intent.
Get Dialog State Pure—Slot To Elicit, Return ValueIdle, Waiting For Bot, Listening, Eliciting Intent / Slot, Confirming, Processing, Ended.
Get Last Transcript Pure—Return ValueWhat Lex heard last.
Get Last Response Pure—Return ValueThe full last response.
Get Conversation History Pure—Return ValuePlayer and bot lines (up to Max History).
Clear History Callable——Forgets the history.
Get Session Attributes Pure—Return ValueAttributes shared with the bot.
Set Session Attribute CallableKey, Value—Sent with the next turn.
Remove Session Attribute CallableKey—Removes one attribute.
Clear Session Attributes Callable——Removes all attributes.
Set Request Attribute CallableKey, Value—Sent with every turn, not stored by Lex.
Clear Request Attributes Callable——Stops sending request attributes.
Start Microphone CallableDevice IndexReturn ValueRecords the player with voice-activity detection.
Stop Microphone Callable—Return ValueStops and sends the utterance.
Cancel Microphone Callable——Stops and discards.
Is Microphone Active Pure—Return ValueTrue while recording.
Get Input Level Pure—Rms, PeakSmoothed microphone level for meters.
List Capture Devices Callable—Return ValueAudio input devices.
Play Response Audio CallableSound (None = last reply)Return Value (Audio Component)Plays a reply 2D or at the owner.
Stop Response Audio Callable——Stops the reply.
Is Playing Response Pure—Return ValueTrue while a reply plays.

Audio and microphone

NodeInputsOutputsPurpose
Create Sound Wave From Pcm CallablePcm, Sample Rate, Num ChannelsReturn ValuePlayable sound wave from 16-bit PCM.
Load WAV As PCM CallableFile Path, Target Sample RatePcm, Problem, Return Value16-bit WAV to mono PCM at the target rate.
Save PCM As WAV CallablePcm, Sample Rate, Num Channels, File PathReturn ValueWrites a WAV file.
Resample PCM16 PurePcm, In Sample Rate, In Num Channels, Out Sample RateReturn ValueMono conversion with linear resampling.
Is Microphone Supported Pure—Return ValueWin64 and Android.
Has Microphone Permission Pure—Return ValueAndroid RECORD_AUDIO granted.
Request Microphone Permission Latent—On Granted / On DeniedAndroid permission dialog (Win64: granted).
Get Pcm Data Pure(LexBot Sound Wave)Return ValueThe reply's 16-bit PCM.
Get Spoken Text Pure(LexBot Sound Wave)Pcm Rate, Return ValueText the reply speaks, and its sample rate.

Config, identity, JSON

NodeInputsOutputsPurpose
Set Region CallableRegion—Switches the AWS region.
Set Credential Mode CallableMode—Overrides the credential mode at runtime.
Set Login Token CallableProvider, Token—Signs the player in to the identity pool.
Clear Login Tokens Callable——The player becomes a guest again.
Set Static Credentials CallableAccess Key Id, Secret Access Key, Session Token—Static Keys mode from now on.
Get Identity Id Pure—Return ValueCognito identity id.
Make User Pool Provider Name PureRegion, User Pool IdReturn Valuecognito-idp.<region>.amazonaws.com/<pool id>.
Is Configured Pure—Problem, Return ValueChecks credentials and the default bot.
Resolve Identity LatentForce RefreshOn Success / On Failure (Identity Id, Error)Fetches credentials ahead of the first turn.
Struct To JSON CallableStructJson, Return ValueAny struct as JSON (for a session attribute).
JSON To Struct CallableJsonOut Struct, Return ValueFills a struct (for a custom payload).
Get JSON Field PureJson, PathValue, Return ValueOne value by path, e.g. reward.items[0].id.
Cancel Callable(latent node)—None of the node's pins fire any more.
Is Finished Pure(latent node)Return ValueTrue after the node finished or was cancelled.

Credentials

ModeUse forHow
Cognito Identity PoolGame clientsGuests get unauthenticated credentials; after Set Login Token the player gets the authenticated role. Credentials refresh automatically before they expire.
Static KeysDevelopment, dedicated servers, keys from your backendSettings keys or Set Static Credentials (with an optional session token).
Default Credential ChainServers and toolsEnvironment variables, the ~/.aws profile, ECS and EC2 instance roles.

C++ API

// Build.cs: PublicDependencyModuleNames.Add("LexBot");
#include "LexBotLibrary.h"

const FString Session = ULexBotLibrary::GenerateSessionId();
ULexBotLibrary::SendTextNative(TEXT("I want a coffee"), Session,
    FLexBotNativeDelegate::CreateLambda([](const FLexBotResponse& Response, const FLexBotError& Error)
    {
        // runs on the game thread
        UE_LOG(LogTemp, Log, TEXT("%s / %s"), *ULexBotLibrary::JoinMessages(Response.Messages, TEXT(" ")), *Error.Message);
    }));

The component (ULexBotConversationComponent) and the latent node classes (ULexBotRecognizeTextAction and the others) can also be used from C++: create the action through its static factory, bind the delegates, then call Activate().

Types

TypeKindMembers
FLexBotResponseStructSession Id, Request Id, Messages, Interpretations, Session State, Request Attributes, Input Transcript, Input Mode, Recognized Bot Name, Sound, Audio Bytes, Audio Content Type, Duration
FLexBotMessageStructContent, Content Type, Card (Title, Subtitle, Image Url, Buttons)
FLexBotIntent / FLexBotSlotStructName, State, Confirmation State, Slots — Has Value, Original / Interpreted / Resolved Values, Shape, List Values, Sub Slots
FLexBotInterpretationStructIntent, Nlu Confidence (-1 = none), Has Sentiment, Sentiment (type + 4 scores), Source
FLexBotSessionStateStructDialog Action, Intent, Active Contexts, Session Attributes, Runtime Hints, Originating Request Id
FLexBotTurn / FLexBotCaptureDevice / FLexBotErrorStructHistory line; input device; Code, Message, Http Status, Retryable
ULexBotSoundWaveClassRuntime sound wave from 16-bit PCM (spoken replies)
EnumsEnumIntent State, Confirmation State, Dialog Action Type, Message Type, Sentiment, Slot Shape, Conversation End, Audio Format, Dialog State, Credential Mode

Settings

Project Settings > Plugins > LexBot (saved to DefaultGame.ini). Changes apply to the next request.

SettingDefaultDescription
Regionus-east-1Region of your bot and identity pool.
Credential ModeCognito Identity PoolCognito Identity Pool, Static Keys or Default Credential Chain.
Identity Pool Id(empty)For example us-east-1:01234567-89ab-cdef-0123-456789abcdef.
Allow Guest AccessOnUnauthenticated identities before Set Login Token.
Access Key Id / Secret Access Key(empty)Static Keys mode - development and servers only.
Allow Static Keys In ShippingOffSettings keys are refused in Shipping builds unless enabled.
Endpoint Override(empty)Custom endpoint.
Request Timeout Ms / Connect Timeout Ms30000 / 5000Time limits per request.
Max Retries / Worker Threads3 / 4Automatic retries; background threads.
Verify SSL / Log Sdk WarningsOn / OnTLS verification; SDK warnings in LogLexBot.
Default Bot Id(empty)Bot used when a node or component leaves Bot Id empty.
Default Bot Alias IdTSTALIASIDAlias used when left empty (TSTALIASID = draft test alias).
Default Locale Iden_USLocale used when left empty.
Default Response AudioNoneInitial Response Audio of new conversation components.
Microphone Sample Rate160008000 or 16000.
Silence Threshold / Silence Timeout Seconds0.02 / 1.2Voice-activity detection.
Max Utterance Seconds / No Speech Timeout Seconds15 / 6Recording limits.

Troubleshooting

Error codeCause and fix
NotConfiguredNo identity pool, or no bot: set Default Bot Id / Alias Id in the settings or pass them to the node.
AccessDeniedExceptionThe identity pool role lacks lex:RecognizeText / lex:RecognizeUtterance on that bot alias ARN.
ResourceNotFoundExceptionWrong bot id, alias id, locale or region, or the locale was not built.
ValidationExceptionInvalid session id characters, a slot that does not exist on the intent, or an unsupported audio format.
DependencyFailedExceptionThe bot's Lambda function failed or timed out. Check its CloudWatch logs.
NoSpeechThe microphone heard nothing above Silence Threshold within No Speech Timeout Seconds. Lower the threshold or raise Microphone Gain.
MicrophonePermission / UnsupportedAndroid permission not granted (Request Microphone Permission), or a platform without capture (Linux).
UnavailableThe SDK library could not be loaded or the engine is shutting down. Check the Output Log for LogLexBot errors.

Credits

© 2026 Alpha XP — alphaxp.net · Support: support@alphaxp.net. Includes the AWS SDK for C++ and the AWS Common Runtime (Apache License 2.0). Built for Unreal Engine 4.27 and 5.8.