AutomationFlowsAI & RAG › Automated Email Inquiry Processing & Routing with Gmail and Gemini AI

Automated Email Inquiry Processing & Routing with Gmail and Gemini AI

ByOneclick AI Squad @oneclick-ai on n8n.io

This automated n8n workflow processes any inquiry emails using AI-powered intelligence to determine customer intent and provide appropriate responses. The system analyzes incoming emails, performs availability checks or direct booking processing, and sends personalized responses…

Event trigger★★★★☆ complexityAI-powered12 nodesGmail TriggerAgentGoogle Gemini ChatHTTP Request ToolGmail
AI & RAG Trigger: Event Nodes: 12 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #6633 — we link there as the canonical source.

This workflow follows the Agent → Gmail recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "Jvq4AmoNIbbAwo5x",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI-Powered Smart Inquiry & Booking Assistant for Any Industry",
  "tags": [],
  "nodes": [
    {
      "id": "e39522a9-4024-4b8e-84c0-4d77cd49e266",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -500,
        120
      ],
      "parameters": {
        "simple": false,
        "filters": {
          "sender": "user@example.com"
        },
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyX",
              "unit": "minutes"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "92249d18-6db6-4e2b-a8c6-7cdaabf68360",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -280,
        120
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "You are a smart AI assistant for [Business Name] (e.g., Cool Realty, AutoDeals, HealthPlus).\n\nBased on the customer\u2019s message, decide the intent:\n\n\"check_info\" \u2192 if they request product/service availability, pricing, or details\n\n\"forward_action\" \u2192 if they want to book, buy, confirm, schedule, or take the next step\n\nReturn only one JSON including:\n\naction: either \"check_info\" or \"forward_action\"\n\nreasoning: brief summary of how you inferred the action\n\ndata_extracted: structured info from the email (e.g., name, date, service, etc.)\n\nreply: full, professional, human-like response to the user\u2019s message\n\nBehavior logic:\n\nAssume 70% availability for requested service/product\n\nRandomly generate sample details (features, price, timelines, etc.)\n\nIf not available, suggest alternatives\n\nUse a warm, helpful, professional tone. Output only the JSON. No extra text.\n\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "1e6c541e-30c6-4a4b-86fd-8bc31ca4c798",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -280,
        340
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-pro"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d98d2938-f78e-4d0d-a89f-a2629f58c1a9",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequestTool",
      "disabled": true,
      "position": [
        -60,
        320
      ],
      "parameters": {
        "url": "=https://google.serper.dev/search",
        "method": "POST",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "=q",
              "value": "={{ $fromAI('parameters0_Value', ``, 'string') }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "X-API-KEY",
              "value": "YOUR_AWS_SECRET_KEY_HERE"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "5755463a-5ef3-409b-9c06-e1acb85e14e1",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        60,
        120
      ],
      "parameters": {
        "jsCode": "const output = [];\n\nfor (const item of $input.all()) {\n  // 1. Grab the raw string from the 'output' field\n  let raw = item.json.output;\n  if (typeof raw !== 'string') {\n    // nothing to do\n    output.push({ json: {} });\n    continue;\n  }\n\n  // 2. Remove `````` fences\n  raw = raw.replace(/``````/g, '').trim();\n\n  // 3. Extract the JSON payload between the first { and last }\n  const start = raw.indexOf('{');\n  const end = raw.lastIndexOf('}');\n  const jsonString = (start !== -1 && end !== -1)\n    ? raw.substring(start, end + 1)\n    : raw;\n\n  // 4. Attempt to parse\n  try {\n    const parsed = JSON.parse(jsonString);\n    output.push({ json: parsed });\n  } catch (e) {\n    // on error, output the raw string and error\n    output.push({\n      json: {\n        error: e.message,\n        raw: jsonString\n      }\n    });\n  }\n}\n\nreturn output;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "ba012b2b-8207-4639-b57b-79956c5bdba8",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        460,
        120
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e4cc28d0-bee8-475a-b0fb-fa446fbfb954",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.action }}",
              "rightValue": "check_availability"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "cbae6b70-6d91-4973-b149-6a960515f06b",
      "name": "Forward booking email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        720,
        200
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=Name : {{ $json.customer_data.name }}\nEmail : {{ $json.customer_data.email }}\nPhone: {{ $json.customer_data.phone }}\nOriginal Message: {{ $json.customer_data.message }}\n\nInternal Note: {{ $json.internal_note }}\n\nSummary : {{ $json.booking_summary }}",
        "options": {},
        "subject": "Inquiry Details",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "7f784192-0b32-437c-bd2a-6ecb4b51f2c8",
      "name": "availability check email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        720,
        20
      ],
      "parameters": {
        "sendTo": "={{ $json.customer_data.email }}",
        "message": "={{ $('Code').item.json.email_response }}",
        "options": {},
        "subject": "Inquiry Details",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "99fc6c79-6888-4093-968b-668f8cec525b",
      "name": "Workflow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -520,
        -160
      ],
      "parameters": {
        "width": 780,
        "height": 240,
        "content": "## Workflow Overview \ud83d\udce7\n\nThis workflow automates the processing of any inquiry emails:\n\n1.  **Gmail Trigger**: Initiates the workflow upon receiving a new email.\n2.  **AI Agent**: Analyzes the email content to determine the customer's intent (availability check or direct booking).\n3.  **Code**: Parses the JSON output from the AI Agent.\n4.  **If**: Routes the workflow based on the detected intent.\n5.  **Gmail Nodes**: Sends appropriate responses or forwards booking details."
      },
      "typeVersion": 1
    },
    {
      "id": "0333faf4-3690-487a-a151-ac329c1eacd8",
      "name": "AI Agent and Code Explanation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        120,
        400
      ],
      "parameters": {
        "color": 5,
        "width": 600,
        "height": 320,
        "content": "## AI Agent and Code Node Explained \ud83e\udd16\n\n-   **AI Agent**: This node acts as an intelligent assistant, powered by the Google Gemini Chat Model (although the Google Gemini Chat Model node currently has execution issues). It processes incoming emails and classifies them as either an \"availability check\" or a \"direct booking request\" based on the prompt instructions. It also attempts to extract relevant customer data and generate appropriate responses or internal notes.\n-   **HTTP Request (Disabled)**: This node is currently disabled and not used by the AI Agent, but it is set up to make a search request to Serper.\n-   **Code**: This node is crucial for parsing the raw string output from the AI Agent into a usable JSON format. It handles potential formatting inconsistencies by removing markdown fences and extracting the valid JSON payload, making the data accessible for subsequent nodes."
      },
      "typeVersion": 1
    },
    {
      "id": "1772a67e-ac94-45f5-b37d-1ef3084b9891",
      "name": "Conditional Routing and Email Responses",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        300,
        -280
      ],
      "parameters": {
        "color": 4,
        "width": 600,
        "height": 280,
        "content": "## Conditional Routing & Email Responses \ud83d\udea6\n\n-   **Wait**: This node is used for wait for data.\n-   **If**: This node acts as a decision point, checking the `action` field from the AI Agent's parsed output. If the `action` is `check_availability`, the workflow proceeds to the \"availability check email\" node.\n-   **availability check email**: This Gmail node sends an email directly to the customer with availability details, as provided by the AI Agent's `email_response`.\n-   **Forward booking email**: If the `If` node's condition is not met (meaning the action is `forward_booking`), this Gmail node is triggered. It forwards the customer's booking request details and internal notes to a predefined internal email address (`@gmail.com`) for manual processing."
      },
      "typeVersion": 1
    },
    {
      "id": "3cfad505-0925-4b8d-b275-c7e319764925",
      "name": "Wait for Data",
      "type": "n8n-nodes-base.wait",
      "position": [
        280,
        120
      ],
      "parameters": {},
      "typeVersion": 1.1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1dd6ab03-d62a-4ed1-b2da-1f254160ff20",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "availability check email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Forward booking email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Wait for Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Data": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This automated n8n workflow processes any inquiry emails using AI-powered intelligence to determine customer intent and provide appropriate responses. The system analyzes incoming emails, performs availability checks or direct booking processing, and sends personalized responses…

Source: https://n8n.io/workflows/6633/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This template and YouTube video goes over 5 different implementations of evaluations within n8n. Categorization Correctness Tools used String similarity Helpfulness

Evaluation, Evaluation Trigger, Google Gemini Chat +8
AI & RAG

Turn a simple email workflow into a LinkedIn content machine. Generate post ideas, draft full posts, and auto-publish to LinkedIn all controlled by replying to emails.

Agent, Google Gemini Chat, Gmail +3
AI & RAG

This workflow is for hotel managers, travel agencies, and hospitality teams who receive booking requests via email. It eliminates the need for manual data entry by automatically parsing emails and att

Google Sheets, Gmail, Agent +4
AI & RAG

Based on the Google Sheet data, the AI will retrieve the userstories ID's, retrieves the userstory data and the corresponding attachments and creates sprint goals according to the defined system promp

Google Gemini Chat, Google Sheets, HTTP Request Tool +6
AI & RAG

Use cases are many: Manage your Gmail inbox, schedule calendar events, and handle contact details — all from one central AI-powered assistant. Perfect for freelancers managing clients, agency owners w

Agent, Gmail Tool, Google Gemini Chat +10