Gmail Smart Inbox: Filter, Draft Responses, and Discord Summary
Searches Gmail for recent unread emails, cross-references senders against Google Contacts to filter out spam and automated messages, identifies important emails from real people, drafts and saves personalized responses in Gmail for each, then posts a formatted summary of all important emails and drafted responses to a Discord channel.
Search Gmail for Unread Emails
Search Gmail for unread emails from the last day in the Primary category. This filters out Promotions, Social, Updates, and Forums tabs automatically. Return the full list of matching emails including sender name, sender email address, subject line, date received, and a snippet or full body of each message. This data will be used in the next step to identify which emails are from real people and deserve a response.

Fetch Google Contacts
Retrieve the user's Google Contacts list. This will be used to cross-reference against email senders to verify which emails come from known, real people versus unknown senders, marketing lists, or automated systems. Return contact names and email addresses.

Filter Spam and Prioritize Emails
Goal: Analyze the fetched emails and contacts list to separate important emails from real people versus spam, marketing, automated notifications, and bulk messages. Produce a prioritized list of emails that deserve a personal response. | Inputs: 1) List of unread Gmail messages (sender, subject, body/snippet, date). 2) Google Contacts list (names and email addresses). | Outputs: A structured list of important emails that need responses. For each email include: sender name, sender email, subject, key points from the message body, urgency level (high/medium/low), and whether the sender is a known contact. Exclude any email that matches the spam/filter criteria below. | Constraints: EXCLUDE emails that match ANY of these patterns: 1) Sender is 'noreply@', 'no-reply@', 'donotreply@', or similar no-reply addresses. 2) Sender domain is a known bulk sender (e.g., marketing platforms like mailchimp, sendgrid, constantcontact, hubspot). 3) Subject or body contains unsubscribe links, promotional language ('limited time offer', 'act now', 'click here to claim'). 4) Automated notifications from services (shipping updates, password resets, login alerts, social media notifications, build/deploy alerts). 5) Newsletter-style emails with generic greetings ('Dear customer', 'Dear subscriber'). 6) Calendar invites or event reminders that don't need a written reply. PRIORITIZE emails where: the sender appears in Google Contacts, the email is addressed directly (not BCC/CC mass send), the message contains a direct question or action request, or the tone is personal and conversational. | Success criteria: The output list contains only emails from real people that genuinely need a personal response. Zero spam, marketing, or automated messages slip through. Each email has enough context (key points, urgency) to draft an appropriate response.
Workflow preview
What the agent will follow (tools, prompts, and workflow steps).
1. Call tool: Gmail - All Email Actions (Search Gmail for Unread Emails).
Instructions:
Search Gmail for unread emails from the last day in the Primary category. This filters out Promotions, Social, Updates, and Forums tabs automatically. Return the full list of matching emails including sender name, sender email address, subject line, date received, and a snippet or full body of each message. This data will be used in the next step to identify which emails are from real people and deserve a response.
Parameters:
{"action": "search_emails", "query": "is:unread newer_than:1d category:primary"}
2. Call tool: Google Contacts (Fetch Google Contacts).
Instructions:
Retrieve the user's Google Contacts list. This will be used to cross-reference against email senders to verify which emails come from known, real people versus unknown senders, marketing lists, or automated systems. Return contact names and email addresses.
Parameters:
{"action": "list_contacts", "page_size": 500}
3. Apply the following prompt: Goal:
Analyze the fetched emails and contacts list to separate important emails from real people versus spam, marketing, automated notifications, and bulk messages. Produce a prioritized list of emails that deserve a personal response.
Inputs:
1) List of unread Gmail messages (sender, subject, body/snippet, date). 2) Google Contacts list (names and email addresses).
Outputs:
A structured list of important emails that need responses. For each email include: sender name, sender email, subject, key points from the message body, urgency level (high/medium/low), and whether the sender is a known contact. Exclude any email that matches the spam/filter criteria below.
Constraints:
EXCLUDE emails that match ANY of these patterns: 1) Sender is 'noreply@', 'no-reply@', 'donotreply@', or similar no-reply addresses. 2) Sender domain is a known bulk sender (e.g., marketing platforms like mailchimp, sendgrid, constantcontact, hubspot). 3) Subject or body contains unsubscribe links, promotional language ('limited time offer', 'act now', 'click here to claim'). 4) Automated notifications from services (shipping updates, password resets, login alerts, social media notifications, build/deploy alerts). 5) Newsletter-style emails with generic greetings ('Dear customer', 'Dear subscriber'). 6) Calendar invites or event reminders that don't need a written reply. PRIORITIZE emails where: the sender appears in Google Contacts, the email is addressed directly (not BCC/CC mass send), the message contains a direct question or action request, or the tone is personal and conversational.
Success criteria:
The output list contains only emails from real people that genuinely need a personal response. Zero spam, marketing, or automated messages slip through. Each email has enough context (key points, urgency) to draft an appropriate response.
4. For each email, complete the steps in this section once. Iterate over each important email identified in the previous filtering step. For each email, draft a personalized response and then save it as a Gmail draft. Process them in order of urgency (high first, then medium, then low).
5. Apply the following prompt: Goal:
Draft a thoughtful, personalized email response for the current email that matches the tone and context of the original message.
Inputs:
The current email object including: sender name, sender email, subject line, message body/key points, urgency level, and whether sender is a known contact.
Outputs:
A complete draft email response including: the recipient email address (the original sender), a reply subject line (Re: original subject), and the response body text. The body should be ready to send as-is.
Constraints:
1) Match the formality level of the original email - if casual, respond casually; if formal, respond formally. 2) Address specific questions or requests from the original message. 3) Keep responses concise but complete - acknowledge what was said, answer questions, and state any next steps. 4) Use the sender's first name if known from contacts. 5) Do NOT use generic filler phrases like 'I hope this email finds you well.' 6) Do NOT over-promise or commit to specific dates/times without the user's input - instead use phrases like 'I will follow up shortly' or 'Let me check on that and get back to you.' 7) End with an appropriate sign-off that matches the tone.
Success criteria:
The draft reads as if the user wrote it personally. It addresses the specific content of the original email, sounds natural, and is ready for the user to review and send with minimal edits.
6. Call tool: Gmail - All Email Actions (Save Draft in Gmail).
Instructions:
Save the drafted response as a Gmail draft. Use the recipient email address, reply subject line, and response body from the previous drafting step. The draft should be saved so the user can review it in their Gmail Drafts folder before deciding to send. Include the original message thread ID if available so the draft appears as a reply in the correct conversation thread.
Parameters:
{"action": "create_draft"}
7. Apply the following prompt: Goal:
Create a well-formatted Discord message summarizing all important emails received and the draft responses that were saved in Gmail.
Inputs:
The complete list of processed important emails with: sender info, subject, key points, urgency level, and a brief description of the drafted response for each.
Outputs:
A single formatted Discord message using markdown. Structure it as: 1) A header with the date and total count of important emails. 2) For each email: sender name, subject, urgency tag, a 1-2 sentence summary of what the email was about, and a 1-sentence summary of the draft response. 3) A footer noting that all draft responses have been saved in Gmail Drafts for review.
Constraints:
1) Use Discord-compatible markdown (bold with **, headers with ##, bullet points, code blocks if needed). 2) Keep each email summary to 2-3 lines max - this is a notification, not a full report. 3) Use urgency indicators: HIGH, MEDIUM, LOW in bold. 4) If no important emails were found, send a brief 'All clear - no important emails requiring response' message instead. 5) Do not include sensitive information like full email bodies or personal details - keep it to sender name, subject, and brief context only.
Success criteria:
The Discord message is scannable at a glance - the user can quickly see how many important emails came in, who they are from, what they are about, and that drafts have been prepared. It should be under 2000 characters to fit Discord's message limit.
8. Call tool: Post On Discord Channel (Post Summary to Discord).
Instructions:
Use Discord Webhook URL:{ENTER YOUR URL HERE}
Post the formatted email summary to the configured Discord channel. The message should use the markdown-formatted summary from the previous step. This serves as a quick notification so the user knows which emails came in and that draft responses are waiting in their Gmail Drafts folder for review.