- OAuth authentication with Gmail API
- Automatic email classification using AI
- Smart response generation
- Scheduled email checking
- Action-based workflows
View source code
Complete source code on GitHub
Use cases
- Customer support ticket triage
- Newsletter filtering and summarization
- Automated follow-ups
- Priority inbox management
- Email-to-task conversion
Architecture
The workflow consists of:- Cron trigger: Checks Gmail inbox every 5 minutes
- Email classifier: Uses AI to categorize emails
- Action router: Routes emails based on classification
- Response generator: Creates appropriate responses
- Gmail sender: Sends automated replies
Prerequisites
Set up Gmail API access:- Create a Google Cloud project
- Enable Gmail API
- Create OAuth 2.0 credentials
- Download credentials as
credentials.json
Step 1: Check for new emails
Createsteps/check-gmail.step.ts to poll Gmail:
steps/check-gmail.step.ts
Step 2: Classify emails with AI
Createsteps/classify-email.step.ts for AI classification:
steps/classify-email.step.ts
Step 3: Route to action handlers
Createsteps/route-email.step.ts to route emails:
steps/route-email.step.ts
Step 4: Generate and send replies
Createsteps/reply-email.step.ts for automated responses:
steps/reply-email.step.ts
Step 5: Track metrics
Createsteps/email-metrics.step.ts to track performance:
steps/email-metrics.step.ts
Configuration
Set environment variables in.env:
Testing
Manually trigger email check:What you learned
Cron triggers
Schedule periodic email checks
AI classification
Use LLMs to categorize and understand emails
Workflow routing
Route tasks based on conditions
State triggers
React to state changes for metrics
Next steps
GitHub PR manager
Automate GitHub workflows
Workflows guide
Learn advanced workflow patterns