Skip to content

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

Caller β†’ Amazon Connect β†’ Lex Bot β†’ Responds based on intents β†’ Connect routes call

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."

  1. Connect receives the call

  2. Connect triggers Lex bot "OrderStatusBot"

  3. Lex identifies intent β€œCheckOrder”

  4. Lex prompts: β€œPlease enter your order ID”

  5. User speaks or presses digits

  6. Lex collects the slot, triggers Lambda to check order

  7. Lex responds with delivery date

  8. 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)