This solution deploys a pre-built Amazon Lex bot for airline travel assistance, providing conversational experiences for both voice and chat modalities.
The Amazon Lex Airline Solution creates a complete conversational bot that helps users with airline-related tasks such as booking flights, checking flight status, and managing reservations. The solution includes:
- Amazon Lex bot with pre-built conversation flows
- Lambda functions for business logic and fulfillment
- DynamoDB table for storing sample data
- Optional Amazon Connect integration
The solution consists of the following components:
- Amazon Lex Bot: Provides the natural language understanding and conversation management
- Lambda Functions:
- Business Logic Function: Handles the core functionality and fulfillment
- Lex Import Function: Imports the pre-built Lex bot configuration
- DynamoDB Import Function: Populates the DynamoDB table with sample data
- Connect Import Function: Sets up Amazon Connect integration (optional)
- DynamoDB Table: Stores sample customer and flight data
- IAM Roles: Provides necessary permissions for the components to interact
aws cloudformation create-stack \
--stack-name AirlineSolution \
--template-body file://amazon_lex_airline_solution_fixed.yaml \
--parameters \
ParameterKey=BotName,ParameterValue=AirlinesBot \
ParameterKey=BusinessLogicFunctionName,ParameterValue=AirlinesBusinessLogic \
ParameterKey=DynamoDBTableName,ParameterValue=Airlines_db \
--capabilities CAPABILITY_IAM./deploy_airline_solution_fixed.sh| Parameter | Description | Default |
|---|---|---|
| BotName | Name of the Lex bot | AirlinesBot |
| BusinessLogicFunctionName | Name of the Lambda function for validation and fulfillment | AirlinesBusinessLogic |
| DynamoDBTableName | Name of the DynamoDB table for sample data | Airlines_db |
| ContactFlowName | Name of the Connect contact flow (optional) | AirlinesContactFlow |
| ConnectInstanceARN | ARN of Connect Instance (optional) | - |
aws lexv2-runtime recognize-text \
--bot-id YOUR_BOT_ID \
--bot-alias-id YOUR_BOT_ALIAS_ID \
--locale-id en_US \
--session-id "test-session" \
--text "I want to book a flight"import boto3
import uuid
# Configure these values
BOT_ID = "YOUR_BOT_ID"
BOT_ALIAS_ID = "YOUR_BOT_ALIAS_ID"
# Initialize Lex client
lex_client = boto3.client('lexv2-runtime')
session_id = str(uuid.uuid4())
# Send a message
response = lex_client.recognize_text(
botId=BOT_ID,
botAliasId=BOT_ALIAS_ID,
localeId='en_US',
sessionId=session_id,
text="I want to book a flight"
)
# Print the response
print(response)- "Hello"
- "I want to book a flight"
- "Check my flight status"
- "What's the status of my flight?"
- "I need to change my reservation"
To delete all resources created by this solution:
# If deployed with CloudFormation
aws cloudformation delete-stack --stack-name AirlineSolution
# If deployed with bash script
./delete_airline_resources.sh- Sample Customer Data
- Amazon Lex Documentation
- AWS Lambda Documentation
- Amazon DynamoDB Documentation
This solution is licensed under the MIT-0 License. See the LICENSE file.
