Exercise 3: Build an advanced customer service chatbot - Amazon Lex

Exercise 3: Build an advanced customer service chatbot

In this advanced exercise, you'll build a sophisticated customer service chatbot for an e-commerce company. This bot demonstrates enterprise-level capabilities including order management, intelligent upselling, lead generation, and revenue optimization. The chatbot uses AI-powered features to provide personalized customer experiences and drive business growth.

SmartCommerce Customer Service Bot Overview

The SmartCommerce Customer Service Bot is designed to handle complex customer interactions while maximizing revenue opportunities. This example demonstrates how businesses can automate customer service while driving sales growth through intelligent conversation management.

  • Custom Intents – The bot includes multiple custom intents for comprehensive customer service:

    • CheckOrderStatus - Verifies and provides order status information

    • ProcessReturn - Handles return requests and exchanges

    • UpsellProducts - Recommends additional products and services

    • CaptureLeadInfo - Collects customer information for lead generation

    • ScheduleCallback - Books customer service callbacks

  • Built-in Intents – Leverages Amazon Lex V2 built-in intents for common interactions:

  • Custom Slot Types – Specialized slot types for business-specific data:

    • ProductCategories - Electronics, Clothing, Home, Books, Sports

    • ReturnReasons - Defective, Wrong Size, Changed Mind, Not as Described

    • ContactPreferences - Email, SMS, Phone Call, In-App Notification

    • CustomerTiers - Bronze, Silver, Gold, Platinum

  • Built-in Slot Types – Uses Amazon Lex V2 built-in slots for common data formats:

Detailed Intent Configuration

CheckOrderStatus Intent

This intent handles order verification and status inquiries, providing customers with real-time order information while identifying upselling opportunities.

  • Required Slots:

  • Sample Utterances:

    • "What's the status of my order {OrderNumber}"

    • "I need to check on order number {OrderNumber}"

    • "Where is my package"

    • "Track my order {OrderNumber}"

    • "Has my order shipped yet"

  • AI-Powered Features:

    • Uses Assisted NLU to understand variations like "my package", "my stuff", "my delivery"

    • Automatically extracts order numbers from natural speech patterns

UpsellProducts Intent

This intent proactively identifies revenue opportunities by recommending complementary products and premium services based on customer history and current interaction context.

  • Required Slots:

    • ProductCategory (ProductCategories) - Category of interest

    • CustomerTier (CustomerTiers) - Customer loyalty level

    • Budget (AMAZON.Number) - Customer's budget range

  • Sample Utterances:

    • "Show me related products"

    • "What else would go with this"

    • "Do you have any deals"

    • "I'm interested in {ProductCategory} items"

    • "What's on sale today"

  • Revenue Optimization Features:

    • Dynamic pricing based on customer tier

    • Personalized recommendations using purchase history

    • Limited-time offer creation to drive immediate purchases

CaptureLeadInfo Intent

This intent systematically collects customer information for lead generation, creating valuable data that can be sold to aggregators or used for targeted marketing campaigns.

  • Required Slots:

    • CustomerFirstName (AMAZON.FirstName) - Customer's first name for personalization

    • CustomerLastName (AMAZON.LastName) - Customer's last name for sales history lookup

    • CustomerEmail (AMAZON.EmailAddress) - Email address

    • CustomerPhone (AMAZON.PhoneNumber) - Phone number

    • InterestCategory (ProductCategories) - Product interests

    • ContactPreference (ContactPreferences) - Preferred contact method

  • Sample Utterances:

    • "I want to hear about new products"

    • "Sign me up for updates"

    • "I'm interested in {InterestCategory}"

    • "Keep me informed about sales"

    • "I want to join your mailing list"

    • "My name is {CustomerFirstName} {CustomerLastName}"

    • "I'm {CustomerFirstName} {CustomerLastName} and I want personalized recommendations"

  • Lead Generation Features:

    • Structured data collection for CRM integration

    • Lead scoring based on interaction quality

    • Automated lead qualification and routing

    • Data formatting for aggregator sales

  • Sales History Integration:

    • Customer name lookup in S3-stored purchase history tables

    • Purchase pattern analysis for personalized recommendations

    • Cross-category purchase behavior identification

    • Seasonal buying trend analysis for targeted offers

    • Customer lifetime value calculation for tier-based pricing

