Skip to content

CiroZhang/gmail_replier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Gmail Auto-Reply Bot

A small Python service that scans your Gmail inbox and drafts/sends polite replies using either OpenAI or a local Ollama model.

Features

  • ✅ OpenAI or Ollama as the LLM backend
  • ✅ Safer system prompt (configurable)
  • ✅ CLI: one-shot or looping mode, adjustable interval
  • ✅ Dry-run mode (preview replies without sending)
  • ✅ Creates/uses a custom Gmail label (default: AutoReplied)
  • ✅ Simple exponential backoff for transient Gmail/API errors

Setup

1) Python & deps

python -m venv .venv
source .venv/bin/activate  
pip install --upgrade pip
pip install google-auth-oauthlib google-auth-httplib2 requests openai

2) Gmail OAuth creds

  1. Go to Google Cloud Console → create project → Enable Gmail API.
  2. Create OAuth client ID (Desktop) and download credentials.json into this project folder.
  3. First run will open a browser for consent; a token.json will be saved.

You can customize paths via env:

  • GMAIL_CREDENTIALS_FILE (default credentials.json)
  • GMAIL_TOKEN_FILE (default token.json)
  • GMAIL_LABEL (default AutoReplied)
  1. Choose an LLM backend

OpenAI (default)

export OPENAI_API_KEY=sk-...        # put your key here
export OPENAI_MODEL=gpt-4o-mini     # optional

Ollama

# Make sure Ollama is running locally and the model is pulled
# e.g., ollama run phi3:3.8b or ollama pull llama3
export OLLAMA_BASE="http://127.0.0.1:11434"
export OLLAMA_MODEL="phi3:3.8b"    

Running

# Use Ollama instead of OpenAI
python main.py --provider ollama

# Change interval to 30s, default 10s
python main.py --interval 30

# Dry run (draft but do not send/label)
python main.py --dry-run

# Provide your own system prompt
python main.py --context "You're a formal, brief assistant that..."

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages