🍷 A sophisticated Alexa skill for wine enthusiasts - completely migrated from Node.js to Python with modern architecture and production deployment.
This project showcases a complete migration from the original Node.js implementation to a modern, production-ready Python version with enhanced features and reliability.
- Primary: Curated local wine database (
wineDatabase.json) with detailed wine information
- Status: ✅ Production Ready & Deployed
- Runtime: Python 3.11 on AWS Lambda
- Framework: ASK SDK for Python v3
- Features: Local curated data source, Bedrock NLG summaries, optional vector/OpenSearch search, enhanced error handling, comprehensive testing
- Function Name:
alexa-wine-skill-python - Runtime: Python 3.11
- Region: us-west-2
- Status: ✅ Active and Fully Functional
- Last Deployed: See CloudWatch logs for
$LATESTversion updates
├── lambda_function.py # Main Alexa skill handlers
├── wine_service.py # Wine search and data management
├── wine_api_service.py # Hybrid data source integration
├── config.py # Environment configuration
├── utils.py # Validation, logging, session utilities
├── requirements.txt # Python dependencies
├── serverless-python.yml # Serverless deployment config (optional)
├── deploy.py # One-shot zip + Lambda update script (recommended)
├── test_wine_skill.py # Comprehensive test suite (25 tests)
└── README.md # This document (Python-only)
├── wineDatabase.json # Curated wine database
├── .env # Environment variables
└── test_*.json # Test payloads for both implementations
- AWS Account with Lambda and Alexa Skills Kit permissions
- Alexa Developer Console account
- Python 3.11+
- AWS CLI configured
- Serverless Framework CLI (optional;
deploy.pyis preferred)
-
Install Dependencies
pip install -r requirements.txt
-
Configure Environment
cp .env.example .env # Edit .env with your values (see Environment Variables below) -
Deploy to AWS Lambda
# Preferred: simple deploy script that zips and updates the Lambda code python3 deploy.py # Optional: using Serverless Framework instead of deploy.py # serverless deploy --config serverless-python.yml
-
Run Tests
python -m pytest test_wine_skill.py -v
- Test Suite: 25 comprehensive tests using pytest
- Coverage: All handlers, wine service, API integration, error scenarios
- Run Tests:
python -m pytest test_wine_skill.py -v
# Test LaunchRequest
aws lambda invoke --function-name alexa-wine-skill-python --payload file://test_launch.json response.json
# Test Wine Search
aws lambda invoke --function-name alexa-wine-skill-python --payload file://test_wine_search.json response.json- Environment Variables: All sensitive data externalized
- No Hardcoded Secrets: API keys and IDs properly managed
- Input Validation: Comprehensive sanitization of user input
- HTTPS Only: All external API calls use secure connections
- Session Security: Proper session attribute management
- Modular Architecture: Clean separation of concerns
- Error Handling: Comprehensive error handling with user-friendly messages
- Logging: Structured logging throughout the application
- Type Hints: Python implementation uses type annotations
- Documentation: Comprehensive inline documentation
- File:
wineDatabase.json - Content: High-quality wine data with ratings, descriptions, pairings
- Benefits: Reliable, fast, no external API dependencies
This project utilizes the X-Wines dataset for wine recommendations. When using this dataset in production, please cite the following paper:
RecSys-DAN: A Comprehensive Dataset for Research on Recommendation Systems with Deep Learning
Authors: [Authors]
Journal: AI, 2023, 7(1), 20
DOI: https://doi.org/10.3390/ai7010020
- Search by wine name, winery, type, region
- Detailed wine information (price, rating, description)
- Food pairing recommendations
- Occasion-based suggestions
- Session-based follow-up questions
- LaunchRequest handling
- Intent-based wine searches
- Session management for multi-turn conversations
- Error handling with helpful user messages
- Card displays for visual devices
- ✅ Upgraded from alexa-sdk v1 to ask-sdk-core v2
- ✅ Updated Node.js runtime from 4.3 to 18.x
- ✅ Removed hardcoded Wine.com API key
- ✅ Added environment variable management
- ✅ Implemented proper error handling
- ✅ Added structured logging
- ✅ Complete rewrite in Python using ASK SDK v3
- ✅ Local curated data source implementation
- ✅ Comprehensive test suite with pytest
- ✅ Production deployment to AWS Lambda
- ✅ Full feature parity verification
- ✅ Performance and reliability testing
- Environment: AWS Lambda (us-west-2)
- Status: ✅ Live and Operational
- Last Deployment: Successfully tested and verified
- Monitoring: CloudWatch logs available
- Performance: Sub-second response times
- v2.0.0 - Complete Python migration with hybrid data sources
- v1.1.0 - Node.js modernization and security fixes
- v1.0.1 - Improved logging
- v1.0.0 - Initial Node.js implementation
Add these to .env as needed:
# Alexa Skill / AWS
ALEXA_SKILL_ID=your_skill_id
AWS_REGION=us-west-2
LOG_LEVEL=info
# Optional: OpenSearch + Vector Search
USE_OPENSEARCH=false
OPENSEARCH_ENDPOINT=https://your-domain
OPENSEARCH_INDEX=xwines-vec-768-1k
OPENSEARCH_USE_IAM=true
USE_VECTOR_SEARCH=false
USE_HYBRID_SEARCH=false
# Optional: Local embeddings via Ollama (for query-time vectors)
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_EMBED_MODEL=nomic-embed-text- Prereqs:
- OpenSearch index with knn_vector field
embedding(dim 768) - Optional local Ollama for query embeddings
- OpenSearch index with knn_vector field
- Notes:
- Enable IAM with
OPENSEARCH_USE_IAM=trueand ensure credentials are available - Hybrid search merges BM25 + kNN; set
USE_VECTOR_SEARCH=falseto use BM25 only
- Enable IAM with
Use ingest_xwines_vectors.py to create the index and ingest wines with embeddings:
python ingest_xwines_vectors.py --csv /path/to/XWines_Slim_1K_wines.csv --index xwines-vec-768-1k --chunk-size 200- "Alexa, open Wine Assistant"
- "Find a Pinot Noir"
- "What's the price of this wine?"
- "Tell me about the rating"
- "Where is this wine from?"
- "Next wine"
- "Previous wine"
- "Start over"
MIT
🎯 Ready for Production: The Python implementation is fully deployed and operational on AWS Lambda with comprehensive testing and monitoring in place. 1.0 Jan-06-2017 first certified Alexa release