Multi-Turn Conversation Flow

The SmartCommerce bot is designed to handle complex, multi-turn conversations that span multiple intents and maintain context throughout the interaction. This creates a natural, human-like experience while maximizing revenue opportunities.

Example Conversation Flow

Turn 1-3: Order Status Check

Customer: "Hi, I need to check on my order" Bot: "I'd be happy to help you check your order status. Can you provide your order number?" Customer: "It's order 12345" Bot: "Thank you. To verify your identity, can you provide the email address associated with this order?" Customer: "john.doe@email.com" Bot: "Perfect! Order #12345 is currently being prepared for shipment. You should receive it by tomorrow. Since you're a Gold tier customer, would you like to hear about some exclusive deals on related items?"

Turn 4-6: Upselling Opportunity

Customer: "Sure, what do you have?" Bot: "Based on your Electronics purchase, I can offer you a 20% discount on premium accessories. What's your budget range for additional items?" Customer: "Maybe around $50" Bot: "Excellent! I have a wireless charging pad normally $60, now $48 with your Gold discount. Plus, if you add it to your current order, shipping is free. Should I add this to your cart?"

Turn 7-11: Lead Generation with Sales History Lookup

Customer: "Not right now, but I'd like to hear about future deals" Bot: "Absolutely! I can set you up to receive personalized offers. What's your first name?" Customer: "John" Bot: "Thanks John! And your last name so I can look up your purchase history for better recommendations?" Customer: "Smith" Bot: "Perfect! Let me check your purchase history... I see you've bought electronics and home items before. Based on your past purchases, I can offer you exclusive deals on smart home accessories. How would you prefer to be contacted?" Customer: "Email is fine" Bot: "Great! I'll make sure john.doe@email.com gets personalized deals based on your purchase history. You're all set for our premium recommendations program!"

Context Management Features

  • Session Persistence: Maintains customer information across multiple intents

  • Intent Chaining: Seamlessly transitions between order checking, upselling, and lead capture

  • Dynamic Personalization: Adjusts offers based on customer tier and purchase history

  • Revenue Tracking: Monitors upsell success rates and lead quality scores

AI-Powered Features

This chatbot leverages multiple AI capabilities to provide intelligent, personalized customer service while driving business growth.

Assisted NLU Implementation

Assisted NLU uses Large Language Models to understand customer intent even when they use non-standard phrasing or combine multiple requests in a single utterance.

  • Natural Language Understanding:

    • "My stuff hasn't arrived yet" → CheckOrderStatus intent

    • "I want to return this junk" → ProcessReturn intent

    • "Show me what else you got" → UpsellProducts intent

  • Multi-Intent Recognition:

    • "Check my order 12345 and sign me up for deals" → CheckOrderStatus + CaptureLeadInfo

Generative Slot Resolution

Uses AI to extract slot values from complex, natural language inputs without requiring exact matches to training data.

  • Smart Extraction:

    • "I bought some electronics last week, order number was something like 12345" → OrderNumber: 12345, ProductCategory: Electronics

    • "Call me on my mobile at 555-123-4567 or email me at john@company.com" → Phone: 555-123-4567, Email: john@company.com

Sentiment Analysis Integration

Monitors customer sentiment throughout the conversation to adjust approach and escalate when necessary.

  • Sentiment-Based Routing:

    • Positive sentiment → Aggressive upselling approach

    • Neutral sentiment → Standard service with gentle upselling

    • Negative sentiment → Focus on problem resolution, minimal upselling

Order Verification and Confirmation System

The bot includes a comprehensive confirmation system that verifies customer identity, confirms order details, and sends confirmations via multiple channels.

Multi-Factor Verification Process

  • Primary Verification:

    • Order number validation

    • Email address confirmation

    • Last 4 digits of payment method (for sensitive operations)

  • Secondary Verification:

    • Shipping address confirmation

    • Purchase date validation

    • Product details verification

Multi-Channel Confirmation System

