AutomationFlowsAI & RAG › Gabarito Aula 4

Gabarito Aula 4

Gabarito Aula 4. Uses gmailTrigger, googleGemini, googleDrive, googleSheets. Event-driven trigger; 13 nodes.

Event trigger★★★★☆ complexityAI-powered13 nodesGmail TriggerGoogle GeminiGoogle DriveGoogle Sheets
AI & RAG Trigger: Event Nodes: 13 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow follows the Gmail Trigger → Google Drive 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 4",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": false,
        "filters": {},
        "options": {
          "downloadAttachments": true
        }
      },
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.3,
      "position": [
        0,
        0
      ],
      "id": "298edfdb-b8cd-4374-a0b1-34e3be30f98f",
      "name": "Gmail Trigger",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "7dcbc794-530a-4f6d-9976-82c9b47016e5",
              "leftValue": "={{ $binary.attachment_0 }}",
              "rightValue": "",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        208,
        0
      ],
      "id": "185ae0f1-4d99-46df-b7b8-fc93a2750571",
      "name": "If"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        416,
        96
      ],
      "id": "6565f5c3-c030-4aa9-9782-aefe3cc4a5d3",
      "name": "No Operation, do nothing"
    },
    {
      "parameters": {
        "fieldToSplitOut": "$binary",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        416,
        -96
      ],
      "id": "f6c92c4e-2b5c-4948-9fd6-6ab626ecdd5a",
      "name": "Split Out"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        624,
        -96
      ],
      "id": "cbe062ce-0da7-4289-ba75-d1cc5a6d9972",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "resource": "document",
        "modelId": {
          "__rl": true,
          "value": "models/gemini-2.5-flash",
          "mode": "list",
          "cachedResultName": "models/gemini-2.5-flash"
        },
        "text": "=Voc\u00ea \u00e9 um assistente de extra\u00e7\u00e3o de dados.\n\nIMPORTANTE (regra cr\u00edtica):\n- A resposta DEVE ser um JSON V\u00c1LIDO, PURO, INICIANDO com { e TERMINANDO com }.\n- N\u00c3O use ```json, N\u00c3O use crases, N\u00c3O use texto antes ou depois.\n- N\u00c3O use quebras de linha fora do JSON.\n- N\u00c3O use aspas extras envolvendo o JSON.\n- Se violar qualquer regra acima, a resposta ser\u00e1 considerada inv\u00e1lida.\n\nTarefa:\nLeia o conte\u00fado do PDF (fatura ou recibo) fornecido e extraia os dados abaixo para preencher uma planilha.\n\nSe algum campo n\u00e3o existir no documento, retorne null.\n\nFormato do JSON (use EXATAMENTE essas chaves):\n{\n  \"data_fatura\": string | null,\n  \"fornecedor\": string | null,\n  \"valor\": number | null,\n  \"moeda\": string | null,\n  \"impostos\": number | null,\n  \"numero_fatura\": string | null,\n  \"categoria\": string | null,\n  \"tipo\": \"corporativo\" | \"pessoal\" | null,\n  \"metodo_pagamento\": string | null,\n  \"nome_sugerido_arquivo\": string\n}\n\nRegras de formata\u00e7\u00e3o:\n- Datas: YYYY-MM-DD\n- Valores num\u00e9ricos: sem s\u00edmbolo de moeda, usando ponto como decimal\n- \"tipo\": use \"corporativo\" ou \"pessoal\" apenas\n- N\u00e3o invente informa\u00e7\u00f5es\n\nRegras para \"arquivo_sugerido\":\n- Formato: Data_Fornecedor_Valor.pdf\n- Fornecedor: sem acentos, sem caracteres especiais, espa\u00e7os como \"_\"\n- Valor: 2 casas decimais, ponto substitu\u00eddo por \"-\"\nExemplo v\u00e1lido de resposta (apenas como refer\u00eancia de formato):\n{\n\"data_fatura\":\"2025-05-02\",\n\"fornecedor\":\"Empresa_X\",\n\"valor\":273.00,\n\"moeda\":\"BRL\",\n\"impostos\":13.00,\n\"numero_fatura\":\"ABC-123\",\n\"categoria\":\"Servicos\",\n\"tipo\":\"corporativo\",\n\"metodo_pagamento\":null,\n\"nome_sugerido_arquivo\":\"2025-05-02_Empresa_X_273-00.pdf\"\n}\n\n## Para an\u00e1lise de nota corporativa ou pessoal:\n\n1. REGRA DE OURO (CLIENTE): Procure no texto se h\u00e1 men\u00e7\u00e3o ao cliente \"Hashtag Treinamentos\". Se a fatura foi emitida para esta empresa, a categoria \u00e9 OBRIGATORIAMENTE \"Corporativo\". \n2. AN\u00c1LISE DE CONTEXTO: Se n\u00e3o houver nome de cliente expl\u00edcito, analise o item comprado: - Se for servi\u00e7o de streaming (ex: Netflix), delivery de comida (ex: iFood), transporte individual (ex: Uber) ou apps de uso geral, classifique como \"Pessoal\". - Se for servi\u00e7o empresarial (ex: Marketing, TI, Consultoria, Material de Escrit\u00f3rio), classifique como \"Corporativo\".\n\nAgora gere a resposta FINAL obedecendo rigorosamente todas as regras acima.",
        "inputType": "binary",
        "binaryPropertyName": "={{ Object.keys($binary)[0] }}",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "typeVersion": 1.1,
      "position": [
        832,
        0
      ],
      "id": "dd3e17c4-e878-470f-b762-fc4cdd4aa224",
      "name": "Analyze document",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "9d32d9b5-8230-4785-b03b-d37fb8284edf",
              "name": "=content.parts[0].text",
              "value": "={{ $json.content.parts[0].text }}",
              "type": "object"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1040,
        0
      ],
      "id": "2c3ee5ba-8dd3-49e3-babc-9116f61a4a85",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "210372ba-d9d3-401a-a908-44e0a11062e1",
              "leftValue": "={{ $json.content.parts[0].text.tipo }}",
              "rightValue": "pessoal",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        1248,
        0
      ],
      "id": "ec08a2fd-5497-47d8-b265-ebbbb6907d18",
      "name": "If1"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        1504,
        -96
      ],
      "id": "988280c4-e504-465e-829c-0361eea42b4b",
      "name": "Merge"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        1520,
        96
      ],
      "id": "b67b8af4-b846-4d30-a697-d68795a0b441",
      "name": "Merge1"
    },
    {
      "parameters": {
        "inputDataFieldName": "={{ Object.keys($binary)[0] }}",
        "name": "={{ $json.content.parts[0].text.nome_sugerido_arquivo }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "value": "https://drive.google.com/drive/u/0/folders/1q7s96KU30N8mKGUtFWAG_y8g-GZ_Kuo3",
          "mode": "url"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1712,
        -96
      ],
      "id": "eb7c4786-d9bf-41da-8fb0-f43e7af13f62",
      "name": "Upload file",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "inputDataFieldName": "={{ Object.keys($binary)[0] }}",
        "name": "={{ $json.content.parts[0].text.nome_sugerido_arquivo }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "value": "https://drive.google.com/drive/u/0/folders/14VrsAJYuKOF1s5hQIOdTruDpOe4tcM_N",
          "mode": "url"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1712,
        96
      ],
      "id": "a6cda9d9-5061-46af-b79e-4a919f0290bf",
      "name": "Upload file1",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1i56_pTHCGHR1PRWgimiI7NbRrgN0bNv6ythXPahruU8",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "P\u00e1gina1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1i56_pTHCGHR1PRWgimiI7NbRrgN0bNv6ythXPahruU8/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Data da Fatura": "={{ $('Edit Fields').item.json.content.parts[0].text.data_fatura }}",
            "Fornecedor": "={{ $('Edit Fields').item.json.content.parts[0].text.fornecedor }}",
            "Valor": "={{ $('Edit Fields').item.json.content.parts[0].text.valor }}",
            "Moeda": "={{ $('Edit Fields').item.json.content.parts[0].text.moeda }}",
            "Impostos": "={{ $('Edit Fields').item.json.content.parts[0].text.impostos }}",
            "N\u00famero da Fatura": "={{ $('Edit Fields').item.json.content.parts[0].text.numero_fatura }}",
            "Categoria": "={{ $('Edit Fields').item.json.content.parts[0].text.categoria }}",
            "Corporativo ou Pessoal": "={{ $('Edit Fields').item.json.content.parts[0].text.tipo }}",
            "M\u00e9todo de Pagamento": "={{ $('Edit Fields').item.json.content.parts[0].text.metodo_pagamento }}",
            "URL do Arquivo": "={{ $json.webViewLink }}",
            "E-mail de Origem": "={{ $('Gmail Trigger').item.json.from.value[0].address }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Data da Fatura",
              "displayName": "Data da Fatura",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Fornecedor",
              "displayName": "Fornecedor",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Valor",
              "displayName": "Valor",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Moeda",
              "displayName": "Moeda",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Impostos",
              "displayName": "Impostos",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "N\u00famero da Fatura",
              "displayName": "N\u00famero da Fatura",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Categoria",
              "displayName": "Categoria",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Corporativo ou Pessoal",
              "displayName": "Corporativo ou Pessoal",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "M\u00e9todo de Pagamento",
              "displayName": "M\u00e9todo de Pagamento",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "URL do Arquivo",
              "displayName": "URL do Arquivo",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "E-mail de Origem",
              "displayName": "E-mail de Origem",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1968,
        0
      ],
      "id": "a5e8c6d2-e894-4aab-93e3-78b84d958342",
      "name": "Append row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Analyze document",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          },
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Analyze document": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Upload file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Upload file1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload file": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload file1": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false
  },
  "versionId": "17d66d70-e536-4c95-a94a-8b798b22b2ab",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "oZ2GLiC4Jvp4taz84p6Ch",
  "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 4. Uses gmailTrigger, googleGemini, googleDrive, googleSheets. Event-driven trigger; 13 nodes.

Source: https://github.com/IDB-devs/Upwork_Project_Automacao_Faturas/blob/main/Upwork_Project_Automacao_Faturas.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

This workflow converts emailed timesheets into structured invoice rows in Google Sheets and stores them in the correct Google Drive folder structure.

Gmail Trigger, OpenAI, Google Sheets +2
AI & RAG

Monitor a Google Drive folder, process each image based on the prompt defined in and save the new image to the specified output Google Drive folder. Maintain a processing log in Google Sheets.

Google Drive Trigger, Google Drive, HTTP Request +2
AI & RAG

Understand your customers before you build for them. This workflow, Market Segmentation: Buyer Persona Pain Point Report, automates the grueling process of primary market research. By scraping real-wo

Form Trigger, Google Gemini, N8N Nodes Olostep +3
AI & RAG

Overview

Gmail Trigger, Google Drive, OpenAI +4
AI & RAG

Automate your product visuals! This n8n workflow instantly processes new product photography requests from Jotform or Google Sheets, uses an AI agent (Gemini Nano Banana) to generate professional AI p

Google Sheets, Google Gemini, Google Drive +2