Lex & Connect
π€ What is Amazon Lex?¶
Amazon Lex is a fully managed service for building conversational interfaces (chatbots) using voice and text. It powers Alexa and offers natural language understanding (NLU) and automatic speech recognition (ASR).
β Ideal for chatbots, voice assistants, and contact center automation.
π What is Amazon Connect?¶
Amazon Connect is a cloud-based contact center platform that allows you to receive and make customer calls through a virtual contact center. It integrates directly with Lex for building conversational IVRs.
β Think of it as an AWS-powered alternative to Twilio Flex or Genesys Cloud.
π How Lex + Connect Work Together¶
You can:
-
Use Lex bots inside Connect for voice IVR automation
-
Route calls using Lambda or contact flows
-
Get caller input via voice, and dynamically trigger Lambda functions
π§ Amazon Lex Features¶
| Feature | Description |
|---|---|
| Text & Voice | Accepts input via both modalities |
| Multi-language | Supports 15+ languages |
| Slot filling | Captures structured data from user input |
| Intent-based logic | Routes input to correct function |
| Lambda integration | Custom backend fulfillment |
| Amazon Connect integration | Native IVR integration |
| Built-in prompts & retries | For incomplete or invalid slot values |
ποΈ Lex Key Components¶
| Component | Description |
|---|---|
| Intent | Represents a user goal (e.g., "BookHotel", "CheckBalance") |
| Utterances | Sample user phrases to trigger an intent |
| Slots | Data Lex needs to complete an intent (e.g., "location", "date") |
| Fulfillment | Trigger AWS Lambda or return a response once the intent is fulfilled |
| Prompting | Lex asks questions to fill missing slot values |
π§βπ» Lex Python Example (Boto3)¶
import boto3
client = boto3.client('lexv2-runtime')
response = client.recognize_text(
botId='ABC123',
botAliasId='XYZ456',
localeId='en_US',
sessionId='user123',
text='I want to book a flight'
)
print(response['messages'])
βοΈ Amazon Connect Features¶
| Feature | Description |
|---|---|
| Inbound/outbound voice | Full voice-based customer support |
| IVR flows | Visual contact flow editor for call routing |
| Lex bot integration | Add conversational IVR logic |
| Real-time monitoring | Live dashboards and contact trace records (CTR) |
| Call recording | Store audio in S3 |
| Call analytics | Integrate with Contact Lens for sentiment and keyword |
| Agent workspace | Web UI with call controls and customer info |
π― Lex + Connect IVR Flow Example¶
Use case: User calls a support line and asks, "I want to check my order status."
-
Connect receives the call
-
Connect triggers Lex bot "OrderStatusBot"
-
Lex identifies intent βCheckOrderβ
-
Lex prompts: βPlease enter your order IDβ
-
User speaks or presses digits
-
Lex collects the slot, triggers Lambda to check order
-
Lex responds with delivery date
-
Connect ends or routes call to agent
π΅ Pricing (2024)¶
π§ Amazon Lex¶
| Type | Price |
|---|---|
| Text requests | $0.004 per request |
| Voice requests | $0.0065 per request |
| Free tier | 10,000 text + 5,000 voice requests/month (12 mo) |
βοΈ Amazon Connect¶
| Type | Price per minute |
|---|---|
| Inbound voice (US) | $0.018 / min |
| Outbound voice (US) | $0.018 / min |
| Phone number rental | $1.00/month (US number) |
| Contact Lens add-on | $0.015 / min (analytics) |
π§ Terraform Integration (Lex)¶
Amazon Lex does not have first-class Terraform support for Lex V2 (latest version) yet. But you can:
-
Manage IAM roles/policies
-
Trigger Lambda functions for fulfillment
-
Use AWS CLI or CDK to define bots
π οΈ Terraform for Amazon Connect Setup¶
resource "aws_connect_instance" "example" {
identity_management_type = "CONNECT_MANAGED"
instance_alias = "my-connect-instance"
auto_resolve_best_voices_enabled = true
contact_flow_logs_enabled = true
}
π― You still need to manually create contact flows and add Lex integration in the AWS Console.
π IAM Permissions¶
| Service | Permissions |
|---|---|
| Lex | lex:RecognizeText, lex:StartConversation |
| Connect | connect:*, lambda:InvokeFunction, cloudwatch:* |
β TL;DR Summary¶
| Feature | Amazon Lex | Amazon Connect |
|---|---|---|
| Voice & text interaction | β Yes | β Yes (via Lex integration) |
| Natural language processing | β Built-in NLU | β Uses Lex or custom |
| Lambda integration | β Yes | β Yes |
| Multi-language | β Yes | β Yes |
| Live contact center | β | β Yes |
| Cloud IVR system | β | β Yes |
| Analytics / Sentiment | β | β (via Contact Lens) |