Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hamiltonjose/156ba6db98cb981975fdfa0f4f5a1d2e to your computer and use it in GitHub Desktop.
Save hamiltonjose/156ba6db98cb981975fdfa0f4f5a1d2e to your computer and use it in GitHub Desktop.
{
"name": "AI-Business-Agent",
"nodes": [
{
"parameters": {
"mode": "insert",
"tableName": {
"__rl": true,
"value": "documents",
"mode": "list",
"cachedResultName": "documents"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
"typeVersion": 1.1,
"position": [
520,
300
],
"id": "243e159d-7bbe-4cb9-a91c-d87afef41b32",
"name": "Supabase Vector Store",
"credentials": {
"supabaseApi": {
"id": "6rCvzKWRmCqAynOD",
"name": "Supabase account"
}
}
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"typeVersion": 1.2,
"position": [
500,
460
],
"id": "67da6447-9a25-4b2b-a102-78513f9ad2d5",
"name": "Embeddings OpenAI",
"credentials": {
"openAiApi": {
"id": "Z3R8Ji2VnI8qLeU1",
"name": "OpenAi account"
}
}
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"typeVersion": 1,
"position": [
620,
460
],
"id": "e201f70d-f88a-40a7-b628-2e1970108e55",
"name": "Default Data Loader"
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
"typeVersion": 1,
"position": [
800,
580
],
"id": "c484c74d-1723-466e-bfcf-f0169d3aa32c",
"name": "Recursive Character Text Splitter"
},
{
"parameters": {
"resource": "fileFolder",
"filter": {
"folderId": {
"__rl": true,
"value": "1IAZITsISsz-ULOETlH3P5bdIeS_RAZZw",
"mode": "list",
"cachedResultName": "business",
"cachedResultUrl": "https://drive.google.com/drive/folders/1IAZITsISsz-ULOETlH3P5bdIeS_RAZZw"
},
"whatToSearch": "files"
},
"options": {
"fields": [
"id",
"name",
"shared",
"mimeType",
"kind"
]
}
},
"type": "n8n-nodes-base.googleDrive",
"typeVersion": 3,
"position": [
-1600,
320
],
"id": "70bb70b2-247b-4779-bc74-021d3c600642",
"name": "Google Drive",
"credentials": {
"googleDriveOAuth2Api": {
"id": "eBFhEOVIrK0AXZD9",
"name": "Google Drive account"
}
}
},
{
"parameters": {
"operation": "download",
"fileId": {
"__rl": true,
"value": "={{ $('Split Out').item.json.file.id }}",
"mode": "id"
},
"options": {
"binaryPropertyName": "file"
}
},
"type": "n8n-nodes-base.googleDrive",
"typeVersion": 3,
"position": [
-380,
320
],
"id": "a4580ec9-13e9-42f2-9c75-8bd40f44932f",
"name": "Download Files",
"credentials": {
"googleDriveOAuth2Api": {
"id": "eBFhEOVIrK0AXZD9",
"name": "Google Drive account"
}
}
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"leftValue": "={{ $('Split Out').item.json.file.mimeType }}",
"rightValue": "application/pdf",
"operator": {
"type": "string",
"operation": "equals"
},
"id": "7fd4b290-3f47-4716-967c-d409b7726d8d"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "pdf"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "ad57547b-19aa-4698-91e0-a63ca03f6101",
"leftValue": "={{ $('Split Out').item.json.file.mimeType }}",
"rightValue": "image/",
"operator": {
"type": "string",
"operation": "startsWith"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "image"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.switch",
"typeVersion": 3.2,
"position": [
-220,
320
],
"id": "7ca21ea2-0cb3-49a2-89b7-d1e6b09f2bc6",
"name": "Switch"
},
{
"parameters": {
"operation": "binaryToPropery",
"binaryPropertyName": "file",
"options": {}
},
"type": "n8n-nodes-base.extractFromFile",
"typeVersion": 1,
"position": [
0,
200
],
"id": "7cf5a446-cdbb-4f91-864e-4ce739df99f0",
"name": "Extract Binary Data from PDF"
},
{
"parameters": {
"operation": "binaryToPropery",
"binaryPropertyName": "file",
"options": {}
},
"type": "n8n-nodes-base.extractFromFile",
"typeVersion": 1,
"position": [
0,
400
],
"id": "2fd1c45b-b0f2-4f9a-b8d3-7880b5306d3d",
"name": "Extract Binary Data from Image"
},
{
"parameters": {
"method": "POST",
"url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "googlePalmApi",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"contents\": [{\n \"parts\":[\n {\"text\": \"Extract full content from this PDF, report exactly as it is.\"},\n {\n \"inline_data\": {\n \"mime_type\": \"application/pdf\",\n \"data\": \"{{ $json.data }}\"\n }\n }\n ]\n }]\n}\n",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
220,
200
],
"id": "1822b01f-2f09-4924-b787-18126fc2aca3",
"name": "GEMINI API HTTP Request (PDF)",
"credentials": {
"googlePalmApi": {
"id": "HeQ7jFCj7D7CdQSi",
"name": "Google Gemini(PaLM) Api account"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "googlePalmApi",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"contents\": [{\n \"parts\":[\n {\"text\": \"Whats on this image?\"},\n {\n \"inline_data\": {\n \"mime_type\": \"image/jpeg\",\n \"data\": \"{{ $json.data }}\"\n }\n }\n ]\n }]\n}\n",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
220,
400
],
"id": "219bf598-3961-486b-ae34-c48239f76e00",
"name": "GEMINI API HTTP Request (IMAGE)",
"credentials": {
"googlePalmApi": {
"id": "HeQ7jFCj7D7CdQSi",
"name": "Google Gemini(PaLM) Api account"
}
}
},
{
"parameters": {
"rule": {
"interval": [
{
"field": "minutes",
"minutesInterval": 1
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [
-1760,
320
],
"id": "03ccc1dc-f858-422a-945d-2c07ecc2b9e4",
"name": "Schedule Trigger"
},
{
"parameters": {
"operation": "getAll",
"tableId": "document_history",
"returnAll": true
},
"type": "n8n-nodes-base.supabase",
"typeVersion": 1,
"position": [
-1460,
320
],
"id": "09321701-d413-4b88-89b5-0e31a9e24709",
"name": "Supabase",
"alwaysOutputData": true,
"executeOnce": true,
"credentials": {
"supabaseApi": {
"id": "6rCvzKWRmCqAynOD",
"name": "Supabase account"
}
}
},
{
"parameters": {
"jsCode": "let newFiles = []\nconst savedFileNames = (() => {\n return $('Supabase').all().map((item) => {\n return item.json.name\n })\n})()\n\nfor (const item of $('Google Drive').all()) {\n if( savedFileNames && !savedFileNames.includes(item.json.name)) newFiles.push({\n name: item.json.name,\n id: item.json.id,\n mimeType: item.json.mimeType\n })\n}\n\nreturn {\n newFiles\n}"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-1320,
320
],
"id": "268d72a9-da61-4d5a-8205-943600407d0f",
"name": "Check for New Files"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "9a9493bf-161d-4d11-ba0b-3152280c01aa",
"leftValue": "={{ $json.newFiles }}",
"rightValue": "",
"operator": {
"type": "array",
"operation": "notEmpty",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-1000,
320
],
"id": "96dba08a-a5b8-463e-a7c5-d7faa2e810ee",
"name": "If"
},
{
"parameters": {
"fieldToSplitOut": "newFiles",
"options": {
"destinationFieldName": "file"
}
},
"type": "n8n-nodes-base.splitOut",
"typeVersion": 1,
"position": [
-840,
320
],
"id": "4a8e019b-7008-4031-8f9c-705151f9b2da",
"name": "Split Out"
},
{
"parameters": {
"tableId": "document_history",
"fieldsUi": {
"fieldValues": [
{
"fieldId": "name",
"fieldValue": "={{ $json.file.name }}"
}
]
}
},
"type": "n8n-nodes-base.supabase",
"typeVersion": 1,
"position": [
-700,
320
],
"id": "4b8c0ff9-9017-4648-8371-28e7ad9bbb21",
"name": "Add New Files",
"credentials": {
"supabaseApi": {
"id": "6rCvzKWRmCqAynOD",
"name": "Supabase account"
}
}
},
{
"parameters": {
"public": true,
"initialMessages": "Hi there! 👋\nI'm [Business Name] assistant. How can I assist you today?",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.1,
"position": [
-1780,
740
],
"id": "19d820ee-477f-4858-a2a6-560af839924b",
"name": "When chat message received",
"webhookId": "77068bd1-7037-400f-967e-056ce4fe4030"
},
{
"parameters": {
"options": {
"systemMessage": "You are an Internal Business Assistant, a highly professional and reliable AI-powered chatbot designed to assist employees of [Company Name] with their work-related queries. Your primary goal is to provide accurate, concise, and contextually relevant answers to support employees in their tasks, decision-making, and understanding of company processes, policies, and resources.\nKey Capabilities and Instructions:\nAccess to Knowledge Base: You have access to a company knowledge base stored in a vector database. For every employee query, you must use the retrieval tool to search the vector storage and retrieve relevant information to ensure your responses are accurate and grounded in the company's data.\nTool Usage: Before formulating a response, always invoke the retrieval tool to fetch contextual information related to the query. If the retrieved information is insufficient or unclear, acknowledge this and provide the best possible response based on available data, while suggesting the employee seek further clarification from a relevant department or supervisor if necessary.\nTone and Style: Maintain a professional, friendly, and approachable tone. Your responses should be clear, concise, and tailored to the employee’s query. Avoid jargon unless it is standard within the company, and explain technical terms if needed.\nResponse Structure:\nAcknowledge the Query: Briefly restate or acknowledge the employee’s question to confirm understanding.\nProvide the Answer: Deliver a clear and accurate response based on the retrieved information.\nOffer Additional Support: If applicable, suggest follow-up actions, additional resources, or contacts for further assistance.\nConfidentiality and Sensitivity: Treat all queries with confidentiality. Do not share sensitive company information unless explicitly permitted by the knowledge base or company policy. If a query involves sensitive data (e.g., employee personal information, financials), redirect the employee to the appropriate department (e.g., HR, Finance).\nLimitations: If the query is outside the scope of the knowledge base or your capabilities, clearly state this and guide the employee to the appropriate resource or point of contact (e.g., IT support, HR, or a manager).\nProactivity: If the retrieved information suggests related topics or resources that could be helpful, include these as suggestions to enhance the employee’s experience.\nExample Interaction Flow:\nEmployee Query: “What is the process for submitting a travel expense reimbursement?”\nAssistant Response:\nAcknowledge: “I understand you’re asking about the process for submitting a travel expense reimbursement.”\nUse Retrieval Tool: Query the vector storage for “travel expense reimbursement process.”\nProvide Answer: Based on retrieved data, e.g., “According to [Company Name]’s policy, to submit a travel expense reimbursement, you need to complete the Expense Reimbursement Form available on the intranet under ‘Finance Forms.’ Attach receipts and submit the form to the Finance Department via [specific email/portal]. Ensure all expenses are submitted within 30 days of the travel date.”\nAdditional Support: “If you need help accessing the form or have specific questions, you can contact the Finance team at [email/contact]. Would you like me to retrieve additional details about allowable expenses?”\nPrompt Instructions:\nFor every query, begin by invoking the retrieval tool with the query or relevant keywords to fetch information from the vector storage.\nIf the retrieved information is incomplete or ambiguous, state: “Based on the available information, [provide best answer]. For further details, please contact [relevant department/contact].”\nIf no relevant information is found, respond: “I couldn’t find specific information on [query topic] in the knowledge base. Please check with [relevant department/contact] or let me know if I can assist with something else.”\nAlways prioritize clarity, accuracy, and employee support. Avoid speculative answers; rely solely on retrieved data or general procedural knowledge if retrieval yields no results.\nIf the query is vague, ask for clarification to ensure the response is relevant, e.g., “Could you specify which department or process you’re referring to? This will help me provide the most accurate information.”\nExample Queries to Handle:\nPolicy inquiries (e.g., “What is the company’s remote work policy?”)\nProcess guidance (e.g., “How do I request IT support for a laptop issue?”)\nResource access (e.g., “Where can I find the employee handbook?”)\nGeneral questions (e.g., “Who is the point of contact for payroll issues?”)"
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 2,
"position": [
-1620,
740
],
"id": "4ac287bc-a9af-41bb-90fe-4f9056ff4d7e",
"name": "AI Agent"
},
{
"parameters": {
"modelName": "models/gemini-2.0-flash",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"typeVersion": 1,
"position": [
-1700,
920
],
"id": "d477e01b-6ca2-4185-8e15-f3920b595ccf",
"name": "Google Gemini Chat Model",
"credentials": {
"googlePalmApi": {
"id": "HeQ7jFCj7D7CdQSi",
"name": "Google Gemini(PaLM) Api account"
}
}
},
{
"parameters": {
"mode": "retrieve-as-tool",
"toolName": "company_knowledge_base",
"toolDescription": "Extract Contextual-related informations from the company's vector storage",
"tableName": {
"__rl": true,
"value": "documents",
"mode": "list",
"cachedResultName": "documents"
},
"topK": 10,
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
"typeVersion": 1.1,
"position": [
-1560,
940
],
"id": "0310e941-df4b-4b8b-9463-d2b73685b384",
"name": "Supabase Vector Store1",
"credentials": {
"supabaseApi": {
"id": "6rCvzKWRmCqAynOD",
"name": "Supabase account"
}
}
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"typeVersion": 1.2,
"position": [
-1460,
1080
],
"id": "7b9c93d4-abdc-4f89-abde-f8f14c4b667f",
"name": "Embeddings OpenAI1",
"credentials": {
"openAiApi": {
"id": "Z3R8Ji2VnI8qLeU1",
"name": "OpenAi account"
}
}
},
{
"parameters": {
"content": "## Scheduled Check For New Uploads",
"height": 280,
"width": 640
},
"type": "n8n-nodes-base.stickyNote",
"position": [
-1800,
240
],
"typeVersion": 1,
"id": "3efdd842-9849-42c9-b731-1e5dfdcbdda4",
"name": "Sticky Note"
},
{
"parameters": {
"content": "## If There Are New Files We Update Our DB",
"height": 260,
"width": 500,
"color": 4
},
"type": "n8n-nodes-base.stickyNote",
"position": [
-1040,
240
],
"typeVersion": 1,
"id": "64002ad5-5bff-4d09-b9f3-a8bc062d289d",
"name": "Sticky Note1"
},
{
"parameters": {
"content": "# Document Data Extraction",
"height": 580,
"width": 800,
"color": 5
},
"type": "n8n-nodes-base.stickyNote",
"position": [
-400,
100
],
"typeVersion": 1,
"id": "c0abaabd-b166-48c3-8708-fb5895a7bfa0",
"name": "Sticky Note2"
},
{
"parameters": {
"content": "# Store Embeddings in Our Vector Storage",
"height": 620,
"width": 500
},
"type": "n8n-nodes-base.stickyNote",
"position": [
460,
100
],
"typeVersion": 1,
"id": "de63e539-81cf-43e9-8b40-38643a1a854a",
"name": "Sticky Note3"
},
{
"parameters": {
"content": "# Business Assistant AI Agent with RAG",
"height": 580,
"width": 660,
"color": 6
},
"type": "n8n-nodes-base.stickyNote",
"position": [
-1820,
660
],
"typeVersion": 1,
"id": "bd5f07e3-15ea-4ad2-aedf-44a5cc7269f1",
"name": "Sticky Note4"
}
],
"pinData": {},
"connections": {
"Embeddings OpenAI": {
"ai_embedding": [
[
{
"node": "Supabase Vector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Default Data Loader": {
"ai_document": [
[
{
"node": "Supabase Vector Store",
"type": "ai_document",
"index": 0
}
]
]
},
"Recursive Character Text Splitter": {
"ai_textSplitter": [
[
{
"node": "Default Data Loader",
"type": "ai_textSplitter",
"index": 0
}
]
]
},
"Google Drive": {
"main": [
[
{
"node": "Supabase",
"type": "main",
"index": 0
}
]
]
},
"Download Files": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
},
"Supabase Vector Store": {
"main": [
[]
]
},
"Switch": {
"main": [
[
{
"node": "Extract Binary Data from PDF",
"type": "main",
"index": 0
}
],
[
{
"node": "Extract Binary Data from Image",
"type": "main",
"index": 0
}
]
]
},
"Extract Binary Data from PDF": {
"main": [
[
{
"node": "GEMINI API HTTP Request (PDF)",
"type": "main",
"index": 0
}
]
]
},
"Extract Binary Data from Image": {
"main": [
[
{
"node": "GEMINI API HTTP Request (IMAGE)",
"type": "main",
"index": 0
}
]
]
},
"GEMINI API HTTP Request (IMAGE)": {
"main": [
[
{
"node": "Supabase Vector Store",
"type": "main",
"index": 0
}
]
]
},
"GEMINI API HTTP Request (PDF)": {
"main": [
[
{
"node": "Supabase Vector Store",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Google Drive",
"type": "main",
"index": 0
}
]
]
},
"Supabase": {
"main": [
[
{
"node": "Check for New Files",
"type": "main",
"index": 0
}
]
]
},
"Check for New Files": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
},
"If": {
"main": [
[
{
"node": "Split Out",
"type": "main",
"index": 0
}
]
]
},
"Add New Files": {
"main": [
[
{
"node": "Download Files",
"type": "main",
"index": 0
}
]
]
},
"Split Out": {
"main": [
[
{
"node": "Add New Files",
"type": "main",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Supabase Vector Store1": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Embeddings OpenAI1": {
"ai_embedding": [
[
{
"node": "Supabase Vector Store1",
"type": "ai_embedding",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "35cf7d9d-4af7-4c18-ad35-18390ee255ba",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "db3c2d3698a1d65c9632c318b0f8874c99c3c8ec38f9fa1684001dc1e7ae08d8"
},
"id": "PhNv72Tm5dzITexL",
"tags": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment