Global AI Network
Agent Template v1.0.0

Gmail AI Email Categorizer & Auto-Reply

45+
Deployments
5m
Setup Time
Free
Pricing

Need custom configuration?

Our solution engineers can help you adapt this agent to your specific infrastructure and requirements.

Enterprise Grade Best Practices Production Optimized

INTEGRATED_MODULES

Gmail
Gmail
Google Sheets
Google Sheets
OpenAI
OpenAI
Step by Step

Setup Tutorial

mission-briefing.md

What This Agent Does

The Email Intelligence & Routing Agent is an AI-powered email management system that automatically processes incoming emails, intelligently categorizes them, and routes each message to the appropriate workflow. This sophisticated automation analyzes email content using advanced AI models, applies relevant labels, generates contextual responses, and creates organized summaries—all without manual intervention.

Key benefits and time savings:

  • Reduce email processing time by 80%: Automatically handle categorization and initial responses
  • Never miss important emails: Priority emails trigger immediate draft creation for executive review
  • Maintain professional communication: AI generates context-aware replies tailored to each email type
  • Centralized organization: All emails are labeled, summarized, and logged for easy retrieval
  • Scalable email management: Handle hundreds of emails daily with consistent, intelligent processing

Target use cases:

  • Executive assistants managing high-volume inboxes
  • Customer service teams triaging inquiries
  • Marketing departments tracking promotional content
  • Finance teams organizing billing and payment communications
  • Any professional needing intelligent email organization and response automation

Who Is It For

This workflow is ideal for busy professionals and teams who receive high volumes of diverse emails and need intelligent automation to stay organized. It's particularly valuable for:

  • Executive assistants managing multiple stakeholders' inboxes
  • Customer service managers handling inquiries at scale
  • Finance professionals organizing billing communications
  • Marketing teams tracking and summarizing promotional content
  • Business owners wanting to automate routine email processing while maintaining quality responses

No coding experience is required—the agent handles all complexity behind the scenes.


Required Integrations

Gmail

Why it's needed: Gmail is the email source and destination for all actions. The agent reads incoming emails, applies labels, creates drafts, sends replies, and marks messages as read.

Setup steps:

  1. Open your TaskAGI workspace and navigate to Integrations
  2. Search for and select Gmail
  3. Click Connect and you'll be redirected to Google's authentication page
  4. Sign in with the Gmail account you want to use for this workflow
  5. Grant TaskAGI permission to:
    • Read your email messages
    • Modify labels and message metadata
    • Create and send drafts
    • Reply to messages
  6. Click Authorize to complete the connection
  7. Return to TaskAGI—your Gmail account is now connected

How to obtain credentials: Gmail uses OAuth 2.0, so you don't need to manually create API keys. Google handles authentication securely through the authorization flow above.

Configuration in TaskAGI:

  • Select your connected Gmail account from the dropdown in any Gmail node
  • Ensure you have Gmail labels created for: "Priority", "Advertisement", "Inquiry", and "Finance" (the agent will reference these)
  • Optional: Create additional labels for custom categorization

OpenAI

Why it's needed: OpenAI's GPT models power the intelligent email classification, response generation, and summarization. The agent uses GPT-4o-mini for analysis and GPT-4o for generating professional responses.

