AutomationFlowsAI & RAG › Gabarito Aula 2

Gabarito Aula 2

Gabarito Aula 2. Uses agent, lmChatGoogleGemini, googleSheetsTool, outputParserStructured. Webhook trigger; 18 nodes.

Webhook trigger★★★★☆ complexityAI-powered18 nodesAgentGoogle Gemini ChatGoogle Sheets ToolOutput Parser StructuredGmailTelegram
AI & RAG Trigger: Webhook Nodes: 18 Complexity: ★★★★☆ AI nodes: yes Added:

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
{
  "name": "Gabarito Aula 2",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "c82263f6-df7d-4dc9-b134-d7c8a5070692",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        0
      ],
      "id": "c36302a1-1114-467b-9d55-3d85f337f7e6",
      "name": "Webhook"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.body.data.fields }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "=Voc\u00ea \u00e9 um agente que processa respostas de um formul\u00e1rio de reembolso.\n\nVoc\u00ea deve trabalhar apenas com os dados recebidos na entrada e pela planilha contida na tool.\n\nAs informa\u00e7\u00f5es que voc\u00ea ir\u00e1 precisar retornar s\u00e3o as seguintes:\n\n- nome: Nome do cliente proveniente do formul\u00e1rio\n- email: E-mail do cliente proveniente do formul\u00e1rio\n- produto_reembolso: De qual produto o cliente est\u00e1 pedindo reembolso, proveniente do formul\u00e1rio\n- comentario: Coment\u00e1rio por escrito do cliente, proveniente do formul\u00e1rio\n- sentimento: Uma an\u00e1lise de sentimento a partir do coment\u00e1rio do cliente no formul\u00e1rio (instru\u00e7\u00f5es mais \u00e0 frente no prompt)\n- cliente_encontrado: uma informa\u00e7\u00e3o de verdadeiro ou falso informando se encontrou o cliente na planilha (tool)\n- nome_completo: Nome do cliente proveniente da planilha (tool)\n- total_gasto_cliente: Valor total gasto pelo cliente proveniente da planilha (tool)\n- dias_desde_compra: h\u00e1 quantos dias o cliente fez a \u00faltima compra, calculado a partir dos dados da planilha (instru\u00e7\u00f5es mais \u00e0 frente no prompt)\n\n\n\nSiga rigorosamente as etapas abaixo.\n\n---\n\n### 1) Extra\u00e7\u00e3o dos campos do formul\u00e1rio\nExtraia os seguintes campos da resposta do formul\u00e1rio:\n- Nome\n- Email\n- Qual produto que voc\u00ea deseja reembolso?\n- Comente aqui o que houve\n\nSe algum campo de texto n\u00e3o existir, retorne uma string vazia \"\".\n\n---\n\n### 2) Busca do cliente na base\n- Normalize o email (trim + lowercase).\n- Use o email como \u00daNICA chave para buscar o cliente na base (Google Sheets) via tool.\n- Nunca invente dados do cliente.\n\n- Se encontrar o cliente:\n  - cliente_encontrado = true\n  - Preencha com os dados exatos da planilha:\n    - nome_completo: valor da coluna \"nome_cliente\"\n    - total_gasto_cliente: valor da coluna \"total_gasto_cliente\"\n\n- Se n\u00e3o encontrar o cliente na planilha:\n  - cliente_encontrado = false\n  - nome_completo: \u201c\u201d\n  - total_gasto_cliente: \u201c\u201d\n\n\n\n\n---\n\n### 3) Datas e prazo\n- Calcule a informa\u00e7\u00e3o dias_desde_compra, subtraindo a data atual da data da \u00faltima compra do cliente\n- A data da \u00faltima compra vem da planilha na tool na coluna data_ultima_compra.\n- A data atual: {{ $now }}\n- Considere apenas a parte da data (dia/m\u00eas/ano) e ignore o hor\u00e1rio\n- Voc\u00ea N\u00c3O deve gerar data atual por conta pr\u00f3pria.\n\nCom essas duas datas:\n- Calcule a quantidade de dias corridos entre data_atual e data_ultima_compra.\n- O c\u00e1lculo deve considerar apenas dias corridos.\n- Se data_ultima_compra ou data_atual n\u00e3o existirem, dias_desde_compra deve ser 0 (zero).\n\n\u26a0\ufe0f Importante:\n- Voc\u00ea N\u00c3O deve decidir aprova\u00e7\u00e3o ou nega\u00e7\u00e3o de reembolso.\n- Apenas calcule e informe os dias desde a compra.\n\n---\n\n### 4) An\u00e1lise de sentimento\nAnalise exclusivamente o texto do campo \"Comente aqui o que houve\" e classifique em:\n- positivo\n- neutro\n- negativo\n- muito_negativo\n\nCrit\u00e9rios:\nPOSITIVO: Texto educado ou positivo.\nNEUTRO: Texto objetivo, calmo ou vazio.\nNEGATIVO: Frustra\u00e7\u00e3o clara ou tom r\u00edspido.\nMUITO_NEGATIVO: Agressivo, xingamentos, amea\u00e7as de procon, processos, reclame aqui ou outros tipos de amea\u00e7a ou CAPS LOCK.\n\nNa d\u00favida entre negativo e muito negativo, seja conservador, escolha negativo.\n\n---\n\n### 5) Formato de sa\u00edda (OBRIGAT\u00d3RIO)\nRetorne APENAS um JSON cru.\nN\u00c3O use markdown (sem ```json).\n\nExemplo de estrutura desejada:\n\n{\n  \"nome\": \"Texto ou vazio\",\n  \"email\": \"Texto ou vazio\",\n  \"produto_reembolso\": \"Texto ou vazio\",\n  \"comentario\": \"Texto ou vazio\",\n  \"sentimento\": \"Texto ou vazio\",\n  \"cliente_encontrado\": true ou false,\n  \"nome_completo\": \"Texto ou vazio\",\n  \"total_gasto_cliente\": numero,\n  \"dias_desde_compra\": numero,\n  }\n\n\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3,
      "position": [
        208,
        0
      ],
      "id": "2edee07e-8791-429c-a802-e1315fdb4c91",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        80,
        208
      ],
      "id": "5cd747dd-a441-4aa6-bfef-4cd0aeb1bf50",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1R3qRxMD9eR6Rcni7LBb4UB2p0ukvDNvo8pHkxhyR23c",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Clientes",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1R3qRxMD9eR6Rcni7LBb4UB2p0ukvDNvo8pHkxhyR23c/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.7,
      "position": [
        368,
        208
      ],
      "id": "1081aff3-7629-4dcc-ac40-b1343b721e20",
      "name": "Get row(s) in sheet in Google Sheets",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"nome\": \"Alon\",\n  \"email\": \"alon@exemplo.com\",\n  \"produto_reembolso\": \"Software de Contabilidade\",\n  \"comentario\": \"O software \u00e9 bom mas tive problemas pessoais\",\n  \"sentimento\": \"neutro\",\n  \"cliente_encontrado\": true,\n  \"nome_completo\": \"Alon Pinheiro\",\n  \"total_gasto_cliente\": 1000,\n  \"dias_desde_compra\": 15\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        480,
        304
      ],
      "id": "8bc88c88-362f-40d9-9aaf-8cb8ec237a7b",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "mode": "raw",
        "jsonOutput": "={{ $json.output }}",
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        560,
        0
      ],
      "id": "f540668c-d313-4341-985b-d39774edd721",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "601a969c-f3cf-4538-b4a3-f476e989c3f4",
              "leftValue": "={{ $json.dias_desde_compra }}",
              "rightValue": 7,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        768,
        0
      ],
      "id": "03893adb-a0b4-42f1-aa5c-dbdcb9f26c1e",
      "name": "If"
    },
    {
      "parameters": {
        "content": "## Cliente Comum",
        "height": 224,
        "width": 1024
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        992,
        -176
      ],
      "id": "00bfa5db-5078-4e55-b558-d28b38bb32d0",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Cliente VIP",
        "height": 176,
        "width": 1024,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        992,
        112
      ],
      "id": "36a95ecb-9f1d-43eb-b0b4-d35553c79703",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## Cliente Reclam\u00e3o",
        "height": 192,
        "width": 1024,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        992,
        352
      ],
      "id": "a3be73f8-7fb8-41cf-92ce-d9ace30ea84c",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "c6568187-3e75-4f7f-bb85-58454356ccf5",
              "leftValue": "={{ $('Edit Fields').item.json.total_gasto_cliente }}",
              "rightValue": 3000,
              "operator": {
                "type": "number",
                "operation": "lt"
              }
            },
            {
              "id": "5c987178-1aeb-48fb-abba-d7287c40dcf5",
              "leftValue": "={{ $('Edit Fields').item.json.sentimento }}",
              "rightValue": "muito_negativo",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1040,
        -96
      ],
      "id": "f833af49-a88e-43ba-86b7-93047e16fc67",
      "name": "If1"
    },
    {
      "parameters": {
        "sendTo": "={{ $json.email }}",
        "subject": "Retorno sobre sua solicita\u00e7\u00e3o de reembolso",
        "message": "=Ol\u00e1, {{ $json.nome }}.\n\nAnalisei sua solicita\u00e7\u00e3o de reembolso.\n\nVerifiquei aqui que a compra foi efetuada h\u00e1 mais de 7 dias. Como o prazo de garantia incondicional \u00e9 de 7 dias corridos, infelizmente n\u00e3o conseguiremos prosseguir com o reembolso.\n\nCaso tenha d\u00favidas sobre o acesso ou uso do produto, nossa equipe de suporte continua \u00e0 disposi\u00e7\u00e3o para te ajudar a tirar o melhor proveito dele.\nAtenciosamente,\nAlon\n",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1312,
        -112
      ],
      "id": "dac8fc87-379e-4bb6-8a71-81312b124c9b",
      "name": "Send a message",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "d7a4c49e-8967-45cf-bfa1-07d61ff0a997",
              "leftValue": "={{ $('Edit Fields').item.json.total_gasto_cliente }}",
              "rightValue": 3000,
              "operator": {
                "type": "number",
                "operation": "gte"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1232,
        144
      ],
      "id": "4fa6351c-2e13-4270-8430-b416cecf0723",
      "name": "If2"
    },
    {
      "parameters": {
        "sendTo": "={{ $('Edit Fields').item.json.email }}",
        "subject": "Atualiza\u00e7\u00e3o sobre seu pedido de reembolso",
        "message": "=Ol\u00e1, {{ $('Edit Fields').item.json.nome }}.\nRecebi sua solicita\u00e7\u00e3o de reembolso. Notei que o prazo contratual de 7 dias j\u00e1 expirou, que \u00e9 o prazo de garantia do produto.\nPor\u00e9m, como voc\u00ea \u00e9 um dos nossos melhores clientes, n\u00e3o quero encerrar seu caso automaticamente. Encaminhei seu pedido pessoalmente para a nossa equipe financeira analisar uma exce\u00e7\u00e3o.\nEm at\u00e9 24h a nossa equipe entrar\u00e1 em contato com voc\u00ea para dar um retorno.\nAtenciosamente, \nAlon\n",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1488,
        144
      ],
      "id": "6e9ed5cd-dc5b-40fb-be74-1daf6168e5f6",
      "name": "Send a message1",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "-5006321970",
        "text": "=[Pedido de Reembolso fora do Prazo] \nPessoal, chegou um pedido de reembolso de um cliente que estourou o prazo de 7 dias (t\u00e1 com {{ $('Edit Fields').item.json.dias_desde_compra }} dias).\n\nO sistema barrou, mas como ele \u00e9 VIP, pe\u00e7o que verifiquem com aten\u00e7\u00e3o e avaliem reembolsar o aluno.\n\nAvisei pra ele que a gente ia analisar com carinho e dar um retorno em 24h. Conseguem ver com o financeiro se liberamos essa exce\u00e7\u00e3o pra n\u00e3o perder o cliente?\n\nCliente: {{ $('Edit Fields').item.json.nome }}\nE-mail: {{ $('Edit Fields').item.json.email }}\nProduto: {{ $('Edit Fields').item.json.produto_reembolso }}\n",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1696,
        144
      ],
      "id": "e5b14d53-b591-4759-9d32-9890a9ca7e16",
      "name": "Send a text message",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "8b7a5a4e-2198-4093-bc3c-d2af0cef2b68",
              "leftValue": "={{ $('Edit Fields').item.json.sentimento }}",
              "rightValue": "muito_negativo",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1408,
        400
      ],
      "id": "91621a9e-35f3-4142-80ec-e234e712fbd6",
      "name": "If3"
    },
    {
      "parameters": {
        "sendTo": "={{ $('Edit Fields').item.json.email }}",
        "subject": "Recebemos sua mensagem - Caso escalado para a Ger\u00eancia",
        "message": "=Ol\u00e1, {{ $('Edit Fields').item.json.nome }}.\n\nLi atentamente seu coment\u00e1rio e lamento sua insatisfa\u00e7\u00e3o.\nO sistema identificou que a compra est\u00e1 fora do prazo de garantia de 7 dias. No entanto, dada a seriedade do seu relato, optei por n\u00e3o finalizar o atendimento por aqui.\n\nEscalei seu caso com prioridade para o nosso gerente de suporte. Ele vai analisar a situa\u00e7\u00e3o e retornar\u00e1 o contato o mais breve poss\u00edvel para resolvermos isso.\n\nAtenciosamente, \nAlon\n",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1632,
        400
      ],
      "id": "e3d36664-ce55-4165-9b80-9a185d26da01",
      "name": "Send a message2",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "-5006321970",
        "text": "=\u26a0\ufe0f Aten\u00e7\u00e3o aqui, gente.\nTemos um cliente que pediu reembolso fora do prazo, mas mandou uma mensagem bem pesada..\n\nO coment\u00e1rio dele foi esse: \"{{ $('Edit Fields').item.json.comentario }}\"\n\nPra evitar que ele v\u00e1 pro Reclame Aqui ou procon, eu j\u00e1 respondi dizendo que escalei o caso pra ger\u00eancia. \n\nConseguem dar uma aten\u00e7\u00e3o pra esse caso por favor?\n\nCliente: {{ $('Edit Fields').item.json.nome }}\nE-mail: {{ $('Edit Fields').item.json.email }}\nProduto: {{ $('Edit Fields').item.json.produto_reembolso }}\n",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1824,
        400
      ],
      "id": "38ad0006-0eda-4397-9256-2d2fcc8c5c2e",
      "name": "Send a text message1",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet in Google Sheets": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If2": {
      "main": [
        [
          {
            "node": "Send a message1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message1": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If3": {
      "main": [
        [
          {
            "node": "Send a message2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message2": {
      "main": [
        [
          {
            "node": "Send a text message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3b7629c9-69fc-404b-8ff5-7c0e58434956",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "M1tYYkQQFX193tqQ",
  "tags": []
}

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

Gabarito Aula 2. Uses agent, lmChatGoogleGemini, googleSheetsTool, outputParserStructured. Webhook trigger; 18 nodes.

Source: https://github.com/IDB-devs/N8N_Automacao_analise_de_reebolso/blob/main/Automacao_analise_de_reebolso.json — 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

process-refund-logic-agent. Uses lmChatGoogleGemini, outputParserStructured, gmail, googleSheetsTool. Webhook trigger; 19 nodes.

Google Gemini Chat, Output Parser Structured, Gmail +3
AI & RAG

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

Supabase, Gmail, Form Trigger +13
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
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