An intelligent invoice processing system that receives PDFs via email, extracts structured data using AWS Bedrock Nova AI model, and returns parsed JSON results automatically.
- Email Integration: Receive invoices via
invoice-bot@katechat.tech - Multi-language Support: Parse invoices in English and German
- AI-Powered Extraction: Uses AWS Bedrock Nova multimodal model with direct PDF input
- Automatic Processing: Fully automated from email receipt to response
- Structured Output: Returns clean JSON with invoice details and line items
- Local Testing: Test parser locally with sample invoices
ai-order-parser/
βββ data/ # Sample invoice PDFs for testing
β βββ 2025-30240870.pdf
β βββ 42507956.pdf
β βββ KR318586338013.pdf
β βββ Rechnung-38110.pdf
β βββ Rechnung_HDK-054031.pdf
βββ processor/ # Lambda function code
β βββ lambda_function.py # Main Lambda handler
β βββ pdf_parser.py # PDF parsing with Bedrock Nova
β βββ email_processor.py # SES email handling
β βββ test_local.py # Local testing script
β βββ requirements.txt # Python dependencies
β βββ README.md # Processor documentation
βββ infrastructure/ # Terraform IaC
β βββ main.tf # Main Terraform configuration
β βββ variables.tf # Variable definitions
β βββ lambda.tf # Lambda function resources
β βββ ses.tf # SES configuration
β βββ s3.tf # S3 bucket for emails
β βββ iam.tf # IAM roles and policies
β βββ outputs.tf # Terraform outputs
β βββ README.md # Infrastructure documentation
βββ deploy.sh # Deployment script
βββ README.md # This file
- AWS CLI configured with appropriate credentials
- Terraform >= 1.0 installed
- Python 3.11+ with pip
- Domain
katechat.techalready configured (provided in requirements)
-
Clone and navigate to project:
cd ai-order-parser -
Deploy infrastructure:
./deploy.sh
-
Wait for DNS propagation (up to 24 hours)
-
Test the system: Send an email with PDF attachment to
invoice-bot@katechat.tech
- Configure environment variables:
cd processor
cp .env.example .env
# Edit .env with your AWS credentials- Test the parser with sample invoices:
# Test a specific PDF
python test_local.py test ../data/Rechnung-38110.pdf
# Test all sample PDFs
python test_local.py test-all
# Show PDF info (without AI parsing)
python test_local.py info ../data/42507956.pdf- Email Receipt: Send invoice PDF to
invoice-bot@katechat.tech - SES Processing: AWS SES receives email and stores in S3
- Lambda Trigger: SES triggers Lambda function automatically
- PDF Extraction: Function extracts PDF attachments from email
- AI Parsing: AWS Bedrock Nova model receives PDF directly for multimodal analysis
- Response: Parsed JSON and original PDF sent back via email
The system extracts invoices into this JSON structure:
{
"invoice_number": "INV-2024-001",
"receiver_name": "John Doe",
"receiver_address": "123 Main St, City, 12345 Country",
"issuer_name": "ACME Corporation",
"issuer_address": "456 Business Ave, Town, 67890 Country",
"total": 250.75,
"items": [
{
"title": "Product A",
"quantity": "2",
"price": 125.00
},
{
"title": "Service Fee",
"quantity": "1",
"price": 0.75
}
]
}The system understands invoices in:
- English: Invoice, Total, Items, etc.
- German: Rechnung, Rechnungsnummer, Gesamt, Summe, etc.
βββββββββββββββββββ ββββββββββββββββ βββββββββββββββββββ
β Email Client βββββΆβ AWS SES βββββΆβ AWS Lambda β
βββββββββββββββββββ ββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββ βββββββββββββββββββ
β AWS S3 β β AWS Bedrock β
β (Storage) β β (Nova AI) β
ββββββββββββββββ βββββββββββββββββββ
- IAM Policies: Minimal permissions for each service
- Email Authentication: SPF, DKIM, and DMARC configured
- Encryption: S3 bucket encrypted at rest
- Access Control: Only authorized email addresses can send via SES
- Temporary Storage: Emails deleted after 30 days
Approximate AWS costs for moderate usage (100 invoices/month):
- Lambda: ~$0.10/month (100 invocations Γ 30s avg)
- SES: ~$1.00/month (200 emails Γ $0.10/1000)
- S3: ~$0.01/month (minimal storage, 30-day lifecycle)
- Bedrock Nova: ~$5.00/month (varies by token usage)
- Route53: ~$0.50/month (DNS queries)
Total: ~$6.61/month
-
Emails not received:
- Check DNS propagation:
dig MX katechat.tech - Verify SES domain verification in AWS console
- Check spam folder
- Check DNS propagation:
-
Lambda function errors:
- Check CloudWatch logs:
/aws/lambda/invoice-parser - Verify Bedrock model permissions
- Ensure S3 bucket permissions
- Check CloudWatch logs:
-
PDF parsing issues:
- Test locally with
test_local.py - Check if PDF is text-based (not scanned image)
- Verify Bedrock Nova model availability in region
- Test locally with
- CloudWatch Logs: Function execution details
- SES Metrics: Email delivery statistics
- Lambda Metrics: Invocation count, duration, errors
REGION: Deployment region (default: eu-central-1)S3_BUCKET: S3 bucket for email storage (auto-generated)FROM_EMAIL: Sender email address (invoice-bot@katechat.tech)
aws_region: AWS region for deploymentdomain_name: Domain for SES (katechat.tech)route53_zone_id: Route53 zone ID (provided)
The system is designed to scale automatically:
- Lambda: Scales to handle concurrent email processing
- SES: No limits on email volume (within SES limits)
- S3: Unlimited storage capacity
- Bedrock: Handles multiple simultaneous requests
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Check the troubleshooting section above
- Review CloudWatch logs for errors
- Test locally using the provided scripts
- Open an issue in the GitHub repository
Built with β€οΈ using AWS Lambda, Bedrock Nova, SES, and Terraform