Setup steps:

  1. Visit OpenAI's platform
  2. Sign up or log in to your OpenAI account
  3. Navigate to API keys in the left sidebar
  4. Click Create new secret key
  5. Copy the generated API key (you won't see it again)
  6. In TaskAGI, go to Integrations and select OpenAI
  7. Click Connect and paste your API key
  8. Click Verify to confirm the connection
  9. Your OpenAI integration is now active

How to obtain API keys:

Configuration in TaskAGI:

  • Select your connected OpenAI account in all AI nodes
  • The workflow uses gpt-4o-mini for classification and summarization (faster, cost-effective)
  • The workflow uses gpt-4o for response generation (higher quality for customer-facing content)
  • No additional configuration needed—prompts are pre-configured

Google Sheets

Why it's needed: Google Sheets serves as a centralized log for all processed emails, creating an auditable record of advertisements and other categorized content for future reference and analysis.

Setup steps:

  1. Open Google Sheets in your browser
  2. Create a new spreadsheet or open an existing one
  3. Name it something descriptive like "Email Processing Log"
  4. Create column headers in the first row:
    • Column A: Date
    • Column B: From
    • Column C: Subject
    • Column D: Category
    • Column E: Summary
  5. Copy the sheet's URL from your browser address bar
  6. In TaskAGI, go to Integrations and select Google Sheets
  7. Click Connect and authorize access to your Google account
  8. Return to the workflow and paste your sheet URL in the "Log to Sheet" node

How to obtain credentials: Google Sheets uses the same OAuth authentication as Gmail. If you've already connected Gmail, Google Sheets will use the same authorization.

Configuration in TaskAGI:

  • Paste the complete sheet URL in the sheet_url parameter of the "Log to Sheet" node
  • Example: https://docs.google.com/spreadsheets/d/1a2b3c4d5e6f7g8h9i0j/edit
  • The agent will automatically append rows with processed email data

Configuration Steps

Step 1: Review Information Nodes

The first three nodes are informational only and don't require configuration:

  • Agent Name Options: Documents available naming conventions
  • Category & Industry: Notes the email categories this agent handles
  • How It Works: Provides workflow overview

No action needed—these are reference nodes.

Step 2: Configure the Gmail Trigger

Node: Gmail Trigger (trigger.schedule_interval)

This node determines how often the agent checks for new emails.

  • Interval: Set to 5 minutes for real-time processing, or adjust based on your needs
  • Timezone: Select your local timezone
  • Start time: Choose when the agent should begin checking (e.g., 8:00 AM)

Example configuration:

Interval: Every 5 minutes
Timezone: America/New_York
Start: 08:00 AM

Step 3: Configure Email Retrieval

Node: Get Recent Emails (gmail.listMessages)

  • Max Results: Set to 10 to process the 10 most recent unread emails per cycle
  • Query: Enter is:unread to only process new messages
  • Label Filter: Optional—leave blank to check all emails

Step 4: Configure the Loop

Node: Loop Through Emails (core.loop)

  • Loop Path: Automatically set to iterate through results from "Get Recent Emails"
  • No configuration needed—this node automatically processes each email sequentially

Step 5: Configure Email Details Retrieval

Node: Get Email Details (gmail.getMessage)

  • Message ID: Automatically pulls from the loop
  • Format: Set to full to get complete email content
  • No manual configuration needed

Step 6: Configure AI Classification

Node: AI Classify Email (openai.createCompletion)

This node analyzes email content and assigns it to one of four categories: Priority, Advertisement, Inquiry, or Finance.

  • Model: gpt-4o-mini (pre-configured)
  • Prompt: Pre-configured to classify emails
  • Temperature: 0.3 (low for consistent categorization)
  • Max Tokens: 50

No changes needed—the prompt is optimized for accurate classification.

Step 7: Configure Routing Logic

Node: Route by Category (core.switch)

This node directs each email to the appropriate workflow branch based on AI classification.

  • Switch Field: Set to the classification output from node 8
  • Cases: Pre-configured for four categories:
    • case_0: Priority emails
    • case_1: Advertisements
    • case_2: Customer inquiries
    • case_3: Finance communications

No configuration needed—routing is automatic based on classification.

Step 8: Configure Priority Email Workflow

Node: Add Priority Label (gmail.addLabelsToMessage)

  • Label: Priority
  • Message ID: From current email in loop

Node: Generate Priority Reply (openai.createCompletion)

  • Model: gpt-4o
  • Prompt: Pre-configured for executive assistant responses
  • Temperature: 0.7 (balanced for professional tone)

Node: Create Priority Draft (gmail.createDraft)

  • To: [[nodes.7.from]] (automatically uses sender's email)
  • Subject: Re: [[nodes.7.subject]] (automatically references original subject)
  • Body: [[nodes.11.message]] (uses AI-generated response)

This creates a draft for manual review before sending.

Step 9: Configure Advertisement Workflow

Node: Add Ad Label (gmail.addLabelsToMessage)

  • Label: Advertisement

Node: Summarize Advertisement (openai.createCompletion)

  • Model: gpt-4o-mini
  • Prompt: Pre-configured for marketing analysis
  • Max Tokens: 150

Node: Log to Sheet (googlesheets.appendRowFromUrl)

  • Sheet URL: Paste your Google Sheets URL here
  • Data: Automatically includes date, sender, subject, category, and summary
  • ⚠️ Critical: This node requires your sheet URL—without it, logging will fail

Step 10: Configure Inquiry Workflow

Node: Add Inquiry Label (gmail.addLabelsToMessage)

  • Label: Inquiry

Node: Generate Inquiry Reply (openai.createCompletion)

  • Model: gpt-4o
  • Prompt: Pre-configured for customer service responses
  • Temperature: 0.7

Node: Reply to Inquiry (gmail.replyToEmail)

  • Message ID: From current email
  • Body: [[nodes.17.message]] (uses AI-generated response)
  • Send Immediately: true (auto-sends professional responses)

Step 11: Configure Finance Workflow

Node: Add Finance Label (gmail.addLabelsToMessage)

  • Label: Finance

Node: Summarize Finance Email (openai.createCompletion)

  • Model: gpt-4o-mini
  • Prompt: Pre-configured for financial analysis
  • Max Tokens: 200

Node: Forward Finance Summary (gmail.sendEmail)

  • To: Enter your finance team's email address (e.g., finance@company.com)
  • Subject: [Finance] [[nodes.20.subject]] (auto-prefixes with [Finance])
  • Body: Pre-configured to include summary and action items
  • ⚠️ Critical: Enter a valid recipient email—without it, forwarding will fail

Step 12: Configure Final Action

Node: Mark as Read (gmail.markAsRead)

  • Message ID: From current email
  • No configuration needed—automatically marks processed emails as read

Testing Your Agent

Pre-Launch Checklist

Before running your first test, verify:

  • ✅ All three integrations (Gmail, OpenAI, Google Sheets) are connected
  • ✅ Gmail labels exist: "Priority", "Advertisement", "Inquiry", "Finance"
  • ✅ Google Sheets URL is entered in the "Log to Sheet" node
  • ✅ Finance team email is entered in the "Forward Finance Summary" node
  • ✅ OpenAI account has available credits

Test Execution Steps

1. Send Test Emails

Send yourself four test emails from different accounts (or use different subjects):

Test 1 (Priority): "Urgent: Board meeting rescheduled to 2 PM"
Test 2 (Advertisement): "50% off our premium software—limited time offer!"
Test 3 (Inquiry): "Hi, I have a question about your pricing plans"
Test 4 (Finance): "Invoice #12345 for services rendered"

2. Run the Workflow

  • In TaskAGI, click Run on your workflow
  • Select Run Now to execute immediately (don't wait for the schedule)
  • Monitor the execution in real-time

3. Verify Each Step

Priority Email:

  • ✅ Check Gmail for a draft reply (not sent automatically)
  • ✅ Verify the "Priority" label was applied
  • ✅ Review the AI-generated response for quality

Advertisement Email:

  • ✅ Verify the "Advertisement" label was applied
  • ✅ Check Google Sheets for a new row with the summary
  • ✅ Confirm the summary captures key promotional details

Inquiry Email:

  • ✅ Verify the "Inquiry" label was applied
  • ✅ Check your inbox for an auto-reply from the workflow
  • ✅ Ensure the response is professional and relevant

Finance Email:

  • ✅ Verify the "Finance" label was applied
  • ✅ Check your finance team's inbox for the forwarded summary
  • ✅ Confirm the summary includes actionable information

All Emails:

  • ✅ Verify all test emails are marked as read
  • ✅ Check execution logs for any errors

Expected Results & Success Indicators

Successful execution shows:

  • All four test emails processed within 30 seconds
  • Appropriate labels applied to each email
  • AI-generated responses are contextually relevant and professional
  • Google Sheets log contains complete records
  • Finance summary forwarded to the designated recipient
  • Zero errors in the execution log

Common issues and solutions:

Issue Solution
"Sheet URL not found" error Verify the Google Sheets URL is complete and accessible
"Invalid recipient" error Confirm the finance team email address is correct
AI responses are generic Adjust temperature settings or refine prompts in OpenAI nodes
Emails not being processed Check that the Gmail query is:unread is working; mark test emails as unread
Labels not applying Verify label names match exactly (case-sensitive)

Fine-Tuning After Testing

Once basic testing succeeds, optimize your agent:

  1. Adjust the schedule interval based on your email volume (5 minutes for high volume, 15-30 minutes for moderate)
  2. Refine AI prompts if responses don't match your style—click into each OpenAI node and edit the prompt text
  3. Add custom categories by duplicating workflow branches and creating new labels
  4. Expand logging by adding more columns to your Google Sheets template

Congratulations! Your Email Intelligence & Routing Agent is now live and working to transform how you manage email. You've eliminated manual categorization, created an audit trail, and automated professional responses—all while maintaining quality and control.