Skip to content

This project automates the process of fetching current exchange rates for various currencies and cryptocurrencies (USD, BTC, EUR, ETH), converting them to Brazilian Real (BRL), and sending the converted rates as a WhatsApp message using the Twilio API. Ideal for anyone who needs to stay updated with real-time exchange rates and receive notification

License

Notifications You must be signed in to change notification settings

carloshpdoc/bot-get-currency

Repository files navigation

Currency Exchange Rate to BRL WhatsApp Notifier

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.

Features

  • 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.

Prerequisites

  • Python 3.6+
  • Twilio Account with WhatsApp API access
  • pip package installer

Installation

  1. Clone the repository:
    git clone https:https://github.com/carloshpdoc/currency-exchange-whatsapp-notifier.git
    cd currency-exchange-whatsapp-notifier
    
  2. Make setup.sh executable:
    chmod +x setup.sh
  3. Run the setup script:
    bash setup.sh
OR
  1. Create a virtual environment (optional but recommended):
    python3 -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
    
  2. Install the required packages:
    pip install -r requirements.txt
    
  3. 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
    

Usage

To run the script and fetch the exchange rates, use the following command:

python send_exchange_rates.py

Scheduling the Script

You can schedule the script to run at specific intervals using a task scheduler like cron (Linux/Mac) or Task Scheduler (Windows).

macOS/Linux

  1. Open Terminal.
  2. Edit the crontab file:
    crontab -e
    
  3. 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
    

Project Structure

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

License

This project is licensed under the MIT License. See the LICENSE file for more information.

Acknowledgments

Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

Social Media

GitHub

Instagram

X (formerly Twitter) Follow

Linkedin

Email

About

This project automates the process of fetching current exchange rates for various currencies and cryptocurrencies (USD, BTC, EUR, ETH), converting them to Brazilian Real (BRL), and sending the converted rates as a WhatsApp message using the Twilio API. Ideal for anyone who needs to stay updated with real-time exchange rates and receive notification

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published