The bot automatically sends confirmations through multiple channels based on customer preferences and action type.

  • Email Confirmations:

    • Order status updates with tracking information

    • Return authorization with prepaid shipping labels

    • Upsell purchase confirmations with delivery details

    • Lead capture confirmation with welcome offers

  • SMS Confirmations:

    • Immediate order status updates

    • Delivery notifications with time windows

    • Flash sale alerts for interested customers

  • In-App Notifications:

    • Real-time order updates

    • Personalized product recommendations

    • Loyalty program updates

Point of Sale (POS) Integration

The chatbot integrates directly with POS systems to process transactions, apply discounts, and update inventory in real-time.

Real-Time Transaction Processing

  • Upsell Transaction Flow:

    1. Customer accepts upsell offer 2. Bot validates inventory availability 3. Bot applies customer-tier discount 4. Bot processes payment using stored payment method 5. Bot updates order with additional items 6. Bot sends confirmation via preferred channel 7. Bot updates customer profile with purchase data
  • Revenue Tracking:

    • Upsell conversion rates by customer tier

    • Average order value increase per interaction

    • Revenue attribution to chatbot interactions

    • Customer lifetime value impact

Dynamic Pricing Engine

  • Tier-Based Pricing:

    • Bronze: Standard pricing

    • Silver: 5% discount on upsells

    • Gold: 10-20% discount on upsells

    • Platinum: 25% discount + free shipping

  • Contextual Pricing:

    • Problem resolution scenarios: Additional discount to maintain satisfaction

    • High-value customers: Exclusive pricing tiers

    • Inventory clearance: Aggressive discounting for slow-moving items

Advanced Lead Generation System

The chatbot includes a sophisticated lead generation system that captures, qualifies, and monetizes customer data through multiple revenue streams.

Multi-Touch Lead Capture Strategy

  • Opportunistic Capture:

    • During order status checks: "Would you like updates on similar products?"

    • After problem resolution: "Can we notify you about product improvements?"

    • During upsell interactions: "Should we alert you to future deals in this category?"

  • Value-Added Capture:

    • Exclusive member pricing access

    • Early access to new product launches

    • Personalized product recommendations

    • Birthday and anniversary special offers

Automated Lead Qualification

  • Scoring Criteria:

    • Purchase history value: 0-25 points

    • Engagement level: 0-20 points

    • Contact information completeness: 0-15 points

    • Product category interest breadth: 0-15 points

    • Response to upsell attempts: 0-25 points

  • Lead Categories:

    • Hot Leads (80-100 points): Immediate sales team contact

    • Warm Leads (60-79 points): Automated nurture sequence

    • Cold Leads (40-59 points): Monthly newsletter

    • Prospects (0-39 points): Quarterly promotional emails

Lead Data Monetization for Aggregators

The system formats and packages lead data for sale to third-party aggregators, creating an additional revenue stream.

  • Data Packages:

    • Premium Package: Full contact info, purchase history, preferences, engagement scores

    • Standard Package: Contact info, basic preferences, category interests

    • Basic Package: Email address, primary interest category

  • Compliance Features:

    • GDPR compliance with explicit consent tracking

    • CCPA compliance with opt-out mechanisms

    • CAN-SPAM compliance for email marketing

    • Data retention and deletion policies

  • Revenue Optimization:

    • Dynamic pricing based on lead quality scores

    • Exclusive data partnerships with premium aggregators

    • Real-time bidding for high-value leads

Revenue Optimization Strategies

Every interaction is designed to maximize revenue through intelligent upselling, cross-selling, and customer lifetime value optimization.

Intelligent Upselling Strategies

  • Contextual Upselling:

    • Order status check → "Your order is ready! Add expedited shipping for just $5?"

    • Return request → "Instead of returning, would you like to exchange for our upgraded model?"

    • Product inquiry → "This item pairs perfectly with [complementary product] - bundle and save 15%"

  • Urgency-Based Selling:

    • "This offer expires in 24 hours"

    • "Only 3 left in stock at this price"

    • "Flash sale ends at midnight"

Cross-Selling Opportunities

  • Product Ecosystem Selling:

    • Electronics → Accessories, warranties, installation services

    • Clothing → Matching items, care products, styling services

    • Home goods → Complementary items, maintenance products, design consultations

  • Service Upselling:

    • Extended warranties and protection plans

    • Premium customer support tiers

    • Subscription services and auto-delivery

    • Professional installation and setup

