A local service that ingests Google Voice SMS from Gmail notifications and performs intelligent task execution via skill-based intent routing.
This agent polls your Gmail for Google Voice SMS notifications, parses messages from a specific allowed sender, recognizes intent (help, status, search, gmail operations, news, weather), executes the appropriate skill, and logs replies for future outbound delivery.
- 📧 Gmail Integration: Uses Gmail API OAuth to read Google Voice notifications
- 🎯 Intent Recognition: Rule-based router for common commands
- 🔧 Extensible Skills: Web search, Gmail summary, weather, and more
- 🔄 Polling Service: APScheduler-based background task
- 🚀 REST API: Health checks and reply preview endpoints
- 🔐 Security: Least-privilege OAuth scopes, number whitelisting
- 📊 Systemd Ready: Production-ready service configuration
- Raspberry Pi (Bullseye/Bookworm)
- Python 3.11+
- Gmail account with Google Voice
- Google Cloud Project with Gmail API enabled
cd /opt
sudo mkdir sms-agent
sudo chown $USER:$USER sms-agent
cd sms-agent
git clone <your-repo> .
python3.11 -m venv venv
source venv/bin/activate
pip install -r requirements.txtcp .env.example .env
nano .envSet your allowed sender number in E.164 format (e.g., +14155550123):
ALLOWED_SENDER_E164=+1XXXXXXXXXX
Follow instructions in scripts/setup_gmail_oauth.md to:
- Enable Gmail API in Google Cloud Console
- Create OAuth 2.0 Desktop credentials
- Run authorization flow to generate token
python -m src.google.gmail_client --authorizesource venv/bin/activate
python -m uvicorn src.main:app --host 0.0.0.0 --port 8000 --reloadsudo cp deploy/sms-agent.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable sms-agent
sudo systemctl start sms-agent
sudo systemctl status sms-agentSee scripts/install_systemd.md for detailed instructions.
curl http://localhost:8000/healthzResponse:
{
"status": "ok",
"timestamp": "2025-10-06T12:34:56.789Z",
"poller_running": true
}View the last N generated replies:
curl http://localhost:8000/reply-preview?limit=10Response:
{
"replies": [
{
"timestamp": "2025-10-06T12:30:00.000Z",
"from_number": "+14155550123",
"original_message": "weather san francisco",
"reply_text": "San Francisco: ⛅️ Partly cloudy +15°C"
}
],
"total": 1
}Send these via SMS to your Google Voice number:
help- Show available commandsstatus- Show agent status and recent activitysearch <query>- Search Wikipedia/web for informationgmail_unread- Summarize unread emailsgmail_from <email>- Show emails from specific sendernews <topic>- Search news about a topicweather <city>- Get current weather
All configuration is managed via .env file:
| Variable | Description | Default |
|---|---|---|
ALLOWED_SENDER_E164 |
Phone number allowed to control the agent | Required |
GOOGLE_CLIENT_ID |
OAuth 2.0 client ID | Required |
GOOGLE_CLIENT_SECRET |
OAuth 2.0 client secret | Required |
GOOGLE_TOKEN_PATH |
Path to store OAuth token | ./token.json |
POLL_INTERVAL_SECONDS |
Gmail polling frequency | 60 |
TIMEZONE |
Timezone for logs | America/Los_Angeles |
SEEN_IDS_PATH |
Path to seen message IDs storage | ./seen_message_ids.jsonl |
REPLY_LOG_PATH |
Path to reply log file | ./replies.log |
MAX_REPLIES_MEMORY |
Ring buffer size for replies | 100 |
Logs are written to:
./logs/sms-agent.log(rotating, 10MB max, 5 backups)- systemd journal:
sudo journalctl -u sms-agent -f
- OAuth token stored locally (keep
token.jsonsecure) - Only messages from
ALLOWED_SENDER_E164are processed - Gmail scopes limited to read-only:
gmail.readonly - No external API keys stored (uses free services)
- Rate limiting on polling to respect Gmail API quotas
- Check Gmail API is enabled in Google Cloud Console
- Verify OAuth token is valid:
ls -la token.json - Check allowed sender number format: must be E.164 (
+1XXXXXXXXXX) - View logs:
tail -f logs/sms-agent.log
# Check service status
sudo systemctl status sms-agent
# View recent logs
sudo journalctl -u sms-agent -n 50
# Restart service
sudo systemctl restart sms-agentRe-run authorization:
cd /opt/sms-agent
source venv/bin/activate
python -m src.google.gmail_client --authorizepytest tests/ -vSee agents.md for architecture details and project_stages.md for development roadmap.
- Outbound SMS via Twilio or Google Apps Script
- LLM-based intent recognition and response generation
- Multi-user support with per-sender permissions
- Webhook receivers for real-time notifications
- Voice command processing
MIT
See agents.md and project_stages.md for contribution guidelines and development stages.