Lex
Lex
The lex
verb connects a call to an Amazon Lex V2 bot.
{
"verb": "lex",
"botId": "MTLNerCD9L",
"botAliasId": "z5yY1iYykE",
"region": "us-east-1",
"locale": "en_US",
"credentials": {
"accessKey": "XXXX",
"secretAccessKey": "YYYY"
},
"passDtmf": true,
"intent": "BookHotel",
"metadata": {
"slots": {
"Location": "Los Angeles"
},
"context": {
"callerId": "+15083084909",
"customerName": "abc company"
}
},
"tts": {
"vendor": "Google",
"language": "en-US",
"voice": "en-US-Wavenet-C"
},
"eventHook": "/lex-events"
}
The following features are supported:
- Optionally specify an initial, or “welcome,” intent.
- Pre-fill slot values for the initial intent.
- Provide text for a spoken welcome message at the start of the conversation.
- Play Lex-generated audio, or use text-to-speech with either AWS/Polly or Google voices.
- Receive real-time notifications of intents and transcriptions as the conversation progresses.
- Provide arbitrary context data to the Lex backend to help guide the flow.
You can use the following attributes with the lex
verb:
Option | Description | Required |
---|---|---|
botId |
Lex bot ID. | Yes |
botAlias |
Lex bot alias ID. | Yes |
credentials |
AWS credentials. | Yes |
credentials.accessKey |
AWS access key ID. | Yes |
credentials.secretAccessKey |
AWS secret access key ID. | Yes |
region |
AWS region where the bot is running. | Yes |
locale |
Language code of the speaker (currently supported languages: en_AU , en_GB , en_US , fr_CA , fr_FR , es_ES , es_US , it_IT ). |
Yes |
eventHook |
A webhook to invoke when a Lex event occurs (e.g., intent detected, transcription, etc.). | No |
intent |
Initial intent to trigger (i.e., “welcome intent”). | No |
welcomeMessage |
Text for a welcome message to play to the caller. | No |
noInputTimeout |
Timeout in milliseconds Lex will wait for a response before triggering a fallback intent. | No |
tts |
If provided, playback will use text-to-speech rather than Lex-generated audio. | No |
tts.vendor |
'aws' , 'Google' , or 'default' . |
No |
tts.language |
Language identifier or 'default' . |
No |
tts.voice |
Voice identifier or 'default' . |
No |
metadata |
Initial slot values and context data. | No |
metadata.slots |
Key-value pairs for slot names and initial values to be pre-filled. | No |
metadata.context |
Key-value pairs for context data to pass to the Lex bot. | No |
metadata['x-amz-lex:channels:platform'] |
Name of the voice platform. | No |
The eventHook
webhook will contain two parameters: event
and data
. The event
parameter identifies the specific event, and the data
parameter is an object containing event data associated with the event. The following events are supported:
intent
: Lex detected an intent.transcription
: A speech transcription was returned from Lex.response-text
: Lex returned a response in the form of text.dtmf
: A DTMF key was pressed by the caller.start-play
: An audio segment returned from Lex or TTS started to play.stop-play
: An audio segment returned from Lex or TTS completed playing.play-interrupted
: An audio segment was interrupted.