Customer Lifetime Value Optimization

  • Loyalty Program Integration:

    • Automatic tier upgrades based on chatbot interactions

    • Bonus points for engaging with upsell offers

    • Exclusive chatbot-only rewards and discounts

  • Retention Strategies:

    • Proactive problem resolution to prevent churn

    • Personalized win-back offers for inactive customers

    • Anniversary and milestone celebration offers

Implementation Procedures

Follow these step-by-step procedures to build your advanced customer service chatbot with all the revenue optimization features.

Prerequisites and Setup Requirements

Before building the SmartCommerce bot, ensure you have the necessary AWS account setup, permissions, and understand the service considerations.

AWS Account and Access Requirements

  • AWS Account: You need an active AWS account with billing enabled. If you don't have one, sign up at aws.amazon.com.

  • IAM Permissions: Your AWS user or role must have the following permissions:

    • lex:* - Full Amazon Lex V2 permissions for bot creation and management

    • iam:CreateRole - To create service roles for the bot

    • iam:AttachRolePolicy - To attach policies to service roles

    • lambda:CreateFunction - For Lambda integration (optional)

    • logs:CreateLogGroup - For Amazon CloudWatch Logs logging

  • Region Selection: Choose an AWS region that supports Amazon Lex V2 and your target audience. Recommended regions include:

    • US East (N. Virginia) - us-east-1

    • US West (Oregon) - us-west-2

    • Europe (Ireland) - eu-west-1

    • Asia Pacific (Sydney) - ap-southeast-2

Service Limits and Quotas

Amazon Lex V2 has several service limits that may affect your bot development and deployment:

  • Bot Limits:

    • Maximum 100 bots per account per region

    • Maximum 100 intents per bot

    • Maximum 100 slot types per bot

    • Maximum 200 slots per intent

  • Runtime Limits:

    • Maximum 15-minute session timeout

    • Maximum 1,000 requests per second (can be increased)

    • Maximum 1,500 characters per text input

  • Training Data Limits:

    • Maximum 1,500 sample utterances per intent

    • Maximum 10,000 slot type values

    • Maximum 140 characters per sample utterance

Note

If you need higher limits for production use, you can request quota increases through the AWS Support Center.

Cost Considerations

Understanding Amazon Lex V2 pricing helps you plan and budget for your chatbot deployment:

  • Request-Based Pricing:

    • Text requests: $0.00075 per request after the first 10,000 requests per month

    • Speech requests: $0.004 per request after the first 1,000 requests per month

  • Free Tier:

    • 10,000 text requests per month for the first year

    • 1,000 speech requests per month for the first year

  • Additional Costs:

    • Lambda functions (if used): $0.20 per 1M requests + compute time

    • Amazon CloudWatch Logs logs: $0.50 per GB ingested

    • Data transfer costs for external integrations

  • Cost Optimization Tips:

    • Use session attributes to reduce redundant API calls

    • Implement efficient conversation flows to minimize turns

    • Monitor usage through CloudWatch Logs to identify optimization opportunities

Important

For current pricing information, visit the Amazon Lex Pricing page as rates may change.

Lambda Integration Overview

While this exercise focuses on the Lex bot configuration, the advanced features described (POS integration, lead generation, revenue optimization) would typically require Lambda functions for backend processing.

  • When Lambda is Needed:

    • Order status verification against external databases

    • Real-time inventory checks for upselling

    • Customer data storage and retrieval

    • Sales history lookup in S3 tables using customer first and last name

    • Purchase pattern analysis for personalized recommendations

    • Payment processing integration

    • Email and SMS confirmation sending

  • S3 Sales History Integration:

    • Query S3 tables using CustomerFirstName and CustomerLastName slots

    • Analyze purchase history to identify buying patterns and preferences

    • Generate personalized product recommendations based on past purchases

    • Calculate customer lifetime value for dynamic pricing strategies

    • Identify cross-sell opportunities from purchase correlation analysis

  • Basic Lambda Setup Requirements:

    • Lambda execution role with appropriate permissions

    • VPC configuration if accessing private resources

    • Environment variables for configuration

    • Error handling and logging implementation

  • Integration Points:

    • Intent fulfillment - Process completed intents

    • Slot validation - Validate user inputs in real-time

    • Dialog management - Control conversation flow

