Inbox manager (GPT, Google Calendar & Supabase)
Overview
Turn your cluttered inbox into a smart, autonomous assistant that categorizes emails, replies to leads, checks your calendar, and notifies you on Telegram—all without lifting a finger.
This workflow is designed for a marketing agency, but can be adapted for any business. It classifies incoming emails into categories like Sales, Client Communication, Reports, Billing, and Other. If it detects a new lead or priority message, it routes the email to one of two agents:
- The Calendar Agent checks your availability in Google Calendar and drafts a consultation reply
- The Knowledge Agent answers FAQs using your business knowledge base (with Supabase embeddings)
Both agents create draft email responses and send a Telegram alert so you're always in the loop.
Who’s it for
- Founders and agency owners buried in emails
- Marketing teams handling lots of inbound leads
- Customer support managers automating Tier 1 replies
- Anyone who wants a cleaner, smarter inbox without hiring a VA
How it works
- Gmail trigger watches for incoming emails
- Email content is passed to an AI classifier to apply a label (Sales, Client, Billing, etc.)
- If the message is a new inquiry or lead, it’s routed to:
- Calendar Agent → checks Google Calendar and drafts a reply with available slots
- Knowledge Agent → searches vector DB and drafts a helpful reply from documentation
- Both agents create a Gmail draft response and send a Telegram notification with summary
Example use case
> A lead emails you asking for a discovery call.
>
> ✅ Email is labeled "Sales"
> ✅ AI Calendar Agent checks your Google Calendar
> ✅ A reply is drafted offering free time slots
> ✅ You get a Telegram ping:
> "New lead: Abdul Mir. I checked your calendar and drafted a reply. Check your email!"
How to set up
- Connect your Gmail and set up a trigger for new messages
- Train the AI classifier with example categories and emails
- Connect Google Calendar API for availability checks
- Upload your internal docs and sync to Supabase vector store
- Connect Telegram for alerts
- Customize AI prompts and escalation logic as needed
Requirements
- Gmail integration
- OpenAI or Claude API (for classification + chat agents)
- Google Calendar API
- Supabase (or Pinecone, Weaviate) for RAG vector DB
- Telegram bot API key
How to customize
- Add custom labels like “Recruiting,” “Investor,” or “Support”
- Replace Telegram with Slack or SMS alerts
- Add CRM sync to update lead status
- Escalate complicated replies to a human via task creation
- Add auto-send (instead of drafts) after review or based on confidence score
n8n Inbox Manager with AI, Google Calendar, and Supabase
This n8n workflow automates the processing of incoming emails, leveraging AI to understand their intent, and then routing them to appropriate actions like creating calendar events, sending Telegram messages, or performing other defined tasks. It acts as an intelligent inbox manager, reducing manual effort and ensuring important communications are handled efficiently.
What it does
This workflow streamlines email management through the following steps:
- Triggers on New Emails: Listens for new emails arriving in a specified Gmail inbox.
- Analyzes Email Content with AI: Uses a Language Model (likely OpenAI) to classify the email's intent (e.g., "create an event", "send a message").
- Routes Based on AI Classification:
- If the AI classifies the email as an "event creation" request, it processes the details to create a Google Calendar event.
- If the AI classifies the email as a "send message" request, it composes and sends a message via Telegram.
- For other classifications or if the AI needs more context, it can engage in a "Think" process, potentially querying a Supabase vector store for relevant information.
- Stores and Retrieves Context (Optional/Implicit): Utilizes a Supabase Vector Store and a Simple Memory to store and retrieve conversational or contextual information, enhancing the AI's ability to understand and respond to complex requests over time.
- Parses Structured Output: Employs a Structured Output Parser to extract specific data (e.g., event details, message content) from the AI's responses.
Prerequisites/Requirements
To use this workflow, you will need:
- n8n Instance: A running n8n instance.
- Gmail Account: Configured with n8n credentials to trigger on new emails and potentially send replies.
- OpenAI API Key: For the AI Agent, OpenAI Chat Model, and Embeddings OpenAI nodes.
- Telegram Account: Configured with n8n credentials to send messages.
- Supabase Project: With a configured vector store, used by the Supabase Vector Store node for knowledge retrieval.
- Langchain Nodes: Ensure the
@n8n/n8n-nodes-langchainpackage is installed in your n8n instance, as this workflow heavily relies on Langchain AI capabilities.
Setup/Usage
- Import the Workflow: Download the provided JSON and import it into your n8n instance.
- Configure Credentials:
- Set up your Gmail OAuth 2.0 credentials for the Gmail Trigger node.
- Configure your OpenAI API Key credentials for the OpenAI Chat Model, Embeddings OpenAI, and AI Agent nodes.
- Set up your Telegram Bot Token credentials for the Telegram node.
- Configure your Supabase Project URL and API Key credentials for the Supabase Vector Store node.
- Review and Customize Nodes:
- Gmail Trigger (Node 824): Ensure the "Watch For" and "Folder" settings are correct for your inbox.
- AI Agent (Node 1119): Review the agent's prompt and tools to ensure it aligns with the types of email tasks you want to automate.
- OpenAI Chat Model (Node 1153): Select your desired OpenAI model (e.g.,
gpt-3.5-turbo,gpt-4). - Structured Output Parser (Node 1179): Customize the schema to match the expected JSON output from your AI for different tasks.
- If (Node 20) and Switch (Node 112): These nodes define the conditional logic for routing. Adjust their conditions to match your specific classification outcomes from the AI.
- Telegram (Node 49) and Gmail (Node 356): Configure the message content and recipients as needed for your automated responses.
- Supabase Vector Store (Node 1231): Ensure it points to the correct Supabase table and embedding configuration.
- Activate the Workflow: Once all credentials and configurations are set, activate the workflow to start processing your emails automatically.
Related Templates
Auto-create TikTok videos with VEED.io AI avatars, ElevenLabs & GPT-4
💥 Viral TikTok Video Machine: Auto-Create Videos with Your AI Avatar --- 🎯 Who is this for? This workflow is for content creators, marketers, and agencies who want to use Veed.io’s AI avatar technology to produce short, engaging TikTok videos automatically. It’s ideal for creators who want to appear on camera without recording themselves, and for teams managing multiple brands who need to generate videos at scale. --- ⚙️ What problem this workflow solves Manually creating videos for TikTok can take hours — finding trends, writing scripts, recording, and editing. By combining Veed.io, ElevenLabs, and GPT-4, this workflow transforms a simple Telegram input into a ready-to-post TikTok video featuring your AI avatar powered by Veed.io — speaking naturally with your cloned voice. --- 🚀 What this workflow does This automation links Veed.io’s video-generation API with multiple AI tools: Analyzes TikTok trends via Perplexity AI Writes a 10-second viral script using GPT-4 Generates your voiceover via ElevenLabs Uses Veed.io (Fabric 1.0 via FAL.ai) to animate your avatar and sync the lips to the voice Creates an engaging caption + hashtags for TikTok virality Publishes the video automatically via Blotato TikTok API Logs all results to Google Sheets for tracking --- 🧩 Setup Telegram Bot Create your bot via @BotFather Configure it as the trigger for sending your photo and theme Connect Veed.io Create an account on Veed.io Get your FAL.ai API key (Veed Fabric 1.0 model) Use HTTPS image/audio URLs compatible with Veed Fabric Other APIs Add Perplexity, ElevenLabs, and Blotato TikTok keys Connect your Google Sheet for logging results --- 🛠️ How to customize this workflow Change your Avatar: Upload a new image through Telegram, and Veed.io will generate a new talking version automatically. Modify the Script Style: Adjust the GPT prompt for tone (educational, funny, storytelling). Adjust Voice Tone: Tweak ElevenLabs stability and similarity settings. Expand Platforms: Add Instagram, YouTube Shorts, or X (Twitter) posting nodes. Track Performance: Customize your Google Sheet to measure your most successful Veed.io-based videos. --- 🧠 Expected Outcome In just a few seconds after sending your photo and theme, this workflow — powered by Veed.io — creates a fully automated TikTok video featuring your AI avatar with natural lip-sync and voice. The result is a continuous stream of viral short videos, made without cameras, editing, or effort. --- ✅ Import the JSON file in n8n, add your API keys (including Veed.io via FAL.ai), and start generating viral TikTok videos starring your AI avatar today! 🎥 Watch This Tutorial --- 📄 Documentation: Notion Guide Need help customizing? Contact me for consulting and support : Linkedin / Youtube
Two-way property repair management system with Google Sheets & Drive
This workflow automates the repair request process between tenants and building managers, keeping all updates organized in a single spreadsheet. It is composed of two coordinated workflows, as two separate triggers are required — one for new repair submissions and another for repair updates. A Unique Unit ID that corresponds to individual units is attributed to each request, and timestamps are used to coordinate repair updates with specific requests. General use cases include: Property managers who manage multiple buildings or units. Building owners looking to centralize tenant repair communication. Automation builders who want to learn multi-trigger workflow design in n8n. --- ⚙️ How It Works Workflow 1 – New Repair Requests Behind the Scenes: A tenant fills out a Google Form (“Repair Request Form”), which automatically adds a new row to a linked Google Sheet. Steps: Trigger: Google Sheets rowAdded – runs when a new form entry appears. Extract & Format: Collects all relevant form data (address, unit, urgency, contacts). Generate Unit ID: Creates a standardized identifier (e.g., BUILDING-UNIT) for tracking. Email Notification: Sends the building manager a formatted email summarizing the repair details and including a link to a Repair Update Form (which activates Workflow 2). --- Workflow 2 – Repair Updates Behind the Scenes:\ Triggered when the building manager submits a follow-up form (“Repair Update Form”). Steps: Lookup by UUID: Uses the Unit ID from Workflow 1 to find the existing row in the Google Sheet. Conditional Logic: If photos are uploaded: Saves each image to a Google Drive folder, renames files consistently, and adds URLs to the sheet. If no photos: Skips the upload step and processes textual updates only. Merge & Update: Combines new data with existing repair info in the same spreadsheet row — enabling a full repair history in one place. --- 🧩 Requirements Google Account (for Forms, Sheets, and Drive) Gmail/email node connected for sending notifications n8n credentials configured for Google API access --- ⚡ Setup Instructions (see more detail in workflow) Import both workflows into n8n, then copy one into a second workflow. Change manual trigger in workflow 2 to a n8n Form node. Connect Google credentials to all nodes. Update spreadsheet and folder IDs in the corresponding nodes. Customize email text, sender name, and form links for your organization. Test each workflow with a sample repair request and a repair update submission. --- 🛠️ Customization Ideas Add Slack or Telegram notifications for urgent repairs. Auto-create folders per building or unit for photo uploads. Generate monthly repair summaries using Google Sheets triggers. Add an AI node to create summaries/extract relevant repair data from repair request that include long submissions.
Automate invoice processing with OCR, GPT-4 & Salesforce opportunity creation
PDF Invoice Extractor (AI) End-to-end pipeline: Watch Drive ➜ Download PDF ➜ OCR text ➜ AI normalize to JSON ➜ Upsert Buyer (Account) ➜ Create Opportunity ➜ Map Products ➜ Create OLI via Composite API ➜ Archive to OneDrive. --- Node by node (what it does & key setup) 1) Google Drive Trigger Purpose: Fire when a new file appears in a specific Google Drive folder. Key settings: Event: fileCreated Folder ID: google drive folder id Polling: everyMinute Creds: googleDriveOAuth2Api Output: Metadata { id, name, ... } for the new file. --- 2) Download File From Google Purpose: Get the file binary for processing and archiving. Key settings: Operation: download File ID: ={{ $json.id }} Creds: googleDriveOAuth2Api Output: Binary (default key: data) and original metadata. --- 3) Extract from File Purpose: Extract text from PDF (OCR as needed) for AI parsing. Key settings: Operation: pdf OCR: enable for scanned PDFs (in options) Output: JSON with OCR text at {{ $json.text }}. --- 4) Message a model (AI JSON Extractor) Purpose: Convert OCR text into strict normalized JSON array (invoice schema). Key settings: Node: @n8n/n8n-nodes-langchain.openAi Model: gpt-4.1 (or gpt-4.1-mini) Message role: system (the strict prompt; references {{ $json.text }}) jsonOutput: true Creds: openAiApi Output (per item): $.message.content → the parsed JSON (ensure it’s an array). --- 5) Create or update an account (Salesforce) Purpose: Upsert Buyer as Account using an external ID. Key settings: Resource: account Operation: upsert External Id Field: taxid_c External Id Value: ={{ $json.message.content.buyer.tax_id }} Name: ={{ $json.message.content.buyer.name }} Creds: salesforceOAuth2Api Output: Account record (captures Id) for downstream Opportunity. --- 6) Create an opportunity (Salesforce) Purpose: Create Opportunity linked to the Buyer (Account). Key settings: Resource: opportunity Name: ={{ $('Message a model').item.json.message.content.invoice.code }} Close Date: ={{ $('Message a model').item.json.message.content.invoice.issue_date }} Stage: Closed Won Amount: ={{ $('Message a model').item.json.message.content.summary.grand_total }} AccountId: ={{ $json.id }} (from Upsert Account output) Creds: salesforceOAuth2Api Output: Opportunity Id for OLI creation. --- 7) Build SOQL (Code / JS) Purpose: Collect unique product codes from AI JSON and build a SOQL query for PricebookEntry by Pricebook2Id. Key settings: pricebook2Id (hardcoded in script): e.g., 01sxxxxxxxxxxxxxxx Source lines: $('Message a model').first().json.message.content.products Output: { soql, codes } --- 8) Query PricebookEntries (Salesforce) Purpose: Fetch PricebookEntry.Id for each Product2.ProductCode. Key settings: Resource: search Query: ={{ $json.soql }} Creds: salesforceOAuth2Api Output: Items with Id, Product2.ProductCode (used for mapping). --- 9) Code in JavaScript (Build OLI payloads) Purpose: Join lines with PBE results and Opportunity Id ➜ build OpportunityLineItem payloads. Inputs: OpportunityId: ={{ $('Create an opportunity').first().json.id }} Lines: ={{ $('Message a model').first().json.message.content.products }} PBE rows: from previous node items Output: { body: { allOrNone:false, records:[{ OpportunityLineItem... }] } } Notes: Converts discount_total ➜ per-unit if needed (currently commented for standard pricing). Throws on missing PBE mapping or empty lines. --- 10) Create Opportunity Line Items (HTTP Request) Purpose: Bulk create OLIs via Salesforce Composite API. Key settings: Method: POST URL: https://<your-instance>.my.salesforce.com/services/data/v65.0/composite/sobjects Auth: salesforceOAuth2Api (predefined credential) Body (JSON): ={{ $json.body }} Output: Composite API results (per-record statuses). --- 11) Update File to One Drive Purpose: Archive the original PDF in OneDrive. Key settings: Operation: upload File Name: ={{ $json.name }} Parent Folder ID: onedrive folder id Binary Data: true (from the Download node) Creds: microsoftOneDriveOAuth2Api Output: Uploaded file metadata. --- Data flow (wiring) Google Drive Trigger → Download File From Google Download File From Google → Extract from File → Update File to One Drive Extract from File → Message a model Message a model → Create or update an account Create or update an account → Create an opportunity Create an opportunity → Build SOQL Build SOQL → Query PricebookEntries Query PricebookEntries → Code in JavaScript Code in JavaScript → Create Opportunity Line Items --- Quick setup checklist 🔐 Credentials: Connect Google Drive, OneDrive, Salesforce, OpenAI. 📂 IDs: Drive Folder ID (watch) OneDrive Parent Folder ID (archive) Salesforce Pricebook2Id (in the JS SOQL builder) 🧠 AI Prompt: Use the strict system prompt; jsonOutput = true. 🧾 Field mappings: Buyer tax id/name → Account upsert fields Invoice code/date/amount → Opportunity fields Product name must equal your Product2.ProductCode in SF. ✅ Test: Drop a sample PDF → verify: AI returns array JSON only Account/Opportunity created OLI records created PDF archived to OneDrive --- Notes & best practices If PDFs are scans, enable OCR in Extract from File. If AI returns non-JSON, keep “Return only a JSON array” as the last line of the prompt and keep jsonOutput enabled. Consider adding validation on parsing.warnings to gate Salesforce writes. For discounts/taxes in OLI: Standard OLI fields don’t support per-line discount amounts directly; model them in UnitPrice or custom fields. Replace the Composite API URL with your org’s domain or use the Salesforce node’s Bulk Upsert for simplicity.