This is the companion python script for frize. It collects data from your email and stores it in a Supabase database.
Before you begin, ensure you have the following:
- Python: The script requires Python to be installed on your machine. You can download it from python.org.
- Gmail API Credentials: Follow the instructions in the Gmail API Python Quickstart Guide to set up your Google Cloud project and obtain the credentials.
- Supabase Account: Sign up for a Supabase account to create a database and obtain the
SUPABASE_URL
andSUPABASE_API_KEY
for API access. - OpenAI API Key: Obtain an API key from OpenAI as we will use it to generate embeddings for our data.
- Clone this repository on your local machine
git clone https://github.com/rittikbasu/rize_reader.git
- Navigate to the project directory
cd rize_reader
- Create a virtual environment
python3 -m venv venv
- Install the dependencies
pip3 install -r requirements.txt
- Activate the virtual environment
- for macOS/Linux:
source venv/bin/activate
- for Windows:
venv\Scripts\activate
- for macOS/Linux:
- Export the required environment variables in your terminal
Note: Put the mail address you recieve your rize emails from in
export SUPABASE_URL=YOUR_SUPABASE_URL SUPABASE_API_KEY=YOUR_SUPABASE_API_KEY OPENAI_API_KEY=YOUR_OPENAI_API_KEY RIZE_MAIL_ID=YOUR_RIZE_MAIL_ID
RIZE_MAIL_ID
. - Save your Gmail API credentials in the same directory as
main.py
and rename it tocredentials.json
. - Run the script
python3 main.py
- You will be prompted to authorize the script to access your Gmail account. You might need to add a redirect_uri to your OAuth consent screen. You can do this by adding the required redirect_uri to the list of Authorized redirect URIs in the OAuth consent screen in the Google Cloud Console.
- The script will start collecting data from your email and storing it in your Supabase database. You can view the data in your Supabase dashboard.
Note: If you've already been using Rize for a while then go to your Gmail account and search for rize and get the total number of emails. Then go to main.py
and change the value of max_results
to the total number of emails you have. This will ensure that the script collects all your previous data as well. Once the script has finished running you can change the value of max_results
back to 1.
You can automate the script to run at regular intervals using a cron job. I personally run it on a cloud server but you can also run it on your local machine. To do this follow the steps below:
- Open your terminal and type
crontab -e
to open the cron table. - Get the path to the python3 executable in your virtual environment by running
which python3
in your terminal and copy it. - Add the following line to the cron table:
This will run the script every day at 12:00 AM.
00 00 * * * /path/to/venv/bin/python3 /path/to/rize_reader/main.py
- Use an absolute path for the
credentials.json
file inmain.py
as cron jobs do not have access to the current working directory.
- Replace
/path/to/rize_reader
with the path to the rize_reader directory and/path/to/venv/bin/python3
with the path to the python3 executable in your virtual environment. - If you get an error where it cannot find the environment variables then declare the variables at the top of the cron table.
Contributions are always welcome! Feel free to open an issue or submit a pull request if you have any ideas or suggestions.