An automated agent that scrapes credit card and miles promotions from Melhores Cartões and formats them into WhatsApp-friendly messages using Groq's LLM.
- Web Scraping: Automatically extracts promotions from Melhores Cartões
- AI-Powered Formatting: Uses Groq's LLM to format promotions into clear, engaging messages
- Multiple Output Options:
- Console output (default)
- Save to file
- Send via Email
- WhatsApp (coming soon)
- Easy Configuration: Environment variable support for all configurations
- Error Handling: Comprehensive error handling and logging
- Clone this repository
- Install dependencies:
pip install -r requirements.txt
- Copy the example environment file:
cp .env.example .env
- Edit the
.envfile with your configuration (see below for details)
Create a .env file in the project root with the following variables:
GROQ_API_KEY: Your Groq API key for LLM processing- Get it from: https://console.groq.com/keys
OUTPUT_DESTINATION_FORMAT=email
GMAIL_EMAIL=your_email@gmail.com
GMAIL_APP_PASSWORD=your_gmail_app_password # See below for how to generate
EMAIL_RECIPIENT=recipient@example.com
EMAIL_SUBJECT=Promoções de Milhas # OptionalOUTPUT_DESTINATION_FORMAT=file
OUTPUT_FILE_NAME=promotions.txt # Optional, defaults to 'promotions.txt'OUTPUT_DESTINATION_FORMAT=consoleTo send emails through Gmail, you'll need to generate an App Password:
-
Enable 2-Step Verification (if not already enabled):
- Go to your Google Account: https://myaccount.google.com/
- Select "Security" in the left navigation panel
- Under "Signing in to Google," select 2-Step Verification
- Follow the on-screen steps to set up 2-Step Verification
-
Generate an App Password:
- Go to the App passwords page: https://myaccount.google.com/apppasswords
- At the top, click Select app and choose Other (Custom name)
- Enter a name that identifies this application (e.g., "Milhas Agent")
- Click Generate
- A 16-character password will be displayed. Copy this password immediately as you won't be able to see it again
-
Use the App Password:
- In your
.envfile, setGMAIL_APP_PASSWORDto the 16-character password you just generated - The email address (
GMAIL_EMAIL) must be the same Gmail account where you generated the App Password
- In your
- Never share your App Password or commit it to version control
- If you suspect your App Password is compromised, revoke it immediately and generate a new one
- Each application should have its own unique App Password
Run the main script with the desired output option:
-
Console Output (default):
python main.py
-
Save to File:
python main.py --output file --output-file my_promotions.txt
-
Send via Email:
python main.py --output email
Make sure you've configured the email settings in your
.envfile first.
-
Debug Mode:
python main.py --debug
-
Override Configuration:
python main.py --output email --gmail-email your_email@gmail.com --gmail-app-password your_app_password
-
Help:
python main.py --help
milhas_whatsapp_agent/
├── ai_agents/ # AI agent implementations for data processing
├── formatters/ # Output formatters (HTML, text, etc.)
├── scraping/ # Web scraping logic
├── services/ # Core services and business logic
├── .env # Environment variables (not versioned)
├── .env.example # Example environment configuration
├── main.py # Main script entry point
└── requirements.txt # Python dependencies
All configuration is done through environment variables in the .env file. The following options are available:
DEBUG_MODE: Set toTrueto enable debug logging (default:False)LOG_LEVEL: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
GMAIL_EMAIL: Your Gmail address (required for email output)GMAIL_APP_PASSWORD: App Password for Gmail (see above for how to generate)EMAIL_RECIPIENT: Recipient email address (can be the same as GMAIL_EMAIL)EMAIL_SUBJECT: Email subject (default: 'Promoções de Milhas')
OUTPUT_FILE_NAME: Path to output file (default: 'promotions.txt')
You can override some settings via command line:
python main.py [--output {console,file,email}] [--output-file FILE] [--debug]Options:
--output: Output destination (console,file, oremail)--output-file: File path when output is set tofile(overridesOUTPUT_FILE_NAME)--debug: Enable debug mode (overridesDEBUG_MODE)
-
Never commit sensitive information
- The
.envfile is included in.gitignoreby default - Double-check that no API keys or passwords are committed to version control
- The
-
Regularly rotate credentials
- Periodically update your Gmail App Password
- Revoke and regenerate API keys that may have been compromised
-
Use environment-specific configurations
- Maintain separate
.envfiles for development and production - Never use production credentials in development environments
- Maintain separate
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Melhores Cartões for the promotions data
- Groq for the LLM processing
- Python for making this all possible!