AI-powered Gmail automation using Composio SDK. Automatically label emails based on custom prompts.
- Frontend: Next.js 15, React 19, TypeScript, Tailwind CSS
- Backend: Python/FastAPI, OpenAI Agents SDK
- Database: Supabase (PostgreSQL with RLS)
- AI Integration: Composio SDK for Gmail tools
- Authenticate and use Gmail tools via Composio SDK
- Implement OAuth flows with connection tracking
- Build AI agents that interact with authenticated APIs
- Set up real-time triggers for email processing
-
System Requirements
-
API Keys & Accounts
- Composio API Key: Get it from app.composio.dev/developers
- Supabase Project: Create at supabase.com
- Anthropic API Key: For Claude models (or use OpenAI/other LLMs)
COMPOSIO_API_KEY= # From app.composio.dev/developers
SUPABASE_URL= # Your Supabase project URL
SUPABASE_SERVICE_KEY= # Service role key (not anon key!)
GMAIL_AUTH_CONFIG_ID= # From Composio Gmail integration
ANTHROPIC_API_KEY= # Your LLM provider key
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_SUPABASE_URL= # Same as backend SUPABASE_URL
NEXT_PUBLIC_SUPABASE_ANON_KEY= # Anon key (not service key!)
NEXT_PUBLIC_ENABLE_CONNECTION_MODAL=true
git clone https://github.com/composiohq/demos
cd demos/gmail-labeller
Set up your Supabase database by following the instructions in apps/SUPABASE_SETUP.md
-
Composio API Key
- Go to app.composio.dev/developers
- Create new API key
- Set up Gmail integration in Composio dashboard
-
Supabase Keys
- Create project at supabase.com
- Get both
anon
key (frontend) andservice_role
key (backend) - Note your project URL
cd apps/backend
uv sync
# Create .env with your keys
cp .env.example .env
# Edit .env with your actual keys
# Run server
uvicorn main:app --reload
cd apps/frontend
pnpm install
# Create .env.local with your keys
cp .env.example .env.local
# Edit .env.local with your actual keys
# Run app
pnpm dev
# Expose local backend for Gmail webhooks
ngrok http 8000
# Use the ngrok URL in your Composio webhook configuration
# Get authenticated Gmail tools
tools = composio.tools.get(user_id, tools=[
"GMAIL_ADD_LABEL_TO_EMAIL",
"GMAIL_CREATE_LABEL"
])
# Create AI agent
agent = Agent(name="Gmail Reaper", tools=tools)
await Runner.run(agent, email_content)
// Status values: INITIATED -> ACTIVE -> FAILED/EXPIRED/REVOKED
const status = await checkConnectionStatus(connectionId)
composio.triggers.create(
user_id=user_id,
slug="GMAIL_NEW_GMAIL_MESSAGE",
trigger_config={"interval": 1, "labelids": "INBOX"}
)
Next.js Frontend -> FastAPI Backend -> Composio SDK -> Gmail API
|
Supabase DB
MIT - Use freely in your projects!
Built by Composio to demonstrate AI tool integration.