Edit: /home/techb158/n8n_data/all-workflows.jsonl (648042B)
{"id":"SDbUXfdFJcuKzJsx","name":"ITAgent","active":0,"nodes":[{"parameters":{"pollTimes":{"item":[{"mode":"everyMinute"}]},"documentId":{"__rl":true,"value":"1D2LMwCiSUzmc8kScWKWRbBtsGSDpjwBGriFAGS07btM","mode":"list","cachedResultName":"Teacher_IT_Tickets","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1D2LMwCiSUzmc8kScWKWRbBtsGSDpjwBGriFAGS07btM/edit?usp=drivesdk"},"sheetName":{"__rl":true,"value":"gid=0","mode":"list","cachedResultName":"Sheet1","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1D2LMwCiSUzmc8kScWKWRbBtsGSDpjwBGriFAGS07btM/edit#gid=0"},"event":"rowAdded","options":{}},"type":"n8n-nodes-base.googleSheetsTrigger","typeVersion":1,"position":[-464,-96],"id":"2447462c-0fd1-49b6-a677-22e36e8ce1c4","name":"Google Sheets Trigger","credentials":{"googleSheetsTriggerOAuth2Api":{"id":"DEhd6yTYhnQh1cFO","name":"Google Sheets Trigger account"}}},{"parameters":{"modelId":{"__rl":true,"value":"gpt-4o","mode":"list","cachedResultName":"GPT-4O"},"messages":{"values":[{"content":"=You are the IT Support Team’s coordinator. Your task is to collect incoming information about new support tickets and produce a concise summary to email to the IT management. The email should be signed with “IT Support Team.”\nHere are the details of the support tickets:\nTicket ID:{{ $json.Ticket_ID }}\nUser:{{ $json.User }}\nIssue:{{ $json.Issue }}\nPriority:{{ $json.Priority }}\nDate Submitted:{{ $json.Date_Submited }}\nStatus:{{ $json.Status }}\nPlease provide the following output parameters:\nEmail_subject\nEmail_content\nMake the content clean and with bullet points"}]},"jsonOutput":true,"options":{}},"type":"@n8n/n8n-nodes-langchain.openAi","typeVersion":1.8,"position":[-256,-96],"id":"d34429c7-f064-4f8e-b4ba-8919207f9c0c","name":"Message a model","credentials":{"openAiApi":{"id":"NpBggKJcrJLV63HW","name":"OpenAi account"}}},{"parameters":{"emailType":"text","options":{"appendAttribution":false}},"type":"n8n-nodes-base.gmail","typeVersion":2.1,"position":[96,-96],"id":"af804f5f-9c7f-4c96-a652-85f95d6bb6e5","name":"Send a message","webhookId":"c9daf051-a8b3-4fb4-a52a-d86f43b84fed","credentials":{"gmailOAuth2":{"id":"vL1hwAuQCCbv0MjK","name":"Gmail account"}}}],"connections":{"Google Sheets Trigger":{"main":[[{"node":"Message a model","type":"main","index":0}]]},"Message a model":{"main":[[{"node":"Send a message","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"pinData":{},"versionId":"f1f5d4e6-07d1-4bbd-b1ff-7034db5c729d","meta":{"templateCredsSetupCompleted":true}}
{"id":"TIyFbbA8cKDGiLn7","name":"Ollama_Chat","active":0,"nodes":[{"parameters":{"options":{}},"type":"@n8n/n8n-nodes-langchain.chatTrigger","typeVersion":1.3,"position":[-704,-144],"id":"1fb35b2e-58ab-4eaf-8bb5-d16508b81909","name":"When chat message received","webhookId":"1a05fd6c-4c54-4e7a-a853-28a541397ec6"},{"parameters":{"promptType":"define","text":"={{ $json.chatInput }}","options":{}},"type":"@n8n/n8n-nodes-langchain.agent","typeVersion":2.2,"position":[-304,-128],"id":"090ecfed-81b1-479c-a81a-471cae41eff5","name":"AI Agent"},{"parameters":{"model":"llama3.1:latest","options":{}},"type":"@n8n/n8n-nodes-langchain.lmChatOllama","typeVersion":1,"position":[-256,96],"id":"fd83f047-9057-4de7-a480-74143b1bb220","name":"Ollama Chat Model","credentials":{"ollamaApi":{"id":"yShAwFAVyxsRy7rz","name":"Ollama account"}}},{"parameters":{"promptType":"define","text":"={{ $json.chatInput }}","batching":{}},"type":"@n8n/n8n-nodes-langchain.chainLlm","typeVersion":1.7,"position":[-672,80],"id":"eaa34a05-15d5-4d63-a9ae-c9173892f17d","name":"Basic LLM Chain"},{"parameters":{"model":"llama3.1:latest","options":{}},"type":"@n8n/n8n-nodes-langchain.lmChatOllama","typeVersion":1,"position":[-672,256],"id":"619fa27b-267f-4ede-a8df-25e8cbebef5c","name":"Ollama Chat Model1","credentials":{"ollamaApi":{"id":"yShAwFAVyxsRy7rz","name":"Ollama account"}}},{"parameters":{},"type":"n8n-nodes-base.merge","typeVersion":3.2,"position":[-288,208],"id":"740ab02c-f7b1-4325-bd4d-0ddd7333f4ea","name":"Merge"},{"parameters":{"operation":"append","documentId":{"__rl":true,"value":"1D2LMwCiSUzmc8kScWKWRbBtsGSDpjwBGriFAGS07btM","mode":"list","cachedResultName":"Teacher_IT_Tickets","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1D2LMwCiSUzmc8kScWKWRbBtsGSDpjwBGriFAGS07btM/edit?usp=drivesdk"},"sheetName":{"__rl":true,"value":"gid=0","mode":"list","cachedResultName":"Sheet1","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1D2LMwCiSUzmc8kScWKWRbBtsGSDpjwBGriFAGS07btM/edit#gid=0"},"columns":{"mappingMode":"defineBelow","value":{},"matchingColumns":[],"schema":[{"id":"Ticket_ID","displayName":"Ticket_ID","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"User","displayName":"User","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"Issue","displayName":"Issue","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"Priority","displayName":"Priority","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"Date_Submited","displayName":"Date_Submited","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"Status","displayName":"Status","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true}],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{}},"type":"n8n-nodes-base.googleSheets","typeVersion":4.7,"position":[-80,208],"id":"54a8553b-3520-4acb-ab04-b8ef58c97488","name":"Append row in sheet","credentials":{"googleSheetsOAuth2Api":{"id":"vwmv6keJbqpxUxCf","name":"Google Sheets account"}}}],"connections":{"When chat message received":{"main":[[{"node":"AI Agent","type":"main","index":0},{"node":"Basic LLM Chain","type":"main","index":0}]]},"Ollama Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Ollama Chat Model1":{"ai_languageModel":[[{"node":"Basic LLM Chain","type":"ai_languageModel","index":0}]]},"Basic LLM Chain":{"main":[[{"node":"Merge","type":"main","index":0}]]},"Merge":{"main":[[{"node":"Append row in sheet","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"pinData":{},"versionId":"8fc48679-aff9-4141-b191-b4d0d20267d6","meta":{"templateCredsSetupCompleted":true}}
{"id":"EXqyVzWFxJ3wSdrW","name":"New_Agent","active":0,"nodes":[],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"pinData":{},"versionId":"ee4ac680-9fa7-4a87-93f8-d8ba772fdaf7","meta":null}
{"id":"pkzCNs9ssYl3DmiK","name":"RAG Chatbot for Company Documents using Google Drive and Gemini","active":0,"nodes":[{"parameters":{"mode":"insert","pineconeIndex":{"__rl":true,"mode":"list","value":"company-files","cachedResultName":"company-files"},"options":{}},"id":"753455a3-ddc8-4a74-b043-70a0af38ff9e","name":"Pinecone Vector Store","type":"@n8n/n8n-nodes-langchain.vectorStorePinecone","position":[912,368],"typeVersion":1,"credentials":{"pineconeApi":{"id":"JQqGjuhPfZsyLOHk","name":"PineconeApi account"}}},{"parameters":{},"id":"a7c8fa7f-cad2-4497-a295-30aa2e98cacc","name":"Embeddings Google Gemini","type":"@n8n/n8n-nodes-langchain.embeddingsGoogleGemini","position":[880,640],"typeVersion":1,"credentials":{"googlePalmApi":{"id":"xTC5bggV3FN3kz5r","name":"Google Gemini(PaLM) Api account"}}},{"parameters":{"dataType":"binary","binaryMode":"specificField","options":{}},"id":"215f0519-4359-4e4b-a90c-7e54b1cc52b5","name":"Default Data Loader","type":"@n8n/n8n-nodes-langchain.documentDefaultDataLoader","position":[1072,592],"typeVersion":1},{"parameters":{"chunkOverlap":100,"options":{}},"id":"863d3d1d-1621-406e-8320-688f64b07b09","name":"Recursive Character Text Splitter","type":"@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter","position":[1056,784],"typeVersion":1},{"parameters":{"options":{"systemMessage":"You are a helpful HR assistant designed to answer employee questions based on company policies.\n\nRetrieve relevant information from the provided internal documents and provide a concise, accurate, and informative answer to the employee's question.\n\nUse the tool called \"company_documents_tool\" to retrieve any information from the company's documents.\n\nIf the answer cannot be found in the provided documents, respond with \"I cannot find the answer in the available resources.\""}},"id":"5af1efb1-ea69-466e-bb3b-2b7e6b1ceef7","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[656,1200],"typeVersion":1.7},{"parameters":{"name":"company_documents_tool","description":"Retrieve information from any company documents"},"id":"825632ac-1edf-4e63-948d-b1a498b2b962","name":"Vector Store Tool","type":"@n8n/n8n-nodes-langchain.toolVectorStore","position":[1056,1424],"typeVersion":1},{"parameters":{"pineconeIndex":{"__rl":true,"mode":"list","value":"company-files","cachedResultName":"company-files"},"options":{}},"id":"72d2f685-bcc3-4e62-a5e3-72c0fe65f8e8","name":"Pinecone Vector Store (Retrieval)","type":"@n8n/n8n-nodes-langchain.vectorStorePinecone","position":[960,1600],"typeVersion":1,"credentials":{"pineconeApi":{"id":"JQqGjuhPfZsyLOHk","name":"PineconeApi account"}}},{"parameters":{},"id":"eeff81cb-6aec-4e7f-afe0-432d87085fb2","name":"Embeddings Google Gemini (retrieval)","type":"@n8n/n8n-nodes-langchain.embeddingsGoogleGemini","position":[928,1760],"typeVersion":1,"credentials":{"googlePalmApi":{"id":"xTC5bggV3FN3kz5r","name":"Google Gemini(PaLM) Api account"}}},{"parameters":{"operation":"download","fileId":{"__rl":true,"mode":"id","value":"={{ $json.id }}"},"options":{"fileName":"={{ $json.name }}"}},"id":"8bb6ebb1-1deb-498b-8da4-b809a736e097","name":"Download File From Google Drive","type":"n8n-nodes-base.googleDrive","position":[688,368],"typeVersion":3,"credentials":{"googleDriveOAuth2Api":{"id":"ghvfZZcpO23tYvmn","name":"Google Drive account"}}},{"parameters":{"content":"## Chat with company documents"},"id":"bd83bacf-dff1-4b7c-af5c-b249fb16c113","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[656,1024],"typeVersion":1},{"parameters":{"pollTimes":{"item":[{"mode":"everyMinute"}]},"triggerOn":"specificFolder","folderToWatch":{"__rl":true,"mode":"list","value":"1evDIoHePhjw_LgVFZXSZyK1sZm2GHp9W","cachedResultUrl":"https://drive.google.com/drive/folders/1evDIoHePhjw_LgVFZXSZyK1sZm2GHp9W","cachedResultName":"INNOVI PRO"},"event":"fileUpdated","options":{}},"id":"7b90daab-0fb2-4c8a-93e6-b138bb04f282","name":"Google Drive File Updated","type":"n8n-nodes-base.googleDriveTrigger","position":[368,512],"typeVersion":1,"credentials":{"googleDriveOAuth2Api":{"id":"ghvfZZcpO23tYvmn","name":"Google Drive account"}}},{"parameters":{"pollTimes":{"item":[{"mode":"everyMinute"}]},"triggerOn":"specificFolder","folderToWatch":{"__rl":true,"mode":"list","value":"1evDIoHePhjw_LgVFZXSZyK1sZm2GHp9W","cachedResultUrl":"https://drive.google.com/drive/folders/1evDIoHePhjw_LgVFZXSZyK1sZm2GHp9W","cachedResultName":"INNOVI PRO"},"event":"fileCreated","options":{"fileType":"all"}},"id":"3a6c6cef-7a19-42ef-8092-eaf57dae4cdd","name":"Google Drive File Created","type":"n8n-nodes-base.googleDriveTrigger","position":[368,240],"typeVersion":1,"credentials":{"googleDriveOAuth2Api":{"id":"ghvfZZcpO23tYvmn","name":"Google Drive account"}}},{"parameters":{},"id":"1e38f1c8-7bd0-4eeb-addc-62339582d350","name":"Window Buffer Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[736,1504],"typeVersion":1.3},{"parameters":{"options":{}},"id":"4b0ab858-99b1-4337-8c5c-a223519e3662","name":"When chat message received","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[320,1200],"webhookId":"5f1c0c82-0ff9-40c7-9e2e-b1a96ffe24cd","typeVersion":1.1},{"parameters":{"content":"## Add docuemnts to vector store when updating or creating new documents in Google Drive","width":320},"id":"bfb684d1-e5c1-41da-8305-b2606a2eade6","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[672,128],"typeVersion":1},{"parameters":{"modelName":"models/gemini-2.0-flash-exp","options":{}},"id":"8f627ec6-4b3f-43ad-a4a3-e2b199a7fe58","name":"Google Gemini Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[560,1504],"typeVersion":1,"credentials":{"googlePalmApi":{"id":"xTC5bggV3FN3kz5r","name":"Google Gemini(PaLM) Api account"}}},{"parameters":{"modelName":"models/gemini-2.0-flash-exp","options":{}},"id":"f2133a06-0088-46de-9f74-a3f9fe478f98","name":"Google Gemini Chat Model (retrieval)","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[1312,1600],"typeVersion":1,"credentials":{"googlePalmApi":{"id":"xTC5bggV3FN3kz5r","name":"Google Gemini(PaLM) Api account"}}},{"parameters":{"content":"## Set up steps\n\n1. Google Cloud Project and Vertex AI API:\n* Create a Google Cloud project.\n* Enable the Vertex AI API for your project.\n2. Google AI API Key:\n* Obtain a Google AI API key from Google AI Studio.\n3. Pinecone Account:\n* Create a free account on the Pinecone website.\nObtain your API key from your Pinecone dashboard.\n* Create an index named company-files in your Pinecone project.\n4. Google Drive:\n* Create a dedicated folder in your Google Drive where company documents will be stored.\n5. Credentials in n8n: Configure credentials in your n8n environment for:\n* Google Drive OAuth2\n* Google Gemini(PaLM) Api (using your Google AI API key)\n* Pinecone API (using your Pinecone API key)\n5. Import the Workflow:\n* Import this workflow into your n8n instance.\n6. Configure the Workflow:\n* Update both Google Drive Trigger nodes to watch the specific folder you created in your Google Drive.\n* Configure the Pinecone Vector Store nodes to use your company-files index.","height":720,"width":420},"id":"578deb96-8393-4850-9757-fa97b2bc9992","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-320,592],"typeVersion":1}],"connections":{"AI Agent":{"main":[[]]},"Vector Store Tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Default Data Loader":{"ai_document":[[{"node":"Pinecone Vector Store","type":"ai_document","index":0}]]},"Window Buffer Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Pinecone Vector Store":{"main":[[]]},"Embeddings Google Gemini":{"ai_embedding":[[{"node":"Pinecone Vector Store","type":"ai_embedding","index":0}]]},"Google Gemini Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Google Drive File Created":{"main":[[{"node":"Download File From Google Drive","type":"main","index":0}]]},"Google Drive File Updated":{"main":[[{"node":"Download File From Google Drive","type":"main","index":0}]]},"When chat message received":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Download File From Google Drive":{"main":[[{"node":"Pinecone Vector Store","type":"main","index":0}]]},"Pinecone Vector Store (Retrieval)":{"ai_vectorStore":[[{"node":"Vector Store Tool","type":"ai_vectorStore","index":0}]]},"Recursive Character Text Splitter":{"ai_textSplitter":[[{"node":"Default Data Loader","type":"ai_textSplitter","index":0}]]},"Embeddings Google Gemini (retrieval)":{"ai_embedding":[[{"node":"Pinecone Vector Store (Retrieval)","type":"ai_embedding","index":0}]]},"Google Gemini Chat Model (retrieval)":{"ai_languageModel":[[{"node":"Vector Store Tool","type":"ai_languageModel","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"pinData":{},"versionId":"8c4dad4c-74c4-44a3-aee8-8691d70bab86","meta":{"templateId":"2753","templateCredsSetupCompleted":true}}
{"id":"PN5D6R3QrkoRhVVZ","name":"Parse PDF with LlamaParse and save to Airtable","active":0,"nodes":[{"parameters":{"operation":"download","fileId":{"__rl":true,"mode":"id","value":"={{ $json.id }}"},"options":{}},"id":"9df72ef9-3b9d-40e4-9cb5-a5ada153c0bb","name":"Google Drive","type":"n8n-nodes-base.googleDrive","position":[1552,368],"typeVersion":3},{"parameters":{"method":"POST","url":"https://api.cloud.llamaindex.ai/api/parsing/upload","sendHeaders":true,"headerParameters":{"parameters":[{"name":"accept","value":"application/json"},{"name":"Authorization","value":"Bearer "},{"name":"parsing_instruction","value":"Please extract invoice line items: Name, Quantity, Unit Price, Amount "}]},"sendBody":true,"contentType":"multipart-form-data","bodyParameters":{"parameters":[{"name":"webhook_url","value":"https://n8n.lowcoding.dev/webhook/0f7f5ebb-8b66-453b-a818-20cc3647c783"},{"parameterType":"formBinaryData","name":"file","inputDataFieldName":"data"},{"name":"disable_ocr","value":"true"},{"name":"disable_image_extraction","value":"True"}]},"options":{}},"id":"e21bb906-658c-4a52-9c7b-b77d6e0e7ea5","name":"Upload File","type":"n8n-nodes-base.httpRequest","position":[1792,368],"typeVersion":4.2},{"parameters":{"pollTimes":{"item":[{"mode":"everyMinute"}]},"triggerOn":"specificFolder","folderToWatch":{"__rl":true,"mode":"list","value":"1IC39VXU8rewBU85offxYlBd9QlYzf8S7","cachedResultUrl":"https://drive.google.com/drive/folders/1IC39VXU8rewBU85offxYlBd9QlYzf8S7","cachedResultName":"Invoices"},"event":"fileCreated","options":{}},"id":"2a0c2331-4612-4b92-a0cc-b316bc663907","name":"Google Drive Trigger","type":"n8n-nodes-base.googleDriveTrigger","position":[1360,368],"typeVersion":1},{"parameters":{"operation":"create","base":{"__rl":true,"mode":"list","value":"appndgSF4faN4jPXi","cachedResultUrl":"https://airtable.com/appndgSF4faN4jPXi","cachedResultName":"Philipp's Base"},"table":{"__rl":true,"mode":"list","value":"tbloPc7Eay4Cvwysq","cachedResultUrl":"https://airtable.com/appndgSF4faN4jPXi/tbloPc7Eay4Cvwysq","cachedResultName":"Invoices"},"columns":{"value":{},"schema":[{"id":"Name","type":"string","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Name","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Line Items","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Line Items","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[]},"options":{}},"id":"4ad70b03-54f1-4715-9848-56fa6ba18278","name":"Create Invoice","type":"n8n-nodes-base.airtable","position":[1840,880],"typeVersion":2.1},{"parameters":{"operation":"create","base":{"__rl":true,"mode":"list","value":"appndgSF4faN4jPXi","cachedResultUrl":"https://airtable.com/appndgSF4faN4jPXi","cachedResultName":"Philipp's Base"},"table":{"__rl":true,"mode":"list","value":"tblIuVR9ocAomznzK","cachedResultUrl":"https://airtable.com/appndgSF4faN4jPXi/tblIuVR9ocAomznzK","cachedResultName":"Line Items"},"columns":{"value":{"Qty":"={{ $json.qty }}","Amount":"={{ parseFloat($json.amount.replace('$', '').trim()) }}","Invoices":"=[\"{{ $('Create Invoice').item.json.id }}\"]","Unit price":"={{ parseFloat($json.unit_price.replace('$', '').trim()) }}","Description":"={{ $json.description }}"},"schema":[{"id":"Name","type":"string","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Name","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Description","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Description","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Qty","type":"number","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Qty","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Unit price","type":"number","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Unit price","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Amount","type":"number","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Amount","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Invoices","type":"array","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Invoices","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[]},"options":{}},"id":"a408eeb4-2dc2-45ff-a989-92676356f596","name":"Create Line Item","type":"n8n-nodes-base.airtable","position":[2240,880],"typeVersion":2.1},{"parameters":{"method":"POST","url":"=https://api.openai.com/v1/chat/completions","authentication":"predefinedCredentialType","nodeCredentialType":"openAiApi","sendBody":true,"specifyBody":"json","jsonBody":"={\n \"model\": \"gpt-4o-mini\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": {{ JSON.stringify($('Set Fields').item.json.prompt) }}\n },\n {\n \"role\": \"user\",\n \"content\": {{ JSON.stringify( JSON.stringify($('Webhook').item.json.body.json[0].items) ) }}\n }\n ],\n \"response_format\":{ \"type\": \"json_schema\", \"json_schema\": {{ $('Set Fields').item.json.schema }}\n\n }\n }","options":{}},"id":"7ee324e8-6df3-48d6-b1b8-6fdb610b1ec7","name":"OpenAI - Extract Line Items","type":"n8n-nodes-base.httpRequest","position":[1616,880],"typeVersion":4.2},{"parameters":{"assignments":{"assignments":[{"id":"dc09a5b4-ff6a-4cee-b87e-35de7336ac05","name":"prompt","type":"string","value":"Please, process parsed data and return only needed."},{"id":"4e0f9af6-517f-42af-9ced-df0e8a7118b0","name":"schema","type":"string","value":"={\n \"name\": \"generate_schema\",\n \"description\": \"Generate schema for an array of objects representing items with their descriptions, quantities, unit prices, and amounts.\",\n \"strict\": true,\n \"schema\": {\n \"type\": \"object\",\n \"required\": [\n \"items\"\n ],\n \"properties\": {\n \"items\": {\n \"type\": \"array\",\n \"description\": \"Array of item objects\",\n \"items\": {\n \"type\": \"object\",\n \"required\": [\n \"description\",\n \"qty\",\n \"unit_price\",\n \"amount\"\n ],\n \"properties\": {\n \"description\": {\n \"type\": \"string\",\n \"description\": \"Description of the item\"\n },\n \"qty\": {\n \"type\": \"string\",\n \"description\": \"Quantity of the item\"\n },\n \"unit_price\": {\n \"type\": \"string\",\n \"description\": \"Unit price of the item formatted as a string\"\n },\n \"amount\": {\n \"type\": \"string\",\n \"description\": \"Total amount for the item formatted as a string\"\n }\n },\n \"additionalProperties\": false\n }\n }\n },\n \"additionalProperties\": false\n }\n}"}]},"options":{}},"id":"eda31919-9091-4d45-bd73-4609b71f93a9","name":"Set Fields","type":"n8n-nodes-base.set","position":[1392,880],"typeVersion":3.4},{"parameters":{"jsCode":"// Get the input from the \"OpenAI - Extract Line Items\" node\nconst input = $(\"OpenAI - Extract Line Items\").first().json;\n\n// Initialize an array for the output\nconst outputItems = [];\n\n// Navigate to the 'content' field in the choices array\nconst content = input.choices[0]?.message?.content;\n\nif (content) {\n try {\n // Parse the stringified JSON in the 'content' field\n const parsedContent = JSON.parse(content);\n\n // Extract 'items' and add them to the output array\n if (Array.isArray(parsedContent.items)) {\n outputItems.push(...parsedContent.items.map(i => ({ json: i })));\n }\n } catch (error) {\n // Handle any parsing errors\n console.error('Error parsing content:', error);\n }\n}\n\n// Return the extracted items\nreturn outputItems;\n"},"id":"cc0d97d8-fb62-43eb-b484-4dd39f8db4b4","name":"Process Line Items","type":"n8n-nodes-base.code","position":[2032,880],"typeVersion":2},{"parameters":{"httpMethod":"POST","path":"0f7f5ebb-8b66-453b-a818-20cc3647c783","options":{}},"id":"741dc44e-6d47-4a77-80c2-5e18b291da33","name":"Webhook","type":"n8n-nodes-base.webhook","position":[1216,880],"webhookId":"0f7f5ebb-8b66-453b-a818-20cc3647c783","typeVersion":2},{"parameters":{"content":"## Scenario 1\n\n","height":400,"width":920},"id":"fbc196c8-7518-4deb-ac47-f37f1b8150eb","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[1168,240],"typeVersion":1},{"parameters":{"content":"## Scenario 2\n\n","height":460,"width":1340},"id":"96368d41-7886-487f-a8a7-e4dac3b01f45","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[1152,784],"typeVersion":1},{"parameters":{"content":"### Replace Google Drive connection","height":80,"width":270,"color":3},"id":"6b7c94d7-c844-4246-ba1a-cea5937792db","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[1376,544],"typeVersion":1},{"parameters":{"content":"### Replace API key in header","height":80,"width":170,"color":3},"id":"9c8141d0-428a-44e5-b900-b07fa64db4f5","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[1760,544],"typeVersion":1},{"parameters":{"content":"### Replace OpenAI connection","height":80,"width":170,"color":3},"id":"48243fe4-4ed1-43dc-b508-8b3f9472bb67","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[1568,1088],"typeVersion":1},{"parameters":{"content":"### Replace Airtable connection","height":80,"width":530,"color":3},"id":"ffc6b530-69ab-4ccb-945d-94f8fdc1e3ab","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[1840,1088],"typeVersion":1},{"parameters":{"content":"### ... or watch set up video [7 min]\n[](https://youtu.be/E4I0nru-fa8)\n","height":239.5888196628349,"width":330.5152611046425,"color":7},"id":"15047f43-5f7e-4c70-a754-fffb41c04611","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[672,928],"typeVersion":1},{"parameters":{"content":"\n## AI Agent for realtime insights on meetings\n**Made by [Mark Shcherbakov](https://www.linkedin.com/in/marklowcoding/) from community [5minAI](https://www.skool.com/5minai)**\n\nTranscribing meetings manually can be tedious and prone to error. This workflow automates the transcription process in real-time, ensuring that key discussions and decisions are accurately captured and easily accessible for later review, thus enhancing productivity and clarity in communications.\n\nThe workflow leverages n8n and LlamaParse to automatically detect new invoices in a designated Google Drive folder, parse essential billing details, and store the extracted data in a structured format. The key functionalities include:\n- Real-time detection of new invoices via Google Drive triggers.\n- Automated HTTP requests to initiate parsing through Lama Cloud.\n- Structured storage of invoice details and line items in a database for future reference.\n\n1. **Google Drive Integration**: Monitors a specific folder in Google Drive for new invoice uploads.\n2. **Parsing with LlamaParse**: Automatically sends invoices for parsing and processes results through webhooks.\n3. **Data Storage in Airtable**: Creates records for invoices and their associated line items, allowing for detailed tracking.","height":657,"width":636,"color":7},"id":"812f6cc7-a093-41d0-9750-48253d9f04a8","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[368,240],"typeVersion":1},{"parameters":{"content":"### Set up steps\n\n1. **Google Drive Trigger**: \n - Set up a trigger to detect new files in a specified folder dedicated to invoices.\n\n2. **File Upload to LlamaParse**: \n - Create an HTTP request that sends the invoice file to LlamaParse for parsing, including relevant header settings and webhook URL.\n\n3. **Webhook Processing**: \n - Establish a webhook node to handle parsed results from LlamaParse, extracting needed invoice details effectively.\n\n4. **Invoice Record Creation**: \n - Create initial records for invoices in your database using the parsed details received from the webhook.\n\n5. **Line Item Processing**: \n - Transform string data into structured line item arrays and create individual records for each item linked to the main invoice.","height":626,"width":280,"color":7},"id":"a80e6528-cf79-4229-8c58-6856fd86b6e7","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[368,928],"typeVersion":1}],"connections":{"Webhook":{"main":[[{"node":"Set Fields","type":"main","index":0}]]},"Set Fields":{"main":[[{"node":"OpenAI - Extract Line Items","type":"main","index":0}]]},"Google Drive":{"main":[[{"node":"Upload File","type":"main","index":0}]]},"Create Invoice":{"main":[[{"node":"Process Line Items","type":"main","index":0}]]},"Process Line Items":{"main":[[{"node":"Create Line Item","type":"main","index":0}]]},"Google Drive Trigger":{"main":[[{"node":"Google Drive","type":"main","index":0}]]},"OpenAI - Extract Line Items":{"main":[[{"node":"Create Invoice","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"pinData":{},"versionId":"7b50adef-3323-4187-8b08-6ff8478d4bde","meta":{"templateId":"2661"}}
{"id":"67Kh5myzaneMj7j3","name":"V1_RAG","active":0,"nodes":[{"parameters":{"pollTimes":{"item":[{"mode":"everyMinute"}]},"triggerOn":"specificFolder","folderToWatch":{"__rl":true,"value":"1Y4ZJrWGIjTDEXyriDMonk39AWr3HKIsA","mode":"list","cachedResultName":"V1_RAG","cachedResultUrl":"https://drive.google.com/drive/folders/1Y4ZJrWGIjTDEXyriDMonk39AWr3HKIsA"},"event":"fileCreated","options":{}},"type":"n8n-nodes-base.googleDriveTrigger","typeVersion":1,"position":[-400,-96],"id":"c9d48559-bf7a-4dfa-a899-634c1bd4e918","name":"Google Drive Trigger","credentials":{"googleDriveOAuth2Api":{"id":"ghvfZZcpO23tYvmn","name":"Google Drive account"}}},{"parameters":{"operation":"download","fileId":{"__rl":true,"value":"={{ $json.id }}","mode":"id"},"options":{}},"type":"n8n-nodes-base.googleDrive","typeVersion":3,"position":[-208,-96],"id":"b7d6ec93-7196-4c8f-bf92-eb02d924290d","name":"Download file","credentials":{"googleDriveOAuth2Api":{"id":"ghvfZZcpO23tYvmn","name":"Google Drive account"}}},{"parameters":{"dataType":"binary","options":{}},"type":"@n8n/n8n-nodes-langchain.documentDefaultDataLoader","typeVersion":1.1,"position":[96,64],"id":"39bf4ae4-9a57-4421-99ab-af47b35a77dc","name":"Default Data Loader"},{"parameters":{"model":"llama3.1:latest"},"type":"@n8n/n8n-nodes-langchain.embeddingsOllama","typeVersion":1,"position":[-80,64],"id":"770c4977-ff45-462b-ba91-00ee37841aa4","name":"Embeddings Ollama","credentials":{"ollamaApi":{"id":"yShAwFAVyxsRy7rz","name":"Ollama account"}}},{"parameters":{"mode":"insert","pineconeIndex":{"__rl":true,"value":"v2n8n","mode":"list","cachedResultName":"v2n8n"},"embeddingBatchSize":1,"options":{}},"type":"@n8n/n8n-nodes-langchain.vectorStorePinecone","typeVersion":1.3,"position":[0,-96],"id":"b4ece1f6-3940-4fa6-8977-585702c6b75b","name":"Pinecone Vector Store","credentials":{"pineconeApi":{"id":"qokqnwePa9h9J5VA","name":"PineconeApi account 2"}}}],"connections":{"Google Drive Trigger":{"main":[[{"node":"Download file","type":"main","index":0}]]},"Download file":{"main":[[{"node":"Pinecone Vector Store","type":"main","index":0}]]},"Default Data Loader":{"ai_document":[[{"node":"Pinecone Vector Store","type":"ai_document","index":0}]]},"Embeddings Ollama":{"ai_embedding":[[{"node":"Pinecone Vector Store","type":"ai_embedding","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"pinData":{},"versionId":"de47ec75-15f3-4003-916a-094dfbb4af71","meta":{"templateCredsSetupCompleted":true}}
{"id":"U6CnpeGsZFZbMs9r","name":"V2_RAG copy","active":0,"nodes":[{"parameters":{"mode":"insert","pineconeIndex":{"__rl":true,"value":"n8nrag","mode":"list","cachedResultName":"n8nrag"},"embeddingBatchSize":1,"options":{"pineconeNamespace":"={{ $json.File_Name }}"}},"type":"@n8n/n8n-nodes-langchain.vectorStorePinecone","typeVersion":1.3,"position":[-128,-80],"id":"551ad270-2dee-44ac-96c8-9d7a68a4bd1c","name":"Pinecone Vector Store","credentials":{"pineconeApi":{"id":"qokqnwePa9h9J5VA","name":"PineconeApi account 2"}}},{"parameters":{"model":"llama3.1:latest"},"type":"@n8n/n8n-nodes-langchain.embeddingsOllama","typeVersion":1,"position":[-224,144],"id":"53d53806-0c21-48b0-92f1-7e5fb5b60c7f","name":"Embeddings Ollama","credentials":{"ollamaApi":{"id":"yShAwFAVyxsRy7rz","name":"Ollama account"}}},{"parameters":{"dataType":"binary","textSplittingMode":"custom","options":{}},"type":"@n8n/n8n-nodes-langchain.documentDefaultDataLoader","typeVersion":1.1,"position":[-64,144],"id":"8db6ebe3-dbcb-4b04-8712-ed3c50c77f0d","name":"Default Data Loader"},{"parameters":{"operation":"download","fileId":{"__rl":true,"value":"={{ $json.id }}","mode":"id"},"options":{}},"type":"n8n-nodes-base.googleDrive","typeVersion":3,"position":[-832,-80],"id":"d59bd7ac-a2c2-403f-b739-811a54285b33","name":"Download file","credentials":{"googleDriveOAuth2Api":{"id":"ghvfZZcpO23tYvmn","name":"Google Drive account"}}},{"parameters":{"pollTimes":{"item":[{"mode":"everyMinute"}]},"triggerOn":"specificFolder","folderToWatch":{"__rl":true,"value":"1Y4ZJrWGIjTDEXyriDMonk39AWr3HKIsA","mode":"list","cachedResultName":"V1_RAG","cachedResultUrl":"https://drive.google.com/drive/folders/1Y4ZJrWGIjTDEXyriDMonk39AWr3HKIsA"},"event":"fileCreated","options":{}},"type":"n8n-nodes-base.googleDriveTrigger","typeVersion":1,"position":[-1008,-80],"id":"4485a1be-49a5-415f-81fa-c2b816c58569","name":"Google Drive Trigger","credentials":{"googleDriveOAuth2Api":{"id":"ghvfZZcpO23tYvmn","name":"Google Drive account"}}},{"parameters":{"content":"## Knowledge Base","height":672,"width":1280},"type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[-1104,-144],"id":"62325837-58b2-43f9-8db7-a680d8a650b8","name":"Sticky Note"},{"parameters":{"content":"## RAG Chatbot","height":656,"width":928},"type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[208,-144],"id":"44d80012-9fd8-4759-8294-d03574bf91e5","name":"Sticky Note1"},{"parameters":{"promptType":"define","text":"={{ $('When chat message received').item.json.chatInput }}","options":{}},"type":"@n8n/n8n-nodes-langchain.agent","typeVersion":2.2,"position":[672,-64],"id":"4b06f526-f001-438d-867a-3dba1cfedf9b","name":"AI Agent"},{"parameters":{"options":{}},"type":"@n8n/n8n-nodes-langchain.chatTrigger","typeVersion":1.3,"position":[240,-64],"id":"bce04505-11b6-40d2-9434-3b69c80d0bcb","name":"When chat message received","webhookId":"a07ff104-e2f7-4a0d-a4bc-f0974afd6df1"},{"parameters":{"model":"llama3.1:latest","options":{}},"type":"@n8n/n8n-nodes-langchain.lmChatOllama","typeVersion":1,"position":[560,112],"id":"86732394-fce0-4ee3-8d01-846286351f2c","name":"Ollama Chat Model","credentials":{"ollamaApi":{"id":"yShAwFAVyxsRy7rz","name":"Ollama account"}}},{"parameters":{},"type":"@n8n/n8n-nodes-langchain.toolVectorStore","typeVersion":1.1,"position":[832,128],"id":"f068f0a1-8ac8-4c84-ad09-8e039f2996e1","name":"Answer questions with a vector store"},{"parameters":{},"type":"n8n-nodes-base.manualTrigger","typeVersion":1,"position":[-1024,176],"id":"e2ae1d99-9508-4dc1-b1a4-13a13c119135","name":"When clicking ‘Execute workflow’"},{"parameters":{"resource":"fileFolder","filter":{"folderId":{"__rl":true,"value":"1Y4ZJrWGIjTDEXyriDMonk39AWr3HKIsA","mode":"list","cachedResultName":"V1_RAG","cachedResultUrl":"https://drive.google.com/drive/folders/1Y4ZJrWGIjTDEXyriDMonk39AWr3HKIsA"}},"options":{}},"type":"n8n-nodes-base.googleDrive","typeVersion":3,"position":[-880,256],"id":"dd99f594-d7b9-4c0a-916d-4a9cb55122e1","name":"Search files and folders","credentials":{"googleDriveOAuth2Api":{"id":"ghvfZZcpO23tYvmn","name":"Google Drive account"}}},{"parameters":{"operation":"download","fileId":{"__rl":true,"value":"={{ $json.File_ID }}","mode":"id"},"options":{}},"type":"n8n-nodes-base.googleDrive","typeVersion":3,"position":[-592,272],"id":"4257c995-1758-49d9-ba06-059af0cf55d7","name":"Download file1","credentials":{"googleDriveOAuth2Api":{"id":"ghvfZZcpO23tYvmn","name":"Google Drive account"}}},{"parameters":{"pineconeIndex":{"__rl":true,"value":"n8nrag","mode":"list","cachedResultName":"n8nrag"},"options":{"pineconeNamespace":"={{ $json.File_Name }}"}},"type":"@n8n/n8n-nodes-langchain.vectorStorePinecone","typeVersion":1.3,"position":[624,256],"id":"dc2ba9c6-a103-41d6-a021-03bbe1231560","name":"Pinecone Vector Store1","credentials":{"pineconeApi":{"id":"qokqnwePa9h9J5VA","name":"PineconeApi account 2"}}},{"parameters":{"model":"llama3.1:latest","options":{}},"type":"@n8n/n8n-nodes-langchain.lmOllama","typeVersion":1,"position":[912,272],"id":"a6ba5176-e51b-48f7-a532-5d2424ac1fea","name":"Ollama Model","credentials":{"ollamaApi":{"id":"yShAwFAVyxsRy7rz","name":"Ollama account"}}},{"parameters":{"model":"llama3.1:latest"},"type":"@n8n/n8n-nodes-langchain.embeddingsOllama","typeVersion":1,"position":[512,352],"id":"80dbf021-ab09-4c26-85a8-02b229f80a49","name":"Embeddings Ollama1","credentials":{"ollamaApi":{"id":"yShAwFAVyxsRy7rz","name":"Ollama account"}}},{"parameters":{"options":{}},"type":"n8n-nodes-base.splitInBatches","typeVersion":3,"position":[-352,-16],"id":"a39411eb-5f22-4aff-b867-ef994ab56703","name":"Loop Over Items"},{"parameters":{"options":{}},"type":"@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter","typeVersion":1,"position":[-64,320],"id":"0ccaa8f1-22d1-46c7-89f0-373adaeed6c9","name":"Recursive Character Text Splitter"},{"parameters":{"assignments":{"assignments":[{"id":"d1c47d01-cd77-4f34-a182-4dd897665975","name":"File_Name","value":"={{ $json.name }}","type":"string"},{"id":"e6ca7a08-8971-43ac-8b12-793f00839619","name":"File_ID","value":"={{ $json.id }}","type":"string"}]},"options":{}},"type":"n8n-nodes-base.set","typeVersion":3.4,"position":[-736,176],"id":"97abf82a-e3de-4146-beeb-55e9b1678add","name":"Edit Fields"},{"parameters":{"assignments":{"assignments":[{"id":"ee7c7e16-9629-46e6-b7a6-47b7749647c4","name":"File_Name","value":"={{ $json.chatInput }}","type":"string"}]},"options":{}},"type":"n8n-nodes-base.set","typeVersion":3.4,"position":[432,-64],"id":"40b13524-4a26-4469-95be-1532cbb8e39b","name":"Edit Fields1"}],"connections":{"Embeddings Ollama":{"ai_embedding":[[{"node":"Pinecone Vector Store","type":"ai_embedding","index":0}]]},"Default Data Loader":{"ai_document":[[{"node":"Pinecone Vector Store","type":"ai_document","index":0}]]},"Download file":{"main":[[{"node":"Pinecone Vector Store","type":"main","index":0}]]},"Google Drive Trigger":{"main":[[{"node":"Download file","type":"main","index":0}]]},"When chat message received":{"main":[[{"node":"Edit Fields1","type":"main","index":0}]]},"Ollama Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Answer questions with a vector store":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"When clicking ‘Execute workflow’":{"main":[[{"node":"Search files and folders","type":"main","index":0}]]},"Search files and folders":{"main":[[{"node":"Edit Fields","type":"main","index":0}]]},"Pinecone Vector Store1":{"ai_vectorStore":[[{"node":"Answer questions with a vector store","type":"ai_vectorStore","index":0}]]},"Ollama Model":{"ai_languageModel":[[{"node":"Answer questions with a vector store","type":"ai_languageModel","index":0}]]},"Embeddings Ollama1":{"ai_embedding":[[{"node":"Pinecone Vector Store1","type":"ai_embedding","index":0}]]},"Download file1":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Loop Over Items":{"main":[[],[{"node":"Pinecone Vector Store","type":"main","index":0}]]},"Pinecone Vector Store":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Recursive Character Text Splitter":{"ai_textSplitter":[[{"node":"Default Data Loader","type":"ai_textSplitter","index":0}]]},"Edit Fields":{"main":[[{"node":"Download file1","type":"main","index":0}]]},"Edit Fields1":{"main":[[{"node":"AI Agent","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"pinData":{},"versionId":"624094f4-1090-4dff-841b-ddb8f2fde1c0","meta":{"templateCredsSetupCompleted":true}}
{"id":"DGYeqoxTvYf9bqV4","name":"V3_RAG","active":0,"nodes":[{"parameters":{"mode":"insert","pineconeIndex":{"__rl":true,"value":"n8nrag","mode":"list","cachedResultName":"n8nrag"},"embeddingBatchSize":2,"options":{"pineconeNamespace":"={{ $json.File_ID }}"}},"type":"@n8n/n8n-nodes-langchain.vectorStorePinecone","typeVersion":1.3,"position":[2192,-1072],"id":"9d46c9c8-9493-4298-b99c-326996111819","name":"Pinecone Vector Store","credentials":{"pineconeApi":{"id":"qokqnwePa9h9J5VA","name":"PineconeApi account 2"}}},{"parameters":{"options":{}},"type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","typeVersion":1.2,"position":[2032,-656],"id":"9a9624bf-1d6d-47da-8443-7448496fcbe5","name":"Embeddings OpenAI","credentials":{"openAiApi":{"id":"NpBggKJcrJLV63HW","name":"OpenAi account"}}},{"parameters":{"dataType":"binary","textSplittingMode":"custom","options":{"metadata":{"metadataValues":[{"name":"Apple_Report","value":"={{ $json.name }}"}]}}},"type":"@n8n/n8n-nodes-langchain.documentDefaultDataLoader","typeVersion":1.1,"position":[2192,-816],"id":"7a9b8f3a-ce55-4aee-9b8f-f6db377195e5","name":"Default Data Loader"},{"parameters":{"content":"# Preprocessing\n","height":636,"width":1276},"type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[528,-1152],"id":"f084ebf2-1adc-4eac-8ab8-356885e60669","name":"Sticky Note"},{"parameters":{"content":"# RAG Chatbot\n","height":732,"width":1272,"color":4},"type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[528,-464],"id":"ca3c0644-4034-4121-a2b2-ca410f51f84f","name":"Sticky Note1"},{"parameters":{"promptType":"define","text":"={{ $('When chat message received').item.json.chatInput }}","options":{"systemMessage":"=## Overview\nYou are an AI Agent. Your job is to retrieve contextually relevant data and provide concise, helpful answers. The current date and time is {{ $now.toString() }}\n\n## Tools\n(None — respond directly without external tools)\n\n## Rules\n- Maintain a friendly, concise tone\n- Responses must be exactly 2 sentences\n- Always format output as bullet points\n- Audience is internal staff\n\n## Instructions\n1) Retrieve and interpret contextually relevant data\n2) Generate a 2-sentence answer in bullet point format\n\n## Examples\n1)\nInput: \"How does RAG work?\"\n- Output:\n • RAG retrieves data from a knowledge base using embeddings. \n • It then combines the retrieved context with a language model to generate an answer.\n"}},"type":"@n8n/n8n-nodes-langchain.agent","typeVersion":2,"position":[992,-368],"id":"7ce2fb46-a004-4165-add7-d3ed7b38c40a","name":"AI Agent"},{"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4.1-mini"},"options":{}},"type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1.2,"position":[1584,96],"id":"25ada185-cf62-42f6-a7b0-dc5116e77fb5","name":"OpenAI Chat Model","credentials":{"openAiApi":{"id":"NpBggKJcrJLV63HW","name":"OpenAi account"}}},{"parameters":{"description":"Returns documents related to report, including financials, outlook, margins, and all key details from the earnings reports.","topK":"=10"},"type":"@n8n/n8n-nodes-langchain.toolVectorStore","typeVersion":1.1,"position":[1296,-224],"id":"ab6b0b82-1ed1-469c-b016-7a0bc8d0769d","name":"Answer questions with a vector store"},{"parameters":{"public":true,"options":{}},"type":"@n8n/n8n-nodes-langchain.chatTrigger","typeVersion":1.1,"position":[576,-208],"id":"2702b937-4694-4326-af04-17e9aee8b557","name":"When chat message received","webhookId":"a106e7fe-0bb0-42e6-8539-df1789689bbf"},{"parameters":{"pineconeIndex":{"__rl":true,"value":"n8nrag","mode":"list","cachedResultName":"n8nrag"},"options":{"pineconeNamespace":"={{ $json.File_Name }}"}},"type":"@n8n/n8n-nodes-langchain.vectorStorePinecone","typeVersion":1.3,"position":[1216,-64],"id":"13e5f3d3-b2c3-4a75-8323-a42895cd0df2","name":"Pinecone Vector Store1","credentials":{"pineconeApi":{"id":"qokqnwePa9h9J5VA","name":"PineconeApi account 2"}}},{"parameters":{"options":{}},"type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","typeVersion":1.2,"position":[1072,96],"id":"c65bc736-84f1-4d1b-a3ab-dea269e42ea9","name":"Embeddings OpenAI1","credentials":{"openAiApi":{"id":"NpBggKJcrJLV63HW","name":"OpenAi account"}}},{"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4.1-mini"},"options":{}},"type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1.2,"position":[880,-16],"id":"902e5743-9404-4554-a304-2600f7ee9a28","name":"OpenAI Chat Model1","credentials":{"openAiApi":{"id":"NpBggKJcrJLV63HW","name":"OpenAi account"}}},{"parameters":{"resource":"fileFolder","filter":{"folderId":{"__rl":true,"value":"1Y4ZJrWGIjTDEXyriDMonk39AWr3HKIsA","mode":"list","cachedResultName":"V1_RAG","cachedResultUrl":"https://drive.google.com/drive/folders/1Y4ZJrWGIjTDEXyriDMonk39AWr3HKIsA"}},"options":{}},"type":"n8n-nodes-base.googleDrive","typeVersion":3,"position":[864,-1072],"id":"a2c36388-b5f3-4cd4-8902-c79328990a95","name":"Search files and folders","credentials":{"googleDriveOAuth2Api":{"id":"ghvfZZcpO23tYvmn","name":"Google Drive account"}}},{"parameters":{"operation":"download","fileId":{"__rl":true,"value":"={{ $json.File_ID }}","mode":"id"},"options":{}},"type":"n8n-nodes-base.googleDrive","typeVersion":3,"position":[1600,-832],"id":"93ec15af-c040-459a-9fce-442819389277","name":"Download file1","credentials":{"googleDriveOAuth2Api":{"id":"ghvfZZcpO23tYvmn","name":"Google Drive account"}}},{"parameters":{"options":{}},"type":"n8n-nodes-base.splitInBatches","typeVersion":3,"position":[1952,-1072],"id":"707b879c-c866-4dbe-bdb0-a2a13f7d88d0","name":"Loop Over Items"},{"parameters":{"options":{}},"type":"@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter","typeVersion":1,"position":[2288,-672],"id":"5d81b1e7-05d7-4ad5-8a46-430d7215fcba","name":"Recursive Character Text Splitter"},{"parameters":{"assignments":{"assignments":[{"id":"dda116d7-f64b-48b8-9f22-fb35eb43c245","name":"File_Name","value":"={{ $json.Name }}","type":"string"},{"id":"3562a21f-d55f-4191-8f7a-cebb23c1da3b","name":"File_ID","value":"={{ $json.ID }}","type":"string"}]},"options":{}},"type":"n8n-nodes-base.set","typeVersion":3.4,"position":[1456,-1040],"id":"125d2bb9-097f-492e-a01e-6f5a509a1faa","name":"Edit Fields"},{"parameters":{"assignments":{"assignments":[{"id":"c183a9f9-0bbd-40e4-ac35-b5111e3ec1ae","name":"File_Name","value":"={{$json[\"chatInput\"].match(/Q[1-4]/i) ? ($json[\"chatInput\"].match(/Q[1-4]/i)[0].toUpperCase() + \".pdf\").trim() : \"\"}}","type":"string"}]},"options":{}},"type":"n8n-nodes-base.set","typeVersion":3.4,"position":[768,-368],"id":"e40ac0c1-1026-457a-87f0-2a1754228780","name":"Edit Fields1"},{"parameters":{"rule":{"interval":[{"field":"hours"}]}},"type":"n8n-nodes-base.scheduleTrigger","typeVersion":1.2,"position":[608,-1072],"id":"c4af0ded-7a8f-4b29-b7b7-cf5ddf407e7a","name":"Schedule Trigger"},{"parameters":{},"type":"n8n-nodes-base.manualTrigger","typeVersion":1,"position":[608,-704],"id":"38e20da7-4bfe-459e-b3f1-d20a62473df5","name":"When clicking ‘Execute workflow’"},{"parameters":{"operation":"append","documentId":{"__rl":true,"value":"1D2LMwCiSUzmc8kScWKWRbBtsGSDpjwBGriFAGS07btM","mode":"list","cachedResultName":"Teacher_IT_Tickets","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1D2LMwCiSUzmc8kScWKWRbBtsGSDpjwBGriFAGS07btM/edit?usp=drivesdk"},"sheetName":{"__rl":true,"value":"gid=0","mode":"list","cachedResultName":"Sheet1","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1D2LMwCiSUzmc8kScWKWRbBtsGSDpjwBGriFAGS07btM/edit#gid=0"},"columns":{"mappingMode":"defineBelow","value":{"Name":"={{ $json.fileName }}","ID":"={{ $json.fileId }}"},"matchingColumns":[],"schema":[{"id":"Name","displayName":"Name","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true,"removed":false},{"id":"ID","displayName":"ID","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true,"removed":false}],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{}},"type":"n8n-nodes-base.googleSheets","typeVersion":4.6,"position":[1328,-896],"id":"980186dc-6855-4bcf-9542-3e2e70dc09b3","name":"Append row in sheet","credentials":{"googleSheetsOAuth2Api":{"id":"vwmv6keJbqpxUxCf","name":"Google Sheets account"}}},{"parameters":{"jsCode":"// ✅ Get ALL incoming data as one flat array\nconst allInputs = $input.all(); \n\n// Separate Drive files vs Sheet rows by their structure\nconst driveInput = [];\nconst sheetInput = [];\n\n// Loop through all incoming items and detect source\nfor (const item of allInputs) {\n const data = item.json;\n \n // Drive files have `id` + `name`\n if (data.id && data.name) {\n driveInput.push(data);\n }\n \n // Sheet rows have `ID` + `Name`\n if (data.ID || data.Name) {\n sheetInput.push(data);\n }\n}\n\n// ✅ Extract already processed IDs from sheet\nconst processedIds = sheetInput\n .filter(row => row.ID && row.ID !== \"\")\n .map(row => row.ID);\n\n// ✅ Filter only NEW files not in sheet\nconst newFiles = driveInput.filter(f => !processedIds.includes(f.id));\n\n// ✅ Debug info\nconsole.log(`Drive files found: ${driveInput.length}`);\nconsole.log(`Sheet rows found: ${sheetInput.length}`);\nconsole.log(`Already processed IDs: ${processedIds.length}`);\nconsole.log(`New files to download: ${newFiles.length}`);\n\n// ✅ Output only the new ones\nreturn newFiles.map(f => ({\n json: {\n fileId: f.id,\n fileName: f.name\n }\n}));\n"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[1184,-1056],"id":"a5267ae9-9a6d-4549-a706-e4786d23fcb8","name":"Code"},{"parameters":{"documentId":{"__rl":true,"value":"1D2LMwCiSUzmc8kScWKWRbBtsGSDpjwBGriFAGS07btM","mode":"list","cachedResultName":"Teacher_IT_Tickets","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1D2LMwCiSUzmc8kScWKWRbBtsGSDpjwBGriFAGS07btM/edit?usp=drivesdk"},"sheetName":{"__rl":true,"value":"gid=0","mode":"list","cachedResultName":"Sheet1","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1D2LMwCiSUzmc8kScWKWRbBtsGSDpjwBGriFAGS07btM/edit#gid=0"},"options":{}},"type":"n8n-nodes-base.googleSheets","typeVersion":4.6,"position":[848,-704],"id":"c1150218-96e6-4de9-a410-15a19e270d89","name":"Get row(s) in sheet","credentials":{"googleSheetsOAuth2Api":{"id":"vwmv6keJbqpxUxCf","name":"Google Sheets account"}}},{"parameters":{},"type":"n8n-nodes-base.merge","typeVersion":3.2,"position":[1040,-896],"id":"0fcb960b-0a19-40f5-9199-39c9c3ef06e5","name":"Merge"},{"parameters":{"content":"# Uploading to VD\n","height":636,"width":828},"type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[1824,-1152],"id":"eac815b4-fd38-4e7c-87c3-3644fcab1537","name":"Sticky Note2"},{"parameters":{"model":"llama3.1:latest"},"type":"@n8n/n8n-nodes-langchain.embeddingsOllama","typeVersion":1,"position":[2016,-816],"id":"799b48cb-038e-493b-8f28-833319130bb9","name":"Embeddings Ollama","credentials":{"ollamaApi":{"id":"yShAwFAVyxsRy7rz","name":"Ollama account"}}},{"parameters":{"model":"llama3.1:latest","options":{}},"type":"@n8n/n8n-nodes-langchain.lmChatOllama","typeVersion":1,"position":[992,-176],"id":"6f4e6c5f-0872-48e2-b01e-046658646a6f","name":"Ollama Chat Model","credentials":{"ollamaApi":{"id":"yShAwFAVyxsRy7rz","name":"Ollama account"}}},{"parameters":{"model":"llama3.1:latest","options":{}},"type":"@n8n/n8n-nodes-langchain.lmChatOllama","typeVersion":1,"position":[1584,-80],"id":"900e7d91-e23a-4c3f-b695-2efe02148a25","name":"Ollama Chat Model1","credentials":{"ollamaApi":{"id":"yShAwFAVyxsRy7rz","name":"Ollama account"}}},{"parameters":{"model":"llama3.1:latest"},"type":"@n8n/n8n-nodes-langchain.embeddingsOllama","typeVersion":1,"position":[1216,96],"id":"bef97d0a-fe5f-4636-a4cf-eb111842ce36","name":"Embeddings Ollama1","credentials":{"ollamaApi":{"id":"yShAwFAVyxsRy7rz","name":"Ollama account"}}}],"connections":{"Embeddings OpenAI":{"ai_embedding":[[]]},"Default Data Loader":{"ai_document":[[{"node":"Pinecone Vector Store","type":"ai_document","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[]]},"Answer questions with a vector store":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"When chat message received":{"main":[[{"node":"Edit Fields1","type":"main","index":0}]]},"Pinecone Vector Store1":{"ai_vectorStore":[[{"node":"Answer questions with a vector store","type":"ai_vectorStore","index":0}]]},"Pinecone Vector Store":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Embeddings OpenAI1":{"ai_embedding":[[]]},"OpenAI Chat Model1":{"ai_languageModel":[[]]},"Search files and folders":{"main":[[{"node":"Merge","type":"main","index":0}]]},"Download file1":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Loop Over Items":{"main":[[],[{"node":"Pinecone Vector Store","type":"main","index":0}]]},"Recursive Character Text Splitter":{"ai_textSplitter":[[{"node":"Default Data Loader","type":"ai_textSplitter","index":0}]]},"Edit Fields":{"main":[[{"node":"Download file1","type":"main","index":0}]]},"Edit Fields1":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Schedule Trigger":{"main":[[{"node":"Search files and folders","type":"main","index":0},{"node":"Get row(s) in sheet","type":"main","index":0}]]},"When clicking ‘Execute workflow’":{"main":[[{"node":"Search files and folders","type":"main","index":0},{"node":"Get row(s) in sheet","type":"main","index":0}]]},"Append row in sheet":{"main":[[{"node":"Edit Fields","type":"main","index":0}]]},"Code":{"main":[[{"node":"Append row in sheet","type":"main","index":0}]]},"Get row(s) in sheet":{"main":[[{"node":"Merge","type":"main","index":1}]]},"Merge":{"main":[[{"node":"Code","type":"main","index":0}]]},"Embeddings Ollama":{"ai_embedding":[[{"node":"Pinecone Vector Store","type":"ai_embedding","index":0}]]},"Ollama Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Ollama Chat Model1":{"ai_languageModel":[[{"node":"Answer questions with a vector store","type":"ai_languageModel","index":0}]]},"Embeddings Ollama1":{"ai_embedding":[[{"node":"Pinecone Vector Store1","type":"ai_embedding","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"pinData":{"Pinecone Vector Store1":[{"json":{"name":"First item","code":1}},{"json":{"name":"Second item","code":2}}]},"versionId":"dd7d78cf-8abc-4d8e-b550-6b276ffb2e09","meta":{"templateCredsSetupCompleted":true}}
{"id":"efdNA57ACq1I9iV4","name":"GPT-Oss","active":0,"nodes":[{"parameters":{"updates":["message"],"additionalFields":{}},"type":"n8n-nodes-base.telegramTrigger","typeVersion":1.2,"position":[0,0],"id":"a597f732-7b96-4970-b363-053a71ac906f","name":"Telegram Trigger","webhookId":"286c06fd-dce8-4e58-b890-e73291d6fd97"},{"parameters":{"promptType":"define","text":"={{ $json.message.text }}","hasOutputParser":true,"options":{"systemMessage":"=# Sentiment Analysis Agent\n\nYou are **SentimentAnalysisBot** and your task is to **analyze user reviews from Telegram messages** and categorize each review as **Positive**, **Neutral**, or **Negative**, then output the result in a strict JSON format.\n\n---\n\n## Context & Background\n- **Input Source:** Telegram Trigger node passes in `userId` and the message text as the review. \n- **Destination:** The JSON output will be appended as a row in Google Sheets.\n\n---\n\n## Primary Responsibilities\n- **Extract** the original review text from the incoming message. \n- **Classify** the sentiment into one of three labels: `Positive`, `Neutral`, or `Negative`. \n- **Output** exactly valid JSON with no extra fields or commentary.\n-Extract user ID from this {{ $json.message.chat.id }}\n\n---\n\n## Available Tools\n- *No external tools* are connected for this task.\n\n---\n\n## Output Format\nYour **only** output must be a JSON object matching this schema **exactly** (no code fences, no extra text):\n\n```json\n{\n \"userId\": \"123444\",\n \"review\": \"this food is bad\",\n \"sentiment\": \"Positive\"\n}"}},"type":"@n8n/n8n-nodes-langchain.agent","typeVersion":2.1,"position":[208,0],"id":"fd1d47d8-6f6e-4ed6-93e6-62597892e55a","name":"AI Agent"},{"parameters":{"model":"gpt-oss:latest","options":{}},"type":"@n8n/n8n-nodes-langchain.lmChatOllama","typeVersion":1,"position":[128,192],"id":"a9d3156f-ebf1-4cd7-bff3-c9f50d5f3d2e","name":"Ollama Chat Model","credentials":{"ollamaApi":{"id":"yShAwFAVyxsRy7rz","name":"Ollama account"}}},{"parameters":{"operation":"append","documentId":{"__rl":true,"value":"1GNIyh7GRA_vcr38GqnKNQ4t04uavKjFyonzu3W643Fg","mode":"list","cachedResultName":"n8nGPToss","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1GNIyh7GRA_vcr38GqnKNQ4t04uavKjFyonzu3W643Fg/edit?usp=drivesdk"},"sheetName":{"__rl":true,"value":"gid=0","mode":"list","cachedResultName":"Sheet1","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1GNIyh7GRA_vcr38GqnKNQ4t04uavKjFyonzu3W643Fg/edit#gid=0"},"columns":{"mappingMode":"defineBelow","value":{"ID":"={{ $json.output.userId }}","Review":"={{ $json.output.sentiment }}"},"matchingColumns":["ID"],"schema":[{"id":"ID","displayName":"ID","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true,"removed":false},{"id":"Review","displayName":"Review","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true,"removed":false}],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{}},"type":"n8n-nodes-base.googleSheets","typeVersion":4.6,"position":[624,0],"id":"542c1698-a4bc-441c-8000-6e5b4b6cb895","name":"Append row in sheet","credentials":{"googleSheetsOAuth2Api":{"id":"vwmv6keJbqpxUxCf","name":"Google Sheets account"}}},{"parameters":{"jsonSchemaExample":"{\n \"userId\": \"123444\",\n \"review\": \"this food is bad\",\n \"sentiment\": \"Positive\"\n}"},"type":"@n8n/n8n-nodes-langchain.outputParserStructured","typeVersion":1.3,"position":[480,192],"id":"46fb703a-7fa1-4e32-b646-55925611a648","name":"Structured Output Parser"}],"connections":{"Telegram Trigger":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Ollama Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"AI Agent":{"main":[[{"node":"Append row in sheet","type":"main","index":0}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"AI Agent","type":"ai_outputParser","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"pinData":{},"versionId":"f0a5f101-3855-426d-8133-bee368d1e9e5","meta":null}
{"id":"tMklwltZMjABsuzs","name":"BNI Recommendation Extractor","active":0,"nodes":[],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"pinData":{},"versionId":"32817d34-5d7d-4593-bfeb-ccfcf6ed79c1","meta":null}
{"id":"i2tIw5XUhcwrrx1I","name":"David Email Support Agent","active":0,"nodes":[{"parameters":{"promptType":"define","text":"={{ $json.Subject }} {{ $json.Content }}","needsFallback":true,"options":{"systemMessage":"=## Primary Role\nYou are a professional customer support AI agent that processes incoming Gmail messages, provides helpful responses to customers, and logs all support requests for tracking purposes.\n\n## Core Responsibilities\n\n### 1. Email Analysis & Response\n- **Read and analyze** each incoming email carefully\n- **Identify the type of request**: technical issue, billing question, feature request, complaint, general inquiry, etc.\n- **Determine urgency level**: Low, Medium, High, Critical\n- **Extract key information**: customer details, issue description, requested action, timeline expectations\n\n### 2. Customer Reply Generation\nGenerate professional, helpful, and empathetic email responses that:\n- **Acknowledge** the customer's concern promptly\n- **Provide clear solutions** or next steps when possible\n- **Set appropriate expectations** for resolution timeline\n- **Maintain a friendly, professional tone**\n- **Include relevant resources** (links, documentation, FAQs) when helpful\n- **Ask clarifying questions** if more information is needed\n- **Escalate to human support** when issues are complex or sensitive\n\n### 3. Google Sheets Logging\nFor every email processed, log the following information:\n- **Date/Time**: When the email was received\n- **Customer Email**: Sender's email address\n- **Customer Name**: If available\n- **Subject Line**: Email subject\n- **Request Type**: Category (Technical, Billing, Feature Request, etc.)\n- **Priority Level**: Low/Medium/High/Critical\n- **Issue Summary**: Brief description (2-3 sentences max)\n- **Status**: New/In Progress/Resolved/Escalated\n- **Response Sent**: Yes/No\n- **Follow-up Required**: Yes/No/Date\n- **Agent Notes**: Any additional context or actions taken\n\n## Response Templates & Guidelines\n\n### Standard Greeting\n\"Hi {{ $json.Nom }},\n\nThank you for reaching out to us. I've received your message regarding [brief issue summary].\"\n\n### Common Scenarios\n\n**Technical Issues:**\n- Acknowledge the frustration\n- Provide step-by-step troubleshooting\n- Offer alternative solutions\n- Set expectations for resolution\n\n**Billing Questions:**\n- Confirm account details (without exposing sensitive info)\n- Explain charges clearly\n- Provide next steps for disputes\n- Include relevant billing resources\n\n**Feature Requests:**\n- Thank them for the suggestion\n- Explain current roadmap (if applicable)\n- Suggest workarounds if available\n- Confirm request has been logged for product team\n\n**Complaints:**\n- Acknowledge their concern with empathy\n- Take responsibility where appropriate\n- Outline steps to resolve\n- Offer compensation if warranted\n\n### Escalation Criteria\nEscalate to human support when:\n- Customer is extremely upset or threatening\n- Issue involves sensitive account information\n- Technical problem requires developer intervention\n- Billing dispute over significant amount\n- Legal or compliance matters\n- Multiple failed resolution attempts\n\n### Tone Guidelines\n- **Professional** yet conversational\n- **Empathetic** and understanding\n- **Clear** and concise\n- **Proactive** in offering solutions\n- **Apologetic** when appropriate (without admitting fault unnecessarily)\n\n## Memory & Context Management\n- **Remember** previous interactions with the same customer\n- **Reference** past solutions or conversations when relevant\n- **Track** ongoing issues to ensure continuity\n- **Note** customer preferences or special circumstances\n\n## Quality Standards\n- **Response time**: Aim for acknowledgment within 1 hour during business hours\n- **Accuracy**: Ensure all information provided is correct and up-to-date\n- **Completeness**: Address all questions/concerns in the customer's email\n- **Follow-up**: Set reminders for promised callbacks or updates\n\n## Example Response Format\n\nSubject: Re: {{ $json.Subject }} - We're here to help!\n\nHi {{ $json.Nom }},\n\nThank you for contacting us about [issue]. I understand [acknowledge their concern/situation].\n\n[Provide solution/next steps/information requested]\n\n[If applicable: set expectations, provide timeline, or explain next steps]\n\nIs there anything else I can help you with today? We're always here to support you.\n\nBest regards,\n[Your Name]\nCustomer Support Team\n\n---\n\n**Note**: Always maintain customer privacy and confidentiality. Never share sensitive information inappropriately, and ensure all logging complies with data protection standards.\n\n"}},"id":"4a1bcd5c-ac55-4edc-8508-f2921dcc1b68","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[1824,592],"typeVersion":2.1},{"parameters":{"pollTimes":{"item":[{"mode":"everyHour","minute":59}]},"simple":false,"filters":{"sender":"abdalla.bala@gmail.com"},"options":{}},"id":"a2a87327-902b-4f95-b819-25221793fb77","name":"Gmail Trigger","type":"n8n-nodes-base.gmailTrigger","position":[1440,592],"typeVersion":1.2,"alwaysOutputData":false,"executeOnce":false,"credentials":{"gmailOAuth2":{"id":"6zeZfhesQ4wkWVzB","name":"Gmail account API Key"}}},{"parameters":{"sessionIdType":"customKey","sessionKey":"={{ $('Gmail Trigger').item.json.id }}"},"id":"06d647bb-b03d-42bf-8462-204546d3b427","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[1888,800],"typeVersion":1.3},{"parameters":{"operation":"appendOrUpdate","documentId":{"__rl":true,"value":"1vIhgniQOWUdgVQkvzQjI2y6e8e0UErDW1E47Ypkkaqk","mode":"list","cachedResultName":"BNI_Referrals","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1vIhgniQOWUdgVQkvzQjI2y6e8e0UErDW1E47Ypkkaqk/edit?usp=drivesdk"},"sheetName":{"__rl":true,"value":618892745,"mode":"list","cachedResultName":"BNI Referrals","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1vIhgniQOWUdgVQkvzQjI2y6e8e0UErDW1E47Ypkkaqk/edit#gid=618892745"},"columns":{"mappingMode":"defineBelow","value":{"Date/Time (Referral)":"={{ $('Code in JavaScript').item.json.Date_de_la_recommandation }}","Customer Email (Referred)":"={{ $('Code in JavaScript').item.json.Adresse_courriel }}","Customer Name (Referred)":"={{ $('Code in JavaScript').item.json.Nom }}","Priority Level":"={{ $('Code in JavaScript').item.json[\"Température\"] }}","Subject Line":"={{ $('Code in JavaScript').item.json.Subject }}","Phone":"={{ $('Code in JavaScript').item.json[\"Numéro_de_téléphone\"] }}","Agent Notes":"={{ $('Code in JavaScript').item.json.Commentaries }}"},"matchingColumns":["Date/Time (Referral)"],"schema":[{"id":"Date/Time (Referral)","displayName":"Date/Time (Referral)","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true,"removed":false},{"id":"Customer Email (Referred)","displayName":"Customer Email (Referred)","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"Customer Name (Referred)","displayName":"Customer Name (Referred)","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"Subject Line","displayName":"Subject Line","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"Priority Level","displayName":"Priority Level","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"Phone","displayName":"Phone","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true,"removed":false},{"id":"Agent Notes","displayName":"Agent Notes","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true}],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{}},"id":"4ce6dbd6-e68a-4e86-92db-4ed5c9b362b4","name":"Append or update row in sheet in Google Sheets","type":"n8n-nodes-base.googleSheetsTool","position":[2032,800],"typeVersion":4.6,"credentials":{"googleSheetsOAuth2Api":{"id":"vwmv6keJbqpxUxCf","name":"Google Sheets account"}}},{"parameters":{"content":"# 🤖 Your First Email Agent with Fallback Model\n\n## 📧 What This Workflow Does\nThis automation creates an intelligent email support system that:\n- **Monitors Gmail** for new customer emails\n- **Processes requests** using AI with smart fallback options\n- **Sends personalized replies** automatically\n- **Logs everything** to Google Sheets for tracking\n\n## 🔄 How the Fallback Model Works\n\n### Primary Model: Google Gemini Chat\n- **Fast & Cost-Effective** - Handles 90% of standard support queries\n- **Great for**: FAQ responses, basic troubleshooting, general inquiries\n\n### Fallback Model: OpenAI GPT\n- **Kicks in when** Gemini fails or encounters complex queries\n- **Better for**: Nuanced responses, technical issues, edge cases\n- **Higher accuracy** for complex customer situations\n\n## 🏗️ Workflow Architecture\n\n```\nGmail Trigger → AI Agent → Response Decision → Actions\n ↓\n [Primary Model]\n ↓\n [Fallback Model] ← (if needed)\n ↓\n [Send Reply + Log Data]\n```\n","height":848,"width":768},"id":"4310966d-894d-490b-9d52-49c1aa03b9ae","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[256,480],"typeVersion":1},{"parameters":{"content":"\n## 💡 Why Use a Fallback Model?\n\n### Reliability\n- **99.9% uptime** - If one model fails, the other continues\n- **No missed emails** - Every customer gets a response\n\n### Cost Optimization\n- **Use cheaper models first** (Gemini) for simple queries\n- **Reserve premium models** (GPT-4) for complex cases\n- **Reduce API costs** by 60-80%\n\n### Quality Assurance\n- **Best of both worlds** - Speed + accuracy\n- **Consistent responses** even during API outages\n- **Improved customer satisfaction**\n\n\n## 🚀 Getting Started Checklist\n\n- [ ] **Gmail account** with API access enabled\n- [ ] **Google Sheets** document created\n- [ ] **Gemini API key** (primary model)\n- [ ] **OpenAI API key** (fallback model)\n- [ ] **N8N instance** running\n- [ ] **Import this workflow** and configure credentials\n\n## 📊 What Gets Logged\n- Customer email & timestamp\n- Request type & priority level\n- Which AI model responded\n- Response time & success rate\n- Follow-up requirements\n\n## 🔧 Customization Options\n- **Modify response templates** for your brand voice\n- **Add more fallback models** (Claude, etc.)\n- **Create custom triggers** (Slack, Discord, etc.)\n- **Build escalation rules** for human handoff\n\n## 💭 Learning Outcomes\nAfter building this workflow, you'll understand:\n- **AI model orchestration** strategiess \n- **Customer service** automation best practices\n- **Multi-model AI** implementation patterns\n\n---\n\n\n\n**🎓 Educational Focus**: This isn't just automation - it's your introduction to building resilient, intelligent systems that handle real-world business challenges.","height":1360,"width":640},"id":"ddc5d69b-8386-45e1-9b7f-139e5b42c15f","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[3872,80],"typeVersion":1},{"parameters":{"content":"## 🎯 Perfect for Beginners Because:\n\n### Simple Setup\n- **Drag & drop** workflow design\n- **Pre-built integrations** with Gmail & Sheets\n- **Copy-paste ready** - Just add your API keys\n\n### Educational Value\n- **Learn AI orchestration** concepts\n- **Understand fallback patterns** in automation\n- **See real-world AI applications** in action\n\n### Immediate Results\n- **Works out of the box** with minimal configuration\n- **See responses** within minutes of setup\n- **Track performance** in Google Sheets dashboard\n","height":448,"width":464},"id":"08ff7ff4-4c41-43e9-a71d-43e07f0c75e4","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[576,-144],"typeVersion":1},{"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4.1-mini"},"options":{}},"id":"99dd9b98-5384-498e-b3e5-2552bb7016b0","name":"OpenAI Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[1600,864],"typeVersion":1.2,"credentials":{"openAiApi":{"id":"NpBggKJcrJLV63HW","name":"OpenAi account"}}},{"parameters":{"options":{}},"id":"b91e9199-c9cd-4dc6-bd8e-9a97aad2f9c4","name":"Gemini Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[1456,864],"typeVersion":1,"credentials":{"googlePalmApi":{"id":"xTC5bggV3FN3kz5r","name":"Google Gemini(PaLM) Api account"}}},{"parameters":{"content":"## Ai Models","height":224,"width":272},"id":"b56d1d13-8b88-4a69-b0d9-c2c35e6f95da","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[1424,768],"typeVersion":1},{"parameters":{"resource":"thread","operation":"reply","threadId":"={{ $('Gmail Trigger').item.json.id }}","messageId":"={{ $('Gmail Trigger').item.json.id }}","message":"={{ $json.output }}","options":{}},"id":"9ecaa23a-40af-4d5f-80ef-a6df1dc9acf9","name":"Reply to a message(Thread)","type":"n8n-nodes-base.gmail","position":[2848,784],"webhookId":"c3d3ef78-4b9a-4392-8b21-497aa09e33af","typeVersion":2.1,"credentials":{"gmailOAuth2":{"id":"vL1hwAuQCCbv0MjK","name":"Gmail account"}}},{"parameters":{"jsCode":"const items = [];\n\nfor (const item of $input.all()) {\n const email = item.json;\n\n // Sender info\n const senderName = email.from?.value?.[0]?.name || '';\n const senderEmail = email.from?.value?.[0]?.address || '';\n\n // Date\n const receivedDate = new Date(email.date);\n const formattedDate = receivedDate.toLocaleString('en-US', {\n year: 'numeric', month: '2-digit', day: '2-digit',\n hour: '2-digit', minute: '2-digit', hour12: true\n });\n\n // Email content\n const content = email.text || email.html || '';\n\n // Helper: extract first occurrence\n const getValue = (label) => {\n const regex = new RegExp(label + '\\\\s+([\\\\s\\\\S]*?)(\\\\n|$)', 'i');\n const match = content.match(regex);\n return match ? match[1].trim() : '';\n };\n\n // Helper: extract second occurrence (for referral section)\n const getSecondValue = (label) => {\n const regex = new RegExp(label + '\\\\s+([\\\\s\\\\S]*?)(\\\\n|$)', 'gi');\n let match;\n let lastMatch = null;\n while ((match = regex.exec(content)) !== null) {\n lastMatch = match[1].trim();\n }\n return lastMatch || '';\n };\n\n // Extract recipient info\n const fullName = getValue(\"Nom\");\n let firstName = '';\n let lastName = '';\n if (fullName) {\n const parts = fullName.trim().split(/\\s+/);\n if (parts.length > 1) {\n firstName = parts[0];\n lastName = parts.slice(1).join(' ');\n } else {\n lastName = fullName;\n }\n }\n\n // Extract referral (recommender) info\n const referralName = getValue(\"Nom du membre\");\n const referralPhone = getSecondValue(\"Numéro de téléphone\");\n const referralEmail = getSecondValue(\"Adresse courriel\");\n\n const rowData = {\n \"Date\": formattedDate,\n \"Sender Name\": senderName,\n \"Sender Email\": senderEmail,\n \"Subject\": email.subject || 'No Subject',\n \"Content\": content,\n // Recipient (person referred)\n \"Date_de_la_recommandation\": getValue(\"Date de la recommandation\"),\n \"Nom\": fullName,\n \"First Name\": firstName,\n \"Last Name\": lastName,\n \"Température\": getValue(\"Température\"),\n \"Numéro_de_téléphone\": getValue(\"Numéro de téléphone\"),\n \"Adresse_courriel\": getValue(\"Adresse courriel\"),\n \"Commentaries\": getValue(\"Commentaries\"),\n // Referral (BNI member who sent it)\n \"Referral Name\": referralName,\n \"Referral Phone\": referralPhone,\n \"Referral Email\": referralEmail,\n // Metadata\n \"Has Attachments\": email.attachments?.length > 0 ? 'Yes' : 'No'\n };\n\n items.push({ json: rowData });\n}\n\nreturn items;\n"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[1600,592],"id":"2653705e-2f5d-4ac7-ac28-8cf92d26a784","name":"Code in JavaScript"},{"parameters":{"jsCode":"const items = [];\n\nfor (const item of $input.all()) {\n const emailData = item.json;\n\n // Sender info\n let senderEmail = '';\n let senderName = '';\n if (emailData.from?.value?.[0]) {\n senderEmail = emailData.from.value[0].address || '';\n senderName = emailData.from.value[0].name || senderEmail;\n } else if (emailData.from?.text) {\n const emailMatch = emailData.from.text.match(/<([^>]+)>/) ||\n emailData.from.text.match(/([^\\s]+@[^\\s]+)/);\n senderEmail = emailMatch ? emailMatch[1] : emailData.from.text;\n const nameMatch = emailData.from.text.match(/^([^<]+)/);\n senderName = nameMatch ? nameMatch[1].trim().replace(/\\\"/g, '') : senderEmail;\n }\n\n // Date\n let receivedDate = new Date(emailData.date || emailData.receivedTime);\n if (isNaN(receivedDate)) receivedDate = new Date();\n const formattedDate = receivedDate.toLocaleString('en-US', {\n year: 'numeric', month: '2-digit', day: '2-digit',\n hour: '2-digit', minute: '2-digit', hour12: true\n });\n\n // Email content\n let emailContent = emailData.text || emailData.body || emailData.textPlain || '';\n if (emailData.html) {\n emailContent = emailData.html\n .replace(/