This project fetches the current exchange rates for various currencies and cryptocurrencies (USD, BTC, EUR, ETH) and converts them to Brazilian Real (BRL). The converted rates are then sent as a WhatsApp message using the Twilio API.
- Fetches exchange rates for USD, BTC, EUR, and ETH.
- Converts exchange rates to BRL.
- Sends the converted exchange rates to a specified WhatsApp number using Twilio.
- Uses environment variables to manage sensitive information.
- Python 3.6+
- Twilio Account with WhatsApp API access
pip
package installer
- Clone the repository:
git clone https://github.com/carloshpdoc/currency-exchange-whatsapp-notifier.git cd currency-exchange-whatsapp-notifier
- Make setup.sh executable:
chmod +x setup.sh
- Run the setup script:
bash setup.sh
- Create a virtual environment (optional but recommended):
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
- Install the required packages:
pip install -r requirements.txt
- Create a .env file in the project root and add your environment variables:
TWILIO_ACCOUNT_SID=your_twilio_account_sid TWILIO_AUTH_TOKEN=your_twilio_auth_token TWILIO_PHONE_NUMBER=your_twilio_phone_number WHATSAPP_PHONE_NUMBER=your_whatsapp_phone_number
To run the script and fetch the exchange rates, use the following command:
python send_exchange_rates.py
You can schedule the script to run at specific intervals using a task scheduler like cron
(Linux/Mac) or Task Scheduler
(Windows).
- Open Terminal.
- Edit the crontab file:
crontab -e
- Add the following lines to schedule the script to run at 8 AM and 2 PM every day:
0 8 * * * /path/to/your/venv/bin/python /path/to/your/script/send_exchange_rates.py 0 14 * * * /path/to/your/venv/bin/python /path/to/your/script/send_exchange_rates.py
currency-exchange-whatsapp-notifier/
├── venv/ # Virtual environment (optional)
├── .env # Environment variables
├── requirements.txt # Python dependencies
├── send_exchange_rates.py # Main script
├── setup.sh # Setup script
└── README.md # Project documentation
This project is licensed under the MIT License. See the LICENSE file for more information.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.