Note

For this exercise, we'll focus on the Lex bot configuration. Lambda integration can be added later as your requirements evolve. The bot will work with static responses for testing and demonstration purposes.

Pre-Implementation Checklist

Before proceeding with the bot creation, verify you have:

  • ✓ Active AWS account with billing enabled

  • ✓ Appropriate IAM permissions for Lex and related services

  • ✓ Selected target AWS region

  • ✓ Reviewed service limits and quotas

  • ✓ Understood cost implications

  • ✓ Planned Lambda integration approach (if needed)

  • ✓ Access to AWS Management AWS Management Console

Create the SmartCommerce Bot

To create the SmartCommerce customer service bot
  1. Sign in to the AWS Management Console and open the Amazon Lex console at https://console.aws.amazon.com/lex/.

  2. Choose Create bot.

  3. For the Creation method, choose Create a blank bot.

  4. In the Bot configuration section:

    • Bot name: SmartCommerceBot

    • Description: Advanced customer service chatbot with upselling, lead generation, and revenue optimization

  5. In the Permissions section, choose Create a new role with basic Amazon Lex permissions.

  6. In the Children's Online Privacy Protection Act (COPPA) section, choose No.

  7. In the Session timeout section, set to 15 minutes to allow for complex multi-turn conversations.

  8. Choose Next.

  9. Add English (US) as the language and choose Done.

Create Custom Slot Types

To create the custom slot types
  1. In the left navigation pane, choose Slot types.

  2. Choose Add slot type and create the following slot types:

    1. ProductCategories:

      • Electronics

      • Clothing

      • Home

      • Books

      • Sports

      • Beauty

      • Automotive

    2. ReturnReasons:

      • Defective

      • Wrong Size

      • Changed Mind

      • Not as Described

      • Damaged in Shipping

      • Better Price Found

    3. ContactPreferences:

      • Email

      • SMS

      • Phone Call

      • In-App Notification

      • Mail

    4. CustomerTiers:

      • Bronze

      • Silver

      • Gold

      • Platinum

Create Custom Intents

To create the CheckOrderStatus intent
  1. In the left navigation pane, choose Intents.

  2. Choose Add intent and name it CheckOrderStatus.

  3. Add the following sample utterances:

    • "What's the status of my order {OrderNumber}"

    • "I need to check on order number {OrderNumber}"

    • "Where is my package"

    • "Track my order {OrderNumber}"

    • "Has my order shipped yet"

    • "When will my order arrive"

    • "I want to know about my delivery"

  4. Add the following slots:

    • OrderNumber (AMAZON.Number) - Required

      Prompt: "Can you provide your order number?"

    • CustomerEmail (AMAZON.EmailAddress) - Required

      Prompt: "To verify your identity, please provide the email address associated with this order."

  5. Set the confirmation prompt: "Let me check order #{OrderNumber} for {CustomerEmail}. Is this correct?"

  6. Set the fulfillment message: "I found your order! Order #{OrderNumber} is {OrderStatus}. {UpsellMessage}"

To create the UpsellProducts intent
  1. Create a new intent named UpsellProducts.

  2. Add sample utterances:

    • "Show me related products"

    • "What else would go with this"

    • "Do you have any deals"

    • "I'm interested in {ProductCategory} items"

    • "What's on sale today"

    • "Show me more options"

  3. Add slots:

    • ProductCategory (ProductCategories) - Required

      Prompt: "What type of products are you interested in?"

    • Budget (AMAZON.Number) - Optional

      Prompt: "What's your budget range for additional items?"

