AutomationFlowsAI & RAG › Poc Sistema Genai Híbrido Para Uso Interno Ifood -> Agente RAG + LLM Chain…

Poc Sistema Genai Híbrido Para Uso Interno Ifood -> Agente RAG + LLM Chain…

Original n8n title: Poc Sistema Genai Híbrido Para Uso Interno Ifood -> Agente RAG + LLM Chain Routing

POC Sistema GenAI Híbrido para uso interno iFood -> Agente RAG + LLM Chain Routing. Uses chatTrigger, chainLlm, googleDrive, documentDefaultDataLoader. Chat trigger; 19 nodes.

Chat trigger trigger★★★★☆ complexityAI-powered19 nodesChat TriggerChain LlmGoogle DriveDocument Default Data LoaderAgentPinecone Vector StoreMemory Buffer WindowGoogle Gemini Chat
AI & RAG Trigger: Chat trigger Nodes: 19 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow follows the Agent → Chainllm 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": "POC Sistema GenAI H\u00edbrido para uso interno iFood -> Agente RAG + LLM Chain Routing",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [
        -208,
        48
      ],
      "id": "046417cd-3f49-4b5a-8101-aa759bba4f5f",
      "name": "When chat message received"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "f04deabd-4e5a-4048-b0f0-9632dcafa8b0",
                    "leftValue": "={{ $json.text }}",
                    "rightValue": "OPERACIONAL",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "23d6889f-72bc-402e-8c1d-dfe350d69f8f",
                    "leftValue": "={{ $json.text }}",
                    "rightValue": "SAUDACAO",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.text }}",
                    "rightValue": "RISCO_FRAUDE",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "id": "d8fd304c-989a-4025-849e-d6cf9b54b148"
                  }
                ],
                "combinator": "and"
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.3,
      "position": [
        336,
        16
      ],
      "id": "65297b2d-7831-4419-9b93-db95464c5e8c",
      "name": "Switch"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.text }}",
        "messages": {
          "messageValues": [
            {
              "type": "AIMessagePromptTemplate",
              "message": "Ol\u00e1, FoodLover! Sou o assistente virtual de suporte do iFood. Posso esclarecer d\u00favidas sobre regras de cancelamento e reembolso. Como posso te ajudar?"
            }
          ]
        },
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        704,
        48
      ],
      "id": "10e29798-d7d8-4631-bcbb-b5a14dd0a681",
      "name": "Chain SAUDA\u00c7\u00c3O"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.text }}",
        "messages": {
          "messageValues": [
            {
              "type": "AIMessagePromptTemplate",
              "message": "=\u26a0\ufe0f **ORIENTA\u00c7\u00c3O DE SEGURAN\u00c7A**  Identifiquei que este cen\u00e1rio envolve poss\u00edveis riscos de fraude ou seguran\u00e7a (conforme Fluxo Seguran\u00e7a).  **Recomenda\u00e7\u00e3o Oficial:** Para estes casos, a orienta\u00e7\u00e3o \u00e9 n\u00e3o prosseguir com a tratativa padr\u00e3o de reembolso. Sugiro encaminhar o caso para an\u00e1lise especializada do time de **Prevention**.  **Pr\u00f3ximos passos sugeridos:** 1. Validar se h\u00e1 hist\u00f3rico de m\u00faltiplos reembolsos ou comportamento at\u00edpico. 2. Se confirmado a suspeita, abrir ticket com a tag `#URGENTE` para avalia\u00e7\u00e3o manual."
            }
          ]
        },
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        736,
        192
      ],
      "id": "01038457-8edb-48b2-ae72-8ac6824e10cd",
      "name": "Chain FRAUDE"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.text }}",
        "messages": {
          "messageValues": [
            {
              "type": "AIMessagePromptTemplate",
              "message": "Desculpe, sou um assistente especializado apenas nas Pol\u00edticas e Processos Operacionais do iFood. N\u00e3o fui treinado para responder sobre outros assuntos.  \ud83d\udca1 Posso ajudar com:  Regras de Reembolso e Estorno  Procedimentos de Cancelamento  Fluxos de Entrega e Seguran\u00e7a  Por favor, tente reformular sua d\u00favida focando nestes temas."
            }
          ]
        },
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        704,
        336
      ],
      "id": "be75931c-d1e9-4f55-a339-c448d5c0464a",
      "name": "Chain FALLBACK"
    },
    {
      "parameters": {},
      "id": "41e4d3e8-2556-4b32-9781-9df45e172845",
      "name": "When clicking \"Execute Workflow\"",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        464,
        -560
      ]
    },
    {
      "parameters": {
        "options": {
          "delimiter": ",",
          "encoding": "utf-8",
          "headerRow": true
        }
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1.1,
      "position": [
        880,
        -560
      ],
      "id": "8aeb2b87-6f66-4800-961c-bb944386be1b",
      "name": "Extract from File"
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "https://drive.google.com/file/d/154od-0dSzUt3wCDkeAMfNWtU9ZMKKRgx/view?usp=drive_link",
          "mode": "url"
        },
        "options": {
          "binaryPropertyName": "data"
        }
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        672,
        -560
      ],
      "id": "2f3919eb-8e32-475f-ab44-ddfcbbeaff24",
      "name": "Download file",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "return items.map(item => {\n  const data = item.json;\n\n  // ESTRAT\u00c9GIA REFINADA:\n  // Colocamos a FONTE e a CATEGORIA no topo do texto.\n  // Mudamos os r\u00f3tulos para \"CEN\u00c1RIO\" e \"A\u00c7\u00c3O\" para guiar o modelo.\n  const textContent = `[FONTE OFICIAL: ${data.fonte}]\n[CATEGORIA: ${data.categoria}]\nCEN\u00c1RIO: ${data.pergunta}\nA\u00c7\u00c3O RECOMENDADA: ${data.resposta}`;\n\n  return {\n    json: {\n      // Metadados (continuam aqui para filtros futuros)\n      categoria: data.categoria,\n      fonte: data.fonte,\n      \n      // O texto \"blindado\" para o vetor\n      text_to_embed: textContent\n    }\n  };\n});"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1104,
        -560
      ],
      "id": "feb4c6c8-78ed-4229-a243-82df5a4b44f0",
      "name": "Code in JavaScript"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "typeVersion": 1.1,
      "position": [
        1472,
        -384
      ],
      "id": "3004e73e-57d5-4fcd-aa93-f7efba00b0c7",
      "name": "Default Data Loader"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('When chat message received').item.json.chatInput }}",
        "options": {
          "systemMessage": "=Voc\u00ea \u00e9 um Especialista de Suporte N\u00edvel 2 do iFood, respons\u00e1vel por auxiliar atendentes humanos com d\u00favidas operacionais complexas.\n\nSUAS FERRAMENTAS:\nVoc\u00ea tem acesso exclusivo \u00e0 ferramenta \"Busca_Docs_iFood\".\nEla cont\u00e9m a \"Verdade Oficial\" sobre Reembolsos, Cancelamentos, Estornos e Entregas.\n\nPROTOCOLOS DE ATENDIMENTO:\n1. CONSULTA OBRIGAT\u00d3RIA: Para QUALQUER pergunta sobre regras, prazos ou procedimentos, voc\u00ea DEVE usar a ferramenta \"Busca_Docs_iFood\" primeiro. Nunca confie na sua mem\u00f3ria interna para regras de neg\u00f3cio.\n2. CITA\u00c7\u00c3O DE FONTE: Ao responder, baseie-se estritamente no retorno da ferramenta. Se o documento trouxer \"[FONTE OFICIAL: Pol\u00edtica X]\", cite essa fonte na sua resposta final.\n3. ORIENTA\u00c7\u00c3O \u00c0 A\u00c7\u00c3O: Transforme a informa\u00e7\u00e3o t\u00e9cnica em instru\u00e7\u00e3o clara.\n   - Ruim: \"O estorno pode levar 14 dias.\"\n   - Bom: \"Oriente o cliente a aguardar at\u00e9 14 dias para o estorno constar na fatura.\"\n\nPROTOCOLO DE SEGURAN\u00c7A (CR\u00cdTICO):\nAo receber o retorno da ferramenta \"Busca_Docs_iFood\", analise criticamente a relev\u00e2ncia:\n1. Se o conte\u00fado recuperado N\u00c3O responder diretamente \u00e0 pergunta do usu\u00e1rio, ou se for vago/gen\u00e9rico demais:\n   - IGNORE o conte\u00fado.\n   - Responda EXATAMENTE esta frase: \"Desculpe, a busca na base de conhecimento n\u00e3o retornou informa\u00e7\u00f5es com confian\u00e7a suficiente para este cen\u00e1rio. Recomendo escalar para um supervisor.\"\n2. N\u00e3o tente \"ajudar\" inferindo coisas que n\u00e3o est\u00e3o escritas. Se n\u00e3o est\u00e1 na ferramenta, n\u00e3o existe.\n\nSEU OBJETIVO:\nFornecer respostas precisas, fundamentadas em documentos oficiais e prontas para serem repassadas ao cliente ou parceiro.",
          "enableStreaming": true
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3,
      "position": [
        864,
        -288
      ],
      "id": "79208ee2-40d4-429c-a1af-b88033aa891f",
      "name": "Agente RAG | OPERACIONAL"
    },
    {
      "parameters": {
        "mode": "retrieve-as-tool",
        "toolDescription": "Ferramenta de busca na Base de Conhecimento Oficial (Knowledge Base) do iFood. Utilize esta ferramenta para consultar regras e procedimentos sobre:\n\n> Reembolsos (Total, Parcial e Autom\u00e1tico)\n\n> Cancelamentos (Pelo restaurante, cliente ou app)\n\n> Fluxos Financeiros e Estornos\n\n> Problemas na Entrega\n\nUse sempre que a d\u00favida envolver uma decis\u00e3o operacional ou valida\u00e7\u00e3o de pol\u00edtica. A entrada (input) deve ser a pergunta completa do usu\u00e1rio.",
        "pineconeIndex": {
          "__rl": true,
          "value": "index-ifood-genai-reembolsos-cancelamentos",
          "mode": "list",
          "cachedResultName": "index-ifood-genai-reembolsos-cancelamentos"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "typeVersion": 1.3,
      "position": [
        1104,
        -96
      ],
      "id": "88e9fa81-8098-4d90-9542-cfc48b8008f1",
      "name": "Busca Docs iFood",
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        944,
        -96
      ],
      "id": "773503bf-850b-426c-a18e-290ce2980d2d",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "mode": "insert",
        "pineconeIndex": {
          "__rl": true,
          "value": "index-ifood-genai-reembolsos-cancelamentos",
          "mode": "list",
          "cachedResultName": "index-ifood-genai-reembolsos-cancelamentos"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "typeVersion": 1.3,
      "position": [
        1328,
        -560
      ],
      "id": "31629b6f-1518-4802-8efc-fc100042a8d5",
      "name": "Pinecone Vector Store",
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-pro-latest",
        "options": {
          "temperature": 0
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        784,
        -96
      ],
      "id": "f4d579e2-baa4-4388-a872-48d6d430cbde",
      "name": "Google Gemini Pro",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-flash-latest",
        "options": {
          "temperature": 0
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        336,
        352
      ],
      "id": "e70c8c29-0ad0-4a7c-8f5d-264c220502ec",
      "name": "Google Gemini Flash",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-embedding-001"
      },
      "id": "fb389a38-a453-41b8-ada5-6fd92fe47620",
      "name": "Gemini Embedding 1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "typeVersion": 1,
      "position": [
        1328,
        -288
      ],
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-embedding-001"
      },
      "id": "ce961c93-f75d-40bf-bd01-3f6a8544157b",
      "name": "Gemini Embedding 2",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "typeVersion": 1,
      "position": [
        1104,
        80
      ],
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Voc\u00ea \u00e9 o 'Gatekeeper' (Classificador) do Suporte a Parceiros.\nSua fun\u00e7\u00e3o \u00e9 analisar a mensagem do usu\u00e1rio e categoriz\u00e1-la em APENAS UMA das classes abaixo:\n\n1. SAUDACAO: Apenas cumprimentos (ex: \"Oi\", \"Bom dia\", \"Tudo bem?\").\n2. RISCO_FRAUDE: Men\u00e7\u00f5es a \"golpe\", \"cart\u00e3o clonado\", \"m\u00faltiplos reembolsos\", \"bloqueio\", \"suspeita de fraude\" ou comportamento abusivo descrito no Fluxo de Seguran\u00e7a.\n3. OPERACIONAL: D\u00favidas sobre Reembolso, Cancelamento, Entregas, Itens faltantes, Status de pedido, Estornos ou Regras da Pol\u00edtica.\n4. OUTROS: Assuntos que n\u00e3o t\u00eam rela\u00e7\u00e3o com a opera\u00e7\u00e3o de delivery ou suporte.\n\nResponda APENAS com a palavra-chave da classe (ex: OPERACIONAL). N\u00e3o explique nada, n\u00e3o use pontua\u00e7\u00e3o extra.\n\nMensagem do usu\u00e1rio: {{ $json.chatInput }}",
        "hasOutputParser": true,
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        -16,
        48
      ],
      "id": "74f006eb-e547-4486-8b33-0d113e354250",
      "name": "LLM Classificador"
    }
  ],
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "LLM Classificador",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Agente RAG | OPERACIONAL",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Chain SAUDA\u00c7\u00c3O",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Chain FRAUDE",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Chain FALLBACK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \"Execute Workflow\"": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Busca Docs iFood": {
      "ai_tool": [
        [
          {
            "node": "Agente RAG | OPERACIONAL",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Agente RAG | OPERACIONAL",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store": {
      "main": [
        []
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Pro": {
      "ai_languageModel": [
        [
          {
            "node": "Agente RAG | OPERACIONAL",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Flash": {
      "ai_languageModel": [
        [
          {
            "node": "LLM Classificador",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Chain FRAUDE",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Chain SAUDA\u00c7\u00c3O",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Chain FALLBACK",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Embedding 1": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Embedding 2": {
      "ai_embedding": [
        [
          {
            "node": "Busca Docs iFood",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Agente RAG | OPERACIONAL": {
      "main": [
        []
      ]
    },
    "LLM Classificador": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "99950abb-75c2-4e27-92b2-db4ec1356e92",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "KHD8y8tRrDntWn4q",
  "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

POC Sistema GenAI Híbrido para uso interno iFood -> Agente RAG + LLM Chain Routing. Uses chatTrigger, chainLlm, googleDrive, documentDefaultDataLoader. Chat trigger; 19 nodes.

Source: https://github.com/ayanliger/ifood-poc-genai/blob/9590e79671f929f2026a9437f4cb8e0fb3f56e02/poc_ifood_genAI.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 acts as a 24/7 sales agent, engaging leads across WhatsApp, Instagram, Facebook, Telegram, and your website. It intelligently transcribes audio messages, answers questions using a knowle

Chat Trigger, Memory Postgres Chat, Tool Workflow +20
AI & RAG

• Create a Google Drive folder to watch. • Connect your Google Drive account in n8n and authorize access. • Point the Google Drive Trigger node to this folder (new/modified files trigger the flow).

Agent, Chat Trigger, Memory Buffer Window +14
AI & RAG

⚡AI-Powered YouTube Playlist & Video Summarization and Analysis v2. Uses lmChatGoogleGemini, agent, splitOut, chainLlm. Chat trigger; 72 nodes.

Google Gemini Chat, Agent, Chain Llm +11
AI & RAG

This n8n workflow transforms entire YouTube playlists or single videos into interactive knowledge bases you can chat with. Ask questions and get summaries without needing to watch hours of content. 🔗

Google Gemini Chat, Agent, Chain Llm +11
AI & RAG

AI-Powered YouTube Playlist & Video Summarization and Analysis v2. Uses lmChatGoogleGemini, agent, chainLlm, vectorStoreQdrant. Chat trigger; 72 nodes.

Google Gemini Chat, Agent, Chain Llm +11