AutomationFlowsAI & RAG › Handle Chat Support and Escalate Unresolved Tickets with Google Gemini and Gmail

Handle Chat Support and Escalate Unresolved Tickets with Google Gemini and Gmail

ByM S Vishnu @vishnu on n8n.io

This webhook-based customer support workflow uses Google Gemini and a Google Docs knowledge base to answer chat messages, remembers conversation context, and escalates unresolved issues by summarizing the chat and sending a support email via Gmail. Receives an incoming chat…

Webhook trigger★★★★☆ complexityAI-powered25 nodesOutput Parser StructuredGmailGoogle Gemini ChatMemory Buffer WindowAgentGoogle Docs Tool
AI & RAG Trigger: Webhook Nodes: 25 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #16053 — 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": "idAQ77NqgpOvm393",
  "name": "Customer_Support workflow",
  "tags": [],
  "nodes": [
    {
      "id": "a63dd4af-5e45-40a5-82b4-d20c71b5a640",
      "name": "User Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1696,
        256
      ],
      "parameters": {
        "options": {
          "responseCode": 201
        },
        "respondWith": "json",
        "responseBody": "={{ $json.output }}"
      },
      "typeVersion": 1.4
    },
    {
      "id": "eeea8c24-2959-4d77-9695-0c93a713f20e",
      "name": "Email Subject and Body Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        2560,
        528
      ],
      "parameters": {
        "autoFix": true,
        "jsonSchemaExample": "{\n  \"subject\": \"<subject of the email>\",\n  \"body\":\"<body of the email>\",\n  \"escalate\": \"true OR false\"\n}\n",
        "customizeRetryPrompt": true
      },
      "typeVersion": 1.3
    },
    {
      "id": "43f6fd57-26f2-4f82-b6b7-d14599211d31",
      "name": "Escalation_Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2736,
        240
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "={{ $json.output.body }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $json.output.subject }} "
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "801c5ff4-3a9c-44ae-ac5a-00bccf15fe59",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        688,
        512
      ],
      "parameters": {
        "options": {
          "topK": 32,
          "topP": 1,
          "temperature": 0.4,
          "safetySettings": {
            "values": [
              {
                "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
                "threshold": "BLOCK_LOW_AND_ABOVE"
              },
              {
                "category": "HARM_CATEGORY_HATE_SPEECH",
                "threshold": "BLOCK_LOW_AND_ABOVE"
              }
            ]
          },
          "maxOutputTokens": 2048
        },
        "modelName": "models/gemini-2.5-flash-lite"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "facdf16e-bda0-4eba-b77b-89520cb2fef7",
      "name": "Google Gemini Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        2240,
        560
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash-lite"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "12ecc1b4-0165-42ea-9a12-a62622e634fa",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        2400,
        576
      ],
      "parameters": {
        "sessionKey": "={{ $('On Message Received').item.json.body.sessionId }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "22aa2a6f-9905-4bab-bcc0-1fca8a20ef77",
      "name": "Google Gemini Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1280,
        816
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash-lite"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d7403fc8-2313-4020-a7aa-3efc891ae880",
      "name": "Google Gemini Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        2512,
        736
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash-lite"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fe77d745-7752-43e3-a087-c69bf212794e",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        1888,
        256
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "686a0aba-5e54-4384-a3b6-fb076493f882",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.output.escalate }}",
              "rightValue": "true"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "9b7033ad-8b41-4420-a80d-3a7b6a68f697",
      "name": "User Response1",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        3008,
        240
      ],
      "parameters": {
        "options": {
          "responseCode": 201
        },
        "respondWith": "text",
        "responseBody": "The issue is escalated and you will recieve a support email within 24 hours. Thank you !"
      },
      "typeVersion": 1.4
    },
    {
      "id": "49a139c7-97b6-453a-ba68-ebcb8bddb656",
      "name": "On Message Received",
      "type": "n8n-nodes-base.webhook",
      "position": [
        336,
        256
      ],
      "parameters": {
        "path": "46c19b6f-f5ca-4c8d-825a-98991fefa656",
        "options": {
          "rawBody": false,
          "ignoreBots": false,
          "ipWhitelist": "",
          "allowedOrigins": "*",
          "binaryPropertyName": "data"
        },
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "18567f20-28d6-4672-ba2d-ca29088c8e11",
      "name": "User Facing Support Agent / Escalator",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        896,
        256
      ],
      "parameters": {
        "text": "={{ $json.body.message }} {{\"OR\"}} {{ $json.labelIds }}",
        "options": {
          "systemMessage": "You are a customer service personnel for example agency, an automation agency brand built by someone.\nYour goal is to respond and resolve user queries using the provided knowledge such as Google doc tool. By default set \\\"escalate\\\" to false in the output parser.\\n- If greeted, introduce yourself.\\n- For general messages try to respond using the context in the google docs.\\n- Always try to find the most relevant answer from the docs.\\n- If you find a relevant answer, reply with it and set \\\"escalate\\\": false.\\n- If it is a general text try to handle it without escalating and set \\\"escalate\\\":false.\\n- If you cannot find or confidently answer the question, ask the user if they want to escalate and set \\\"escalate\\\": false.\\n- If the user shows the intention of escalating by pressing the escalate button provided by you then set \\\"escalate\\\": true and politely mention that you\u2019ll escalate to the support team. If the escalation is successful, you'll immediately receive \"SENT\" from gmail node, you can inform the user that their ticket has been raised successfully\"\n\nMake sure to parse the output as required by the output parser."
        },
        "promptType": "define",
        "needsFallback": true,
        "hasOutputParser": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "dca42381-1427-4c1b-881a-bf4db5d1ef41",
      "name": "KnowledgeBase",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        1136,
        592
      ],
      "parameters": {
        "operation": "get"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "38a01c73-4b23-468d-99db-069c515c8dfa",
      "name": "Human Escalate Flag",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1280,
        608
      ],
      "parameters": {
        "autoFix": true,
        "jsonSchemaExample": "{\n  \"reply\": \"<text to show user>\",\n  \"escalate\": \"true OR false\",\n  \"quickReplies\": [{\"label\":\"Contact Support\",\"value\":\"contact_support\"}],\n  \"attachments\":[{\"type\":\"image\",\"url\":\"https://...\"}]\n}\n",
        "customizeRetryPrompt": true
      },
      "typeVersion": 1.3
    },
    {
      "id": "da2b76fc-c43f-484e-96d0-1a837b7d3b8e",
      "name": "Chat Summarize and Email Draft",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2352,
        240
      ],
      "parameters": {
        "text": "you are a escalator, the fact that you are prompted is that there is a serious escalation that is required and has to be emailed. You have access to the chats of the particular scenario, you have to analyze the situation and write the subject and body of the email so that appropriate action can be taken. Try to give a brief summary using as little words as possible.",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "14cfa67e-6935-4c7a-aea5-89a0b488049e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "disabled": true,
      "position": [
        -64,
        80
      ],
      "parameters": {
        "width": 256,
        "height": 208,
        "content": "## Chat Support Agent\n\nA Webhook based Chat support workflow which can be integrated with almost every chat interface available out there.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "5335ee6b-528c-46db-b01a-daa5ef417c90",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        64
      ],
      "parameters": {
        "width": 1552,
        "height": 896,
        "content": "## Chat System\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ffe78b42-bd00-4daa-86f4-c3b10380fed6",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        64
      ],
      "parameters": {
        "color": 3,
        "width": 1120,
        "height": 896,
        "content": "## AI Agent Node\n**Create a word file to be used as the knowledgebase on which the chatbot is supposed to infer the responses.**\n\n\n** Modify the AI agent parameters and the system message based on your requirements.\n\nOptionally, You can also use sheets or tables with the FAQ dataset of Question-Answer pairs if creating a FAQ chatbot.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "50b31ffe-145b-4a15-8ff6-bf9c67602a44",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2064,
        64
      ],
      "parameters": {
        "color": 3,
        "width": 912,
        "height": 896,
        "content": "## Chat Summarizer \n**Link an email account(gmail) which the AI would use to communicate with you.**\nAdd the customer support email account id where you wish the isssue to be reached.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "b2bbfce1-6b4d-4fa6-ad78-e2225a9b3908",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -64,
        336
      ],
      "parameters": {
        "width": 256,
        "height": 288,
        "content": "## Credentials\n\n1. AI API key\n2. DB Credentials (If simple memory is replaced).\n3. Google Cloud API for Google Docs\n4. Google Cloud for Gmail API\n\nThe Webhook url must be copied from first node."
      },
      "typeVersion": 1
    },
    {
      "id": "e908ab51-7c1c-48b7-839e-dfbee4a2e8ed",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -624,
        80
      ],
      "parameters": {
        "color": 4,
        "width": 480,
        "height": 896,
        "content": "## Working\n\n1. The workflow receives the user messages via webhook trigger.\n\n2. The message reaches the AI agent node, here:\n   i. The message is sent to the LLM along with the   Knowledgebase and the previous 5 messages (based on the context window).\n   ii. Then a response is created based on the agent parameters and the system message. The agent also analyzed the user message for any intention for escalation to the agent.\n   iii. Based on the user intent, the human escalation flag is set to true or false.\n\n3. If the response is created while the escalation flag is set to false, the message is sent as it is to the user.\n\n4. If the escalation flag is set to true, \nThe entire chat session is summarized and emailed to the chat support personnel's email.\n\n5. The a user response is provided as \"The issue is escalated and you will recieve a support email within 24 hours. Thank you !\"."
      },
      "typeVersion": 1
    },
    {
      "id": "7962e231-f1c9-4f47-a5cd-e8009c1f2e08",
      "name": "Simple Memory2",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        976,
        640
      ],
      "parameters": {
        "sessionKey": "={{ $json.body.sessionId }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "700d2c23-2c83-462f-9c2e-5229fadb26a1",
      "name": "FallBack",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        832,
        592
      ],
      "parameters": {
        "options": {
          "topK": 32,
          "topP": 1,
          "temperature": 0.4,
          "safetySettings": {
            "values": [
              {
                "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
                "threshold": "BLOCK_LOW_AND_ABOVE"
              },
              {
                "category": "HARM_CATEGORY_HATE_SPEECH",
                "threshold": "BLOCK_LOW_AND_ABOVE"
              }
            ]
          },
          "maxOutputTokens": 2048
        },
        "modelName": "models/gemini-2.5-flash-lite"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2a999805-c551-424a-80b4-f9d44cb5c19e",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        672
      ],
      "parameters": {
        "color": 6,
        "width": 800,
        "height": 304,
        "content": "## Upgrades\n\n1. You can simply swap the webhook trigger with any of the other triggers like the telegram or whatsapp trigger and the workflow should work fine.\n\n2. The Chat summarizer can be easily modified and with the addition of simple UI, a human in the loop can be system can be created.\n\n3. You can opt to use your own email server instead of gmail.\n\n4. You can add a Database such as postgress and make the system more robust.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "6c18a697-c039-41f7-8036-78c47537cf69",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        544
      ],
      "parameters": {
        "color": 3,
        "width": 432,
        "height": 128,
        "content": "## Caution\n**Ensure that the Authentication is in place when used in production**"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "dc518372-9413-4b8b-bd53-350169fa38f4",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Chat Summarize and Email Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FallBack": {
      "ai_languageModel": [
        [
          {
            "node": "User Facing Support Agent / Escalator",
            "type": "ai_languageModel",
            "index": 1
          }
        ]
      ]
    },
    "KnowledgeBase": {
      "ai_tool": [
        [
          {
            "node": "User Facing Support Agent / Escalator",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Chat Summarize and Email Draft",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "User Response": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory2": {
      "ai_memory": [
        [
          {
            "node": "User Facing Support Agent / Escalator",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Escalation_Email": {
      "main": [
        [
          {
            "node": "User Response1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Human Escalate Flag": {
      "ai_outputParser": [
        [
          {
            "node": "User Facing Support Agent / Escalator",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "On Message Received": {
      "main": [
        [
          {
            "node": "User Facing Support Agent / Escalator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "User Facing Support Agent / Escalator",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Chat Summarize and Email Draft",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Human Escalate Flag",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Email Subject and Body Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Email Subject and Body Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Chat Summarize and Email Draft",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Chat Summarize and Email Draft": {
      "main": [
        [
          {
            "node": "Escalation_Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "User Facing Support Agent / Escalator": {
      "main": [
        [
          {
            "node": "User Response",
            "type": "main",
            "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 webhook-based customer support workflow uses Google Gemini and a Google Docs knowledge base to answer chat messages, remembers conversation context, and escalates unresolved issues by summarizing the chat and sending a support email via Gmail. Receives an incoming chat…

Source: https://n8n.io/workflows/16053/ — 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

Are you drowning in daily operational chaos, desperately trying to juggle sales, projects, content, and client communication? Imagine an AI brain that handles it all, freeing you to lead your business

Telegram Trigger, Telegram, OpenAI +13
AI & RAG

Enhance your support, onboarding, and internal knowledge workflows with an intelligent RAG-powered chatbot that responds using live data stored in Google Sheets. 🤖📚 Built for teams that rely on struct

Chat Trigger, Output Parser Structured, Memory Buffer Window +6
AI & RAG

leads. Uses supabase, gmail, formTrigger, httpRequest. Webhook trigger; 62 nodes.

Supabase, Gmail, Form Trigger +13
AI & RAG

Catat Keuangan Keluarga. Uses chatTrigger, agent, lmChatGoogleGemini, outputParserStructured. Webhook trigger; 55 nodes.

Chat Trigger, Agent, Google Gemini Chat +5
AI & RAG

This workflow is an AI-powered Dental Appointment Assistant that automates appointment booking, rescheduling, and cancellations through Telegram or a Webhook. It uses intelligent agents to understand

Memory Buffer Window, Output Parser Structured, Mcp Client Tool +12