To create the CaptureLeadInfo intent
  1. Create a new intent named CaptureLeadInfo.

  2. Add sample utterances:

    • "I want to hear about new products"

    • "Sign me up for updates"

    • "I'm interested in {InterestCategory}"

    • "Keep me informed about sales"

    • "I want to join your mailing list"

    • "Send me deals and offers"

    • "My name is {CustomerFirstName} {CustomerLastName}"

    • "I'm {CustomerFirstName} {CustomerLastName} and I want personalized recommendations"

  3. Add slots:

    • CustomerFirstName (AMAZON.FirstName) - Required

      Prompt: "What's your first name for personalized service?"

    • CustomerLastName (AMAZON.LastName) - Required

      Prompt: "And your last name so I can look up your purchase history?"

    • CustomerEmail (AMAZON.EmailAddress) - Required

    • CustomerPhone (AMAZON.PhoneNumber) - Optional

    • InterestCategory (ProductCategories) - Required

    • ContactPreference (ContactPreferences) - Required

Enable AI-Powered Features

To enable Assisted NLU and other AI features
  1. In the left navigation pane, choose Bot settings.

  2. Under Assisted NLU, choose Enable.

  3. Under Generative AI, enable:

    • Assisted slot resolution

    • Descriptive bot building

  4. Under Sentiment Analysis, choose Enable.

  5. Choose Save.

Test and Deploy the Bot

To test the SmartCommerce bot
  1. Choose Build to compile your bot.

  2. Once the build is complete, choose Test.

  3. Test the following conversation flows:

    1. Order Status Flow:

      • User: "Check my order 12345"

      • Bot: Requests email verification

      • User: Provides email

      • Bot: Provides status and offers upsell

    2. Upselling Flow:

      • User: "Show me deals"

      • Bot: Asks for product category

      • User: "Electronics"

      • Bot: Presents personalized offers

    3. Lead Generation Flow:

      • User: "Sign me up for updates"

      • Bot: Collects contact information

      • User: Provides details

      • Bot: Confirms subscription and offers immediate discount

  4. Verify that AI features are working:

    • Test natural language variations like "my stuff hasn't arrived"

    • Verify sentiment analysis adjusts bot responses

    • Confirm slot resolution works with complex inputs

  5. Once testing is complete, choose Publish to deploy your bot.

Performance Analytics and Optimization

Monitor and optimize your SmartCommerce bot's performance using comprehensive analytics and revenue tracking.

Key Performance Metrics

  • Revenue Metrics:

    • Upsell conversion rate by customer tier

    • Average order value increase per interaction

    • Revenue per conversation

    • Customer lifetime value impact

  • Lead Generation Metrics:

    • Lead capture rate by interaction type

    • Lead quality scores and conversion rates

    • Data monetization revenue from aggregator sales

    • Email subscription growth rate

  • Operational Metrics:

    • Intent recognition accuracy

    • Slot filling success rate

    • Conversation completion rate

    • Customer satisfaction scores

Continuous Optimization Strategies

  • A/B Testing:

    • Test different upsell messaging approaches

    • Compare aggressive vs. gentle lead capture techniques

    • Optimize discount percentages for maximum conversion

  • Machine Learning Optimization:

    • Analyze successful conversation patterns

    • Identify optimal timing for upsell offers

    • Refine customer tier classification algorithms

Exercise Conclusion

Congratulations! You've successfully built an advanced customer service chatbot that demonstrates enterprise-level capabilities for revenue optimization and customer engagement. This SmartCommerce bot showcases how businesses can leverage Amazon Lex V2's AI-powered features to:

  • Maximize Revenue: Through intelligent upselling, cross-selling, and dynamic pricing strategies

  • Generate Leads: By systematically capturing and qualifying customer information for multiple revenue streams

  • Enhance Customer Experience: Using AI to understand natural language and provide personalized interactions

  • Optimize Operations: Through automated customer service that scales efficiently while maintaining quality

The techniques demonstrated in this exercise can be adapted and expanded for various industries and use cases, providing a foundation for building sophisticated conversational AI solutions that drive business growth.

Next Steps

To further enhance your SmartCommerce bot, consider implementing:

  • Advanced Integrations:

    • CRM system integration for complete customer profiles

    • Inventory management system connections for real-time availability

    • Payment processing integration for seamless transactions

  • Multi-Channel Deployment:

    • Website chat widget integration

    • Social media platform connections

    • Voice interface implementation

  • Advanced Analytics:

    • Custom dashboard development for business metrics

    • Predictive analytics for customer behavior

    • ROI tracking and attribution modeling