# templates

name: AI Agent To Chat With Files In Supabase Storage and Google Drive
author_name: Mark Shcherbakov
author_username: lowcodingdev
categories: []
created_at: 2025-05-15T20:44:33.064Z
updated_at: 2025-05-15T20:44:33.064Z
url: https://n8n.io/workflows/4086
scraped_at: 2025-07-06 21:16:30
description:
  Video Guide

  I prepared a detailed guide that illustrates the entire process of building an AI agent using Supabase and Google Drive within N8N workflows.



  Youtube Link

  Who is this for?
  This workflow is designed for developers, data scientists, and business users who wish to automate document management and enable AI-powered interactions over their stored files. It's especially beneficial for scenarios where users need to process, analyze, and retrieve information from uploaded documents rapidly.

  What problem does this workflow solve?
  Managing files across multiple platforms often involves tedious manual processes. This workflow facilitates automated file handling, making it easier for users to upload, parse, and interact with documents through an AI agent. It reduces redundancy and enhances the efficiency of data retrieval and management tasks.

  What this workflow does
  This workflow integrates Supabase storage with Google Drive and employs an AI agent to manage files effectively. The agent can:
  Upload files to Supabase storage and activate processes based on file changes in Google Drive.
  Retrieve and parse documents, converting them into a structured format for easy querying.
  Utilize an AI agent to answer user queries based on saved document data.

  Data Collection: The workflow initially gathers files from Supabase storage, ensuring no duplicates are processed in the 'files' table.
  File Handling: It processes files to be parsed based on their type, leveraging LlamaParse for effective data transformation.
  Google Drive Integration: The workflow monitors a designated Google Drive folder to upload files automatically and refresh document records in the database with new data.
  AI Interaction: A webhook is established to enable the AI agent to converse with users, facilitating queries and leveraging stored document knowledge.

  Setup

  Supabase Storage Setup:
     Create a private bucket in Supabase storage, modifying the default name in the URL.
     Upload your files using the provided upload options.

  Database Configuration:
     Establish the 'file' and 'document' tables in Supabase with the necessary fields.
     Execute any required SQL queries for enabling vector matching features.

  N8N Workflow Logic:
     Start with a manual trigger for the initial workflow segment or consider alternative triggers like webhooks.
     Replace all relevant credentials across nodes with your own to ensure seamless operation.

  File Processing and Google Drive Monitoring:
     Set up file processing to take care of downloading and parsing files based on their types.
     Create triggers to monitor the designated Google Drive folder for file uploads and updates.

  Integrate AI Agent:
     Configure the webhook for the AI agent to accept chat inputs while maintaining session context for enhanced user interactions.
     Utilize PostgreSQL to store user interactions and manage conversation states effectively.  

  Testing and Adjustments:
     Once everything is set up, run tests with the AI agent to validate its responses based on the documents in your database.
     Fine-tune the workflow and AI model as needed to achieve desired performance.

nodes_used:
  ["n8n-nodes-base.httpRequest","n8n-nodes-base.googleDrive","n8n-nodes-base.supabase","@n8n/n8n-nodes-langchain.agent","@n8n/n8n-nodes-langchain.embeddingsOpenAi","@n8n/n8n-nodes-langchain.lmChatOpenAi","@n8n/n8n-nodes-langchain.memoryBufferWindow","@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter","@n8n/n8n-nodes-langchain.vectorStoreSupabase","@n8n/n8n-nodes-langchain.documentDefaultDataLoader"]

workflow_json:
  {"meta":{"instanceId":"6a2a7715680b8313f7cb4676321c5baa46680adfb913072f089f2766f42e43bd","templateCredsSetupCompleted":true},"nodes":[{"id":"003915bb-a2e9-42b0-b81f-5bb5bf0c8cb4","name":"Get All files","type":"n8n-nodes-base.httpRequest","position":[1180,1280],"parameters":{"url":"=https://<project_id>.supabase.co/storage/v1/object/list/private","method":"POST","options":{},"jsonBody":"={\n  \"prefix\": \"\",\n  \"limit\": 100,\n  \"offset\": 0,\n  \"sortBy\": {\n    \"column\": \"name\",\n    \"order\": \"asc\"\n  }\n}","sendBody":true,"specifyBody":"json","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi"},"credentials":{"supabaseApi":{"id":"t8AQJzvZvrOMDLec","name":"Supabase account info@ Demo"}},"typeVersion":4.2},{"id":"f46e056d-8311-4951-ad38-21759fabdaf7","name":"Default Data Loader","type":"@n8n/n8n-nodes-langchain.documentDefaultDataLoader","position":[3500,1820],"parameters":{"options":{"metadata":{"metadataValues":[{"name":"=file_id","value":"={{ $json.id }}"}]}},"jsonData":"={{ $('Merge Text').item.json.text }}","jsonMode":"expressionData"},"typeVersion":1},{"id":"3cfdcacb-d0ef-422b-9048-a64e5f0dac66","name":"Recursive Character Text Splitter","type":"@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter","position":[3520,1960],"parameters":{"options":{},"chunkSize":500,"chunkOverlap":200},"typeVersion":1},{"id":"3056ea0a-b788-43c7-a070-f40bd1ad3356","name":"Embeddings OpenAI","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[3320,1800],"parameters":{"model":"text-embedding-3-small","options":{}},"credentials":{"openAiApi":{"id":"fLfRtaXbR0EVD0pl","name":"OpenAi account"}},"typeVersion":1},{"id":"e6ad8067-0468-440d-a322-2a3de8851431","name":"Create File record2","type":"n8n-nodes-base.supabase","position":[3260,1620],"parameters":{"tableId":"files","fieldsUi":{"fieldValues":[{"fieldId":"name","fieldValue":"={{ $('Loop Over Items').item.json.name }}"},{"fieldId":"storage_id","fieldValue":"={{ $('Loop Over Items').item.json.id }}"}]}},"credentials":{"supabaseApi":{"id":"t8AQJzvZvrOMDLec","name":"Supabase account info@ Demo"}},"typeVersion":1},{"id":"53ac0d69-d935-48a0-8fb8-5cc8f591dbb8","name":"If","type":"n8n-nodes-base.if","position":[1500,1280],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"9b14e306-a04d-40f7-bc5b-b8eda8d8f7f2","operator":{"type":"boolean","operation":"true","singleValue":true},"leftValue":"={{ \n    !$('Aggregate').item.json.data || \n    !Array.isArray($('Aggregate').item.json.data) || \n    !$('Aggregate').item.json.data.some(item => \n        item.storage_id === $('Loop Over Items').item.json.id \n    ) \n}}","rightValue":""},{"id":"c3c0af88-9aea-4539-8948-1b69e601c27c","operator":{"type":"string","operation":"notEquals"},"leftValue":"={{ $json.name }}","rightValue":".emptyFolderPlaceholder"}]}},"typeVersion":2.2},{"id":"f57e857a-094f-470c-ad27-9fc29466ab0e","name":"Get All Files","type":"n8n-nodes-base.supabase","position":[800,1280],"parameters":{"tableId":"files","operation":"getAll"},"credentials":{"supabaseApi":{"id":"t8AQJzvZvrOMDLec","name":"Supabase account info@ Demo"}},"typeVersion":1,"alwaysOutputData":true},{"id":"4484ca47-6879-43b7-8879-261f409014e1","name":"Download","type":"n8n-nodes-base.httpRequest","position":[1660,1280],"parameters":{"url":"=https://<project_id>.supabase.co/storage/v1/object/private/{{ $json.name }}","options":{},"authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi"},"credentials":{"supabaseApi":{"id":"t8AQJzvZvrOMDLec","name":"Supabase account info@ Demo"}},"typeVersion":4.2},{"id":"f81d2f91-d665-4217-8955-a308ef2b37be","name":"Loop Over Items","type":"n8n-nodes-base.splitInBatches","position":[1340,1280],"parameters":{"options":{},"batchSize":"=1"},"typeVersion":3},{"id":"8857a553-37aa-4ac2-ac4d-e5402849cb2e","name":"When clicking ‘Test workflow’","type":"n8n-nodes-base.manualTrigger","disabled":true,"position":[620,1280],"parameters":{},"typeVersion":1},{"id":"e967af7e-43bd-47cb-8b04-eb431a82c93b","name":"Aggregate","type":"n8n-nodes-base.aggregate","position":[1000,1280],"parameters":{"options":{},"aggregate":"aggregateAllItemData"},"typeVersion":1,"alwaysOutputData":true},{"id":"8abdb8f6-e31d-48cf-8189-831adf7d4889","name":"When chat message received","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[1420,300],"webhookId":"3c40d311-7996-4ed4-b2fa-c73bea5f4cf5","parameters":{"options":{}},"typeVersion":1.1},{"id":"75cf7f9e-d8f6-4a7a-b464-d152fd025188","name":"Insert into Supabase Vectorstore","type":"@n8n/n8n-nodes-langchain.vectorStoreSupabase","position":[3420,1620],"parameters":{"mode":"insert","options":{"queryName":"match_documents"},"tableName":{"__rl":true,"mode":"list","value":"documents","cachedResultName":"documents"}},"credentials":{"supabaseApi":{"id":"t8AQJzvZvrOMDLec","name":"Supabase account info@ Demo"}},"typeVersion":1},{"id":"b3ceb557-53c6-4d19-ac97-c999ba87c7f5","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[1120,1160],"parameters":{"height":89.3775420487804,"content":"### Replace Storage name, database ID and credentials."},"typeVersion":1},{"id":"a81fe332-86ea-46aa-b140-ee5745f0b0e0","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[760,1160],"parameters":{"height":80,"content":"### Replace credentials."},"typeVersion":1},{"id":"44070cd1-0f4d-48ea-8ce0-8d59f94133e7","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[3260,1500],"parameters":{"height":80,"content":"### Replace credentials."},"typeVersion":1},{"id":"3fed931d-69de-4c1b-a951-5e49c683f551","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[1620,1160],"parameters":{"height":89.3775420487804,"content":"### Replace Storage name, database ID and credentials."},"typeVersion":1},{"id":"d462978c-7ea3-4b92-a940-64756377c461","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[3220,1940],"parameters":{"height":80,"content":"### Replace credentials."},"typeVersion":1},{"id":"6f0a219d-4258-4982-b912-784a850ef308","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[2080,800],"parameters":{"height":80,"content":"### Replace credentials."},"typeVersion":1},{"id":"469b3caf-c9a8-4f8b-a745-c672e2b1089f","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[560,40],"parameters":{"color":7,"width":636.2128494576581,"height":497.1532689930921,"content":"![5min Logo](https://cflobdhpqwnoisuctsoc.supabase.co/storage/v1/object/public/my_storage/banner.png)\n## AI Agent To Chat With Files In Supabase Storage\n**Made by [Mark Shcherbakov](https://www.linkedin.com/in/marklowcoding/) from community [5minAI](https://www.skool.com/5minai-2861)**\n\nManually retrieving and analyzing specific information from large document repositories is time-consuming and inefficient. This workflow automates the process by vectorizing documents and enabling AI-powered interactions, making it easy to query and retrieve context-based information from uploaded files.\n\nThe workflow integrates Supabase with an AI-powered chatbot to process, store, and query text and PDF files. The steps include:\n- Fetching and comparing files to avoid duplicate processing.\n- Handling file downloads and extracting content based on the file type.\n- Converting documents into vectorized data for contextual information retrieval.\n- Storing and querying vectorized data from a Supabase vector store.\n\n"},"typeVersion":1},{"id":"cb6664f2-0a05-4abb-818d-d72536b57bac","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[1360,40],"parameters":{"color":5,"width":1112,"height":890,"content":"## Scenario 2 - AI agent"},"typeVersion":1},{"id":"a825794d-e7f3-41ba-a113-8503ebaf2be7","name":"Sticky Note10","type":"n8n-nodes-base.stickyNote","position":[540,1000],"parameters":{"color":5,"width":3285,"height":1139,"content":"## Scenario 1 - Flow for adding new files from Supabase storage"},"typeVersion":1},{"id":"1d44ef3b-b1d9-481c-8078-2f0d8d586247","name":"AI Agent1","type":"@n8n/n8n-nodes-langchain.agent","position":[1960,260],"parameters":{"text":"={{ $('Merge').item.json.message }}","options":{"systemMessage":"You are a helpful assistant.\n\nIMPORTANT Always use knowledge base to respond users.","passthroughBinaryImages":false},"promptType":"define"},"typeVersion":1.8},{"id":"d1da58a8-e6c0-4a6d-aa53-88c223a97f0a","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[1880,480],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"SphXAX7rlwRLkiox","name":"Test club key"}},"typeVersion":1.2},{"id":"acb2de9b-a9fa-4934-9759-b84b067dc26a","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[2020,480],"parameters":{"sessionKey":"={{ $('Merge').item.json.session_id }}","sessionIdType":"customKey"},"typeVersion":1.3},{"id":"4d91a4e9-e381-485a-847e-50b5dcc43f6b","name":"Embeddings OpenAI1","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[2160,660],"parameters":{"options":{}},"credentials":{"openAiApi":{"id":"SphXAX7rlwRLkiox","name":"Test club key"}},"typeVersion":1.2},{"id":"19b5a9a8-7407-4a1c-822f-3000b67da99b","name":"Supabase Vector Store","type":"@n8n/n8n-nodes-langchain.vectorStoreSupabase","position":[2160,500],"parameters":{"mode":"retrieve-as-tool","options":{},"toolName":"knowledge_base","tableName":{"__rl":true,"mode":"list","value":"documents","cachedResultName":"documents"},"toolDescription":"Gather facts from knowledge base to respond user."},"credentials":{"supabaseApi":{"id":"t8AQJzvZvrOMDLec","name":"Supabase account info@ Demo"}},"typeVersion":1.1},{"id":"0b48a55c-9b47-4913-9aec-264d3932c533","name":"File Created","type":"n8n-nodes-base.googleDriveTrigger","position":[600,2480],"parameters":{"event":"fileCreated","options":{},"pollTimes":{"item":[{"mode":"everyMinute"}]},"triggerOn":"specificFolder","folderToWatch":{"__rl":true,"mode":"list","value":"1rFIHlWMlbt0vAh1CWjcmNOmJYk_8jUIb","cachedResultUrl":"https://drive.google.com/drive/folders/1rFIHlWMlbt0vAh1CWjcmNOmJYk_8jUIb","cachedResultName":"Case - dentist"}},"credentials":{"googleDriveOAuth2Api":{"id":"1Irxryx1yQ3upU2i","name":"Google Drive account"}},"typeVersion":1},{"id":"fd7a9260-7d85-4129-bf2d-f7700781091b","name":"Download File","type":"n8n-nodes-base.googleDrive","position":[1200,2580],"parameters":{"fileId":{"__rl":true,"mode":"id","value":"={{ $('Set File ID').last().json.file_id }}"},"options":{"googleFileConversion":{"conversion":{"docsToFormat":"application/pdf","sheetsToFormat":"application/pdf","slidesToFormat":"application/pdf","drawingsToFormat":"application/pdf"}}},"operation":"download"},"credentials":{"googleDriveOAuth2Api":{"id":"1Irxryx1yQ3upU2i","name":"Google Drive account"}},"executeOnce":true,"typeVersion":3},{"id":"e17a7bc1-6483-439b-acb0-2b13f66466e5","name":"File Updated","type":"n8n-nodes-base.googleDriveTrigger","position":[620,2660],"parameters":{"event":"fileUpdated","options":{},"pollTimes":{"item":[{"mode":"everyMinute"}]},"triggerOn":"specificFolder","folderToWatch":{"__rl":true,"mode":"list","value":"1rFIHlWMlbt0vAh1CWjcmNOmJYk_8jUIb","cachedResultUrl":"https://drive.google.com/drive/folders/1rFIHlWMlbt0vAh1CWjcmNOmJYk_8jUIb","cachedResultName":"Case - dentist"}},"credentials":{"googleDriveOAuth2Api":{"id":"1Irxryx1yQ3upU2i","name":"Google Drive account"}},"typeVersion":1},{"id":"b0e5b639-cf0e-4289-8ce7-96e6fd1e831f","name":"Delete Old Doc Rows","type":"n8n-nodes-base.supabase","position":[1020,2580],"parameters":{"tableId":"documents","operation":"delete","filterType":"string","filterString":"=metadata->>drive_file_id=like.*{{ $json.file_id }}*"},"credentials":{"supabaseApi":{"id":"QBhcokohbJHfQZ9A","name":"Supabase club"}},"typeVersion":1,"alwaysOutputData":true},{"id":"c583b665-b756-4b8c-8150-34f559df9007","name":"Set File ID","type":"n8n-nodes-base.set","position":[860,2580],"parameters":{"options":{},"assignments":{"assignments":[{"id":"10646eae-ae46-4327-a4dc-9987c2d76173","name":"file_id","type":"string","value":"={{ $json.id }}"},{"id":"7d0b3a5e-9dfa-46d3-bf16-f6fc1d44f242","name":"extension","type":"string","value":"={{ $json.fileExtension }}"}]}},"typeVersion":3.4},{"id":"558473fe-cc06-41d8-ab06-cc6c03a8c40e","name":"Create File record1","type":"n8n-nodes-base.supabase","position":[2380,2780],"parameters":{"tableId":"files","fieldsUi":{"fieldValues":[{"fieldId":"name","fieldValue":"={{ $('Download File').item.binary.data.fileName }}"},{"fieldId":"google_drive_id","fieldValue":"={{ $('Set File ID').item.json.file_id }}"}]}},"credentials":{"supabaseApi":{"id":"t8AQJzvZvrOMDLec","name":"Supabase account info@ Demo"}},"typeVersion":1},{"id":"87e490c4-f9cb-4821-a234-a9c9d2c93836","name":"Default Data Loader1","type":"@n8n/n8n-nodes-langchain.documentDefaultDataLoader","position":[2640,2980],"parameters":{"options":{"metadata":{"metadataValues":[{"name":"=file_id","value":"={{ $json.id }}"},{"name":"drive_file_id","value":"={{ $('Set File ID').item.json.file_id }}"}]}},"jsonData":"={{ $('Set Text3').item.json.text }}","jsonMode":"expressionData"},"typeVersion":1},{"id":"373efd3c-f7dd-4efc-a268-ed05d8b2e309","name":"Embeddings OpenAI3","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[2480,2960],"parameters":{"model":"text-embedding-3-small","options":{}},"credentials":{"openAiApi":{"id":"fLfRtaXbR0EVD0pl","name":"OpenAi account"}},"typeVersion":1},{"id":"17daf2dd-1d4c-498e-8404-7cc371f81894","name":"Recursive Character Text Splitter1","type":"@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter","position":[2660,3180],"parameters":{"options":{},"chunkSize":500,"chunkOverlap":200},"typeVersion":1},{"id":"afcfc728-9798-4703-998d-edc535eb859e","name":"Insert into Supabase Vectorstore1","type":"@n8n/n8n-nodes-langchain.vectorStoreSupabase","position":[2580,2780],"parameters":{"mode":"insert","options":{"queryName":"match_documents"},"tableName":{"__rl":true,"mode":"list","value":"documents","cachedResultName":"documents"}},"credentials":{"supabaseApi":{"id":"t8AQJzvZvrOMDLec","name":"Supabase account info@ Demo"}},"typeVersion":1},{"id":"78e7d15c-5797-488c-b869-bb887878e930","name":"Sticky Note11","type":"n8n-nodes-base.stickyNote","position":[540,2240],"parameters":{"color":5,"width":2465,"height":1139,"content":"## Scenario 3 - Flow for adding new files from Supabase storage"},"typeVersion":1},{"id":"f572511d-6374-4b0b-8907-9f6c82179feb","name":"Edit Fields","type":"n8n-nodes-base.set","position":[1600,300],"parameters":{"options":{},"assignments":{"assignments":[{"id":"ad3055e5-41eb-4e00-9f55-dbcde47a03c7","name":"session_id","type":"string","value":"={{   $('When chat message received').item.json.sessionId }}"},{"id":"56126e31-5fe0-4a9c-b9c9-d62fcb8bd469","name":"message","type":"string","value":"={{   $('When chat message received').item.json.chatInput }}"}]}},"typeVersion":3.4},{"id":"be2de117-410c-49c2-b95c-45b4a0e036d6","name":"Edit Fields1","type":"n8n-nodes-base.set","position":[1600,140],"parameters":{"options":{},"assignments":{"assignments":[{"id":"5e5fbeb0-d866-40fe-8c1b-66b946bd1cec","name":"session_id","type":"string","value":"={{ $('Webhook').item.json.body.session_id }}"},{"id":"28ec27a5-f814-435c-a5bf-df92160eee3e","name":"message","type":"string","value":"={{ $('Webhook').item.json.body.message }}"}]}},"typeVersion":3.4},{"id":"ce8790a1-55a5-4583-8301-03bbde363ee2","name":"Upload File","type":"n8n-nodes-base.httpRequest","position":[2040,1280],"parameters":{"url":"https://api.cloud.llamaindex.ai/api/parsing/upload","method":"POST","options":{},"sendBody":true,"contentType":"multipart-form-data","sendHeaders":true,"authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"file","parameterType":"formBinaryData","inputDataFieldName":"data"},{"name":"do_not_cache","value":"=true"}]},"genericAuthType":"httpHeaderAuth","headerParameters":{"parameters":[{"name":"accept","value":"application/json"}]}},"credentials":{"httpHeaderAuth":{"id":"AkhbJSroTy15x6o9","name":"Llama parse bqman"}},"typeVersion":4.2},{"id":"10b8cf52-4301-40a2-a27d-9952f1d3bcda","name":"Get Processing Status","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[2240,1280],"parameters":{"url":"=https://api.cloud.llamaindex.ai/api/parsing/job/{{ $json.id }}","options":{},"sendHeaders":true,"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","headerParameters":{"parameters":[{"name":"accept","value":"application/json"}]}},"credentials":{"httpHeaderAuth":{"id":"AkhbJSroTy15x6o9","name":"Llama parse bqman"}},"typeVersion":4.2},{"id":"c0fc7854-1d04-492d-9541-389356333efd","name":"Wait to stay within service limits","type":"n8n-nodes-base.wait","position":[2660,1040],"webhookId":"17a96ed6-b5ff-47bb-a8a2-39c1eb40185a","parameters":{"amount":7},"typeVersion":1.1},{"id":"971b40d2-a320-4815-9ccc-27de52b58bbd","name":"Is Job Ready?","type":"n8n-nodes-base.switch","position":[2420,1280],"parameters":{"rules":{"values":[{"outputKey":"PENDING","conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"0fa97d86-432a-409a-917e-5f1a002b1ab9","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.status }}","rightValue":"PENDING"}]},"renameOutput":true},{"outputKey":"ERROR","conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"e6058aa0-a3e2-4ce3-9bed-6ff41a5be052","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.status }}","rightValue":"ERROR"}]},"renameOutput":true},{"outputKey":"CANCELED","conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"ceb6338f-4261-40ac-be11-91f61c7302ba","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.status }}","rightValue":"CANCELED"}]},"renameOutput":true},{"outputKey":"SUCCESS","conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"300fce8c-b19a-4d0c-86e8-f62853c70ce2","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.status }}","rightValue":"SUCCESS"}]},"renameOutput":true}]},"options":{"allMatchingOutputs":true}},"typeVersion":3},{"id":"c8f65cc5-e67a-47ae-b43a-fc065fb4900e","name":"Stop and Error","type":"n8n-nodes-base.stopAndError","position":[2660,1300],"parameters":{"errorMessage":"Problem with Llamaparser. Error during parsing."},"typeVersion":1},{"id":"90658f0a-7236-493d-8dd0-fdad64196753","name":"Get Parsed Data","type":"n8n-nodes-base.httpRequest","position":[2660,1480],"parameters":{"url":"=https://api.cloud.llamaindex.ai/api/parsing/job/{{ $json.id }}/result/markdown","options":{"redirect":{"redirect":{}}},"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"AkhbJSroTy15x6o9","name":"Llama parse bqman"}},"typeVersion":4.2},{"id":"810aad96-7677-4c27-b3b2-25106b70083a","name":"Sticky Note12","type":"n8n-nodes-base.stickyNote","position":[2060,1460],"parameters":{"width":280,"height":80,"content":"### Add Llamaparse Header auth\nAuthorization: Bearer <api_key>"},"typeVersion":1},{"id":"a0fd62b8-219e-4eb7-b274-1344b0042fac","name":"Merge","type":"n8n-nodes-base.merge","position":[1800,260],"parameters":{},"typeVersion":3.1},{"id":"e5356266-5e4a-41a2-8151-95f994435560","name":"If1","type":"n8n-nodes-base.if","position":[1820,1280],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"f05d708d-f36e-4c6d-8753-81a61ae42546","operator":{"type":"string","operation":"notExists","singleValue":true},"leftValue":"={{ $json.data }}","rightValue":""}]}},"typeVersion":2.2},{"id":"c04fa3f9-74c6-4c7c-ae2a-46a797db0e55","name":"Set Text","type":"n8n-nodes-base.set","position":[2060,1600],"parameters":{"options":{},"assignments":{"assignments":[{"id":"e9bbecd9-3d40-4a6a-9401-94daab15cde0","name":"text","type":"string","value":"={{ $('If1').item.json.data }}"}]}},"typeVersion":3.4},{"id":"2f41ef18-6229-4d3c-9a3c-8b02ec3c60b2","name":"Set Text1","type":"n8n-nodes-base.set","position":[2840,1480],"parameters":{"options":{},"assignments":{"assignments":[{"id":"e9bbecd9-3d40-4a6a-9401-94daab15cde0","name":"text","type":"string","value":"={{ $('Get Parsed Data').item.json.markdown }}"}]}},"typeVersion":3.4},{"id":"9c92b25b-7762-4465-878f-6568073ba521","name":"Merge Text","type":"n8n-nodes-base.merge","position":[3060,1620],"parameters":{},"typeVersion":3.1},{"id":"4a523ad6-d74d-4207-8347-facc7f313fdd","name":"Upload File1","type":"n8n-nodes-base.httpRequest","position":[1380,2580],"parameters":{"url":"https://api.cloud.llamaindex.ai/api/parsing/upload","method":"POST","options":{},"sendBody":true,"contentType":"multipart-form-data","sendHeaders":true,"authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"file","parameterType":"formBinaryData","inputDataFieldName":"data"},{"name":"do_not_cache","value":"=true"}]},"genericAuthType":"httpHeaderAuth","headerParameters":{"parameters":[{"name":"accept","value":"application/json"}]}},"credentials":{"httpHeaderAuth":{"id":"AkhbJSroTy15x6o9","name":"Llama parse bqman"}},"typeVersion":4.2},{"id":"c0a43e5e-ec2b-49f5-bbc0-cef914c68c4c","name":"Get Processing Status1","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[1580,2580],"parameters":{"url":"=https://api.cloud.llamaindex.ai/api/parsing/job/{{ $json.id }}","options":{},"sendHeaders":true,"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","headerParameters":{"parameters":[{"name":"accept","value":"application/json"}]}},"credentials":{"httpHeaderAuth":{"id":"AkhbJSroTy15x6o9","name":"Llama parse bqman"}},"typeVersion":4.2},{"id":"68cc70a4-dba0-4ec9-8506-88bb20b37e87","name":"Wait to stay within service limits1","type":"n8n-nodes-base.wait","position":[2000,2340],"webhookId":"17a96ed6-b5ff-47bb-a8a2-39c1eb40185a","parameters":{"amount":7},"typeVersion":1.1},{"id":"aef3b805-166e-47a8-a81c-900f999ae045","name":"Is Job Ready?1","type":"n8n-nodes-base.switch","position":[1760,2580],"parameters":{"rules":{"values":[{"outputKey":"PENDING","conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"0fa97d86-432a-409a-917e-5f1a002b1ab9","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.status }}","rightValue":"PENDING"}]},"renameOutput":true},{"outputKey":"ERROR","conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"e6058aa0-a3e2-4ce3-9bed-6ff41a5be052","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.status }}","rightValue":"ERROR"}]},"renameOutput":true},{"outputKey":"CANCELED","conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"ceb6338f-4261-40ac-be11-91f61c7302ba","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.status }}","rightValue":"CANCELED"}]},"renameOutput":true},{"outputKey":"SUCCESS","conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"300fce8c-b19a-4d0c-86e8-f62853c70ce2","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.status }}","rightValue":"SUCCESS"}]},"renameOutput":true}]},"options":{"allMatchingOutputs":true}},"typeVersion":3},{"id":"5233be31-2ecf-4ddd-96e2-b0fd614f535f","name":"Stop and Error1","type":"n8n-nodes-base.stopAndError","position":[2000,2600],"parameters":{"errorMessage":"Problem with Llamaparser. Error during parsing."},"typeVersion":1},{"id":"09283faa-4ab9-4d59-a610-3491d7f2daf8","name":"Get Parsed Data1","type":"n8n-nodes-base.httpRequest","position":[2000,2780],"parameters":{"url":"=https://api.cloud.llamaindex.ai/api/parsing/job/{{ $json.id }}/result/markdown","options":{"redirect":{"redirect":{}}},"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"AkhbJSroTy15x6o9","name":"Llama parse bqman"}},"typeVersion":4.2},{"id":"5ef6959d-1eb4-49cd-9b19-3b0e1aaa0eb7","name":"Sticky Note13","type":"n8n-nodes-base.stickyNote","position":[1400,2760],"parameters":{"width":280,"height":80,"content":"### Add Llamaparse Header auth\nAuthorization: Bearer <api_key>"},"typeVersion":1},{"id":"18fd1d0f-664e-4584-8154-794ca8aad768","name":"Set Text3","type":"n8n-nodes-base.set","position":[2180,2780],"parameters":{"options":{},"assignments":{"assignments":[{"id":"e9bbecd9-3d40-4a6a-9401-94daab15cde0","name":"text","type":"string","value":"={{ $('Get Parsed Data1').item.json.markdown }}"}]}},"typeVersion":3.4},{"id":"337b8593-8f5a-47b2-8b75-f5b3b4195fe8","name":"Webhook","type":"n8n-nodes-base.webhook","position":[1420,140],"webhookId":"05979e87-19bc-4e8b-adbb-7e04808f8b21","parameters":{"path":"05979e87-19bc-4e8b-adbb-7e04808f8b21","options":{},"httpMethod":"POST","responseMode":"lastNode"},"typeVersion":2},{"id":"7911c133-f998-4efd-a9c8-9c52c8e545c4","name":"Sticky Note14","type":"n8n-nodes-base.stickyNote","position":[2380,2660],"parameters":{"width":480,"height":80,"content":"### Replace credentials."},"typeVersion":1}],"connections":{"If":{"main":[[{"node":"Download","type":"main","index":0}],[{"node":"Loop Over Items","type":"main","index":0}]]},"If1":{"main":[[{"node":"Upload File","type":"main","index":0}],[{"node":"Set Text","type":"main","index":0}]]},"Merge":{"main":[[{"node":"AI Agent1","type":"main","index":0}]]},"Webhook":{"main":[[{"node":"Edit Fields1","type":"main","index":0}]]},"Download":{"main":[[{"node":"If1","type":"main","index":0}]]},"Set Text":{"main":[[{"node":"Merge Text","type":"main","index":1}]]},"Aggregate":{"main":[[{"node":"Get All files","type":"main","index":0}]]},"Set Text1":{"main":[[{"node":"Merge Text","type":"main","index":0}]]},"Set Text3":{"main":[[{"node":"Create File record1","type":"main","index":0}]]},"Merge Text":{"main":[[{"node":"Create File record2","type":"main","index":0}]]},"Edit Fields":{"main":[[{"node":"Merge","type":"main","index":1}]]},"Set File ID":{"main":[[{"node":"Delete Old Doc Rows","type":"main","index":0}]]},"Upload File":{"main":[[{"node":"Get Processing Status","type":"main","index":0}]]},"Edit Fields1":{"main":[[{"node":"Merge","type":"main","index":0}]]},"File Created":{"main":[[{"node":"Set File ID","type":"main","index":0}]]},"File Updated":{"main":[[{"node":"Set File ID","type":"main","index":0}]]},"Upload File1":{"main":[[{"node":"Get Processing Status1","type":"main","index":0}]]},"Download File":{"main":[[{"node":"Upload File1","type":"main","index":0}]]},"Get All Files":{"main":[[{"node":"Aggregate","type":"main","index":0}]]},"Get All files":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Is Job Ready?":{"main":[[{"node":"Wait to stay within service limits","type":"main","index":0}],[{"node":"Stop and Error","type":"main","index":0}],[{"node":"Stop and Error","type":"main","index":0}],[{"node":"Get Parsed Data","type":"main","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"AI Agent1","type":"ai_memory","index":0}]]},"Is Job Ready?1":{"main":[[{"node":"Wait to stay within service limits1","type":"main","index":0}],[{"node":"Stop and Error1","type":"main","index":0}],[{"node":"Stop and Error1","type":"main","index":0}],[{"node":"Get Parsed Data1","type":"main","index":0}]]},"Get Parsed Data":{"main":[[{"node":"Set Text1","type":"main","index":0}]]},"Loop Over Items":{"main":[[],[{"node":"If","type":"main","index":0}]]},"Get Parsed Data1":{"main":[[{"node":"Set Text3","type":"main","index":0}]]},"Embeddings OpenAI":{"ai_embedding":[[{"node":"Insert into Supabase Vectorstore","type":"ai_embedding","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"AI Agent1","type":"ai_languageModel","index":0}]]},"Embeddings OpenAI1":{"ai_embedding":[[{"node":"Supabase Vector Store","type":"ai_embedding","index":0}]]},"Embeddings OpenAI3":{"ai_embedding":[[{"node":"Insert into Supabase Vectorstore1","type":"ai_embedding","index":0}]]},"Create File record1":{"main":[[{"node":"Insert into Supabase Vectorstore1","type":"main","index":0}]]},"Create File record2":{"main":[[{"node":"Insert into Supabase Vectorstore","type":"main","index":0}]]},"Default Data Loader":{"ai_document":[[{"node":"Insert into Supabase Vectorstore","type":"ai_document","index":0}]]},"Delete Old Doc Rows":{"main":[[{"node":"Download File","type":"main","index":0}]]},"Default Data Loader1":{"ai_document":[[{"node":"Insert into Supabase Vectorstore1","type":"ai_document","index":0}]]},"Get Processing Status":{"main":[[{"node":"Is Job Ready?","type":"main","index":0}],[{"node":"Stop and Error","type":"main","index":0}]]},"Supabase Vector Store":{"ai_tool":[[{"node":"AI Agent1","type":"ai_tool","index":0}]]},"Get Processing Status1":{"main":[[{"node":"Is Job Ready?1","type":"main","index":0}],[{"node":"Stop and Error1","type":"main","index":0}]]},"When chat message received":{"main":[[{"node":"Edit Fields","type":"main","index":0}]]},"Insert into Supabase Vectorstore":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Recursive Character Text Splitter":{"ai_textSplitter":[[{"node":"Default Data Loader","type":"ai_textSplitter","index":0}]]},"When clicking ‘Test workflow’":{"main":[[{"node":"Get All Files","type":"main","index":0}]]},"Recursive Character Text Splitter1":{"ai_textSplitter":[[{"node":"Default Data Loader1","type":"ai_textSplitter","index":0}]]},"Wait to stay within service limits":{"main":[[{"node":"Get Processing Status","type":"main","index":0}]]},"Wait to stay within service limits1":{"main":[[{"node":"Get Processing Status1","type":"main","index":0}]]}}}


name: Tesla Quant Trading AI Agent using Telegram + GPT-4.1 (Main InterFace)
author_name: Don Jayamaha Jr
author_username: don-the-gem-dealer
categories: []
created_at: 2025-05-16T08:44:07.297Z
updated_at: 2025-05-16T08:44:07.297Z
url: https://n8n.io/workflows/4092
scraped_at: 2025-07-06 21:16:30
description:
  📈 Get daily and on-demand Tesla (TSLA) trading signals via Telegram—powered by GPT-4.1 and real-time market data.
  This is the central AI supervisor that orchestrates seven sub-agents for technical analysis, price pattern recognition, and news sentiment. Reports are delivered in structured Telegram-ready HTML, optimized for traders seeking fast, intelligent decision-making signals.

  ⚠️ This master agent requires 7 connected sub-workflows to function. One of them, the News & Sentiment Agent, also requires a DeepSeek Chat API key for language processing.

  🔌 Required Sub-Workflows

  You must download and publish the following workflows:

  Tesla Financial Market Data Analyst Tool
  Tesla News and Sentiment Analyst Tool (Requires DeepSeek Chat API Key)
  Tesla 15min Indicators Tool
  Tesla 1hour Indicators Tool
  Tesla 1day Indicators Tool
  Tesla 1hour & 1day Klines Tool
  Tesla Quant Technical Indicators Webhooks Tool (Requires Alpha Vantage Premium API Key)

  📍 See all tools at:
  🔗 https://n8n.io/creators/don-the-gem-dealer/

  🔍 What This Agent Does

  Listens to your trading query via Telegram
  Calls the Financial Analyst and News & Sentiment Analyst
  These agents aggregate:

     RSI, MACD, BBANDS, SMA, EMA, ADX
     Candlestick pattern + volume divergence analysis
     News summaries and sentiment scoring via DeepSeek Chat
  GPT-4.1 composes the final structured TSLA trade report with:

     Spot and leverage setups
     Signal rationale
     Confidence score
     Sentiment tag
     News summary

  🧠 Output Example

  TSLA Trading Report (Daily Summary)
  Spot Trade
  • Action: Buy
  • Entry: 172.45
  • TP: 182.00
  • SL: 169.80
  • Signal: RSI bounce + Bullish Engulfing
  • Sentiment: Neutral

  Leveraged Position
  • Position: Long
  • Leverage: 3x
  • TP: 186
  • SL: 170
  • Confidence: High (83/100)

  📰 Top News
  • Tesla Model Y delivery surge – Electrek
  • Options market pricing in upside – Bloomberg
  • FSD delayed in Canada – TeslaNorth

  🛠️ Setup Instructions

  1. Import All 8 Workflows

  Ensure all sub-agents above are published in your n8n instance.

  2. Create Your Telegram Bot

  Use @BotFather to generate the token and connect to the trigger/send nodes.

  3. Connect OpenAI GPT-4.1

  Add your OpenAI credentials for GPT-4.1 in the designated node.

  4. Add DeepSeek Chat API Key

  Sign up at https://deepseek.com and insert your DeepSeek Chat credentials in the News Agent.

  5. Add Alpha Vantage Premium API Key

  Sign up at https://www.alphavantage.co/premium/
  Use HTTP Header Auth for webhook-based indicator fetchers.

  6. Replace Telegram ID

  Update the placeholder &lt;&lt;replace your ID here&gt;&gt; with your actual Telegram numeric ID in the auth node.

  📌 Included Sticky Notes

  ✅ Telegram Bot Setup
  ✅ Agent Routing & Memory
  ✅ Financial vs. Sentiment Trigger Flow
  ✅ Report Formatting (HTML)
  ✅ API Requirements (GPT-4.1, DeepSeek, Alpha Vantage)
  ✅ Troubleshooting & Licensing

  🧾 Licensing & Attribution

  © 2025 Treasurium Capital Limited Company
  Architecture, prompts, and trade report structure are IP-protected. No unauthorized rebranding permitted.

  🔗 For support: LinkedIn – Don Jayamaha

  🚀 Deploy the Tesla Quant Trading AI system with GPT-4.1, DeepSeek Chat, and Alpha Vantage Premium—right into Telegram.
  All 8 workflows are required.

  🎥 Tesla Quant AI Agent – Live Demo

  Experience the power of the Tesla Quant Trading AI Agent in action.
    

nodes_used:
  ["n8n-nodes-base.telegram","n8n-nodes-base.code","@n8n/n8n-nodes-langchain.agent","@n8n/n8n-nodes-langchain.lmChatOpenAi","@n8n/n8n-nodes-langchain.memoryBufferWindow","@n8n/n8n-nodes-langchain.toolWorkflow"]

workflow_json:
  {"id":"YtPhfFCx9D9Eq9zi","meta":{"instanceId":"a5283507e1917a33cc3ae615b2e7d5ad2c1e50955e6f831272ddd5ab816f3fb6","templateCredsSetupCompleted":true},"name":"Tesla Quant Trading AI Agent n8n","tags":[],"nodes":[{"id":"8677aed4-a1bf-4439-8b5e-57c283f81862","name":"Telegram Trigger","type":"n8n-nodes-base.telegramTrigger","position":[-560,-100],"webhookId":"721eba88-462f-40ab-8c53-c6c2f3897e11","parameters":{"updates":["message"],"additionalFields":{}},"credentials":{"telegramApi":{"id":"FH5VC4KOy7sBQBc0","name":"Dad's Tesla AI Agent"}},"typeVersion":1.2},{"id":"fddcfaab-f575-4e72-b3f1-e0965e3c71b5","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[140,260],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"yUizd8t0sD5wMYVG","name":"OpenAi account"}},"typeVersion":1.2},{"id":"f6e5726a-1010-4a55-9d54-f6889eb780e1","name":"Telegram","type":"n8n-nodes-base.telegram","position":[1380,-100],"webhookId":"77b6658d-8dfb-415b-9e67-4f34ef086cdb","parameters":{"text":"={{ $json.message }}","chatId":"={{ $('Telegram Trigger').item.json.message.chat.id }}","additionalFields":{"appendAttribution":false}},"credentials":{"telegramApi":{"id":"FH5VC4KOy7sBQBc0","name":"Dad's Tesla AI Agent"}},"typeVersion":1.2},{"id":"62f3f30c-47e4-4c86-828b-3ab4de28e6c3","name":"User Authentication (Replace Telegram ID)","type":"n8n-nodes-base.code","position":[-300,-100],"parameters":{"jsCode":"if ($input.first().json.message.from.id !== <<replace your ID here>>) { // Replace with your actual ID\n  return {unauthorized: true};\n} else {\n  // Return the original data when authorized\n  return $input.all();\n}"},"typeVersion":2},{"id":"5a79ae5f-583d-41a0-9055-914de6eaf341","name":"Tesla Quant Trading AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[520,-100],"parameters":{"text":"={{ $('Telegram Trigger').item.json.message.text }}","options":{"systemMessage":"You are the **Tesla Quant Trading AI Agent**, responsible for generating structured, professional swing-trading reports for **TSLA** based on both **real-time technical analysis** and **curated sentiment data**.\n\n---\n\n### 🔗 Connected Tools:\n\n1. **Tesla Financial Market Data Analyst Tool**  \n   - Aggregates multi-timeframe indicators + candlestick signals from:\n     • Tesla 15min Indicators Tool  \n     • Tesla 1h Indicators Tool  \n     • Tesla 1d Indicators Tool  \n     • Tesla Klines Tool (1h & 1d pattern/volume)  \n   - Uses Alpha Vantage indicators: **RSI, BBANDS, SMA, EMA, ADX, MACD**  \n   - Each tool returns the **20 most recent points**, cleaned and trimmed  \n   - Pattern logic: detects **Doji, Engulfing**, and **volume divergence**\n\n2. **Tesla News and Sentiment Analyst Tool**  \n   - Scrapes from trusted RSS sources: **Google News, Yahoo Finance, Electrek, CleanTechnica, TeslaNorth**  \n   - Returns:  \n     • **Sentiment score**: Bullish / Bearish / Neutral  \n     • **Summary**: 2–3 sentence narrative  \n     • **Top 3–5 Headlines** (with sources)\n\n---\n\n### 📊 Responsibilities:\n\n1. **Ingest structured inputs** from the tools listed above:\n   - Indicator values and candlestick/volume behavior  \n   - News sentiment summaries and headlines\n\n2. **Perform technical analysis** across timeframes:\n   - **Short-Term**: 15m + 1h  \n   - **Long-Term**: 1d + 1h  \n   - Assess trend, support/resistance, divergence, and reversal signals  \n   - Confirm with lagging indicators and macro sentiment alignment\n\n3. **Generate two trade strategy sections**:\n\n<b>Spot Recommendations</b>  \n• Action: Buy / Sell / Hold  \n• Entry Price  \n• Stop Loss  \n• Take Profit  \n• Rationale:  \n - <b>Primary Signals</b>: e.g. candle pattern, breakout  \n - <b>Lagging Indicators</b>: RSI, BBANDS, etc.  \n - <b>Sentiment & Macro Analysis</b>: use news summary + headlines\n\n<b>Leveraged Recommendations</b>  \n• Position: Long / Short  \n• Leverage: 2x / 3x / 5x  \n• Entry Price  \n• Stop Loss  \n• Take Profit  \n• Rationale:  \n - <b>Primary Price Action Signals</b>  \n - <b>Lagging Indicator Confirmation</b>  \n - <b>Sentiment & Macro Analysis</b>\n\n4. **Score your signal strength**  \n• Confidence score (0–100)  \n• Strength label: Low / Medium / High / Very High\n\n5. **Include sentiment and headlines** at the bottom of the report:  \n• A short <b>News Sentiment Summary</b>  \n• Top 3 Tesla-related headlines with bullet formatting\n\n---\n\n### 🧾 Output Format (Telegram HTML)\n\nStart your message with:\n<b>TSLA Analysis</b>\n\n\nUse:\n• `<b>` for bold headers  \n• `•` for bullet points  \n• Clean line breaks  \n\n---\n\n⚠️ DO NOT:\n• Fabricate or assume any data  \n• Repeat this prompt or system instructions  \n• Include raw JSON or raw API format in your output\n\nOnly use what is provided via structured input. Write like a seasoned quantitative analyst.\n"},"promptType":"define"},"typeVersion":1.8},{"id":"966cf9b6-abd4-48a0-bd32-6c83985a33ac","name":"Tesla Financial Market Data Analyst Tool","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[700,260],"parameters":{"name":"Tesla_Financial_Market_Data_Analyst","workflowId":{"__rl":true,"mode":"list","value":"WmWhVZ3XkJdjTmME","cachedResultName":"Work Drive — Tesla Financial Market Data Analyst"},"workflowInputs":{"value":{"message":"={{ $fromAI(\"message\",\"Populate this with a relevant message to this subagent\")}}","sessionId":"={{ $json.sessionId }}"},"schema":[{"id":"message","type":"string","display":true,"removed":false,"required":false,"displayName":"message","defaultMatch":false,"canBeUsedToMatch":true},{"id":"sessionId","type":"string","display":true,"removed":false,"required":false,"displayName":"sessionId","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false}},"typeVersion":2.1},{"id":"dbf1bef5-044a-4594-af1b-1468d4cdc06a","name":"Tesla News and Sentiment Analyst Tool","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[980,260],"parameters":{"name":"Tesla_News_and_Sentiment_Analyst","workflowId":{"__rl":true,"mode":"list","value":"kOIhNsok4gtt6fD3","cachedResultName":"Work Drive — Tesla News and Sentiment Analyst"},"workflowInputs":{"value":{"message":"={{ $fromAI(\"message\",\"Populate this with a relevant message to this subagent\")}}","sessionId":"={{ $json.sessionId }}"},"schema":[{"id":"message","type":"string","display":true,"removed":false,"required":false,"displayName":"message","defaultMatch":false,"canBeUsedToMatch":true},{"id":"sessionId","type":"string","display":true,"removed":false,"required":false,"displayName":"sessionId","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false}},"typeVersion":2.1},{"id":"2109ef95-4256-4713-aa9d-8a8ecd40eff3","name":"Add SessionId","type":"n8n-nodes-base.set","position":[260,-100],"parameters":{"options":{},"assignments":{"assignments":[{"id":"c9d7a6f2-7e01-46fb-a4ee-f0c3b248bd6b","name":"sessionId","type":"string","value":"={{ $('Telegram Trigger').item.json.message.chat.id }}"},{"id":"d5929b35-1751-4a6a-bbee-d844cbb8e0aa","name":"DateandTime","type":"string","value":"={{ $json.currentDate }}"}]}},"typeVersion":3.4},{"id":"0f45fae9-fef5-4595-97f0-04f974790cd3","name":"Splits message is more than 4000 characters","type":"n8n-nodes-base.code","position":[1020,-100],"parameters":{"jsCode":"// Input: assumes incoming message in `item.json.message`\nconst input = $json.output;\nconst chunkSize = 4000;\n\n// Function to split text\nfunction splitMessage(text, size) {\n  const result = [];\n  for (let i = 0; i < text.length; i += size) {\n    result.push(text.substring(i, i + size));\n  }\n  return result;\n}\n\n// Logic\nif (input.length <= chunkSize) {\n  return [{ json: { message: input } }];\n} else {\n  const chunks = splitMessage(input, chunkSize);\n  return chunks.map(chunk => ({ json: { message: chunk } }));\n}"},"typeVersion":2},{"id":"8e7dcfd4-7f2a-47b4-8e5a-1bc4d77fced7","name":"Date & Time","type":"n8n-nodes-base.dateTime","position":[-20,-100],"parameters":{"options":{}},"typeVersion":2},{"id":"f31dbe9c-25a2-4751-ba34-38ed0ae9e18c","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[420,260],"parameters":{},"typeVersion":1.3},{"id":"97dfa658-3a67-4ed7-9662-b62573e0958b","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-640,-340],"parameters":{"color":4,"height":420,"content":"## Trigger Incoming Telegram Command\n\nThis node **listens for new Telegram messages** to initiate report generation."},"typeVersion":1},{"id":"b7d99e5f-0f36-4963-aa2c-33db04689fc5","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-380,-340],"parameters":{"color":2,"width":260,"height":420,"content":"## Validate User Access\n\nEnsures only **authorized Telegram user IDs** can trigger the agent."},"typeVersion":1},{"id":"9a4d6ba0-2d75-4453-8b05-bc4dedf81be5","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-80,-340],"parameters":{"color":5,"height":420,"content":"## Capture Timestamp\n\nCaptures the **current system date and time** for session tracking and report stamping."},"typeVersion":1},{"id":"157ba065-d228-41f0-a88f-ea8122fb5fa8","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[200,-340],"parameters":{"height":420,"content":"## Generate Session Metadata\n\nAssigns **sessionId based on Telegram chat ID** and stores current **date/time** for context continuity."},"typeVersion":1},{"id":"6fe0bc11-94da-4c82-bf28-5fe6429d6e86","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[480,-340],"parameters":{"color":7,"width":340,"height":420,"content":"## Main AI Agent: Trading Report Generator\n\nUses **GPT model to combine technical and sentiment data** into a structured **TSLA swing-trading report**.\nCalls **Financial Market Analyst + Sentiment Analyst**.\n\n"},"typeVersion":1},{"id":"7a1e3a33-713a-4a72-81c0-001e74af8f73","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[940,-340],"parameters":{"color":5,"width":260,"height":420,"content":"## Handle Telegram Message Limits\n\nChecks **output message length and splits into 4000-character** chunks if needed.\n\n"},"typeVersion":1},{"id":"b5ac3bcb-baa5-4d39-9e44-6be888317089","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[1300,-340],"parameters":{"color":4,"width":260,"height":420,"content":"## Send Final Report to Telegram\n\nSends **formatted HTML report (or split parts)** back to the **original Telegram user**."},"typeVersion":1},{"id":"5df88223-3acc-4b27-b592-58d499a638dd","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[60,220],"parameters":{"color":2,"height":400,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n## GPT Model for Reasoning\nUses **OpenAI GPT (e.g., GPT-4o)** to process signal analysis and produce **final report** text."},"typeVersion":1},{"id":"c7bcc5bc-48b9-464b-9a6b-062535810543","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[340,220],"parameters":{"color":3,"height":400,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Short-Term Memory Module\nMaintains **state during session**. Helps agent **track message history and previous context**.\n\n"},"typeVersion":1},{"id":"b17ec86d-5d91-469f-bc9d-fb5e22ecbfaf","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[620,220],"parameters":{"color":6,"height":400,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Fetch Technical Indicator Insights\nCalls all **15m, 1h, 1d, and Klines sub-agents** via **webhook** to retrieve structured **market analysis**.\n\n"},"typeVersion":1},{"id":"1eda1d9b-2b50-4cd1-8b83-6a7d37517d31","name":"Sticky Note10","type":"n8n-nodes-base.stickyNote","position":[900,220],"parameters":{"color":6,"height":400,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Scrape Tesla News & Generate Sentiment\nPulls latest **Tesla-related headlines from trusted RSS feeds** and **returns structured sentiment** summary.\n\n"},"typeVersion":1},{"id":"8e2ebe09-5488-4fb9-8175-b88ba68fcb9e","name":"Sticky Note11","type":"n8n-nodes-base.stickyNote","position":[1900,-1680],"parameters":{"width":1280,"height":2300,"content":"\n# 🧠 Tesla Quant Trading AI Agent – Full System Documentation\n\nA professional-grade AI-driven stock analysis system designed to deliver structured Tesla (TSLA) swing-trading insights based on real-time technical indicators and sentiment signals.\n\n---\n\n## 🧩 Included Workflows\n\n> Download and install **all** of the following workflows for the system to function correctly.\n\n| Workflow Name                               | Function                                                                 |\n| ------------------------------------------- | ------------------------------------------------------------------------ |\n| ✅ Tesla 15min Indicators Tool               | Pulls Alpha Vantage data for short-term signals (15m: RSI, BBANDS, etc.) |\n| ✅ Tesla 1hour Indicators Tool               | Pulls Alpha Vantage data for medium-term signals (1h: RSI, BBANDS, etc.) |\n| ✅ Tesla 1day Indicators Tool                | Pulls Alpha Vantage data for long-term signals (1d: RSI, BBANDS, MACD)   |\n| ✅ Tesla 1hour & 1day Klines Tool            | Analyzes candlestick patterns and volume divergences (OHLCV)             |\n| ✅ Tesla Quant Technical Indicators Webhooks | Webhook handlers that power the above 4 indicator-fetching tools         |\n| ✅ Tesla Financial Market Data Analyst Tool  | Synthesizes multi-timeframe indicator + candle data                      |\n| ✅ Tesla News and Sentiment Analyst Tool     | Scrapes Tesla news RSS + assigns sentiment with headlines                |\n| ✅ Tesla Quant Trading AI Agent              | Final agent that generates Telegram-style trade reports                  |\n\n---\n\n## ⚙️ Installation Instructions\n\n### Step 1: Import Workflows\n\n1. Open your **n8n editor UI**.\n2. Import each workflow JSON file one by one.\n3. Make sure all workflows are **activated** or properly linked via `Execute Workflow` nodes.\n\n### Step 2: Set Up Credentials\n\n1. Go to **Credentials → HTTP Auth → Query Parameter Auth**.\n2. Create a credential named: `Alpha Vantage Premium`\n\n   * Add: `apikey=YOUR_API_KEY`\n3. Add your **OpenAI API** credentials (for GPT-4.1 or equivalent).\n\n### Step 3: Configure Webhooks\n\n1. Deploy the **Tesla Quant Technical Indicators Webhooks Tool**.\n2. Ensure that `/15minData`, `/1hourData`, `/1dayData`, and `/klinesData` routes are properly reachable.\n\n### Step 4: Set Up Execution\n\n1. Trigger the **Tesla Quant Trading AI Agent** manually or via a scheduler.\n2. The agent will:\n\n   * Call all technical + sentiment tools via workflow execution\n   * Format and analyze data\n   * Output full trading report in Telegram-HTML style\n\n---\n\n## 🖥️ System Overview\n\n**Data Flow:**\n\n```\n[Webhook HTTP Trigger] \n→ [Indicator Tool (15m, 1h, 1d)] \n→ [Candlestick Tool (1h, 1d)]\n→ [Financial Market Data Analyst] \n→ [Sentiment Analyst] \n→ [Final Report Generator]\n```\n\n**Output Example:**\n\n* Spot + Leverage trade entries\n* Confidence score (0–100)\n* Reasoning: price action, indicators, and sentiment\n* Summary headlines and sentiment context\n\n---\n\n## 📬 Output Format\n\n* Styled using Telegram HTML (`<b>`, `•`, newlines)\n* Structured trade report with:\n\n  * Action type\n  * Entry/exit prices\n  * Rationale in 3 parts\n  * News sentiment and 3 headlines\n\n---\n\n## 🚀 Support & Licensing\n\n🔗 **Don Jayamaha – LinkedIn**\n[http://linkedin.com/in/donjayamahajr](http://linkedin.com/in/donjayamahajr)\n\n© 2025 Treasurium Capital Limited Company. All rights reserved.\nThis AI workflow architecture, including logic, design, and prompt structures, is the intellectual property of **Treasurium Capital Limited Company**. Unauthorized reproduction, redistribution, or resale is prohibited under **U.S. copyright law**. Licensed use only.\n\n"},"typeVersion":1}],"active":false,"settings":{"executionOrder":"v1"},"versionId":"b77078ba-b904-4315-aa13-f80fded7f9a9","connections":{"Telegram":{"main":[[]]},"Date & Time":{"main":[[{"node":"Add SessionId","type":"main","index":0}]]},"Add SessionId":{"main":[[{"node":"Tesla Quant Trading AI Agent","type":"main","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"Tesla Quant Trading AI Agent","type":"ai_memory","index":0}]]},"Telegram Trigger":{"main":[[{"node":"User Authentication (Replace Telegram ID)","type":"main","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"Tesla Quant Trading AI Agent","type":"ai_languageModel","index":0}]]},"Tesla Quant Trading AI Agent":{"main":[[{"node":"Splits message is more than 4000 characters","type":"main","index":0}]]},"Tesla News and Sentiment Analyst Tool":{"ai_tool":[[{"node":"Tesla Quant Trading AI Agent","type":"ai_tool","index":0}]]},"Tesla Financial Market Data Analyst Tool":{"ai_tool":[[{"node":"Tesla Quant Trading AI Agent","type":"ai_tool","index":0}]]},"User Authentication (Replace Telegram ID)":{"main":[[{"node":"Date & Time","type":"main","index":0}]]},"Splits message is more than 4000 characters":{"main":[[{"node":"Telegram","type":"main","index":0}]]}}}


name: Manage Calendar with Voice & Text using GPT-4, Telegram & Google Calendar
author_name: Marian Tcaciuc
author_username: mariantk
categories: []
created_at: 2025-05-16T11:08:27.232Z
updated_at: 2025-05-16T11:08:27.232Z
url: https://n8n.io/workflows/4102
scraped_at: 2025-07-06 21:16:30
description:
  Manage Calendar with Voice & Text Commands using GPT-4, Telegram & Google Calendar

  This n8n workflow transforms your Telegram bot into a personal AI calendar assistant, capable of understanding both voice and text commands in Romanian, and managing your Google Calendar using the GPT-4 model via LangChain.

  Whether you want to create, update, fetch, or delete events, you can simply speak or write your request to your Telegram bot — and the assistant takes care of the rest.

  🚀 Features

  Voice command support using Telegram voice messages (.ogg)
  Transcription using OpenAI Whisper
  Natural language understanding with GPT-4 via LangChain
  Google Calendar integration:
    ✅ Create Events
    🔁 Update Events
    ❌ Delete Events
    📅 Fetch Events
  Responses sent back via Telegram

  🛠️ Step-by-Step Setup Instructions

  1. Create a Telegram Bot
  Go to @BotFather on Telegram.
  Send /newbot and follow the instructions.
  Save the Bot Token.

  2. Configure Telegram Trigger Node
  Paste the Telegram token into the Telegram Trigger and Telegram nodes.
  Set updates to ["message"].

  3. Set up OpenAI Credentials
  Get an OpenAI API key from https://platform.openai.com
  Create a credential in n8n for OpenAI.
  This is used for both transcription and AI reasoning.

  4. Set up Google Calendar
  In Google Cloud Console:
    Enable Google Calendar API
    Set up OAuth2 credentials
    Add your n8n redirect URI (usually https://yourdomain/rest/oauth2-credential/callback)
  Create a credential in n8n using Google Calendar OAuth2
  Grant access to your calendar (e.g., "Family" calendar).

  ⚙️ Customization Options

  🗣️ Change Language or Locale
  The transcription node uses "en" for English. Change to another locale if needed.

  ✏️ Edit Prompt
  You can modify the prompt in the AI Agent node to include your name, work schedule, or specific behavior expectations.

  📆 Change Calendar Logic
  Adjust time ranges or filters in the Get Events node
  Add custom logic before Create Event (e.g., validation, conflict checks)

  📚 Helpful Tips

  Make sure n8n has HTTPS enabled to receive Telegram updates.
  You can test the flow first using only text, then voice.
  Use AI memory or vector stores (like Supabase) if you want context-aware planning in the future.

nodes_used:
  ["n8n-nodes-base.telegram","@n8n/n8n-nodes-langchain.agent","@n8n/n8n-nodes-langchain.lmChatOpenAi","@n8n/n8n-nodes-langchain.openAi"]

workflow_json:
  {"id":"X5xgTiDwTjqy8RqW","meta":{"instanceId":"fc43dbbe2855b618f22a32e0af198c70dc1ce7b2c715dfe283e581dd4cc1c13a","templateCredsSetupCompleted":true},"name":"Agent AI Calendar [n8n pro]","tags":[],"nodes":[{"id":"01b29a4c-25cf-4c03-ab87-810f070d4be3","name":"Create Event","type":"n8n-nodes-base.googleCalendarTool","position":[640,340],"parameters":{"end":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End', `Cand se termina evenimentul`, 'string') }}","start":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start', `Cand incepe evenimentul`, 'string') }}","calendar":{"__rl":true,"mode":"id","value":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Calendar', ``, 'string') }}","__regex":"(^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*)"},"additionalFields":{"description":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Description', ``, 'string') }}"},"useDefaultReminders":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Use_Default_Reminders', `Daca vrei sa folosesti reminderul defaul de la calendar sau vrei unul special`, 'boolean') }}"},"credentials":{"googleCalendarOAuth2Api":{"id":"27JiaYgdKeyU1SZC","name":"Google Calendar account"}},"typeVersion":1.3},{"id":"1758e2e3-e25d-4b1b-b57d-c711ec8553ce","name":"Get events","type":"n8n-nodes-base.googleCalendarTool","position":[760,340],"parameters":{"options":{},"timeMax":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Before', ``, 'string') }}","timeMin":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('After', ``, 'string') }}","calendar":{"__rl":true,"mode":"id","value":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Calendar', ``, 'string') }}","__regex":"(^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*)"},"operation":"getAll","returnAll":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}"},"credentials":{"googleCalendarOAuth2Api":{"id":"27JiaYgdKeyU1SZC","name":"Google Calendar account"}},"typeVersion":1.3},{"id":"9092f4dd-1982-4bb7-94f9-7f29e4fec6ef","name":"Update Calendar","type":"n8n-nodes-base.googleCalendarTool","position":[880,340],"parameters":{"eventId":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Event_ID', ``, 'string') }}","calendar":{"__rl":true,"mode":"id","value":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Calendar', ``, 'string') }}","__regex":"(^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*)"},"operation":"update","updateFields":{},"useDefaultReminders":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Use_Default_Reminders', ``, 'boolean') }}"},"credentials":{"googleCalendarOAuth2Api":{"id":"27JiaYgdKeyU1SZC","name":"Google Calendar account"}},"typeVersion":1.3},{"id":"738a78e0-6256-4827-aac9-9eaf7c6ae91c","name":"Detele Event","type":"n8n-nodes-base.googleCalendarTool","position":[1000,340],"parameters":{"eventId":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Event_ID', ``, 'string') }}","options":{},"calendar":{"__rl":true,"mode":"id","value":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Calendar', ``, 'string') }}","__regex":"(^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*)"},"operation":"delete"},"credentials":{"googleCalendarOAuth2Api":{"id":"27JiaYgdKeyU1SZC","name":"Google Calendar account"}},"typeVersion":1.3},{"id":"19674d23-67eb-46a1-a975-d64a64b6188a","name":"Receive User Input (Telegram)\t","type":"n8n-nodes-base.telegramTrigger","position":[-360,0],"webhookId":"19e39057-373f-4ca7-b999-c747d5f71767","parameters":{"updates":["message"],"additionalFields":{}},"credentials":{"telegramApi":{"id":"NYxlz922izZOpLZg","name":"Telegram account"}},"typeVersion":1.2},{"id":"0159ed56-542d-4fa1-867f-cba130466061","name":"Is Voice Message?\t","type":"n8n-nodes-base.if","position":[-80,0],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"c64b00ea-20f1-4d44-aed6-1528d537fc84","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.message.voice.mime_type }}","rightValue":"audio/ogg"}]}},"typeVersion":2.2},{"id":"008051e4-e006-4f18-a204-f64b322a4da6","name":"Download Voice File\t","type":"n8n-nodes-base.telegram","position":[140,-100],"webhookId":"1e904d77-b0a3-41ac-8624-a729103c9a14","parameters":{"fileId":"={{ $('Receive User Input (Telegram)\t').item.json.message.voice.file_id }}","resource":"file"},"credentials":{"telegramApi":{"id":"NYxlz922izZOpLZg","name":"Telegram account"}},"typeVersion":1.2},{"id":"e738c52a-d6b4-4fde-8dd8-2095db8eaf88","name":"Transcribe Voice to Text\t","type":"@n8n/n8n-nodes-langchain.openAi","position":[320,-100],"parameters":{"options":{"language":"en"},"resource":"audio","operation":"transcribe"},"credentials":{"openAiApi":{"id":"XYtY87CqnqwNVBos","name":"OpenAi account"}},"typeVersion":1.8},{"id":"5563f7c4-a87a-4728-a5ae-6e17ba59ff99","name":"Extract Text Message\t","type":"n8n-nodes-base.set","position":[140,100],"parameters":{"options":{},"assignments":{"assignments":[{"id":"41b525e6-a59f-47c7-b6ee-2b88eaa386fe","name":"Text","type":"string","value":"={{ $json.message.text }}"}]}},"typeVersion":3.4},{"id":"7ee11667-7834-464d-92e8-07be97f7f18a","name":"AI Calendar Assistant (LangChain)\t","type":"@n8n/n8n-nodes-langchain.agent","position":[520,100],"parameters":{"text":"=You're my personal digital assistant. Your purpose is to help me manage my personal calendar efficiently, taking into account priorities, work-life balance, and recurring events.\n\nToday is {{ $now }}\n\nInstructions:\n{{ $json.text }}\n{{ $json.Text }}","options":{},"promptType":"define"},"typeVersion":1.9},{"id":"8651b116-a5eb-4e21-b03f-5375efb0d8ed","name":"GPT-4 Language Model\t","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[360,340],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4.1","cachedResultName":"gpt-4.1"},"options":{}},"credentials":{"openAiApi":{"id":"XYtY87CqnqwNVBos","name":"OpenAi account"}},"typeVersion":1.2},{"id":"d014339d-7cb6-4bfe-bfbe-3f319a4fdf2c","name":"Send Response to Telegram\t","type":"n8n-nodes-base.telegram","position":[940,100],"webhookId":"b85c201f-13bd-4990-83e9-62c5e38fa8a4","parameters":{"text":"={{ $json.output }}","chatId":"={{ $('Receive User Input (Telegram)\t').item.json.message.chat.id }}","additionalFields":{"appendAttribution":false}},"credentials":{"telegramApi":{"id":"NYxlz922izZOpLZg","name":"Telegram account"}},"typeVersion":1.2},{"id":"6c74e5a0-56dc-4fbf-8826-fb1b16d96504","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-420,-740],"parameters":{"width":1600,"height":140,"content":"## Global Workflow Description\n  \n**\"AI-Powered Calendar Assistant: Voice & Text Input → GPT-4 → Google Calendar\"**  \n\n*Explains:* Built using Telegram, OpenAI (Whisper + GPT-4), and Google Calendar to help users manage events through natural language input."},"typeVersion":1},{"id":"5728ff55-e8c3-4b3f-9c85-0b111c1e18ec","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-420,-480],"parameters":{"height":320,"content":"## Start / Input\n\n**\"Start: Listen for Telegram input (text or voice message)\"**  \n \n*Explains:* This node triggers the workflow when a user sends a message via Telegram."},"typeVersion":1},{"id":"a2d2cdbf-ad34-4931-a4c9-ba79c89e09ac","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-140,-480],"parameters":{"width":200,"height":320,"content":"## Decision: Voice or Text\n \n**\"Check if the incoming message is a voice note (.ogg)\"**  \n\n*Explains:* If the message is a voice file, the workflow follows the transcription path. Otherwise, it processes the text directly."},"typeVersion":1},{"id":"92b826ed-4189-4d0e-911a-48ae3b44c45e","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[120,-480],"parameters":{"width":300,"height":320,"content":"## Voice Transcription\n \n**\"Download the voice file and transcribe it to text \"**  \n\n\n*Explains:* Uses OpenAI Whisper to convert voice messages to plain text."},"typeVersion":1},{"id":"fbdcd510-14b6-4d50-8fd7-352b421ac8a4","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[80,300],"parameters":{"height":240,"content":"## Text Extraction\n\n**\"Extract plain text from user’s message (if no voice)\"**  \n\n*Explains:* Gets the written message text for further processing."},"typeVersion":1},{"id":"76874498-00dc-499f-9930-8f02e143ad8d","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[440,500],"parameters":{"width":640,"height":360,"content":"## AI Interpretation\n\n**\"Analyze user intent using GPT-4 and decide next calendar action\"**  \n\n*Explains:* AI determines whether the user wants to create, update, fetch, or delete a calendar event.\n\n## Google Calendar Actions\n\n**\"Perform the selected Google Calendar action (Create / Update / Fetch / Delete)\"**  \n\n*Explains:* Executes the action chosen by the AI assistant using dynamic values."},"typeVersion":1},{"id":"7d55eed3-9715-4759-a806-e6d56e38f892","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[820,-220],"parameters":{"width":340,"height":240,"content":"## Send Response\n\n**\"Send a confirmation or result message back to the user\"**  \n\n*Explains:* Closes the loop by replying with the output from the assistant."},"typeVersion":1}],"active":false,"settings":{"executionOrder":"v1"},"versionId":"bca5c9d1-8464-47a8-aa76-0b864ef17a3f","connections":{"Get events":{"ai_tool":[[{"node":"AI Calendar Assistant (LangChain)\t","type":"ai_tool","index":0}]]},"Create Event":{"ai_tool":[[{"node":"AI Calendar Assistant (LangChain)\t","type":"ai_tool","index":0}]]},"Detele Event":{"ai_tool":[[{"node":"AI Calendar Assistant (LangChain)\t","type":"ai_tool","index":0}]]},"Update Calendar":{"ai_tool":[[{"node":"AI Calendar Assistant (LangChain)\t","type":"ai_tool","index":0}]]},"Is Voice Message?\t":{"main":[[{"node":"Download Voice File\t","type":"main","index":0}],[{"node":"Extract Text Message\t","type":"main","index":0}]]},"Download Voice File\t":{"main":[[{"node":"Transcribe Voice to Text\t","type":"main","index":0}]]},"Extract Text Message\t":{"main":[[{"node":"AI Calendar Assistant (LangChain)\t","type":"main","index":0}]]},"GPT-4 Language Model\t":{"ai_languageModel":[[{"node":"AI Calendar Assistant (LangChain)\t","type":"ai_languageModel","index":0}]]},"Transcribe Voice to Text\t":{"main":[[{"node":"AI Calendar Assistant (LangChain)\t","type":"main","index":0}]]},"Send Response to Telegram\t":{"main":[[]]},"Receive User Input (Telegram)\t":{"main":[[{"node":"Is Voice Message?\t","type":"main","index":0}]]},"AI Calendar Assistant (LangChain)\t":{"main":[[{"node":"Send Response to Telegram\t","type":"main","index":0}]]}}}


name: Generate Invoices, Save to Drive and Send Email to Customer with JS + G Sheets
author_name: Joseph
author_username: mjomba
categories: []
created_at: 2025-05-16T11:59:58.245Z
updated_at: 2025-05-16T11:59:58.245Z
url: https://n8n.io/workflows/4105
scraped_at: 2025-07-06 21:16:30
description:
  This workflow automates invoice generation from form submissions, ensuring unique order IDs, creating PDF invoices, storing files, emailing customers, and logging invoice data — all seamlessly integrated.

  🔹 Workflow Overview

  Trigger (Webhook)
     Starts when an order form is submitted, capturing customer and order details.

  Generate Random Order ID
     A Function node creates a unique alphanumeric invoice ID (e.g., INV-X92B7D).

  Check for Duplicate Order ID
     Google Sheets looks up the generated order ID in your invoice log sheet to prevent duplicates.

  Conditional Check (IF Node)

     If the ID already exists → regenerates a new ID (loops back)
     If unique → proceeds to invoice creation

  Prepare Invoice Data
     A Set node formats customer info, date, order items, and the unique order ID to fit your invoice template.

  Convert HTML to PDF
     HTTP Request node sends your invoice HTML to the RapidAPI HTML-to-PDF service and receives the PDF file.

  Upload PDF to Cloud Storage
     Save the PDF in Google Drive or Dropbox with a clear file name like Invoice-INV-X92B7D.pdf.

  Send Invoice Email to Customer
     Email node attaches the PDF and includes the order ID in the email subject/body.

  Log Invoice Details
     Append invoice data (customer info, order ID, total, PDF link) to your Google Sheet for tracking.

  ⚙️ Node Details & Setup

  1. Webhook Trigger

  Configure to receive form submissions (order details like name, email, items, total).

  2. Function: Generate Random Order ID

  Sample JS code generates unique IDs prefixed by INV-.

  3. Google Sheets: Lookup Row

  Set up connection to your invoice log sheet.
  Search for existing order ID to avoid duplicates.

  4. IF Node: Check Order ID Existence

  Condition: If order ID found → loop to regenerate.
  Else → continue workflow.

  5. Set Node: Prepare Invoice HTML

  Define variables like customer name, date, items, and order ID.
  This data populates your HTML invoice template.

  6. HTTP Request: Convert HTML to PDF

  API URL to get your key
  Send invoice HTML in the request body.
  Receive PDF file blob or download URL.

  7. Google Drive (or Dropbox) Upload

  Upload the PDF file.
  Use file name format: Invoice-{{$json["order_id"]}}.pdf

  8. Email Node

  Recipient: customer email from the form data.
  Attach generated PDF.
  Include order ID in email subject or body for reference.

  9. Google Sheets: Append Row

  Log invoice metadata to keep records updated.

  📁 Google Sheets Template

  You can make a copy of the invoice log template here

  This sheet includes columns for order\_id, customer name, email, total, and invoice PDF link. Customize it as needed.

  📌 Additional Notes

  Customize the invoice HTML template inside the Set node to match your branding.
  Ensure API credentials for RapidAPI, Google Drive/Dropbox, and email are properly set up in your n8n credentials.
  You can expand this workflow by adding payment processing or SMS notifications.

  Need help or want a custom workflow?

  Reach out via email at joseph@uppfy.com.

nodes_used:
  ["n8n-nodes-base.emailSend","n8n-nodes-base.googleSheets","n8n-nodes-base.httpRequest","n8n-nodes-base.googleDrive","n8n-nodes-base.code"]

workflow_json:
  {"id":"K4XpJbwBJYnDiYkF","meta":{"instanceId":"b3c467df4053d13fe31cc98f3c66fa1d16300ba750506bfd019a0913cec71ea3","templateCredsSetupCompleted":true},"name":"Generate Invoices","tags":[],"nodes":[{"id":"e56cbf88-1e0d-4dd7-a269-091ad2ce8420","name":"Webhook Simulator","type":"n8n-nodes-base.webhook","position":[-240,20],"webhookId":"7f884a07-861e-49da-bb0e-1ac6ca40ea00","parameters":{"path":"7f884a07-861e-49da-bb0e-1ac6ca40ea00","options":{}},"typeVersion":2},{"id":"b01307f7-b5cb-421e-833a-0889925bb09c","name":"Generate Invoice ID","type":"n8n-nodes-base.code","position":[-20,20],"parameters":{"jsCode":"function generateOrderID(length = 6) {\n  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';\n  let result = 'INV-';\n  for (let i = 0; i < length; i++) {\n    result += chars.charAt(Math.floor(Math.random() * chars.length));\n  }\n  return result;\n}\n\nreturn [\n  {\n    json: {\n      order_id: generateOrderID()\n    }\n  }\n];\n"},"typeVersion":2},{"id":"bf50ca10-4021-4e6f-9c08-56fd84ce13ed","name":"Check if ID Already Exists","type":"n8n-nodes-base.googleSheets","position":[200,20],"parameters":{"options":{},"filtersUI":{"values":[{"lookupValue":"={{ $json.order_id }}","lookupColumn":"Invoice ID"}]},"sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1QW_Lg1aoEBku8GaxwPbZfBY5ITAuSdvoAXRyNdCEujM/edit#gid=0","cachedResultName":"Invoices"},"documentId":{"__rl":true,"mode":"list","value":"1QW_Lg1aoEBku8GaxwPbZfBY5ITAuSdvoAXRyNdCEujM","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1QW_Lg1aoEBku8GaxwPbZfBY5ITAuSdvoAXRyNdCEujM/edit?usp=drivesdk","cachedResultName":"Uppfy Shop Invoices"}},"credentials":{"googleSheetsOAuth2Api":{"id":"d0qeLhShx9sGXalR","name":"Google Sheets"}},"typeVersion":4.5,"alwaysOutputData":true},{"id":"c63871fa-ca0f-4069-ac0d-422d39018a9e","name":"If Does not Exist","type":"n8n-nodes-base.if","position":[420,20],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"loose"},"combinator":"and","conditions":[{"id":"cee7659a-cea3-494a-b4f3-c76d035a3a32","operator":{"type":"string","operation":"empty","singleValue":true},"leftValue":"={{ $json.row_number }}","rightValue":""}]},"looseTypeValidation":true},"typeVersion":2.2},{"id":"feb9ed84-a62c-4cec-bf36-b53a76711bcd","name":"Set Fields","type":"n8n-nodes-base.set","position":[740,-140],"parameters":{"options":{},"assignments":{"assignments":[{"id":"1bd457b4-2c15-433a-96b3-5fabb8566866","name":"order_id","type":"string","value":"={{ $('Generate Invoice ID').item.json.order_id }}"},{"id":"15c51334-b127-485e-9be4-051b086d74b2","name":"customer_name","type":"string","value":"={{ $('Webhook Simulator').item.json.customer_name }}"},{"id":"8c4f2d5c-09c8-4b8c-a77f-ab3c1d752c13","name":"customer_email","type":"string","value":"={{ $('Webhook Simulator').item.json.customer_email }}"},{"id":"ea1bbfe4-c12d-450f-9bee-fff8710eed42","name":"products","type":"array","value":"={{ $('Webhook Simulator').item.json.products }}"},{"id":"025d0783-7eb0-4ac4-b373-39f744692cfd","name":"total","type":"number","value":"={{ $('Webhook Simulator').item.json.total }}"}]}},"typeVersion":3.4},{"id":"0532fa4b-cdd9-4857-8701-6a5baf48fd7c","name":"Create Invoice HTML","type":"n8n-nodes-base.code","position":[740,100],"parameters":{"jsCode":"const { order_id, customer_name, customer_email, products, total } = $json;\n\n// Format products table rows\nconst productRows = products.map((item, index) => {\n  const subtotal = item.quantity * item.price;\n  return `\n    <tr>\n      <td style=\"padding: 8px; border: 1px solid #ccc;\">${index + 1}</td>\n      <td style=\"padding: 8px; border: 1px solid #ccc;\">${item.name}</td>\n      <td style=\"padding: 8px; border: 1px solid #ccc;\">${item.quantity}</td>\n      <td style=\"padding: 8px; border: 1px solid #ccc;\">$${item.price.toFixed(2)}</td>\n      <td style=\"padding: 8px; border: 1px solid #ccc;\">$${subtotal.toFixed(2)}</td>\n    </tr>\n  `;\n}).join('');\n\nconst html = `\n<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <title>Invoice ${order_id}</title>\n</head>\n<body style=\"font-family: Arial, sans-serif; color: #333; max-width: 700px; margin: auto; padding: 20px; border: 1px solid #ddd;\">\n  <h2 style=\"text-align: center;\">Invoice</h2>\n  <p><strong>Order ID:</strong> ${order_id}</p>\n  <p><strong>Customer Name:</strong> ${customer_name}</p>\n  <p><strong>Email:</strong> ${customer_email}</p>\n\n  <table style=\"width: 100%; border-collapse: collapse; margin-top: 20px;\">\n    <thead>\n      <tr>\n        <th style=\"padding: 8px; border: 1px solid #ccc;\">#</th>\n        <th style=\"padding: 8px; border: 1px solid #ccc;\">Product</th>\n        <th style=\"padding: 8px; border: 1px solid #ccc;\">Qty</th>\n        <th style=\"padding: 8px; border: 1px solid #ccc;\">Unit Price</th>\n        <th style=\"padding: 8px; border: 1px solid #ccc;\">Subtotal</th>\n      </tr>\n    </thead>\n    <tbody>\n      ${productRows}\n    </tbody>\n    <tfoot>\n      <tr>\n        <td colspan=\"4\" style=\"text-align: right; padding: 8px; border: 1px solid #ccc;\"><strong>Total:</strong></td>\n        <td style=\"padding: 8px; border: 1px solid #ccc;\"><strong>$${total.toFixed(2)}</strong></td>\n      </tr>\n    </tfoot>\n  </table>\n\n  <p style=\"margin-top: 40px; text-align: center;\">Thank you for your order!</p>\n</body>\n</html>\n`;\n\nreturn [\n  {\n    json: {\n      html\n    }\n  }\n];\n"},"typeVersion":2},{"id":"5a3adb6a-9f64-477e-9622-3d2b9ef2e6de","name":"HTML to PDF","type":"n8n-nodes-base.httpRequest","position":[-20,320],"parameters":{"url":"https://html2pdf2.p.rapidapi.com/html2pdf","method":"POST","options":{},"sendBody":true,"sendHeaders":true,"bodyParameters":{"parameters":[{"name":"html","value":"={{ $json.html }}"}]},"headerParameters":{"parameters":[{"name":"x-rapidapi-host","value":"html2pdf2.p.rapidapi.com"},{"name":"x-rapidapi-key","value":"\"your_rapid_api_key\""}]}},"typeVersion":4.2},{"id":"cebf6d0d-d43f-4e50-abc0-79ff8da1817a","name":"Upload PDF to GDrive","type":"n8n-nodes-base.googleDrive","position":[420,320],"parameters":{"name":"={{ $('Set Fields').item.json.order_id }} - {{ $('Set Fields').item.json.customer_name }}","driveId":{"__rl":true,"mode":"list","value":"My Drive"},"options":{},"folderId":{"__rl":true,"mode":"list","value":"root","cachedResultName":"/ (Root folder)"}},"credentials":{"googleDriveOAuth2Api":{"id":"l8Cc2MEVE7foBfbK","name":"Google Drive account"}},"typeVersion":3},{"id":"b181eddc-e786-4d44-a334-e1b581b3981f","name":"Email Invoice to Customer","type":"n8n-nodes-base.emailSend","position":[640,320],"webhookId":"cdc852fc-03b9-4a89-ba56-879064da5cbb","parameters":{"html":"=Hello  {{ $('Set Fields').item.json.customer_name }},\n\nPlease pay this invoice\n\n\n{{ $('Create Invoice HTML').item.json.html }}\n\n\n<!DOCTYPE html>\n<html>\n<head>\n    <style>\n        .button {\n            display: inline-block;\n            background-color: #4CAF50;\n            border: none;\n            border-radius: 4px;\n            color: white;\n            padding: 15px 32px;\n            text-align: center;\n            text-decoration: none;\n            font-size: 16px;\n            font-weight: bold;\n            margin: 4px 2px;\n            cursor: pointer;\n            font-family: Arial, sans-serif;\n        }\n    </style>\n</head>\n<body>\n    <div style=\"text-align: center;\">\n        <a href=\"YOUR_PAYMENT_LINK_HERE\" class=\"button\">Pay Now</a>\n    </div>\n</body>\n</html>\n\n","options":{"appendAttribution":false},"subject":"={{ $('Set Fields').item.json.order_id }} - New Invoice from Uppfy Shop ","toEmail":"={{ $('Set Fields').item.json.customer_email }}","fromEmail":"Uppfy Shop <your_from_email>"},"credentials":{"smtp":{"id":"xcnAVXwtuOa1IOqE","name":"SMTP account"}},"typeVersion":2.1},{"id":"883e32b6-a812-44c8-b525-97e819af90bd","name":"Append Details to Invoices Sheet","type":"n8n-nodes-base.googleSheets","position":[860,320],"parameters":{"columns":{"value":{"Status":"Unpaid","Invoice ID":"={{ $('Set Fields').item.json.order_id }}","Invoice URL":"={{ $('Upload PDF to GDrive').item.json.webViewLink }}","Invoice Amt.":"=${{ $('Set Fields').item.json.total }}","Customer Name":"={{ $('Set Fields').item.json.customer_name }}","Customer Email":"={{ $('Set Fields').item.json.customer_email }}"},"schema":[{"id":"Invoice ID","type":"string","display":true,"removed":false,"required":false,"displayName":"Invoice ID","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Customer Name","type":"string","display":true,"removed":false,"required":false,"displayName":"Customer Name","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Customer Email","type":"string","display":true,"removed":false,"required":false,"displayName":"Customer Email","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Invoice Amt.","type":"string","display":true,"required":false,"displayName":"Invoice Amt.","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Invoice URL","type":"string","display":true,"required":false,"displayName":"Invoice URL","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Status","type":"string","display":true,"required":false,"displayName":"Status","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":["Invoice ID"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"appendOrUpdate","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1QW_Lg1aoEBku8GaxwPbZfBY5ITAuSdvoAXRyNdCEujM/edit#gid=0","cachedResultName":"Invoices"},"documentId":{"__rl":true,"mode":"list","value":"1QW_Lg1aoEBku8GaxwPbZfBY5ITAuSdvoAXRyNdCEujM","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1QW_Lg1aoEBku8GaxwPbZfBY5ITAuSdvoAXRyNdCEujM/edit?usp=drivesdk","cachedResultName":"Uppfy Shop Invoices"}},"credentials":{"googleSheetsOAuth2Api":{"id":"d0qeLhShx9sGXalR","name":"Google Sheets"}},"typeVersion":4.5},{"id":"cd06d6c9-903d-4af8-8327-eb36ba3bc73a","name":"Download PDF from API","type":"n8n-nodes-base.httpRequest","position":[200,320],"parameters":{"url":" https://rhodium-tecnologia-html2pdf.s3.amazonaws.com/public/pdfs/1747392997249.pdf","options":{}},"typeVersion":4.2},{"id":"7d308e22-9b2d-4993-8aad-cc701303d38d","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-280,-160],"parameters":{"width":180,"height":320,"content":"## Pinned Data to Simulate Webhook Query"},"typeVersion":1}],"active":false,"settings":{"executionOrder":"v1"},"versionId":"dec45f2b-cb36-4f86-a8cc-d3c498ae7aa2","connections":{"Set Fields":{"main":[[{"node":"Create Invoice HTML","type":"main","index":0}]]},"HTML to PDF":{"main":[[{"node":"Download PDF from API","type":"main","index":0}]]},"If Does not Exist":{"main":[[{"node":"Set Fields","type":"main","index":0}],[{"node":"Generate Invoice ID","type":"main","index":0}]]},"Webhook Simulator":{"main":[[{"node":"Generate Invoice ID","type":"main","index":0}]]},"Create Invoice HTML":{"main":[[{"node":"HTML to PDF","type":"main","index":0}]]},"Generate Invoice ID":{"main":[[{"node":"Check if ID Already Exists","type":"main","index":0}]]},"Upload PDF to GDrive":{"main":[[{"node":"Email Invoice to Customer","type":"main","index":0}]]},"Download PDF from API":{"main":[[{"node":"Upload PDF to GDrive","type":"main","index":0}]]},"Email Invoice to Customer":{"main":[[{"node":"Append Details to Invoices Sheet","type":"main","index":0}]]},"Check if ID Already Exists":{"main":[[{"node":"If Does not Exist","type":"main","index":0}]]}}}


name: Create AI Videos with OpenAI Scripts, Leonardo Images & HeyGen Avatars
author_name: Adam Crafts
author_username: adamcrafts
categories: []
created_at: 2025-05-16T14:23:39.655Z
updated_at: 2025-05-16T14:23:39.655Z
url: https://n8n.io/workflows/4107
scraped_at: 2025-07-06 21:16:30
description:
  Short Content Automation 🎬 (AI Video System with Bulk Gen, Avatar & Music Customization)

  Overview 🎯

  The "Short Content" automation is a powerful, all-in-one solution designed to streamline the creation of short videos for social media, marketing, or personal projects. Leveraging cutting-edge AI tools and seamless workflows, this automation handles everything from scriptwriting to video assembly—saving time and effort while delivering professional results.


      
        Best Short Content AI System - Watch Video
  Problem 🛠️

  Creating short videos manually is time-consuming and expensive. Businesses and creators struggle with:

  Hiring writers, designers, and editors.  
  Juggling multiple tools for scripts, visuals, and editing.  
  Inconsistent quality and slow turnaround times.  

  This automation solves these challenges with a fully AI-driven, one-click workflow.

  Solution ✅

  A no-code, end-to-end automation that:

  Writes scripts using AI (LLM) or manual input.  
  Generates visuals (Leonardo AI) or acting scenes (RunwayML).  
  Edits and assembles videos (JSON2Video).  
  Generates avatars using HeyGen or Captions.ai.  
  Tracks progress and analytics in Baserow.  

  🔥 Result:  
  High-quality short videos in minutes, not days—with zero manual effort.

  Setup ⚙️ (4–8 minutes)

  Upload Blueprint to N8N  
     Import the provided JSON workflow into your N8N instance.

  Upload Database to Baserow (Free)  
  Follow the setup video step-by-step.

  How It Works 🌟

  Start with a Pre-Built Form  
     Fill in the included Baserow form with your video requirements.

  Generate Videos Instantly  
     Single Video Mode: Run one video at a time for quick results.  
     Bulk Mode: Upload a CSV or use Baserow to queue unlimited videos—perfect for scaling content.

  Workflow Handles the Rest  

  Manage & Iterate  
     Track all videos in Baserow: Edit inputs, retry failed jobs, or adjust styles anytime.

  What’s Included 📦

  ✅ Baserow Template: Pre-configured database.  
  ✅ N8N JSON Blueprint: Ready-to-use workflow.  
  ✅ Step-by-Step Video Guides: Setup & usage instructions.

  Customization 🎨

  🔧 Video Generation Customization

  Script Options**: Auto-generate using AI or write manually.  
  Captions**: Customize type, color, and style.  
  Video Types**: Storytelling, trends, educational, etc.  
  Audio**: Add background music easily.  
  Avatars**:  
    Switch between HeyGen and Captions.ai.  
    Adjust size, position, voice, and appearance.

  ⚙️ System Customization

  N8N Workflow**: Easily customizable for new integrations, prompts, and logic.  
  Baserow Database**: Modify options or add new ones to match your workflow.

  🌐 Explore more workflows

  ❤️ Buy more workflows at: adamcrafts
  🦾 Custom workflows at: adamcrafts@cloudysoftwares.com

  &gt; Build once, customize endlessly, and scale your video content like never before. 🚀

nodes_used:
  ["n8n-nodes-base.httpRequest","n8n-nodes-base.baserow","n8n-nodes-base.code","@n8n/n8n-nodes-langchain.chainLlm","@n8n/n8n-nodes-langchain.lmChatOpenAi","@n8n/n8n-nodes-langchain.outputParserStructured"]

workflow_json:
  {"meta":{"instanceId":"2d54f61dfd963457efb86a8690aae457934e92fb9e4b8b6490ca74fc37094458","templateCredsSetupCompleted":true},"nodes":[{"id":"552f4aea-6eba-4ef3-a15a-5803a25ed701","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[-4060,260],"parameters":{"content":""},"typeVersion":1},{"id":"e70c19bc-c100-4c4e-bb0c-3480bf43b82e","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-2380,-240],"parameters":{"content":""},"typeVersion":1},{"id":"e51cd6c7-872a-48b8-a6b7-ac47f35a409a","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-1180,1240],"parameters":{"content":""},"typeVersion":1},{"id":"1edeb5fc-2774-46ed-a4f8-c4ac3f3a9ac7","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-700,540],"parameters":{"content":""},"typeVersion":1},{"id":"aa0dff4d-a840-45e0-8de9-fcd170be08d2","name":"Should Process?","type":"n8n-nodes-base.if","position":[-4680,860],"parameters":{},"typeVersion":1},{"id":"1b62d439-f82e-432b-a1bc-5b73abc8b5e6","name":"Switch ScriptType","type":"n8n-nodes-base.switch","position":[-4460,960],"parameters":{},"typeVersion":3.2},{"id":"df9759eb-5511-4323-86b8-7d40bb0e43e9","name":"Basic LLM Chain","type":"@n8n/n8n-nodes-langchain.chainLlm","onError":"continueErrorOutput","position":[-4020,460],"parameters":{},"typeVersion":1.5},{"id":"8ff00af2-cb59-4a48-8504-1e388f00d8c3","name":"If","type":"n8n-nodes-base.if","position":[-4240,1160],"parameters":{},"typeVersion":2.2},{"id":"3ccaa3f8-51b7-44f9-83b2-0ad7fb291596","name":"Body","type":"n8n-nodes-base.set","position":[-4900,860],"parameters":{},"typeVersion":3.4},{"id":"d78562f1-6236-4aa8-81dc-741c82d2b9ea","name":"Structured Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[-3872,1130],"parameters":{},"typeVersion":1.2},{"id":"42276de0-b0f6-490e-9fba-28008e01293b","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-3932,680],"parameters":{},"typeVersion":1.2},{"id":"11c7ba76-0b22-4dfd-b063-dbfc2cf1d582","name":"Leo - Improve Prompt","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[-2984,110],"parameters":{},"typeVersion":4.2},{"id":"8d813e38-4689-4102-9a84-322e57573e72","name":"Leo - Get imageId","type":"n8n-nodes-base.httpRequest","position":[-2324,-90],"parameters":{},"typeVersion":4.2},{"id":"759c964b-560e-476c-9948-041d781d7225","name":"Leo - Generate Image","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[-2764,10],"parameters":{},"notesInFlow":false,"typeVersion":4.2},{"id":"7ba0fa55-3a4a-45ce-bf84-7b0695014e1f","name":"Wait1","type":"n8n-nodes-base.wait","position":[-2544,-90],"webhookId":"ae4c943c-3a67-4532-8fc5-3f0b5c1e9cd3","parameters":{},"typeVersion":1.1},{"id":"8e770b9e-44c3-4d6f-b816-04a141dcea1b","name":"Scenes Mapping","type":"n8n-nodes-base.set","position":[-3644,710],"parameters":{},"typeVersion":3.4},{"id":"eb75b3e1-7945-47cb-99a3-b123d4509840","name":"Split Out","type":"n8n-nodes-base.splitOut","position":[-3424,710],"parameters":{},"typeVersion":1},{"id":"9d1a5b5a-e6f9-4e0b-b0ab-c5d00a42b933","name":"Runway - Create Video","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[-1884,-190],"parameters":{},"typeVersion":4.2},{"id":"e6e34dd1-14b9-457a-94d7-d649df9bf6fa","name":"Runway - Get Video","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[-1444,-290],"parameters":{},"typeVersion":4.2},{"id":"9e5b3314-5ff5-40d5-b25b-650b2b86b673","name":"Wait2","type":"n8n-nodes-base.wait","position":[-1664,-290],"webhookId":"1d9b1044-08ca-446c-a290-e1e28d356402","parameters":{},"typeVersion":1.1},{"id":"9122333a-9cbd-4e05-a071-fa63237abc70","name":"loop_over_scenes","type":"n8n-nodes-base.splitInBatches","position":[-3204,710],"parameters":{},"typeVersion":3},{"id":"12e3944f-bf50-452a-a566-e21e37b8ae8c","name":"Code","type":"n8n-nodes-base.code","position":[-2764,910],"parameters":{},"typeVersion":2},{"id":"87281d2b-c75b-442c-b7b4-069e9b547c3b","name":"Wait","type":"n8n-nodes-base.wait","position":[-1004,835],"webhookId":"5cac0c0c-2373-410d-a4fa-93631e4f7a16","parameters":{},"typeVersion":1.1},{"id":"1d14b153-cf53-4bb8-bc48-500d407f1136","name":"json2video : Video Rendering","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[-1224,835],"parameters":{},"typeVersion":4.2},{"id":"e85203de-a496-4424-92cf-6702be3107fd","name":"json2video : Check Video Rendering","type":"n8n-nodes-base.httpRequest","position":[-784,785],"parameters":{},"typeVersion":4.2},{"id":"1f7e969a-9eb0-4d34-8bee-cc412794757a","name":"Baserow","type":"n8n-nodes-base.baserow","position":[-344,760],"parameters":{},"typeVersion":1},{"id":"8c3c9f77-c674-4082-8417-d218e4c1f146","name":"Baserow Processing","type":"n8n-nodes-base.baserow","position":[-4460,760],"parameters":{},"typeVersion":1},{"id":"f051222a-69de-488b-95ee-8ddba38cfecc","name":"output","type":"n8n-nodes-base.set","position":[-1224,510],"parameters":{},"typeVersion":3.4},{"id":"4ccc7e0b-95a8-4bf8-9328-914796d04e5f","name":"Update Script","type":"n8n-nodes-base.baserow","position":[-3644,510],"parameters":{},"typeVersion":1},{"id":"1ac9cf4f-2ea5-4901-8021-daa1aaebe526","name":"BackgroundType","type":"n8n-nodes-base.if","position":[-2104,-90],"parameters":{},"typeVersion":2.2},{"id":"3f4cfe61-ad21-4306-b510-ff5a6cdc9c6a","name":"output image","type":"n8n-nodes-base.set","position":[-1884,10],"parameters":{},"typeVersion":3.4},{"id":"ae0c2d35-18f4-4360-a61d-d5c40624864e","name":"Execute Workflow2","type":"n8n-nodes-base.executeWorkflow","position":[-1664,-90],"parameters":{},"typeVersion":1.2},{"id":"53ee6f59-3e74-4dbf-9655-4557f2e3dd80","name":"Execute Workflow3","type":"n8n-nodes-base.executeWorkflow","position":[-2544,110],"parameters":{},"typeVersion":1.2},{"id":"3cc71591-718c-48c5-a81f-903bc27703a7","name":"Execute Workflow4","type":"n8n-nodes-base.executeWorkflow","position":[-3600,880],"parameters":{},"typeVersion":1.2},{"id":"ffba25bf-ebfb-437c-88a9-baffa9183ad2","name":"HeyGen","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[-2324,985],"parameters":{},"typeVersion":4.2},{"id":"0f0c91ed-3a81-4add-9219-fb0b2b769592","name":"Wait4","type":"n8n-nodes-base.wait","position":[-2104,885],"webhookId":"d2c37f01-834e-40d3-888e-6e7e4296f474","parameters":{},"typeVersion":1.1},{"id":"e2144fa4-4a79-4203-8690-7fc3654aa2aa","name":"HeyGen : Check Video","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[-1884,810],"parameters":{},"typeVersion":4.2},{"id":"5e3c03f0-2688-48e2-88f9-8c56cb2bcd82","name":"heygen_response","type":"n8n-nodes-base.switch","position":[-1664,885],"parameters":{},"typeVersion":3.2},{"id":"f1fe987d-97f3-4f86-b160-1ec019db8ba9","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-2160,1300],"parameters":{"content":""},"typeVersion":1},{"id":"ecd90ffe-b4f3-4895-858e-f2dbbc758f3f","name":"Wait6","type":"n8n-nodes-base.wait","position":[-2104,285],"webhookId":"1ae300a3-2b49-4ee0-9817-9d29692d7bd8","parameters":{},"typeVersion":1.1},{"id":"7f2db63c-6ccd-427b-976d-788906acaffa","name":"CaptionsAI1","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[-2324,385],"parameters":{},"typeVersion":4.2},{"id":"ef6d1fda-f589-4a80-bef9-6b58a0c7be4c","name":"CaptionsAI : Check Poll1","type":"n8n-nodes-base.httpRequest","position":[-1884,210],"parameters":{},"typeVersion":4.2},{"id":"704dc30e-92d7-4fbf-84f7-fa28c8e3c800","name":"Aggregate","type":"n8n-nodes-base.aggregate","position":[-2544,385],"parameters":{},"typeVersion":1},{"id":"7fa5ee4a-b331-44e3-8eac-bb51a1640f02","name":"j2v_response","type":"n8n-nodes-base.switch","position":[-564,835],"parameters":{},"typeVersion":3.2},{"id":"4bf31cad-30ba-4111-82c6-543c8270ba78","name":"json2video Execute ERROR","type":"n8n-nodes-base.executeWorkflow","position":[-1004,1035],"parameters":{},"typeVersion":1.2},{"id":"2b7f8cf6-e72f-4709-8384-470be9018a58","name":"json2video Execute ERROR1","type":"n8n-nodes-base.executeWorkflow","position":[-344,960],"parameters":{},"typeVersion":1.2},{"id":"000f4384-59f2-45cc-8ac7-947578faf961","name":"CAPTIONS Execute ERROR","type":"n8n-nodes-base.executeWorkflow","position":[-1444,385],"parameters":{},"typeVersion":1.2},{"id":"8c0f1519-7c15-4753-a3a4-e0ea7bdecd91","name":"cap_response","type":"n8n-nodes-base.switch","position":[-1664,285],"parameters":{},"typeVersion":3.2},{"id":"ca2a0e83-1945-44da-88db-fd43f7abdd01","name":"Code Add Sub","type":"n8n-nodes-base.code","position":[-1444,10],"parameters":{},"typeVersion":2},{"id":"32919f30-7192-4fe9-a8c0-5056f23930da","name":"Execute Workflow","type":"n8n-nodes-base.executeWorkflow","position":[-3942,1310],"parameters":{},"typeVersion":1.2},{"id":"0d2c27de-ced5-4717-bd69-120cdca0c404","name":"Code Heygen","type":"n8n-nodes-base.code","position":[-1444,885],"parameters":{},"typeVersion":2},{"id":"49cbb913-b8d8-407b-aba1-772b183fc2cb","name":"Webhook","type":"n8n-nodes-base.webhook","position":[-5120,860],"webhookId":"9dc1daa9-0cc3-4171-bd2c-f334afe7f786","parameters":{},"typeVersion":2},{"id":"ece27b23-6adb-4bde-bd27-16f9c52074b1","name":"If_with_heygen","type":"n8n-nodes-base.if","position":[-2544,910],"parameters":{},"typeVersion":2.2},{"id":"4b574962-192a-4896-9b20-d1a1a6a2dba9","name":"If_with_avatar","type":"n8n-nodes-base.if","position":[-2984,785],"parameters":{},"typeVersion":2.2},{"id":"17443565-19e6-4f87-b3d0-ae760ef2e9c0","name":"heygen Execute ERROR","type":"n8n-nodes-base.executeWorkflow","position":[-2104,1110],"parameters":{},"typeVersion":1.2},{"id":"db4608b4-de96-4fca-8015-9a529c5d7ec2","name":"heygen Execute ERROR2","type":"n8n-nodes-base.executeWorkflow","position":[-1664,1085],"parameters":{},"typeVersion":1.2},{"id":"59b0d81e-47dd-4142-9e4f-2720d3ab4cd2","name":"Execute Workflow5","type":"n8n-nodes-base.executeWorkflow","position":[-2764,235],"parameters":{},"typeVersion":1.2},{"id":"5907b590-cb1a-40f2-973a-c267f4f2a618","name":"CAPTIONS Execute ERROR1","type":"n8n-nodes-base.executeWorkflow","position":[-2104,485],"parameters":{},"typeVersion":1.2},{"id":"5003eb72-ccaf-4397-b222-74520118b710","name":"Execute Workflow6","type":"n8n-nodes-base.executeWorkflow","position":[-1224,-340],"parameters":{},"typeVersion":1.2},{"id":"d7bfd001-f3e7-4615-9cb4-c999f85796b4","name":"Basic LLM Chain Manual","type":"@n8n/n8n-nodes-langchain.chainLlm","onError":"continueErrorOutput","position":[-4020,910],"parameters":{},"typeVersion":1.5},{"id":"7d14ce33-6879-4fbf-8c4d-741dc0199fd8","name":"OpenAI Chat Model1","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-3992,1130],"parameters":{},"typeVersion":1.2},{"id":"0cd3ffe5-17c2-4036-93ff-f26366905418","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-5280,-380],"parameters":{"content":""},"typeVersion":1},{"id":"2dc14abe-5ce2-47dd-95a3-a53e0cc3ba3d","name":"Baserow Error","type":"n8n-nodes-base.baserow","position":[-4900,1280],"parameters":{},"typeVersion":1},{"id":"ec2f48d4-fe85-4395-b6e0-6944a169f405","name":"Stop and Error","type":"n8n-nodes-base.stopAndError","position":[-4680,1280],"parameters":{},"typeVersion":1},{"id":"b57d294a-0872-43b4-9477-84f72990adb4","name":"When Executed by Another Workflow","type":"n8n-nodes-base.executeWorkflowTrigger","position":[-5120,1280],"parameters":{},"typeVersion":1.1},{"id":"2410ae4a-e42b-41de-b5a6-fcef0726918a","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-5160,1160],"parameters":{"content":""},"typeVersion":1},{"id":"8105cbf3-f289-4de6-b39a-db9ba5a8b85d","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[-4640,-380],"parameters":{"content":""},"typeVersion":1},{"id":"9e42ccf0-a874-4171-bea5-54647a79fb93","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[-1880,520],"parameters":{"content":""},"typeVersion":1}],"connections":{"If":{"main":[[{"node":"Basic LLM Chain Manual","type":"main","index":0}],[{"node":"Execute Workflow","type":"main","index":0}]]},"Body":{"main":[[{"node":"Should Process?","type":"main","index":0}]]},"Code":{"main":[[{"node":"If_with_heygen","type":"main","index":0}]]},"Wait":{"main":[[{"node":"json2video : Check Video Rendering","type":"main","index":0}]]},"Wait1":{"main":[[{"node":"Leo - Get imageId","type":"main","index":0}]]},"Wait2":{"main":[[{"node":"Runway - Get Video","type":"main","index":0}]]},"Wait4":{"main":[[{"node":"HeyGen : Check Video","type":"main","index":0}]]},"Wait6":{"main":[[{"node":"CaptionsAI : Check Poll1","type":"main","index":0}]]},"HeyGen":{"main":[[{"node":"Wait4","type":"main","index":0}],[{"node":"heygen Execute ERROR","type":"main","index":0}]]},"output":{"main":[[{"node":"loop_over_scenes","type":"main","index":0}]]},"Webhook":{"main":[[{"node":"Body","type":"main","index":0}]]},"Aggregate":{"main":[[{"node":"CaptionsAI1","type":"main","index":0}]]},"Split Out":{"main":[[{"node":"loop_over_scenes","type":"main","index":0}]]},"CaptionsAI1":{"main":[[{"node":"Wait6","type":"main","index":0}],[{"node":"CAPTIONS Execute ERROR1","type":"main","index":0}]]},"Code Heygen":{"main":[[{"node":"json2video : Video Rendering","type":"main","index":0}]]},"Code Add Sub":{"main":[[{"node":"json2video : Video Rendering","type":"main","index":0}]]},"cap_response":{"main":[[{"node":"Code Add Sub","type":"main","index":0}],[{"node":"Wait6","type":"main","index":0}],[{"node":"CAPTIONS Execute ERROR","type":"main","index":0}]]},"j2v_response":{"main":[[{"node":"Baserow","type":"main","index":0}],[{"node":"Wait","type":"main","index":0}],[{"node":"json2video Execute ERROR1","type":"main","index":0}]]},"output image":{"main":[[{"node":"loop_over_scenes","type":"main","index":0}]]},"Baserow Error":{"main":[[{"node":"Stop and Error","type":"main","index":0}]]},"BackgroundType":{"main":[[{"node":"Runway - Create Video","type":"main","index":0}],[{"node":"output image","type":"main","index":0}]]},"If_with_avatar":{"main":[[{"node":"Aggregate","type":"main","index":0}],[{"node":"Code","type":"main","index":0}]]},"If_with_heygen":{"main":[[{"node":"HeyGen","type":"main","index":0}],[{"node":"json2video : Video Rendering","type":"main","index":0}]]},"Scenes Mapping":{"main":[[{"node":"Split Out","type":"main","index":0}]]},"Basic LLM Chain":{"main":[[{"node":"Scenes Mapping","type":"main","index":0},{"node":"Update Script","type":"main","index":0}],[{"node":"Execute Workflow4","type":"main","index":0}]]},"Should Process?":{"main":[[{"node":"Switch ScriptType","type":"main","index":0},{"node":"Baserow Processing","type":"main","index":0}]]},"heygen_response":{"main":[[{"node":"Code Heygen","type":"main","index":0}],[{"node":"Wait4","type":"main","index":0}]]},"loop_over_scenes":{"main":[[{"node":"If_with_avatar","type":"main","index":0}],[{"node":"Leo - Improve Prompt","type":"main","index":0}]]},"Leo - Get imageId":{"main":[[{"node":"BackgroundType","type":"main","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"Basic LLM Chain","type":"ai_languageModel","index":0}]]},"Switch ScriptType":{"main":[[{"node":"If","type":"main","index":0}],[{"node":"Basic LLM Chain","type":"main","index":0}]]},"OpenAI Chat Model1":{"ai_languageModel":[[{"node":"Basic LLM Chain Manual","type":"ai_languageModel","index":0}]]},"Runway - Get Video":{"main":[[{"node":"output","type":"main","index":0}],[{"node":"Execute Workflow6","type":"main","index":0}]]},"HeyGen : Check Video":{"main":[[{"node":"heygen_response","type":"main","index":0}],[{"node":"heygen Execute ERROR2","type":"main","index":0}]]},"Leo - Generate Image":{"main":[[{"node":"Wait1","type":"main","index":0}],[{"node":"Execute Workflow3","type":"main","index":0}]]},"Leo - Improve Prompt":{"main":[[{"node":"Leo - Generate Image","type":"main","index":0}],[{"node":"Execute Workflow5","type":"main","index":0}]]},"Runway - Create Video":{"main":[[{"node":"Wait2","type":"main","index":0}],[{"node":"Execute Workflow2","type":"main","index":0}]]},"Basic LLM Chain Manual":{"main":[[{"node":"Update Script","type":"main","index":0},{"node":"Scenes Mapping","type":"main","index":0}],[{"node":"Execute Workflow4","type":"main","index":0}]]},"CaptionsAI : Check Poll1":{"main":[[{"node":"cap_response","type":"main","index":0}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"Basic LLM Chain","type":"ai_outputParser","index":0},{"node":"Basic LLM Chain Manual","type":"ai_outputParser","index":0}]]},"json2video : Video Rendering":{"main":[[{"node":"Wait","type":"main","index":0}],[{"node":"json2video Execute ERROR","type":"main","index":0}]]},"When Executed by Another Workflow":{"main":[[{"node":"Baserow Error","type":"main","index":0}]]},"json2video : Check Video Rendering":{"main":[[{"node":"j2v_response","type":"main","index":0}]]}}}


name: AI image generator from text built on fal.ai
author_name: n8n Team
author_username: n8n-team
categories: []
created_at: 2025-05-16T14:29:12.278Z
updated_at: 2025-05-16T14:29:12.278Z
url: https://n8n.io/workflows/4108
scraped_at: 2025-07-06 21:16:30
description:
  Who this template is for

  This template is for developers, content creators, or application builders who want to integrate an AI-powered text-to-image generation service into their applications or systems via an API endpoint.

  Use case

  Creating a secure API endpoint that converts text prompts into AI-generated images, with built-in content moderation to prevent inappropriate content generation. This can be used for creative applications, content creation tools, prototyping interfaces, or any system that needs on-demand image generation.

  How this workflow works

  Receives text prompt through a webhook endpoint
  Filters the prompt for inappropriate content using AI moderation
  Submits valid prompts to the Fal.ai Flux image generation service
  Polls for completion status and retrieves the generated image when ready
  Returns the image results in a structured JSON format to the client

  Set up steps

  Create a Fal.ai account and obtain API credentials
  Configure the HTTP Header Auth credentials with your Fal.ai API key
  Set up an OpenAI API key for the content moderation component
  Deploy the workflow and note the webhook URL for your API endpoint
  Test the endpoint by sending a POST request with a JSON body containing a "prompt" field

nodes_used:
  ["n8n-nodes-base.httpRequest","@n8n/n8n-nodes-langchain.lmChatOpenAi","@n8n/n8n-nodes-langchain.textClassifier"]

workflow_json:
  {"meta":{"instanceId":"cb484ba7b742928a2048bf8829668bed5b5ad9787579adea888f05980292a4a7"},"nodes":[{"id":"c5b7bac5-6e31-4338-af76-32a34be8ae4d","name":"Webhook","type":"n8n-nodes-base.webhook","position":[-440,280],"webhookId":"5cca11bb-eaea-4c3a-86f7-16d5802b6ac8","parameters":{"path":"ai_text_to_image_generator","options":{},"httpMethod":"POST","responseMode":"responseNode"},"typeVersion":2},{"id":"ba2850cc-3d2b-45d7-9c1d-87bff38d99c3","name":"Fetch Status","type":"n8n-nodes-base.httpRequest","position":[300,280],"parameters":{"url":"=https://queue.fal.run/fal-ai/flux/requests/{{ $json.request_id }}/status","options":{},"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"0qP44IHCmBfL54Vb","name":"Falai Polina"}},"typeVersion":4.2},{"id":"44e08f96-e6b2-49a8-8077-571e07108d8d","name":"Wait","type":"n8n-nodes-base.wait","position":[680,460],"webhookId":"150069ed-885b-497f-a32a-09e7088136e6","parameters":{"amount":1},"typeVersion":1.1},{"id":"a1455b63-eed2-4c6d-86dc-11bf0937892b","name":"Is Ready?","type":"n8n-nodes-base.if","position":[480,280],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"ac50759b-e2f3-4efd-a2af-f28b7d209b45","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.status }}","rightValue":"COMPLETED"}]}},"typeVersion":2.2},{"id":"6b4446ef-0c5f-4d8b-839e-e7a9d6ae4773","name":"Submit Request","type":"n8n-nodes-base.httpRequest","position":[100,280],"parameters":{"url":"https://queue.fal.run/fal-ai/flux/schnell","method":"POST","options":{},"jsonBody":"={\"prompt\": \"{{ $json.body.prompt }}\"}","sendBody":true,"sendHeaders":true,"specifyBody":"json","authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","headerParameters":{"parameters":[{"name":"Content-Type","value":"application/json"}]}},"credentials":{"httpHeaderAuth":{"id":"0qP44IHCmBfL54Vb","name":"Falai Polina"}},"typeVersion":4.2},{"id":"3f1df77f-8576-4c32-a1c8-7e80f5bf572d","name":"Fetch Result","type":"n8n-nodes-base.httpRequest","position":[680,280],"parameters":{"url":"={{ $json.response_url }}","options":{},"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"0qP44IHCmBfL54Vb","name":"Falai Polina"}},"typeVersion":4.2},{"id":"744b0b05-d1f7-4972-b16d-70328b7a36c9","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-260,440],"parameters":{"options":{}},"credentials":{"openAiApi":{"id":"QpFZ2EiM3WGl6Zr3","name":"Marketing OpenAI"}},"typeVersion":1.1},{"id":"9ab24ceb-c1c1-42b8-88d9-249c2db60a8d","name":"400 Error","type":"n8n-nodes-base.respondToWebhook","position":[100,640],"parameters":{"options":{"responseCode":400},"respondWith":"json","responseBody":"={{\n{\n  \"error\": \"Prompt is in violation of terms of use. Please try again.\",\n  \"result\": []\n}\n}}"},"typeVersion":1.1},{"id":"c5ef424e-1fb5-44d5-9612-4c76c7d1d232","name":"Success","type":"n8n-nodes-base.respondToWebhook","position":[900,280],"parameters":{"options":{},"respondWith":"json","responseBody":"={{\n{\n  \"error\": null,\n  \"result\": $json.images\n}\n}}"},"typeVersion":1.1},{"id":"eb43cc4a-4d15-47b9-9c81-840ecc9cfafa","name":"NSFW Filter","type":"@n8n/n8n-nodes-langchain.textClassifier","position":[-260,280],"parameters":{"options":{"fallback":"other"},"inputText":"={{ $json.body.prompt }}","categories":{"categories":[{"category":"NSFW","description":"text is NSFW"},{"category":"SFW","description":"text is SFW"}]}},"typeVersion":1},{"id":"db102cc6-b414-4187-b269-8f73158f0fb3","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-480,120],"parameters":{"width":540,"height":460,"content":"## Receives text prompt through a webhook endpoint and filters the prompt for inappropriate content using AI moderation"},"typeVersion":1},{"id":"b2ff86e9-62cc-45d1-9f89-6a5d2010c976","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[80,0],"parameters":{"width":540,"height":580,"content":"## Submits valid prompts to the Fal.ai and polls for completion status and retrieves the generated image when ready\n\nFal.ai is a model inference and finetuning service dedicated to AI image and video. It hosts many popular third party models including Flux by Black Forest Labs.\n\nSign up here - https://fal.ai - for an api key."},"typeVersion":1}],"connections":{"Wait":{"main":[[{"node":"Fetch Status","type":"main","index":0}]]},"Webhook":{"main":[[{"node":"NSFW Filter","type":"main","index":0}]]},"Is Ready?":{"main":[[{"node":"Fetch Result","type":"main","index":0}],[{"node":"Wait","type":"main","index":0}]]},"NSFW Filter":{"main":[[{"node":"400 Error","type":"main","index":0}],[{"node":"Submit Request","type":"main","index":0}],[{"node":"400 Error","type":"main","index":0}]]},"Fetch Result":{"main":[[{"node":"Success","type":"main","index":0}]]},"Fetch Status":{"main":[[{"node":"Is Ready?","type":"main","index":0}]]},"Submit Request":{"main":[[{"node":"Fetch Status","type":"main","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"NSFW Filter","type":"ai_languageModel","index":0}]]}}}


name: Clone Viral TikToks with AI Avatars & Auto-Post to 9 Platforms using Perplexity & Blotato
author_name: Dr. Firas
author_username: drfiras
categories: []
created_at: 2025-05-16T15:33:36.828Z
updated_at: 2025-05-16T15:33:36.828Z
url: https://n8n.io/workflows/4110
scraped_at: 2025-07-06 21:16:30
description:
  Clone a viral TikTok with AI and auto-post it to 9 platforms using Perplexity & Blotato

  Who is this for?

  This workflow is perfect for:
  Content creators looking to repurpose viral content
  Social media managers who want to scale short-form content across multiple platforms
  Entrepreneurs and marketers aiming to save time and boost visibility with AI-powered automation

  What problem is this workflow solving?

  Reproducing viral video formats with your own branding and pushing them to multiple platforms is time-consuming and hard to scale. This workflow solves that by:
  Cloning a viral TikTok video’s structure
  Generating a new version with your avatar
  Rewriting the script, caption, and overlay text
  Auto-posting it to 9 social media platforms — without manual uploads

  What this workflow does

  From a simple Telegram message with a TikTok link, the workflow:

  Downloads a TikTok video and extracts its thumbnail, audio, and caption
  Transcribes the audio and saves original text into Google Sheets
  Uses Perplexity AI to suggest a new content idea in the same niche
  Rewrites the script, caption, and overlay using GPT-4o
  Generates a new video with your avatar using Captions.ai
  Adds subtitles and overlay text with JSON2Video
  Saves metadata to Google Sheets for tracking
  Sends the final video to Telegram for preview
  Auto-publishes the video to Instagram, YouTube, TikTok, Facebook, LinkedIn, Threads, X (Twitter), Pinterest, and Bluesky via Blotato

  Setup

  Connect your Telegram bot to the trigger node.
  Add your OpenAI, Perplexity, Cloudinary, Captions.ai, and Blotato API keys.
  Make sure your Google Sheet is ready with the appropriate columns.
  Replace the default avatar name in the Captions.ai node with yours.
  Fill in your social media account IDs in the "Assign Platform IDs" node.
  Test by sending a TikTok URL to your Telegram bot.

  How to customize this workflow to your needs

  Change avatar output style**: adjust resolution, voice, or avatar ID.
  Refine script structure**: tweak GPT instructions for different tone/format.
  Swap Perplexity with ChatGPT or Claude** if needed.
  Filter by platform**: disable any Blotato nodes you don’t need.
  Add approval step**: insert a Telegram confirmation node before publishing.
  Adjust subtitle style or overlay text font** in JSON2Video.

  📄 Documentation: Notion Guide

  Need help customizing?
  Contact me for consulting and support : Linkedin / Youtube

nodes_used:
  ["n8n-nodes-base.googleSheets","n8n-nodes-base.httpRequest","n8n-nodes-base.telegram","n8n-nodes-base.code","@n8n/n8n-nodes-langchain.openAi"]

workflow_json:
  {"id":"21dF4yje1iQpP4jQ","meta":{"instanceId":"a2b23892dd6989fda7c1209b381f5850373a7d2b85609624d7c2b7a092671d44","templateCredsSetupCompleted":true},"name":"💥Clone a viral TikTok and auto-post it to 9 platforms using Perplexity & Blotato vide","tags":[],"nodes":[{"id":"8ad59e84-639c-4a44-afdc-611d15f32d7f","name":"Assign Social Media IDs","type":"n8n-nodes-base.set","position":[-80,920],"parameters":{"mode":"raw","options":{},"jsonOutput":"{\n  \"instagram_id\": \"0000\",\n  \"youtube_id\": \"0000\",\n  \"threads_id\": \"0000\",\n  \"tiktok_id\": \"0000\",\n  \"facebook_id\": \"0000\",\n  \"facebook_page_id\": \"000000000000\",\n  \"twitter_id\": \"0000\",\n  \"linkedin_id\": \"0000\",\n  \"pinterest_id\": \"0000\",\n  \"pinterest_board_id\": \"00000000000000000000\",\n  \"bluesky_id\": \"0000\"\n}\n"},"typeVersion":3.4},{"id":"2e243d6a-81ef-487f-8852-bd48cfaf5ad8","name":"Upload Video to Blotato","type":"n8n-nodes-base.httpRequest","position":[140,920],"parameters":{"url":"https://backend.blotato.com/v2/media","method":"POST","options":{},"sendBody":true,"sendHeaders":true,"bodyParameters":{"parameters":[{"name":"url","value":"={{ $('Update Final Video URL in Sheet').item.json['URL de la vidéo'] }}"}]},"headerParameters":{"parameters":[{"name":"blotato-api-key","value":"YOUR_API_KEY"}]}},"typeVersion":4.2},{"id":"f84ff66b-9270-494f-80e7-29ad2fd51b4d","name":"INSTAGRAM","type":"n8n-nodes-base.httpRequest","position":[420,680],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Social Media IDs').item.json.instagram_id }}\",\n    \"target\": {\n      \"targetType\": \"instagram\"\n    },\n    \"content\": {\n      \"text\": \"{{ $('Save Rewritten Video to Google Sheets').item.json.Caption }}\",\n      \"platform\": \"instagram\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ]\n    }\n  }\n}\n\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key","value":"=YOUR_API_KEY"}]}},"typeVersion":4.2},{"id":"3776e592-07be-47e2-89a8-f8d338f0c25e","name":"YOUTUBE","type":"n8n-nodes-base.httpRequest","position":[640,680],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Social Media IDs').item.json.youtube_id }}\",\n    \"target\": {\n      \"targetType\": \"youtube\",\n      \"title\": \"{{ $('Save Rewritten Video to Google Sheets').item.json['Texte superposé'] }}\",\n      \"privacyStatus\": \"unlisted\",\n      \"shouldNotifySubscribers\": \"false\"\n    },\n    \"content\": {\n      \"text\": \"{{ $('Save Rewritten Video to Google Sheets').item.json.Caption }}\",\n      \"platform\": \"youtube\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ]\n    }\n  }\n}\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key","value":"YOUR_API_KEY"}]}},"typeVersion":4.2},{"id":"c590765f-deb4-4221-ada7-37c700656ff1","name":"TIKTOK","type":"n8n-nodes-base.httpRequest","position":[840,680],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Social Media IDs').item.json.tiktok_id }}\",\n    \"target\": {\n      \"targetType\": \"tiktok\",\n      \"isYourBrand\": \"false\", \n      \"disabledDuet\": \"false\",\n      \"privacyLevel\": \"PUBLIC_TO_EVERYONE\",\n      \"isAiGenerated\": \"true\",\n      \"disabledStitch\": \"false\",\n      \"disabledComments\": \"false\",\n      \"isBrandedContent\": \"false\"\n      \n    },\n    \"content\": {\n      \"text\": \"{{ $('Save Rewritten Video to Google Sheets').item.json.Caption }}\",\n      \"platform\": \"tiktok\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ]\n    }\n  }\n}\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key","value":"YOUR_API_KEY"}]}},"typeVersion":4.2},{"id":"9a9dc42a-20b6-427d-a7d9-08f4ab924e9e","name":"FACEBOOK","type":"n8n-nodes-base.httpRequest","position":[420,920],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Social Media IDs').item.json.facebook_id }}\",\n    \"target\": {\n      \"targetType\": \"facebook\",\n      \"pageId\": \"{{ $('Assign Social Media IDs').item.json.facebook_page_id }}\"\n\n      \n    },\n    \"content\": {\n      \"text\": \"{{ $('Save Rewritten Video to Google Sheets').item.json.Caption }}\",\n      \"platform\": \"facebook\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ]\n    }\n  }\n}","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key","value":"YOUR_API_KEY"}]}},"typeVersion":4.2},{"id":"987a372a-d27e-4a3e-a8b7-b2085463c05a","name":"THREADS","type":"n8n-nodes-base.httpRequest","position":[640,920],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Social Media IDs').item.json.threads_id }}\",\n    \"target\": {\n      \"targetType\": \"threads\"\n      \n    },\n    \"content\": {\n      \"text\": \"{{ $('Save Rewritten Video to Google Sheets').item.json.Caption }}\",\n      \"platform\": \"threads\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ]\n    }\n  }\n}\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key","value":"YOUR_API_KEY"}]}},"typeVersion":4.2},{"id":"e9d66412-e27d-47f0-9d17-5ec36fe81859","name":"TWETTER","type":"n8n-nodes-base.httpRequest","position":[840,920],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Social Media IDs').item.json.twitter_id }}\",\n    \"target\": {\n      \"targetType\": \"twitter\"\n      \n    },\n    \"content\": {\n      \"text\": \"{{ $('Save Rewritten Video to Google Sheets').item.json.Caption }}\",\n      \"platform\": \"twitter\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ]\n    }\n  }\n}\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key","value":"=YOUR_API_KEY"}]}},"typeVersion":4.2},{"id":"9e7e0fa8-3f0e-4111-9d78-96123ccec1c8","name":"LINKEDIN","type":"n8n-nodes-base.httpRequest","position":[420,1160],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Social Media IDs').item.json.linkedin_id }}\",\n    \"target\": {\n      \"targetType\": \"linkedin\"\n      \n    },\n    \"content\": {\n      \"text\": \"{{ $('Save Rewritten Video to Google Sheets').item.json.Caption }}\",\n      \"platform\": \"linkedin\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ]\n    }\n  }\n}\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key","value":"YOUR_API_KEY"}]}},"typeVersion":4.2},{"id":"3368ee92-d40f-482d-8174-53bfd188d2c8","name":"BLUESKY","type":"n8n-nodes-base.httpRequest","position":[640,1160],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"= {\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Social Media IDs').item.json.bluesky_id }}\",\n    \"target\": {\n      \"targetType\": \"bluesky\"\n      \n    },\n    \"content\": {\n      \"text\": \"{{ $('Save Rewritten Video to Google Sheets').item.json.Caption }}\",\n      \"platform\": \"bluesky\",\n      \"mediaUrls\": [\n        \"https://pbs.twimg.com/media/GE8MgIiWEAAfsK3.jpg\"\n      ]\n    }\n  }\n}\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key","value":"YOUR_API_KEY"}]}},"typeVersion":4.2},{"id":"fea89732-09cc-420d-b2e0-f0f4160d27cb","name":"PINTEREST","type":"n8n-nodes-base.httpRequest","position":[840,1160],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Social Media IDs').item.json.pinterest_id }}\",\n    \"target\": {\n      \"targetType\": \"pinterest\",\n      \"boardId\": \"{{ $('Assign Social Media IDs').item.json.pinterest_board_id }}\"      \n    },\n    \"content\": {\n      \"text\": \"{{ $('Save Rewritten Video to Google Sheets').item.json.Caption }}\",\n      \"platform\": \"pinterest\",\n      \"mediaUrls\": [\n        \"https://pbs.twimg.com/media/GE8MgIiWEAAfsK3.jpg\"\n      ]\n    }\n  }\n}\n\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key","value":"YOUR_API_KEY"}]}},"typeVersion":4.2},{"id":"d1400430-0340-4194-b5eb-bd3ae150d577","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-740,-380],"parameters":{"width":2460,"height":300,"content":"# 🟫 STEP 1 — Clone a viral TikTok video"},"typeVersion":1},{"id":"91bf1e19-3e2c-44b3-a7d0-8bea3f80eb04","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-740,-20],"parameters":{"color":4,"width":1920,"height":320,"content":"# 🟦 STEP 2 — Suggest new content idea\n"},"typeVersion":1},{"id":"a831f320-0b5f-4853-8b9c-0ddeaaf84083","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-740,340],"parameters":{"width":1920,"height":300,"content":"# 🟪 STEP 3 — Create the new video with your avatar\n\n"},"typeVersion":1},{"id":"3bb22fc4-b5b4-4323-9039-5b6cf0458084","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-740,660],"parameters":{"color":3,"width":1920,"height":680,"content":"# 🟥 STEP 4 — Publish to 9 platforms\n"},"typeVersion":1},{"id":"6ad81fc8-d79d-44d1-bf17-cdea14e915d1","name":"Trigger: Get TikTok URL via Telegram","type":"n8n-nodes-base.telegramTrigger","position":[-620,-280],"webhookId":"9a749f58-0f17-45ef-80a9-0e8d17bde5b5","parameters":{"updates":["message"],"additionalFields":{}},"credentials":{"telegramApi":{"id":"fO6eyZMLBk66Au44","name":"Telegram account 5"}},"typeVersion":1.1},{"id":"4047a3b1-1fb9-40da-b127-f2e7432a649e","name":"Download TikTok Video (RapidAPI)","type":"n8n-nodes-base.httpRequest","position":[-400,-280],"parameters":{"url":"=https://tiktok-download-video1.p.rapidapi.com/getVideo?url={{ $json.message.text }}","options":{},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-rapidapi-host","value":"tiktok-download-video1.p.rapidapi.com"},{"name":"x-rapidapi-key","value":"YOUR_API_KEY"}]}},"typeVersion":4.2},{"id":"6ec78da8-f197-42c0-b631-055bd7bf1eef","name":"Extract Video Thumbnail","type":"n8n-nodes-base.httpRequest","position":[-180,-280],"parameters":{"url":"={{ $json.data.origin_cover }}","options":{}},"typeVersion":4.2},{"id":"f17f39cd-d9f4-4b1b-85de-ade8a5492542","name":"Upload Thumbnail to Cloudinary","type":"n8n-nodes-base.httpRequest","position":[40,-280],"parameters":{"url":"https://api.cloudinary.com/v1_1/YOUR_ID/image/upload","method":"POST","options":{},"sendBody":true,"contentType":"multipart-form-data","authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"file","parameterType":"formBinaryData","inputDataFieldName":"data"},{"name":"upload_preset","value":"n8n_clone"}]},"genericAuthType":"httpBasicAuth"},"credentials":{"httpBasicAuth":{"id":"K1UGehJnDI8N25UA","name":"Unnamed credential"}},"typeVersion":4.2},{"id":"160a5960-1312-4c5f-b066-f1ecc30202e6","name":"Analyze Thumbnail (GPT-4o Vision)","type":"@n8n/n8n-nodes-langchain.openAi","position":[260,-280],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o","cachedResultName":"GPT-4O"},"options":{},"resource":"image","imageUrls":"={{ $json.url }}","operation":"analyze"},"credentials":{"openAiApi":{"id":"6h3DfVhNPw9I25nO","name":"OpenAi account"}},"typeVersion":1.8},{"id":"14a42907-4bc7-4c4a-9ced-a2a23bb88343","name":"Extract Overlay Text (GPT-4o)","type":"@n8n/n8n-nodes-langchain.openAi","position":[480,-280],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o","cachedResultName":"GPT-4O"},"options":{},"messages":{"values":[{"content":"=Identify the primary text located at the top of the image described above:\n{{ $json.content }}\n\nReturn only that specific top text as the output.\n\nDo not include any quotation marks.\n\nFocus only on the top section's text in the image and disregard any other content."}]}},"credentials":{"openAiApi":{"id":"6h3DfVhNPw9I25nO","name":"OpenAi account"}},"typeVersion":1.8},{"id":"2c183a03-3bb5-45b8-8bc9-5981f0bc30b5","name":"Download TikTok Audio","type":"n8n-nodes-base.httpRequest","position":[840,-280],"parameters":{"url":"={{ $('Download TikTok Video (RapidAPI)').item.json.data.music }}","options":{}},"typeVersion":4.2},{"id":"c6614b8c-6415-4094-a800-302ae8711d14","name":"Transcribe Audio to Script (GPT)","type":"@n8n/n8n-nodes-langchain.openAi","position":[1060,-280],"parameters":{"options":{},"resource":"audio","operation":"transcribe"},"credentials":{"openAiApi":{"id":"6h3DfVhNPw9I25nO","name":"OpenAi account"}},"typeVersion":1.8},{"id":"02ddecfe-5a85-4247-9a33-fc95c42775a0","name":"Generate Unique Template ID","type":"n8n-nodes-base.code","position":[1280,-280],"parameters":{"jsCode":"// Utility to create a random alphanumeric ID\nfunction createUniqueId(length = 12) {\n  const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n  let id = '';\n  for (let i = 0; i < length; i++) {\n    const randomIndex = Math.floor(Math.random() * characters.length);\n    id += characters[randomIndex];\n  }\n  return id;\n}\n\n// Return the ID in the expected output structure\nreturn [\n  {\n    json: {\n      code: createUniqueId()\n    }\n  }\n];"},"typeVersion":2},{"id":"e7e17a73-c75d-413d-842b-aecd0da25eb7","name":"Save Original Video to Google Sheets","type":"n8n-nodes-base.googleSheets","position":[1500,-280],"parameters":{"columns":{"value":{"Caption":"={{ $('Download TikTok Video (RapidAPI)').item.json.data.title }}","ID du modèle":"={{ $json.code }}","Lien de la vidéo":"={{ $('Trigger: Get TikTok URL via Telegram').item.json.message.text }}","Modèle de script vidéo":"={{ $('Transcribe Audio to Script (GPT)').item.json.text }}","Modèle de texte superposé":"={{ $('Download TikTok Audio').item.json.message.content }}"},"schema":[{"id":"ID du modèle","type":"string","display":true,"required":false,"displayName":"ID du modèle","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Lien de la vidéo","type":"string","display":true,"required":false,"displayName":"Lien de la vidéo","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Modèle de texte superposé","type":"string","display":true,"required":false,"displayName":"Modèle de texte superposé","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Modèle de script vidéo","type":"string","display":true,"required":false,"displayName":"Modèle de script vidéo","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Caption","type":"string","display":true,"required":false,"displayName":"Caption","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1SoYJvZbVNn4L1FNfk9eFqx_vGlCsMxgw8bx0DVFgBLY/edit#gid=0","cachedResultName":"Template"},"documentId":{"__rl":true,"mode":"id","value":"="}},"credentials":{"googleSheetsOAuth2Api":{"id":"51us92xkOlrvArhV","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"e6647507-595e-4f13-9c06-818f90b7759a","name":"Suggest Similar Idea (Perplexity)","type":"n8n-nodes-base.httpRequest","position":[-620,60],"parameters":{"url":"https://api.perplexity.ai/chat/completions","method":"POST","options":{},"jsonBody":"={\n  \"model\": \"sonar-reasoning\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Suggest a content idea different from this video script: \\\"{{ $json['Modèle de script vidéo'] }}\\\". It should be in the same niche and on the exact same topic or content idea but offer fresh value. You must pick one idea from your research that matches the topic idea of the video script exactly but is also different and unique from it so it would stand out on social media. Example: if the video script contains a list of tools, your topic must also be a list of tools in that video script topic but slightly different, maybe different tools etc. If the video's script is about a plan, strategies, or whatever, you must also make your topic about that. So you must maintain the nature of the topic in the video script. You absolutely must be specific as the original video script. You can't just mention generic tools or strategies if the original video script contains specific tools. Etc. That is the level of accuracy and perfect matching of the video script original topic. Make sure it appeals to a broad audience like the example.\"\n    }\n  ]\n}\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"Authorization","value":"Bearer YOUR_TOKEN_HERE"},{"name":"Content-Type","value":"application/json"}]}},"typeVersion":4.2},{"id":"a6c047ca-824e-4e33-895f-3be02e509fc6","name":"Clean Perplexity Response","type":"n8n-nodes-base.code","position":[-380,60],"parameters":{"jsCode":"// Step 1: Pull raw input\nlet raw = $input.first().json.choices[0].message.content;\n// Step 2: Forcefully remove anything between <think> and </think>\nlet cleaned = raw.replace(/<think>(.|\\n)*?<\\/think>/gi,\n'').trim();\n// Optional cleanup: remove leading/trailing blank lines\ncleaned = cleaned.replace(/^\\s+|\\s+$/g, '');\n// Done\nreturn [\n{\njson: {\ncleanedResponse: cleaned\n}\n}\n];\n"},"typeVersion":2},{"id":"3b5e242f-b10c-4c8e-be2a-acbc95a92658","name":"Rewrite Script, Caption, Overlay (GPT-4o)","type":"@n8n/n8n-nodes-langchain.openAi","position":[-60,60],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o","cachedResultName":"GPT-4O"},"options":{},"messages":{"values":[{"content":"=You are rewriting a TikTok video script, caption, and overlay —\nnot inventing a new one. You must follow this format and obey\nthese rules strictly.\n---\n### CONTEXT:\nHere is the content idea to use:\n{{ $json.cleanedResponse }}\n\n---\n### STEP 1: Rewrite the original video script BELOW using the new\ntopic/context above but maintaiin as stubbornly as possible the\noriginal script structure and style:\nOriginal script: {{ $('Save Original Video to Google Sheets').item.json['Modèle de script vidéo'] }}\n\n\n🛑 DO NOT CHANGE the original structure or style but\nThis includes:\n- Numbered list\n- Sentence breaks\n- \"I\" or first-person narration\n- Colloquial/informal tone (like “you're gonna wanna...”)\n✂️ You MUST keep:\n- first person narration of the orignal script at all costs\n- MUST be under 700 characters (yes \"Characters\" not wordcount)\nthis is an absolute MUST, no more than 700 characters!!! But never\nchange the structure or narration style of the original script. It\nmust be an exact imitation.\n✏️ You MAY change:\n- Tool names\n- Use cases\n- Descriptions\n- Niche-specific keywords\n\n#Rule: never use any characers like \"\" in your generated video\nscript as this will yeild syntax errors.\n---\n### STEP 2: Rewrite the caption text using the new topic.\nKeep:\n- Same structure and tone\n- Same use of #hashtags but space between each hashtag\n- Similar sentence count and layout\nCaption:\n{{ $('Save Original Video to Google Sheets').item.json.Caption }}\n\n---\n### STEP 3: Rewrite the text overlay (short version for the\nthumbnail or first screen)\nKeep:\n- EXACT Same length format, case, structure\n- Do NOT invent new words unless absolutely necessary\nOverlay:\n{{ $('Save Original Video to Google Sheets').item.json['Modèle de texte superposé'] }}\n---\n### FINAL OUTPUT FORMAT (no markdown formatting):\nText Overlay: [REWRITTEN TEXT OVERLAY]\nVideo Script: [REWRITTEN SCRIPT]\nCaption Text: [REWRITTEN CAPTION TEXT]\nDO NOT return any explanations. Only return the rewritten\nsections."}]}},"credentials":{"openAiApi":{"id":"6h3DfVhNPw9I25nO","name":"OpenAi account"}},"typeVersion":1.8},{"id":"befec852-bca2-4c54-9c2c-49a8c082e2b4","name":"Split Rewritten Content into Sections","type":"n8n-nodes-base.code","position":[420,60],"parameters":{"jsCode":"// Récupère le contenu du premier item\nconst input = $input.first().json.message.content;\n\n// On tolère les retours à la ligne réels (\\n) ou échappés (\\\\n)\n\n// Text Overlay\nconst textOverlayMatch = input.match(\n  /Text\\s*Overlay:\\s*(.+?)(?:\\r?\\n|\\\\n)/s\n);\n\n// Video Script\nconst videoScriptMatch = input.match(\n  /Video\\s*Script:\\s*(.+?)(?:\\r?\\n|\\\\n)Caption\\s*Text:/s\n);\n\n// Caption Text (jusqu'à la fin)\nconst captionTextMatch = input.match(\n  /Caption\\s*Text:\\s*(.+)/s\n);\n\nreturn [\n  {\n    json: {\n      textOverlay:   textOverlayMatch   ? textOverlayMatch[1].trim()   : null,\n      videoScript:   videoScriptMatch   ? videoScriptMatch[1].trim()   : null,\n      captionText:   captionTextMatch   ? captionTextMatch[1].trim()   : null,\n    }\n  }\n];\n"},"typeVersion":2},{"id":"49828685-cf54-45ac-96d9-03697215f80e","name":"Generate New Video ID","type":"n8n-nodes-base.code","position":[640,60],"parameters":{"jsCode":"// Utility to create a random alphanumeric ID\nfunction createUniqueId(length = 12) {\n  const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n  let id = '';\n  for (let i = 0; i < length; i++) {\n    const randomIndex = Math.floor(Math.random() * characters.length);\n    id += characters[randomIndex];\n  }\n  return id;\n}\n\n// Return the ID in the expected output structure\nreturn [\n  {\n    json: {\n      code: createUniqueId()\n    }\n  }\n];"},"typeVersion":2},{"id":"c9f02616-a944-471b-9c4d-7fa381d684b9","name":"Save Rewritten Video to Google Sheets","type":"n8n-nodes-base.googleSheets","position":[820,60],"parameters":{"columns":{"value":{"Sujet":"={{ $('Clean Perplexity Response').first().json.cleanedResponse }}","Script":"={{ $('Split Rewritten Content into Sections').item.json.videoScript }}","Caption":"={{ $('Split Rewritten Content into Sections').item.json.captionText }}","ID du modèle":"={{ $('Generate Unique Template ID').first().json.code }}","ID de la vidéo":"={{ $json.code }}","Texte superposé":"={{ $('Split Rewritten Content into Sections').item.json.textOverlay }}"},"schema":[{"id":"ID du modèle","type":"string","display":true,"required":false,"displayName":"ID du modèle","defaultMatch":false,"canBeUsedToMatch":true},{"id":"ID de la vidéo","type":"string","display":true,"removed":false,"required":false,"displayName":"ID de la vidéo","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Sujet","type":"string","display":true,"removed":false,"required":false,"displayName":"Sujet","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Texte superposé","type":"string","display":true,"removed":false,"required":false,"displayName":"Texte superposé","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Script","type":"string","display":true,"removed":false,"required":false,"displayName":"Script","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Caption","type":"string","display":true,"required":false,"displayName":"Caption","defaultMatch":false,"canBeUsedToMatch":true},{"id":"URL de la vidéo","type":"string","display":true,"removed":true,"required":false,"displayName":"URL de la vidéo","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Date de publication","type":"string","display":true,"removed":true,"required":false,"displayName":"Date de publication","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Statut","type":"string","display":true,"removed":true,"required":false,"displayName":"Statut","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"id","value":"=52679157"},"documentId":{"__rl":true,"mode":"id","value":"="}},"credentials":{"googleSheetsOAuth2Api":{"id":"51us92xkOlrvArhV","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"dbd21507-ecdf-49c7-b449-e4a6f9fcca86","name":"Fetch Available Avatars","type":"n8n-nodes-base.httpRequest","position":[-620,440],"parameters":{"url":"https://api.captions.ai/api/creator/list","method":"POST","options":{},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Content-Type","value":"application/json"},{"name":"x-api-key","value":"YOUR_API_KEY"}]}},"typeVersion":4.2},{"id":"988a3283-a57d-4c81-b582-bb59e715208b","name":"Generate Video with Avatar","type":"n8n-nodes-base.httpRequest","position":[-380,440],"parameters":{"url":"https://api.captions.ai/api/creator/submit","method":"POST","options":{},"jsonBody":"={\n\"script\": \"{{ $('Save Rewritten Video to Google Sheets').item.json.Script }}\",\n\"creatorName\": \"{{ $json.supportedCreators[0] }}\",\n\"resolution\": \"fhd\"\n}","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"Content-Type","value":"application/json"},{"name":"x-api-key","value":"YOUR_API_KEY"}]}},"typeVersion":4.2},{"id":"99f95617-c27e-4952-9da6-93bb818d374c","name":"Wait for Avatar Rendering (3 min)","type":"n8n-nodes-base.wait","position":[-180,440],"webhookId":"779e4676-d28f-4be9-9118-c90c688e805a","parameters":{"unit":"minutes","amount":3},"typeVersion":1.1},{"id":"78dd3c62-a184-4ec0-9153-002a0ac3209f","name":"Fetch Avatar Video URL","type":"n8n-nodes-base.httpRequest","position":[20,440],"parameters":{"url":"https://api.captions.ai/api/creator/poll","method":"POST","options":{},"jsonBody":"={\n \"operationId\": \"{{ $json[\"operationId\"] }}\"\n}","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"Content-Type","value":"application/json"},{"name":"x-api-key","value":"YOUR_API_KEY"}]}},"typeVersion":4.2},{"id":"8c6af2a2-c052-40b3-825a-463d7c17b060","name":"Add Overlay Text with JSON2Video","type":"n8n-nodes-base.httpRequest","position":[220,440],"parameters":{"url":"https://api.json2video.com/v2/movies","method":"POST","options":{},"jsonBody":"=\n{\n\"id\": \"qbaasr7s\",\n\"resolution\": \"instagram-story\",\n\"quality\": \"high\",\n\"scenes\": [\n{\n\"id\": \"qyjh9lwj\",\n\"comment\": \"Scene 1\",\n\"elements\": []\n}\n],\n\"elements\": [\n{\n\"id\": \"q6dznzcv\",\n\"type\": \"video\",\n\"src\": \"{{ $json.url }}\",\n\"resize\": \"cover\"\n},\n{\n\"id\": \"top-text\",\n\"type\": \"text\",\n\"text\": \"{{ $('Save Rewritten Video to Google Sheets').item.json['Texte superposé'] }}\",\n\"settings\": {\n\"font-family\": \"Arial\",\n\"font-size\": \"60px\",\n\"color\": \"#000000\",\n\"background-color\": \"#FFFFFF\",\n\"horizontal-position\": \"center\",\n\"vertical-position\": \"top\",\n\"margin-top\": \"100px\",\n\"word-break\": \"break-word\",\n\"overflow-wrap\": \"break-word\",\n\"font-weight\": \"bold\",\n\"text-align\": \"center\",\n\"width\": \"80%\",\n\"padding\": \"0px\",\n\"line-height\": \"1.2\",\n\"margin\": \"50px 0 0 0\",\n\"padding\": \"0 10px 0 10px\",\n\"border-radius\": \"15px\"\n}\n},\n{\n\"id\": \"q41n9kxp\",\n\"type\": \"subtitles\",\n\"settings\": {\n\"style\": \"classic\",\n\"position\": \"bottom\",\n\"font-family\": \"Arial\",\n\"font-size\": \"100px\",\n\"word-color\": \"#ffd700\",\n\"shadow-color\": \"#260B1B\",\n\"line-color\": \"#F1E7F4\",\n\"shadow-offset\": 0,\n\"box-color\": \"#260B1B\",\n\"outline-color\": \"#000000\",\n\"outline-width\": 8\n},\n\"language\": \"en\"\n}\n]\n}","sendBody":true,"specifyBody":"json","authentication":"genericCredentialType","genericAuthType":"httpCustomAuth"},"credentials":{"httpCustomAuth":{"id":"GELGbE2ThQ80HY5A","name":"Custom Auth account"}},"typeVersion":4.2},{"id":"cf55a393-1e63-46f7-b57c-07508141554f","name":"Wait for Caption Rendering","type":"n8n-nodes-base.wait","position":[420,440],"webhookId":"67093c5d-34fa-44e8-9dfd-e25ca5f99ac2","parameters":{"unit":"minutes","amount":2},"typeVersion":1.1},{"id":"4a939455-0c36-49cc-9279-36f2cd8ebcec","name":"Fetch Final Video from JSON2Video","type":"n8n-nodes-base.httpRequest","position":[620,440],"parameters":{"url":"=https://api.json2video.com/v2/movies?id={{ $json.project }}","options":{},"authentication":"genericCredentialType","genericAuthType":"httpCustomAuth"},"credentials":{"httpCustomAuth":{"id":"GELGbE2ThQ80HY5A","name":"Custom Auth account"}},"typeVersion":4.2},{"id":"e64423b9-6e5e-4ab8-b9c1-1bb791fcfa06","name":"Update Final Video URL in Sheet","type":"n8n-nodes-base.googleSheets","position":[820,440],"parameters":{"columns":{"value":{"ID de la vidéo":"={{ $('Save Rewritten Video to Google Sheets').item.json['ID de la vidéo'] }}","URL de la vidéo":"={{ $json.movie.url }}"},"schema":[{"id":"ID du modèle","type":"string","display":true,"removed":true,"required":false,"displayName":"ID du modèle","defaultMatch":false,"canBeUsedToMatch":true},{"id":"ID de la vidéo","type":"string","display":true,"removed":false,"required":false,"displayName":"ID de la vidéo","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Sujet","type":"string","display":true,"removed":true,"required":false,"displayName":"Sujet","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Texte superposé","type":"string","display":true,"removed":true,"required":false,"displayName":"Texte superposé","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Script","type":"string","display":true,"removed":true,"required":false,"displayName":"Script","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Caption","type":"string","display":true,"removed":true,"required":false,"displayName":"Caption","defaultMatch":false,"canBeUsedToMatch":true},{"id":"URL de la vidéo","type":"string","display":true,"removed":false,"required":false,"displayName":"URL de la vidéo","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Date de publication","type":"string","display":true,"removed":true,"required":false,"displayName":"Date de publication","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Statut","type":"string","display":true,"removed":true,"required":false,"displayName":"Statut","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":["ID de la vidéo"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"appendOrUpdate","sheetName":{"__rl":true,"mode":"list","value":52679157,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1SoYJvZbVNn4L1FNfk9eFqx_vGlCsMxgw8bx0DVFgBLY/edit#gid=52679157","cachedResultName":"MA VIDEO"},"documentId":{"__rl":true,"mode":"id","value":"="}},"credentials":{"googleSheetsOAuth2Api":{"id":"51us92xkOlrvArhV","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"d72dc835-b954-4dbd-a210-af7fc6ce058e","name":"Send Video URL via Telegram","type":"n8n-nodes-base.telegram","position":[-600,920],"webhookId":"37975672-4633-4c65-a8d8-4d101bff5f84","parameters":{"text":"=Url VIDEO : {{ $json['URL de la vidéo'] }}","chatId":"={{ $('Trigger: Get TikTok URL via Telegram').item.json.message.chat.id }}","additionalFields":{}},"credentials":{"telegramApi":{"id":"fO6eyZMLBk66Au44","name":"Telegram account 5"}},"typeVersion":1.2},{"id":"33552176-18ab-44ec-9bb6-174e9f9c777d","name":"Send Final Video Preview","type":"n8n-nodes-base.telegram","position":[-400,920],"webhookId":"ee91d7ee-1c35-41fa-b8f0-f153b8776369","parameters":{"file":"={{ $('Update Final Video URL in Sheet').item.json['URL de la vidéo'] }}","chatId":"={{ $json.result.chat.id }}","operation":"sendVideo","additionalFields":{}},"credentials":{"telegramApi":{"id":"fO6eyZMLBk66Au44","name":"Telegram account 5"}},"typeVersion":1.2}],"active":false,"settings":{"executionOrder":"v1"},"versionId":"2bb57143-bfe3-49fd-9492-7396d9611cc7","connections":{"Download TikTok Audio":{"main":[[{"node":"Transcribe Audio to Script (GPT)","type":"main","index":0}]]},"Generate New Video ID":{"main":[[{"node":"Save Rewritten Video to Google Sheets","type":"main","index":0}]]},"Fetch Avatar Video URL":{"main":[[{"node":"Add Overlay Text with JSON2Video","type":"main","index":0}]]},"Assign Social Media IDs":{"main":[[{"node":"Upload Video to Blotato","type":"main","index":0}]]},"Extract Video Thumbnail":{"main":[[{"node":"Upload Thumbnail to Cloudinary","type":"main","index":0}]]},"Fetch Available Avatars":{"main":[[{"node":"Generate Video with Avatar","type":"main","index":0}]]},"Upload Video to Blotato":{"main":[[{"node":"INSTAGRAM","type":"main","index":0},{"node":"YOUTUBE","type":"main","index":0},{"node":"TIKTOK","type":"main","index":0},{"node":"FACEBOOK","type":"main","index":0},{"node":"THREADS","type":"main","index":0},{"node":"TWETTER","type":"main","index":0},{"node":"LINKEDIN","type":"main","index":0},{"node":"BLUESKY","type":"main","index":0},{"node":"PINTEREST","type":"main","index":0}]]},"Send Final Video Preview":{"main":[[{"node":"Assign Social Media IDs","type":"main","index":0}]]},"Clean Perplexity Response":{"main":[[{"node":"Rewrite Script, Caption, Overlay (GPT-4o)","type":"main","index":0}]]},"Generate Video with Avatar":{"main":[[{"node":"Wait for Avatar Rendering (3 min)","type":"main","index":0}]]},"Wait for Caption Rendering":{"main":[[{"node":"Fetch Final Video from JSON2Video","type":"main","index":0}]]},"Generate Unique Template ID":{"main":[[{"node":"Save Original Video to Google Sheets","type":"main","index":0}]]},"Send Video URL via Telegram":{"main":[[{"node":"Send Final Video Preview","type":"main","index":0}]]},"Extract Overlay Text (GPT-4o)":{"main":[[{"node":"Download TikTok Audio","type":"main","index":0}]]},"Upload Thumbnail to Cloudinary":{"main":[[{"node":"Analyze Thumbnail (GPT-4o Vision)","type":"main","index":0}]]},"Update Final Video URL in Sheet":{"main":[[{"node":"Send Video URL via Telegram","type":"main","index":0}]]},"Add Overlay Text with JSON2Video":{"main":[[{"node":"Wait for Caption Rendering","type":"main","index":0}]]},"Download TikTok Video (RapidAPI)":{"main":[[{"node":"Extract Video Thumbnail","type":"main","index":0}]]},"Transcribe Audio to Script (GPT)":{"main":[[{"node":"Generate Unique Template ID","type":"main","index":0}]]},"Analyze Thumbnail (GPT-4o Vision)":{"main":[[{"node":"Extract Overlay Text (GPT-4o)","type":"main","index":0}]]},"Fetch Final Video from JSON2Video":{"main":[[{"node":"Update Final Video URL in Sheet","type":"main","index":0}]]},"Suggest Similar Idea (Perplexity)":{"main":[[{"node":"Clean Perplexity Response","type":"main","index":0}]]},"Wait for Avatar Rendering (3 min)":{"main":[[{"node":"Fetch Avatar Video URL","type":"main","index":0}]]},"Save Original Video to Google Sheets":{"main":[[{"node":"Suggest Similar Idea (Perplexity)","type":"main","index":0}]]},"Trigger: Get TikTok URL via Telegram":{"main":[[{"node":"Download TikTok Video (RapidAPI)","type":"main","index":0}]]},"Save Rewritten Video to Google Sheets":{"main":[[{"node":"Fetch Available Avatars","type":"main","index":0}]]},"Split Rewritten Content into Sections":{"main":[[{"node":"Generate New Video ID","type":"main","index":0}]]},"Rewrite Script, Caption, Overlay (GPT-4o)":{"main":[[{"node":"Split Rewritten Content into Sections","type":"main","index":0}]]}}}


name: Analyze Crypto Market with CoinGecko: Volatility Metrics & Investment Signals
author_name: ist00dent
author_username: ist00dent
nodes_used: ["n8n-nodes-base.httpRequest"]
categories: []
created_at: 2025-05-16T17:00:04.497Z
updated_at: 2025-05-16T17:00:04.497Z
url: https://n8n.io/workflows/4115
scraped_at: 2025-07-06 21:16:30
description:
  This n8n template lets you automatically pull market data for the cryptocurrencies from CoinGecko every hour, calculate custom volatility and market-health metrics, classify each coin’s price action into buy/sell/hold/neutral signals with risk ratings, and expose both individual analyses and a portfolio summary via a webhook. It’s perfect for crypto analysts, DeFi builders, or portfolio managers who want on-demand insights without writing a single line of backend code.

  🔧 How it works
  Schedule Trigger fires every hour (or interval you choose).
  HTTP Request (CoinGecko) fetches the top 10 coins by market cap, including 24 h, 7 d, and 30 d price change percentages.
  Split In Batches ensures each coin is processed sequentially.
  Function (Calculate Market Metrics) computes:
    A weighted volatility score
    Market-cap-to-volume ratio
    Price-to-ATH ratio
    Composite market score

  IF & Switch nodes categorize each coin’s 24 h price action (up &gt;5%, down &gt;5%, high volatility, or stable) and append:
    signal (BUY/SELL/HOLD/NEUTRAL)
    riskRating (High/Medium/Low/Unknown)
    recommendation & investmentStrategy guidance

  NoOp & Merge nodes consolidate each branch back into a single data stream.

  Function (Generate Portfolio Summary) aggregates all analyses into:
    A Markdown portfolioSummary
    Counts of buy/sell/hold/neutral signals
    Risk distribution

  Webhook Response returns the full JSON payload with individual analyses and the summary for downstream consumers.

  👤 Who is it for?
  This workflow is ideal for:

  Crypto researchers and analysts who need scheduled market insights

  DeFi and trading bot developers looking to automate signal generation

  Portfolio managers seeking a no-code overview of top assets

  Automation engineers exploring API integration and data enrichment

  📑 Data Structure
  When you trigger the webhook, you’ll receive a JSON object containing:

  individualAnalyses: Array of { coin, symbol, currentPrice, priceChanges, marketMetrics, signal, riskRating, recommendation }

  portfolioSummary: Markdown report summarizing signals, risk distribution, and top opportunity

  marketSignals: Counts of each signal type

  riskDistribution: Counts of each risk rating

  timestamp: ISO string of analysis time

  ⚙️ Setup Instructions
  Import: In n8n Editor → click “Import from JSON” → paste this workflow JSON.

  Configure Schedule: Double-click the Schedule Trigger → set your desired interval (default: every hour).

  Webhook Path: Open the Webhook node → choose a unique path (e.g., /crypto‐analysis) and “POST”.

  Activate: Save and activate the workflow.

  Test:
    Open the webhook url to other tab or use cURL
  curl -X POST https://&lt;your-n8n-host&gt;/webhook/&lt;path&gt;

  You’ll get back a JSON payload with both portfolioSummary and individualAnalyses.

  📝 Tips
  Rate-Limit Handling: If CoinGecko returns 429, insert a Delay node (e.g., 500 ms) after the HTTP Request.
  Batch Size: Default is 1 coin at a time; you can bump it to parallelize.
  Customization: Tweak volatility weightings or add new metrics directly in the “Calculate Market Metrics” Function node.
  Extension: Swap CoinGecko for another API by updating the HTTP Request URL and field mappings.

workflow_json:
  {"id":"Uw1r9yGqgPRykfUs","meta":{"instanceId":"3fed23de697c60307f3b4f5caeafbeffabaf7bbd62c1b20ae70d5faf5a9806b4"},"name":"day9_getting_updated_in_crypto","tags":[{"id":"4zX1mtizlZxTekJP","name":"training-tasks-n8n","createdAt":"2025-04-29T10:41:14.716Z","updatedAt":"2025-04-29T10:41:14.716Z"},{"id":"F1KjxL3SjfvVqZqo","name":"training-n8n","createdAt":"2025-04-29T10:40:13.332Z","updatedAt":"2025-04-29T10:40:13.332Z"}],"nodes":[{"id":"745e4849-8c61-4b29-9980-24de93821adb","name":"Fetch Crypto Data","type":"n8n-nodes-base.httpRequest","position":[220,385],"parameters":{"url":"https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=10&page=1&sparkline=false&price_change_percentage=24h,7d,30d","options":{}},"typeVersion":3},{"id":"f4e6c40d-ab60-473b-9961-961eb1fa3505","name":"Calculate Market Metrics","type":"n8n-nodes-base.function","position":[660,385],"parameters":{"functionCode":"// Calculate a volatility score based on price changes\nconst item = $input.item.json;\n\n// Extract price change percentages\nconst priceChange24h = item.price_change_percentage_24h || 0;\nconst priceChange7d = item.price_change_percentage_7d_in_currency || 0;\nconst priceChange30d = item.price_change_percentage_30d_in_currency || 0;\n\n// Calculate absolute values to measure volatility regardless of direction\nconst absChange24h = Math.abs(priceChange24h);\nconst absChange7d = Math.abs(priceChange7d);\nconst absChange30d = Math.abs(priceChange30d);\n\n// Calculate a weighted volatility score (more weight to recent changes)\nconst volatilityScore = (absChange24h * 0.5) + (absChange7d * 0.3) + (absChange30d * 0.2);\n\n// Calculate market cap to volume ratio (higher means less liquid/more volatile)\nconst marketCapToVolumeRatio = item.market_cap / (item.total_volume || 1);\n\n// Calculate price to ATH ratio (close to 1 means near all-time high)\nconst priceToAthRatio = item.current_price / (item.ath || item.current_price);\n\n// Calculate a composite market score\nconst marketScore = (\n  (volatilityScore * 0.4) + \n  (Math.min(marketCapToVolumeRatio, 10) * 0.3) + \n  ((1 - priceToAthRatio) * 30) // Invert so coins further from ATH get higher scores\n);\n\n// Add calculated metrics to the item\nitem.volatilityScore = parseFloat(volatilityScore.toFixed(2));\nitem.marketCapToVolumeRatio = parseFloat(marketCapToVolumeRatio.toFixed(2));\nitem.priceToAthRatio = parseFloat(priceToAthRatio.toFixed(4));\nitem.marketScore = parseFloat(marketScore.toFixed(2));\n\n// Add a timestamp for the analysis\nitem.analyzedAt = new Date().toISOString();\n\nreturn {json: item};"},"typeVersion":1},{"id":"5d760f94-ca2f-44cc-aef0-83eb2cf438ee","name":"IF 24h Price Up >5%","type":"n8n-nodes-base.if","position":[880,60],"parameters":{"conditions":{"number":[{"value1":"={{ $json.price_change_percentage_24h }}","value2":5,"operation":"larger"}]}},"typeVersion":1},{"id":"19ca8650-b642-4910-ac7c-50b1ceb41ffc","name":"IF 24h Price Down >5%","type":"n8n-nodes-base.if","position":[1100,260],"parameters":{"conditions":{"number":[{"value1":"={{ $json.price_change_percentage_24h }}","value2":-5}]}},"typeVersion":1},{"id":"c5d69bbb-df7e-4089-b0c8-50653cd936f0","name":"IF High Volatility","type":"n8n-nodes-base.if","position":[1320,560],"parameters":{"conditions":{"number":[{"value1":"={{ $json.volatilityScore }}","value2":10,"operation":"larger"}]}},"typeVersion":1},{"id":"77902b9a-2cf8-4b6f-95e9-590b51278c59","name":"Set Uptrend Data","type":"n8n-nodes-base.set","position":[1540,60],"parameters":{"values":{"string":[{"name":"priceAction","value":"Strong upward momentum in the past 24 hours"},{"name":"signal","value":"BUY"},{"name":"recommendation","value":"Consider buying on continued strength above resistance levels. Set stop loss at recent support."},{"name":"investmentStrategy","value":"Momentum strategy with trailing stop loss. Consider dollar-cost averaging to manage volatility risk."}]},"options":{"dotNotation":true}},"typeVersion":2},{"id":"4706270b-3bdc-4806-a302-830a88c9a982","name":"Set Downtrend Data","type":"n8n-nodes-base.set","position":[1540,260],"parameters":{"values":{"string":[{"name":"priceAction","value":"Rapid price decline in the past 24 hours"},{"name":"signal","value":"SELL"},{"name":"recommendation","value":"Consider reducing exposure or implementing hedging strategies. Watch for oversold conditions."},{"name":"investmentStrategy","value":"Capital preservation is priority. Consider re-evaluation after price stabilization."}]},"options":{"dotNotation":true}},"typeVersion":2},{"id":"608729c4-23a5-4c5b-b9a0-d77f12166aa3","name":"Set Volatility Data","type":"n8n-nodes-base.set","position":[1540,460],"parameters":{"values":{"string":[{"name":"priceAction","value":"High volatility with significant price swings"},{"name":"signal","value":"HOLD"},{"name":"recommendation","value":"High volatility indicates market uncertainty. Consider waiting for clearer signals before making major positions."},{"name":"investmentStrategy","value":"Range-trading strategy may be effective. Set both upper and lower limit orders."}]},"options":{"dotNotation":true}},"typeVersion":2},{"id":"f8134b51-4b41-4684-97a9-008e5f0260df","name":"Set Stable Data","type":"n8n-nodes-base.set","position":[1540,660],"parameters":{"values":{"string":[{"name":"priceAction","value":"Relatively stable price action with minimal volatility"},{"name":"signal","value":"NEUTRAL"},{"name":"recommendation","value":"Market is consolidating. Watch for breakout signals in either direction."},{"name":"investmentStrategy","value":"Consider accumulating small positions or implementing a neutral options strategy."}]},"options":{"dotNotation":true}},"typeVersion":2},{"id":"5f43178c-7bb5-405d-a988-b3b0ae0a0405","name":"Merge Results","type":"n8n-nodes-base.noOp","position":[1760,360],"parameters":{},"typeVersion":1},{"id":"e422a9e1-9016-4db9-912b-58be44604eb2","name":"Set High Risk Rating","type":"n8n-nodes-base.set","position":[2200,-40],"parameters":{"values":{"string":[{"name":"riskRating","value":"High Risk"},{"name":"investmentStrategy","value":"={{ $json.investmentStrategy }} Due to high risk profile, use strict position sizing (max 2-5% of portfolio)."}]},"options":{"dotNotation":true}},"typeVersion":2},{"id":"383a55c7-f42f-4a32-b6ba-742049406f67","name":"Set Medium Risk Rating","type":"n8n-nodes-base.set","position":[2200,160],"parameters":{"values":{"string":[{"name":"riskRating","value":"Medium Risk"},{"name":"investmentStrategy","value":"={{ $json.investmentStrategy }} Moderate risk profile suggests balanced position sizing (5-10% of portfolio)."}]},"options":{"dotNotation":true}},"typeVersion":2},{"id":"2f50e6cd-dd62-4fb2-8ee2-28096c758e23","name":"Set Low Risk Rating","type":"n8n-nodes-base.set","position":[2200,460],"parameters":{"values":{"string":[{"name":"riskRating","value":"Low Risk"},{"name":"investmentStrategy","value":"={{ $json.investmentStrategy }} Lower risk profile allows for larger position sizing (10-15% of portfolio)."}]},"options":{"dotNotation":true}},"typeVersion":2},{"id":"5a820de9-11f8-4aa7-8811-afb6153a7b54","name":"Set Default Risk Rating","type":"n8n-nodes-base.set","position":[2200,660],"parameters":{"values":{"string":[{"name":"riskRating","value":"Unknown Risk"},{"name":"investmentStrategy","value":"={{ $json.investmentStrategy }} Risk profile is unclear - use conservative position sizing until more data is available."}]},"options":{"dotNotation":true}},"typeVersion":2},{"id":"9b39eb90-f0c8-44df-9721-ef1d60a8a0fc","name":"Final Merge","type":"n8n-nodes-base.noOp","position":[2420,360],"parameters":{},"typeVersion":1},{"id":"f84bd02a-92d1-49c7-9ba3-36e860a31636","name":"Format Final Analysis","type":"n8n-nodes-base.function","position":[2640,635],"parameters":{"functionCode":"// Create a formatted summary for each coin\nconst item = $input.item.json;\n\n// Format dollar amounts nicely\nconst formatCurrency = (value) => {\n  return new Intl.NumberFormat('en-US', {\n    style: 'currency',\n    currency: 'USD',\n    minimumFractionDigits: 2,\n    maximumFractionDigits: 2\n  }).format(value);\n};\n\n// Format percentages nicely\nconst formatPercent = (value) => {\n  return `${value > 0 ? '+' : ''}${value.toFixed(2)}%`;\n};\n\n// Create a detailed analysis report\nconst analysisReport = {\n  coin: item.name,\n  symbol: item.symbol.toUpperCase(),\n  currentPrice: formatCurrency(item.current_price),\n  marketCap: formatCurrency(item.market_cap),\n  volume24h: formatCurrency(item.total_volume),\n  priceChanges: {\n    \"24h\": formatPercent(item.price_change_percentage_24h),\n    \"7d\": formatPercent(item.price_change_percentage_7d_in_currency),\n    \"30d\": formatPercent(item.price_change_percentage_30d_in_currency)\n  },\n  marketMetrics: {\n    volatilityScore: item.volatilityScore,\n    marketCapToVolumeRatio: item.marketCapToVolumeRatio,\n    priceToAthRatio: item.priceToAthRatio,\n    marketScore: item.marketScore\n  },\n  analysis: {\n    priceAction: item.priceAction,\n    signal: item.signal,\n    riskRating: item.riskRating,\n    recommendation: item.recommendation,\n    investmentStrategy: item.investmentStrategy\n  },\n  timestamp: item.analyzedAt\n};\n\n// Generate a natural language summary\nconst summary = `\n## ${item.name} (${item.symbol.toUpperCase()}) Analysis\n\nCurrent Price: ${formatCurrency(item.current_price)} (${formatPercent(item.price_change_percentage_24h)} 24h)\\n\\n\n\nMarket Signal: **${item.signal}** - *${item.priceAction}*\nRisk Rating: **${item.riskRating}**\\n\\n\n\n**Recommendation:**\n${item.recommendation}\n\n**Investment Strategy:**\n${item.investmentStrategy}\n\n---\n*Analysis based on volatility score of ${item.volatilityScore} and market score of ${item.marketScore}*\n`;\n\n// Return both structured data and a human-readable summary\nreturn {\n  json: {\n    ...item,\n    analysisReport,\n    summary\n  }\n};"},"typeVersion":1},{"id":"911280f8-82cb-42ee-bd8a-6de15c58f188","name":"Collect All Analyses","type":"n8n-nodes-base.noOp","position":[660,-140],"parameters":{},"typeVersion":1},{"id":"a4de8078-7f49-4b22-a11a-a2efabfa16b1","name":"Generate Portfolio Summary","type":"n8n-nodes-base.function","position":[880,-140],"parameters":{"functionCode":"// Create a portfolio summary based on all coin analyses\nconst allCoins = $input.all();\n\n// Extract all analyzed coins\nconst analyzedCoins = allCoins.map(coin => coin.json);\n\n// Count signals by type\nconst signalCounts = {\n  BUY: 0,\n  SELL: 0,\n  HOLD: 0,\n  NEUTRAL: 0\n};\n\n// Count risk ratings\nconst riskCounts = {\n  \"High Risk\": 0,\n  \"Medium Risk\": 0,\n  \"Low Risk\": 0,\n  \"Unknown Risk\": 0\n};\n\n// Calculate portfolio metrics\nanalyzedCoins.forEach(coin => {\n  // Count signals\n  if (coin.signal) {\n    signalCounts[coin.signal] = (signalCounts[coin.signal] || 0) + 1;\n  }\n\n  // Count risk ratings\n  if (coin.riskRating) {\n    riskCounts[coin.riskRating] = (riskCounts[coin.riskRating] || 0) + 1;\n  }\n});\n\n// Sort coins by market score (highest first)\nconst sortedCoins = [...analyzedCoins].sort((a, b) => b.marketScore - a.marketScore);\n\n// Get top recommendation\nconst topOpportunity = sortedCoins[0];\n\n// Generate portfolio summary markdown\nconst portfolioSummary = `# Cryptocurrency Market Analysis\n\n## Market Overview\n**Analyzed Coins:** ${analyzedCoins.length}  \n**Buy Signals:** ${signalCounts.BUY}  \n**Sell Signals:** ${signalCounts.SELL}  \n**Hold Signals:** ${signalCounts.HOLD}  \n**Neutral Signals:** ${signalCounts.NEUTRAL}  \n\n## Risk Distribution\n**High Risk Assets:** ${riskCounts[\"High Risk\"]}  \n**Medium Risk Assets:** ${riskCounts[\"Medium Risk\"]}  \n**Low Risk Assets:** ${riskCounts[\"Low Risk\"]}  \n\n## Top Opportunity  \n${topOpportunity ? `**${topOpportunity.name} (${topOpportunity.symbol.toUpperCase()})**  \n${topOpportunity.summary}` : \"No opportunities found\"}\n\n## Detailed Coin Analyses  \n${sortedCoins.map(coin => `**${coin.name} (${coin.symbol})**  \n${coin.summary}`).join('\\n\\n')}\n\n*Analysis generated on ${new Date().toLocaleString()}*`;\n\nreturn [\n  {\n    json: {\n      portfolioSummary,\n      individualAnalyses: analyzedCoins.map(coin => coin.analysisReport),\n      marketSignals: signalCounts,\n      riskDistribution: riskCounts,\n      timestamp: new Date().toISOString()\n    }\n  }\n];\n"},"typeVersion":1},{"id":"3277b96e-ab2c-4561-a29c-958998f45686","name":"Loop Over Items","type":"n8n-nodes-base.splitInBatches","position":[440,385],"parameters":{"options":{}},"typeVersion":3},{"id":"8256a60a-ddb8-4d72-b443-8fba819815bb","name":"Switch by Market Score","type":"n8n-nodes-base.switch","position":[1980,339],"parameters":{"rules":{"rules":[{"value2":20,"operation":"larger"},{"value2":10,"operation":"larger"},{"operation":"larger"}]},"value1":"={{ $json.marketScore }}","fallbackOutput":3},"typeVersion":1},{"id":"b8cb4f7d-3818-48df-89ea-9db22797375a","name":"Split Out","type":"n8n-nodes-base.splitOut","position":[1100,-140],"parameters":{"options":{},"fieldToSplitOut":"individualAnalyses"},"typeVersion":1},{"id":"936e9ada-4b6b-4cab-90e1-0bea30eaaa0c","name":"Respond to Webhook","type":"n8n-nodes-base.respondToWebhook","position":[1320,-140],"parameters":{"options":{},"respondWith":"allIncomingItems"},"typeVersion":1.1},{"id":"7791cebf-4733-4cf6-8341-96771733b507","name":"Webhook","type":"n8n-nodes-base.webhook","position":[0,380],"webhookId":"31941fd9-9fd5-4fab-a1b9-9c347e26f5c9","parameters":{"path":"31941fd9-9fd5-4fab-a1b9-9c347e26f5c9","options":{},"responseMode":"responseNode"},"typeVersion":2},{"id":"d25b2427-9fc7-4042-92f2-673de5019206","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[2120,-140],"parameters":{"width":260,"height":960,"content":"## Categorize and set the rating of coin"},"typeVersion":1},{"id":"ac3a6503-5ce7-406d-9efb-122928239337","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[680,40],"parameters":{},"typeVersion":1},{"id":"c4e4e17d-bf13-44a2-9a9e-1d22104f1062","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[140,-20],"parameters":{"content":"## This workflow aims to"},"typeVersion":1}],"active":false,"settings":{"executionOrder":"v1"},"versionId":"be12f8a1-3c44-4a1c-8f74-d1df269de92c","connections":{"Webhook":{"main":[[{"node":"Fetch Crypto Data","type":"main","index":0}]]},"Split Out":{"main":[[{"node":"Respond to Webhook","type":"main","index":0}]]},"Final Merge":{"main":[[{"node":"Format Final Analysis","type":"main","index":0}]]},"Merge Results":{"main":[[{"node":"Switch by Market Score","type":"main","index":0}]]},"Loop Over Items":{"main":[[{"node":"Collect All Analyses","type":"main","index":0}],[{"node":"Calculate Market Metrics","type":"main","index":0}]]},"Set Stable Data":{"main":[[{"node":"Merge Results","type":"main","index":0}]]},"Set Uptrend Data":{"main":[[{"node":"Merge Results","type":"main","index":0}]]},"Fetch Crypto Data":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"IF High Volatility":{"main":[[{"node":"Set Volatility Data","type":"main","index":0}],[{"node":"Set Stable Data","type":"main","index":0}]]},"Set Downtrend Data":{"main":[[{"node":"Merge Results","type":"main","index":0}]]},"IF 24h Price Up >5%":{"main":[[{"node":"Set Uptrend Data","type":"main","index":0}],[{"node":"IF 24h Price Down >5%","type":"main","index":0}]]},"Set Low Risk Rating":{"main":[[{"node":"Final Merge","type":"main","index":0}]]},"Set Volatility Data":{"main":[[{"node":"Merge Results","type":"main","index":0}]]},"Collect All Analyses":{"main":[[{"node":"Generate Portfolio Summary","type":"main","index":0}]]},"Set High Risk Rating":{"main":[[{"node":"Final Merge","type":"main","index":0}]]},"Format Final Analysis":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"IF 24h Price Down >5%":{"main":[[{"node":"Set Downtrend Data","type":"main","index":0}],[{"node":"IF High Volatility","type":"main","index":0}]]},"Set Medium Risk Rating":{"main":[[{"node":"Final Merge","type":"main","index":0}]]},"Switch by Market Score":{"main":[[{"node":"Set High Risk Rating","type":"main","index":0}],[{"node":"Set Medium Risk Rating","type":"main","index":0}],[{"node":"Set Low Risk Rating","type":"main","index":0}],[{"node":"Set Default Risk Rating","type":"main","index":0}]]},"Set Default Risk Rating":{"main":[[{"node":"Final Merge","type":"main","index":0}]]},"Calculate Market Metrics":{"main":[[{"node":"IF 24h Price Up >5%","type":"main","index":0},{"node":"IF 24h Price Down >5%","type":"main","index":0},{"node":"IF High Volatility","type":"main","index":0}]]},"Generate Portfolio Summary":{"main":[[{"node":"Split Out","type":"main","index":0}]]}}}


name: WhatsApp Expense Tracker with PostgreSQL Database & AI-Powered Reports
author_name: Roshan Ramani
author_username: rawsun007
categories: []
created_at: 2025-05-17T05:57:32.971Z
updated_at: 2025-05-17T05:57:32.971Z
url: https://n8n.io/workflows/4136
scraped_at: 2025-07-06 21:16:30
description:
  Track Personal Finances with WhatsApp and AI Assistant

  Transform your WhatsApp into a powerful personal finance command center. This AI-powered workflow converts natural language messages into structured financial data, automates record-keeping, and delivers instant insights—all within your favorite messaging app.

  Who is this for?

  This template is perfect for:
  Personal finance enthusiasts** who want effortless expense tracking
  Small business owners** managing personal and business expenses  
  Freelancers** tracking income and expenses across projects
  Anyone** who prefers messaging over complex finance apps
  Users seeking privacy** with self-hosted financial data

  What problem is this workflow solving?

  Traditional expense tracking requires switching between apps, manual data entry, and complex spreadsheets. Most people abandon these systems within weeks. This workflow solves the friction by:
  Eliminating app-switching—everything happens in WhatsApp
  Converting natural language to structured data automatically
  Providing instant confirmations and reports
  Requiring zero learning curve or behavior change

  What this workflow does

  Smart Transaction Processing
  Send natural messages like Spent 300 on groceries at Walmart and the AI automatically extracts:
  Date**: Today's date (or specified date)
  Category**: Groceries  
  Type**: Expense/Income/Debt
  Amount**: 300
  Person/Company**: Walmart

  Intelligent Message Classification
  The workflow automatically routes messages to three processing branches:
  Branch 1**: Reports and analytics (show March expenses)
  Branch 2**: Transaction logging (spent 50 on coffee)  
  Branch 3**: General financial chat (how can I save money?)

  Advanced Reporting
  Generate instant reports by messaging:
  today's report → Daily income/expense summary
  March vs April report → Monthly comparisons with percentages
  show groceries spending → Category-specific analysis
  Automatic daily summaries at your preferred time

  Database Integration
  All transactions are stored in PostgreSQL with proper schema:
  CREATE TABLE financial_transactions (
   date DATE NOT NULL,
   category TEXT NOT NULL, 
   type TEXT NOT NULL,
   amount NUMERIC(12,2) NOT NULL,
   person TEXT
  );

  Setup

  Prerequisites

  n8n instance** (self-hosted or n8n.cloud)
  WhatsApp Business Cloud API** credentials
  PostgreSQL database** (version 12+)
  OpenRouter API key** for AI processing

  Quick Setup Steps

  Import the workflow template into your n8n instance
  Configure credentials:
    WhatsApp Business Cloud API (App Token + Phone Number ID)
    PostgreSQL connection details
    OpenRouter API key for AI processing
  Create database table using the provided SQL schema
  Test the connection by sending a sample message
  Customize the scheduled report timing (default: 8 AM daily)

  Verification Checklist

  [ ] WhatsApp webhook receives messages
  [ ] AI correctly parses transaction messages
  [ ] Database insertions work properly
  [ ] Confirmation messages are sent back
  [ ] Reports generate with accurate data

  How to customize this workflow to your needs

  AI Model Configuration

  Default**: Uses OpenRouter with GPT-3.5-turbo for cost efficiency
  Upgrade**: Switch to GPT-4 or Claude for better accuracy
  Local**: Replace with self-hosted Ollama for complete privacy

  Database Options

  PostgreSQL**: Recommended for production use
  Google Sheets**: Alternative for simpler setups (nodes included)
  MySQL/SQLite**: Easily adaptable with minor SQL modifications

  Message Classification

  Customize the classification system:
  0**: Reports (modify SQL queries for different analytics)
  1**: Transactions (adjust parsing rules for your language/currency)
  2**: Chat (customize AI responses for financial advice)

  Reporting Customization

  Scheduled reports**: Change timing, format, and recipients
  Custom periods**: Add quarterly, yearly, or custom date ranges
  Categories**: Modify auto-categorization rules for your spending patterns
  Currency**: Update formatting for your local currency

  Advanced Features

  Multi-user support**: Add user identification for family/team use
  Receipt photos**: Extend workflow to process image receipts via OCR
  Budgets**: Add budget tracking and overspend alerts
  Integrations**: Connect to banks via Plaid or other financial APIs

  Complete Package Included

  When you download this template, you get everything needed for immediate implementation:

  Ready-to-Use n8n Workflow

  Fully configured nodes** with descriptive names explaining each step
  Color-coded sticky notes** throughout the workflow explaining:
   What each branch does (Reports/Transactions/Chat)
   How the AI classification works
   Database connection requirements
   Error handling and troubleshooting tips

  Comprehensive Documentation Bundle

  Quick Start Guide**: Get running in under 10 minutes
  Detailed Setup Guide**: Complete configuration walkthrough with screenshots
  Branch Explanation Guide**: Deep dive into each processing branch:
   Branch 0: Reports & Analytics - SQL queries and formatting
   Branch 1: Transaction Processing - AI parsing and database insertion
   Branch 2: Financial Chat - AI responses and conversation handling

  Built-in Workflow Documentation

  Sticky notes at every major step** explaining the logic
  Node descriptions** that clarify what each component does
  Visual flow indicators** showing message routing paths
  Dependency callouts** highlighting required credentials and connections

  Technical Implementation Details

  Database schema** with complete SQL commands
  API configuration examples** for all external services
  Troubleshooting checklist** for common setup issues
  Performance optimization** recommendations

  Bonus Resources

  Example message templates** to test each workflow branch
  Sample data** for testing reports and analytics
  Customization recipes** for common modifications
  Integration patterns** for extending functionality

  Example Usage

  Log Expenses:

  Spent 1200 on rent this month
  Paid 45 for gas at Shell
  Coffee 5.50 at Starbucks

  Log Income:

  Received 5000 salary from Company ABC
  Freelance payment 800 from Client XYZ

  Generate Reports:

  today's summary
  show this week's expenses
  compare March vs April spending
  how much on food this month?

  Expected Responses:
  ✅ Logged: expense | Rent | ₹1,200.00 | Landlord
  ✅ Logged: income | salary |₹12,000.00|company

  📊 Today's Summary:
  Income: ₹0.00
  Expenses: ₹1,245.50  
  Savings: -₹1,245.50

  📈 March vs April:
  Expenses: ₹15,000 vs ₹12,500 (-16.7%)
  Top categories: Rent, Food, Transport

nodes_used:
  ["n8n-nodes-base.postgres","n8n-nodes-base.whatsApp","n8n-nodes-base.code","@n8n/n8n-nodes-langchain.agent","@n8n/n8n-nodes-langchain.outputParserStructured","@n8n/n8n-nodes-langchain.toolCalculator","@n8n/n8n-nodes-langchain.toolCode","@n8n/n8n-nodes-langchain.lmChatOpenRouter"]

workflow_json:
  {"id":"cMhDQYcAoghnCPCK","meta":{"instanceId":"cbc68f6c587084f6fe53914a07ed22d475640cb7a6f4ade193e6f0c6d7a06ce8","templateCredsSetupCompleted":true},"name":"Track___Analyze_Personal_Finances_with_WhatsApp_AI_Assistant_version_2.json","tags":[],"nodes":[{"id":"2d9465b4-58ac-4c00-a782-e8ae4e0767e5","name":"Date and time","type":"@n8n/n8n-nodes-langchain.toolCode","position":[-480,900],"parameters":{},"typeVersion":1.2},{"id":"3ca24176-0bbf-439e-bc09-d4c7c9550db9","name":"Structured Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[-360,900],"parameters":{},"typeVersion":1.2},{"id":"ced1f18b-bdaf-4c29-96f7-b9eb2ed168b2","name":"OpenRouter Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenRouter","position":[-2000,920],"parameters":{},"typeVersion":1},{"id":"e28ef82b-c4ca-4956-8714-1ccdf56234bc","name":"OpenRouter Chat Model1","type":"@n8n/n8n-nodes-langchain.lmChatOpenRouter","position":[-1220,180],"parameters":{},"typeVersion":1},{"id":"bdb2baa4-8595-4526-8526-2249e2546b8c","name":"Calculator","type":"@n8n/n8n-nodes-langchain.toolCalculator","position":[160,180],"parameters":{},"typeVersion":1},{"id":"df26c9be-997b-4c9d-b8bf-4f91851225f8","name":"OpenRouter Chat Model3","type":"@n8n/n8n-nodes-langchain.lmChatOpenRouter","position":[40,180],"parameters":{},"typeVersion":1},{"id":"d28325fc-2633-469f-8e0b-ed63e1a5cd21","name":"OpenRouter Chat Model4","type":"@n8n/n8n-nodes-langchain.lmChatOpenRouter","position":[-2180,-700],"parameters":{},"typeVersion":1},{"id":"2af86825-6971-4c04-8807-fdb3fb8f5d2f","name":"Postgres2","type":"n8n-nodes-base.postgresTool","position":[-1540,-800],"parameters":{},"typeVersion":2.6},{"id":"c1b15283-b5ed-47be-88d4-eaa8ec621d18","name":"OpenRouter Chat Model5","type":"@n8n/n8n-nodes-langchain.lmChatOpenRouter","position":[-1660,-800],"parameters":{},"typeVersion":1},{"id":"68bf1381-c0e1-4f40-a94a-c9128cced0ca","name":"Calculator1","type":"@n8n/n8n-nodes-langchain.toolCalculator","position":[-1080,-700],"parameters":{},"typeVersion":1},{"id":"f0f2a8f1-9571-4097-978e-d403daf2e144","name":"Structured Output Parser2","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[-1420,-800],"parameters":{},"typeVersion":1.2},{"id":"57c96e65-3eaa-4fb4-add1-910cd3a54732","name":"OpenRouter Chat Model6","type":"@n8n/n8n-nodes-langchain.lmChatOpenRouter","position":[-1200,-700],"parameters":{},"typeVersion":1},{"id":"6da02d5c-d2ff-4531-a1b1-15f26090f5bd","name":"Convert to File","type":"n8n-nodes-base.convertToFile","position":[-180,60],"parameters":{},"typeVersion":1.1},{"id":"1bde35b3-c836-4f2a-bb0f-b8ce24e8b937","name":"Send Financial Response","type":"n8n-nodes-base.whatsApp","position":[1160,700],"webhookId":"f71b40d3-80fc-49d5-85f9-bdac44343b7a","parameters":{},"typeVersion":1},{"id":"f779c955-66b3-43a2-879c-080ab3c1350e","name":"Normal Conversation ","type":"n8n-nodes-base.whatsApp","position":[-760,1480],"webhookId":"f71b40d3-80fc-49d5-85f9-bdac44343b7a","parameters":{},"typeVersion":1},{"id":"21f3f5df-e990-4198-9557-6b91685d953c","name":"Incoming WhatsApp Trigger","type":"n8n-nodes-base.whatsAppTrigger","position":[-2240,700],"webhookId":"c9f59683-0d8a-474e-add3-d07c8fa53c94","parameters":{},"typeVersion":1},{"id":"3b0b47d7-69e9-46de-b1d0-7ccc5b178cda","name":"Message Intent Classifier","type":"@n8n/n8n-nodes-langchain.agent","position":[-2020,700],"parameters":{},"typeVersion":1.9},{"id":"5b78429c-34e6-46d8-87da-3dcf6ca9fdda","name":"Route by Intent","type":"n8n-nodes-base.switch","position":[-1660,700],"parameters":{},"typeVersion":3.2},{"id":"8a41699f-020f-4f8b-af2f-001f81f1d2eb","name":"Parse & Validate Transaction","type":"@n8n/n8n-nodes-langchain.agent","position":[-580,700],"parameters":{},"typeVersion":1.9},{"id":"9fb81ef2-04ca-4fc2-b041-84c13fef05f7","name":"Split Transaction Lines","type":"n8n-nodes-base.splitOut","position":[-160,700],"parameters":{},"typeVersion":1},{"id":"ac5c1e98-c006-4dcc-a547-ac3b47abd40d","name":"Format Transaction JSON","type":"n8n-nodes-base.code","position":[60,700],"parameters":{},"typeVersion":2},{"id":"bd7e2c87-aa9a-4d70-abeb-3500107a9e49","name":"Validate Transaction Fields","type":"n8n-nodes-base.code","position":[280,700],"parameters":{},"typeVersion":2},{"id":"458e9264-0077-4365-9ed9-abcbd2aac464","name":"Insert Transaction into DB","type":"n8n-nodes-base.postgres","position":[500,700],"parameters":{},"typeVersion":2.6},{"id":"2d6dec05-660e-4a2b-ac3b-a4985ba384b2","name":"Build Confirmation Message","type":"@n8n/n8n-nodes-langchain.agent","position":[740,700],"parameters":{},"typeVersion":1.9},{"id":"f545840e-4c0f-49be-a219-9178e2a8deb9","name":"Daily 8AM Trigger","type":"n8n-nodes-base.scheduleTrigger","position":[-2480,-920],"parameters":{},"typeVersion":1.2},{"id":"0d2d89ca-3a89-4989-9614-7f610da7e395","name":"Build Daily Report Query","type":"@n8n/n8n-nodes-langchain.agent","position":[-2260,-920],"parameters":{},"typeVersion":1.9},{"id":"fb61c689-a2cd-41af-8fc9-7a9428217338","name":"Execute Daily Report Query","type":"@n8n/n8n-nodes-langchain.agent","position":[-1640,-1020],"parameters":{},"typeVersion":1.9,"alwaysOutputData":false},{"id":"75e06bba-f2e5-4ad9-8c8d-8da69b335a99","name":"Build Daily Financial Summary","type":"@n8n/n8n-nodes-langchain.agent","position":[-1220,-920],"parameters":{},"typeVersion":1.9},{"id":"de60a090-1035-44ac-bb47-57d2313c87c0","name":"Send Daily Report","type":"n8n-nodes-base.whatsApp","position":[-840,-920],"webhookId":"f71b40d3-80fc-49d5-85f9-bdac44343b7a","parameters":{},"typeVersion":1},{"id":"b8adeb56-e85e-4456-9948-138812b37be6","name":"Build Custom Report Query","type":"@n8n/n8n-nodes-langchain.agent","position":[-1220,0],"parameters":{},"typeVersion":1.9},{"id":"65a22ebc-6d8e-4852-870c-86bd1233cb31","name":"Transform Custom Query for Postgres","type":"n8n-nodes-base.code","position":[-840,60],"parameters":{},"typeVersion":2},{"id":"e4df15d9-c259-4402-9f25-f1d272d97b14","name":"Format Custom Query Results","type":"n8n-nodes-base.code","position":[-400,60],"parameters":{},"executeOnce":false,"typeVersion":2},{"id":"e6f8b8f5-814f-4a29-9b5c-401144c382b3","name":"Execute Custom Report Query","type":"n8n-nodes-base.postgres","position":[-620,60],"parameters":{},"typeVersion":2.6},{"id":"fb3a83be-4785-45e3-a527-4a03516db609","name":"Build Custom Financial Summary","type":"@n8n/n8n-nodes-langchain.agent","position":[60,-40],"parameters":{},"executeOnce":true,"typeVersion":1.9},{"id":"64940c1f-41c1-46d9-b183-9f8af3cfb864","name":"Send Custom Report","type":"n8n-nodes-base.whatsApp","position":[480,60],"webhookId":"f71b40d3-80fc-49d5-85f9-bdac44343b7a","parameters":{},"typeVersion":1},{"id":"a22028ea-7164-4e43-9107-2ebbeb875117","name":"simple conversation ","type":"@n8n/n8n-nodes-langchain.agent","position":[-1180,1480],"parameters":{},"typeVersion":1.9},{"id":"e86fe657-0ec0-41de-adac-5d59f304caea","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-2900,-300],"parameters":{"content":""},"typeVersion":1},{"id":"cb66ba94-01aa-4a0c-b2b1-acd6511d55af","name":"Transform Custom Query for Postgres1","type":"n8n-nodes-base.code","position":[-1880,-920],"parameters":{},"typeVersion":2},{"id":"1edd968f-3e50-49eb-a9b7-45a83cb0ba66","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-3080,-1160],"parameters":{"content":""},"typeVersion":1},{"id":"7c7fa6ca-5ca5-44cb-a26e-46a4147821e8","name":"Date and time1","type":"@n8n/n8n-nodes-langchain.toolCode","position":[-1100,180],"parameters":{},"typeVersion":1.2},{"id":"5e3a3c5a-1a6d-4a5c-9f04-0ff8f984fe18","name":"Date and time2","type":"@n8n/n8n-nodes-langchain.toolCode","position":[280,180],"parameters":{},"typeVersion":1.2},{"id":"2cec7aab-a6a0-443e-972f-eeba83f8f75d","name":"Date and time3","type":"@n8n/n8n-nodes-langchain.toolCode","position":[900,920],"parameters":{},"typeVersion":1.2},{"id":"a246fac9-ae73-4192-bdb6-cf7e700b94cc","name":"Date and time4","type":"@n8n/n8n-nodes-langchain.toolCode","position":[-1880,920],"parameters":{},"typeVersion":1.2},{"id":"138de4a3-4c50-4d7b-ae6e-ba02b96d2565","name":"Date and time5","type":"@n8n/n8n-nodes-langchain.toolCode","position":[-1020,1680],"parameters":{},"typeVersion":1.2},{"id":"6e9a0c1e-5302-453f-8d2c-7398172c9055","name":"OpenRouter Chat Model2","type":"@n8n/n8n-nodes-langchain.lmChatOpenRouter","position":[-620,900],"parameters":{},"typeVersion":1},{"id":"ab6ae6d1-a9b5-4eef-8930-0ee27c5787f0","name":"OpenRouter Chat Model7","type":"@n8n/n8n-nodes-langchain.lmChatOpenRouter","position":[-1180,1700],"parameters":{},"typeVersion":1},{"id":"a680e6d7-8332-466b-8d3e-8923fb929ab7","name":"OpenRouter Chat Model8","type":"@n8n/n8n-nodes-langchain.lmChatOpenRouter","position":[780,920],"parameters":{},"typeVersion":1},{"id":"5e75c9ba-ef19-4052-b7a1-9233d469ae4b","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-1880,-100],"parameters":{"content":""},"typeVersion":1},{"id":"444ed176-46c1-4daf-bbfc-9231baccdf19","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-1860,1380],"parameters":{"content":""},"typeVersion":1},{"id":"fcca8840-954e-4ac5-b842-86fe24e35484","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-1240,560],"parameters":{"content":""},"typeVersion":1}],"active":true,"settings":{"executionOrder":"v1"},"versionId":"e4a85103-baa6-4c56-a921-59ea3c322f7a","connections":{"Postgres2":{"ai_tool":[[{"node":"Execute Daily Report Query","type":"ai_tool","index":0}]]},"Calculator":{"ai_tool":[[{"node":"Build Custom Financial Summary","type":"ai_tool","index":0}]]},"Calculator1":{"ai_tool":[[{"node":"Build Daily Financial Summary","type":"ai_tool","index":0}]]},"Date and time":{"ai_tool":[[{"node":"Parse & Validate Transaction","type":"ai_tool","index":0}]]},"Date and time1":{"ai_tool":[[{"node":"Build Custom Report Query","type":"ai_tool","index":0}]]},"Date and time2":{"ai_tool":[[{"node":"Build Custom Financial Summary","type":"ai_tool","index":0}]]},"Date and time3":{"ai_tool":[[{"node":"Build Confirmation Message","type":"ai_tool","index":0}]]},"Date and time4":{"ai_tool":[[{"node":"Message Intent Classifier","type":"ai_tool","index":0}]]},"Date and time5":{"ai_tool":[[{"node":"simple conversation ","type":"ai_tool","index":0}]]},"Convert to File":{"main":[[{"node":"Build Custom Financial Summary","type":"main","index":0}]]},"Route by Intent":{"main":[[{"node":"Build Custom Report Query","type":"main","index":0}],[{"node":"Parse & Validate Transaction","type":"main","index":0}],[{"node":"simple conversation ","type":"main","index":0}]]},"Daily 8AM Trigger":{"main":[[{"node":"Build Daily Report Query","type":"main","index":0}]]},"simple conversation ":{"main":[[{"node":"Normal Conversation ","type":"main","index":0}]]},"OpenRouter Chat Model":{"ai_languageModel":[[{"node":"Message Intent Classifier","type":"ai_languageModel","index":0}]]},"OpenRouter Chat Model1":{"ai_languageModel":[[{"node":"Build Custom Report Query","type":"ai_languageModel","index":0}]]},"OpenRouter Chat Model2":{"ai_languageModel":[[{"node":"Parse & Validate Transaction","type":"ai_languageModel","index":0}]]},"OpenRouter Chat Model3":{"ai_languageModel":[[{"node":"Build Custom Financial Summary","type":"ai_languageModel","index":0}]]},"OpenRouter Chat Model4":{"ai_languageModel":[[{"node":"Build Daily Report Query","type":"ai_languageModel","index":0}]]},"OpenRouter Chat Model5":{"ai_languageModel":[[{"node":"Execute Daily Report Query","type":"ai_languageModel","index":0}]]},"OpenRouter Chat Model6":{"ai_languageModel":[[{"node":"Build Daily Financial Summary","type":"ai_languageModel","index":0}]]},"OpenRouter Chat Model7":{"ai_languageModel":[[{"node":"simple conversation ","type":"ai_languageModel","index":0}]]},"OpenRouter Chat Model8":{"ai_languageModel":[[{"node":"Build Confirmation Message","type":"ai_languageModel","index":0}]]},"Format Transaction JSON":{"main":[[{"node":"Validate Transaction Fields","type":"main","index":0}]]},"Split Transaction Lines":{"main":[[{"node":"Format Transaction JSON","type":"main","index":0}]]},"Build Daily Report Query":{"main":[[{"node":"Transform Custom Query for Postgres1","type":"main","index":0}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"Parse & Validate Transaction","type":"ai_outputParser","index":0}]]},"Build Custom Report Query":{"main":[[{"node":"Transform Custom Query for Postgres","type":"main","index":0}]]},"Incoming WhatsApp Trigger":{"main":[[{"node":"Message Intent Classifier","type":"main","index":0}]]},"Message Intent Classifier":{"main":[[{"node":"Route by Intent","type":"main","index":0}]]},"Structured Output Parser2":{"ai_outputParser":[[{"node":"Execute Daily Report Query","type":"ai_outputParser","index":0}]]},"Build Confirmation Message":{"main":[[{"node":"Send Financial Response","type":"main","index":0}]]},"Execute Daily Report Query":{"main":[[{"node":"Build Daily Financial Summary","type":"main","index":0}]]},"Insert Transaction into DB":{"main":[[{"node":"Build Confirmation Message","type":"main","index":0}]]},"Execute Custom Report Query":{"main":[[{"node":"Format Custom Query Results","type":"main","index":0}]]},"Format Custom Query Results":{"main":[[{"node":"Convert to File","type":"main","index":0}]]},"Validate Transaction Fields":{"main":[[{"node":"Insert Transaction into DB","type":"main","index":0}]]},"Parse & Validate Transaction":{"main":[[{"node":"Split Transaction Lines","type":"main","index":0}]]},"Build Daily Financial Summary":{"main":[[{"node":"Send Daily Report","type":"main","index":0}]]},"Build Custom Financial Summary":{"main":[[{"node":"Send Custom Report","type":"main","index":0}]]},"Transform Custom Query for Postgres":{"main":[[{"node":"Execute Custom Report Query","type":"main","index":0}]]},"Transform Custom Query for Postgres1":{"main":[[{"node":"Execute Daily Report Query","type":"main","index":0}]]}}}


name: AI SEO Readability Audit: Check Website Friendliness for LLMs
author_name: Leonard
author_username: leonardvanhemert
categories: []
created_at: 2025-05-17T14:15:31.298Z
updated_at: 2025-05-17T14:15:31.298Z
url: https://n8n.io/workflows/4151
scraped_at: 2025-07-06 21:16:30
description:
  Who is this for?
  This workflow is designed for SEO specialists, content creators, marketers, and website developers who want to ensure their web content is easily accessible, understandable, and indexable by Large Language Models (LLMs) like ChatGPT, Perplexity, and Google AI Overviews. If you're looking to optimize your site for the evolving AI-driven search landscape, this template is for you.

  What problem is this workflow solving? / Use case
  Modern AI tools often crawl websites without executing JavaScript. This can lead to them "seeing" a very different version of your page than a human user or traditional search engine bot might. This workflow helps you:
  Identify how much of your content is visible without JavaScript.
  Check for crucial on-page SEO elements that AI relies on (headings, meta descriptions, structured data).
  Detect if your site presents JavaScript-blocking warnings.
  Get an AI-generated readability score and actionable recommendations to improve AI-friendliness.

  What this workflow does
  Receives a URL via a chat interface.
  Sanitizes the input URL to ensure it's correctly formatted.
  Fetches the website's HTML content, simulating a non-JavaScript crawler (like Googlebot).
  Extracts key HTML features: visible text length, presence of H1/H2/H3 tags, meta description, Open Graph data, structured data (JSON-LD), and &lt;noscript&gt; tags. It also checks for common JavaScript-blocking messages.
  Performs an AI SEO Analysis using an LLM (via OpenAI) based on the extracted features.
  Provides a report including an AI Readability Score (0-10), a summary, actionable recommendations, and a reminder to check the robots.txt file for AI bot access.

  Setup
  Estimated setup time:** 2-5 minutes.
  Import this workflow into your n8n instance.
  Ensure you have an OpenAI account and API key.
  Configure the "OpenAI Chat Model" node with your OpenAI API credentials. If you don't have credentials set up yet, create new ones in n8n.
  Activate the workflow.
  Interact with the chat interface provided by the "When chat message received" trigger node (you can access this via its webhook URL).

  How to customize this workflow to your needs
  Change LLM Model:** In the "OpenAI Chat Model" node, you can select a different model that suits your needs or budget.
  Adjust AI Prompt:** Modify the prompt in the "AI SEO Analysis" node (Chain Llm) to change the focus of the analysis or the format of the report. For example, you could ask for more technical details or a different scoring system.
  User-Agent:** The "Get HTML from Website" node uses a Googlebot User-Agent. You can change this to simulate other bots if needed.
  JS Block Indicators:** The "Extract HTML Features" node contains a list of common JavaScript-blocking phrases. You can expand this list with other languages or specific messages relevant to your checks.

nodes_used:
  ["n8n-nodes-base.httpRequest","n8n-nodes-base.code","@n8n/n8n-nodes-langchain.chainLlm","@n8n/n8n-nodes-langchain.lmChatOpenAi"]

workflow_json:
  {"id":"qthXGkJCm1YAAQpW","meta":{"instanceId":"c586b172acc6a68496c50087fe4c45ad1d861562820afb3dfa9dc2c12688d8c2","templateCredsSetupCompleted":true},"name":"AI SEO Readability Audit: Check Website Friendliness for LLMs","tags":[{"id":"JkpR8IEIpOrc2x6l","name":"Leonard van Hemert","createdAt":"2025-05-17T14:14:16.649Z","updatedAt":"2025-05-17T14:14:16.649Z"}],"nodes":[{"id":"ea4c49eb-5a9d-4de9-acc7-3eef90b11f29","name":"When chat message received","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[-340,-140],"webhookId":"f41e2ff4-b329-4c64-9147-963726a1eb76","parameters":{"public":true,"options":{"title":"🚀 AI SEO Readability Checker","subtitle":"Test how AI-friendly your website is for search engines like ChatGPT & Perplexity – built by [Leonard van Hemert](https://nl.linkedin.com/in/leonard-van-hemert)","responseMode":"lastNode","inputPlaceholder":"https://example.com"},"initialMessages":"Hi! 👋  \nSend your website link and I’ll check how AI-friendly it is for tools like ChatGPT and Perplexity. Let’s go! 🚀"},"typeVersion":1.1},{"id":"0ede3abb-3cad-4e9a-bc8c-79d8eac06fe6","name":"Get HTML from Website","type":"n8n-nodes-base.httpRequest","position":[100,-140],"parameters":{"url":"={{ $json.url }}","options":{"timeout":10000},"jsonHeaders":"{\n  \"User-Agent\": \"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)\",\n  \"Accept-Language\": \"nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7\"\n}","sendHeaders":true,"specifyHeaders":"json"},"retryOnFail":true,"typeVersion":4.2,"alwaysOutputData":true},{"id":"96d8c97a-8d7b-41fb-a109-d56e34d7dff1","name":"Sanitize Website URL","type":"n8n-nodes-base.code","position":[-120,-140],"parameters":{"jsCode":"return [\n  {\n    json: {\n      url: (() => {\n        let input = $json.chatInput.trim().toLowerCase();\n        if (!input.startsWith('http')) input = 'https://' + input;\n        return input;\n      })()\n    }\n  }\n];"},"typeVersion":2},{"id":"2b8a702e-b141-4f71-9e8f-2caa69cfad80","name":"Extract HTML Features","type":"n8n-nodes-base.code","position":[320,-140],"parameters":{"jsCode":"const html = $json.data || '';\n\n// Remove scripts, styles, and extract visible text\nconst cleanedText = html\n  .replace(/<script[\\s\\S]*?<\\/script>/gi, '')\n  .replace(/<style[\\s\\S]*?<\\/style>/gi, '')\n  .replace(/<[^>]*>/g, '') // strip all HTML tags\n  .replace(/\\s+/g, ' ')\n  .trim();\n\n// Preview: first 400 chars of visible content\nconst previewText = cleanedText.slice(0, 400);\n\n// Lowercased text for language-agnostic JS block detection\nconst lowerText = cleanedText.toLowerCase();\n\n// Common JS-related blocking messages (EN + NL + DE)\nconst jsBlockIndicators = [\n  'enable javascript',\n  'javascript is required',\n  'please enable javascript',\n  'javascript moet ingeschakeld zijn',\n  'schakel javascript in',\n  'javascript erforderlich'\n];\n\n// Scan for any of the indicators\nconst jsWarningDetected = jsBlockIndicators.some(phrase => lowerText.includes(phrase));\n\nreturn [\n  {\n    json: {\n      visibleTextLength: cleanedText.length,\n      previewText,\n      hasH1: /<h1[\\s>]/i.test(html),\n      hasH2: /<h2[\\s>]/i.test(html),\n      hasH3: /<h3[\\s>]/i.test(html),\n      hasMetaDescription: /<meta[^>]+name=[\"']description[\"']/i.test(html),\n      hasOpenGraph: /<meta[^>]+property=[\"']og:/i.test(html),\n      hasStructuredData: /<script[^>]*type=[\"']application\\/ld\\+json[\"']/i.test(html),\n      hasNoscript: /<noscript[\\s>]/i.test(html),\n      jsWarning: jsWarningDetected,\n      robotsTxt: $('Sanitize Website URL').first().json.url.replace(/\\/$/, '') + '/robots.txt'\n    }\n  }\n];"},"typeVersion":2},{"id":"58591741-7896-4f0f-a5d6-a16efccdf4a3","name":"AI SEO Analysis","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[540,-140],"parameters":{"text":"=You are an expert in AI SEO analysis and AI search engine accessibility.\n\nYou are evaluating a website’s readability for LLM-based tools like ChatGPT, Perplexity, and Google AI Overviews. The website's raw HTML was fetched *without JavaScript execution*, simulating how LLMs typically see pages.\n\n---\n\n### 🧾 Technical Scan Summary\n\n**Visible content (no JS):**\n- Text length: {{ $json.visibleTextLength }} characters\n- Preview: \"{{ $json.previewText }}\"\n\n**Detected features:**\n- Structured Data (JSON-LD): {{ $json.hasStructuredData }}\n- Meta Description: {{ $json.hasMetaDescription }}\n- Open Graph Metadata: {{ $json.hasOpenGraph }}\n- Headings: H1: {{ $json.hasH1 }}, H2: {{ $json.hasH2 }}, H3: {{ $json.hasH3 }}\n- `<noscript>` fallback present: {{ $json.hasNoscript }}\n- JavaScript-blocking warning found: {{ $json.jsWarning }}\n\n---\n\n### 🎯 Your task:\nEvaluate the AI-readability of this website and return:\n\n1. An **AI Readability Score (0–10)**\n2. A **brief summary** of the current state (2–4 sentences)\n3. Up to **5 actionable recommendations** to improve visibility and accessibility for AI search engines\n\n💡 If the text length is below 300 or the `JavaScript-blocking warning found` is true, clearly state that the site may not be accessible to LLMs due to JavaScript dependency.\n\n⚠️ **Important:**\nYou must also **tell the user** to check their `robots.txt` file manually, and provide this exact clickable link:  \n👉 [{{ $json.robotsTxt }}]({{ $json.robotsTxt }})  \nExplain they must ensure bots like `GPTBot`, `ChatGPT-User`, and `Google-Extended` are **not blocked**.\n\nDo not perform this check yourself — just inform the user to do it.\n\n---\n\n🎁 Format your response like this:\n\n**Score:** x/10  \n**Summary:** ...  \n**Recommendations:**\n- ...\n- Check your robots.txt file at [{{ $json.robotsTxt }}]({{ $json.robotsTxt }}) to ensure AI bots are allowed.","promptType":"define"},"typeVersion":1.6},{"id":"080e40e2-bfb3-42df-8f92-ac1379135aad","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-380,20],"parameters":{"color":4,"width":740,"height":700,"content":"# 🚀 AI SEO Readability Audit Workflow\n\n**Purpose:** This workflow analyzes a website's HTML to assess its readability and accessibility for Large Language Models (LLMs) like ChatGPT and Perplexity, which often crawl without executing JavaScript.\n\n**How it Works:**\n1.  Enter a website URL in the chat.\n2.  The workflow fetches the raw HTML (simulating a no-JS crawler).\n3.  It extracts key SEO features (text content, headings, meta tags, etc.).\n4.  An LLM (via OpenAI) analyzes these features to provide:\n    - An AI Readability Score (0-10)\n    - A summary of the site's AI-friendliness\n    - Actionable recommendations\n    - A reminder to check `robots.txt`\n\n**Setup Required:**\n- An **OpenAI Account & API Key**: Configure your credentials in the \"OpenAI Chat Model\" node.\n- **n8n Instance**: This workflow runs on any n8n instance (cloud or self-hosted).\n\n**To Use:**\n1.  Ensure the \"OpenAI Chat Model\" node is configured with your API key.\n2.  Activate the workflow.\n3.  Open the chat URL provided by the \"When chat message received\" trigger.\n\n**Customization:**\n- **LLM Model:** Change the model in the \"OpenAI Chat Model\" node.\n- **Analysis Prompt:** Modify the prompt in the \"AI SEO Analysis\" node.\n\n🔗 *For more details on setup and customization, see the template description on n8n.io.*"},"typeVersion":1},{"id":"a737c2cb-1d6c-4e69-9d92-c7177c42049a","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[360,260],"parameters":{"width":540,"height":460,"content":"# **🚀 Developed by Leonard van Hemert**  \n\nThank you for using this **AI SEO Readability Audit** workflow! 🎉  \n\nThis workflow was created to help users understand how AI tools \"see\" their websites and to provide actionable insights for improving AI-friendliness.\n\nIf you find this useful, feel free to **connect with me on LinkedIn** and stay updated on my latest AI & automation projects!  \n\n🔗 **Follow me on LinkedIn**: [Leonard van Hemert](https://www.linkedin.com/in/leonard-van-hemert/)  \n\nI truly appreciate the support from the **n8n community**, and I can’t wait to see how you use and improve this workflow! 🚀  \n\nHappy optimizing,  \n**Leonard van Hemert** 💡"},"typeVersion":1},{"id":"7228e3be-1ef7-4f5a-bcb0-2a9299d53cfe","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[628,80],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o","cachedResultName":"gpt-4o"},"options":{"temperature":0.3}},"credentials":{"openAiApi":{"id":"1OV4I35YEqCf9qI5","name":"OpenAI account"}},"typeVersion":1.2}],"active":true,"settings":{"callerPolicy":"workflowsFromSameOwner","executionOrder":"v1","executionTimeout":300},"versionId":"9e18a350-a243-4368-b3d3-746a55bceb24","connections":{"AI SEO Analysis":{"main":[[]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"AI SEO Analysis","type":"ai_languageModel","index":0}]]},"Sanitize Website URL":{"main":[[{"node":"Get HTML from Website","type":"main","index":0}]]},"Extract HTML Features":{"main":[[{"node":"AI SEO Analysis","type":"main","index":0}]]},"Get HTML from Website":{"main":[[{"node":"Extract HTML Features","type":"main","index":0}]]},"When chat message received":{"main":[[{"node":"Sanitize Website URL","type":"main","index":0}]]}}}


name: Cold Email Outreach with Gmail and Google Sheets Status Tracking
author_name: Usman Liaqat
author_username: usmanliaqat
nodes_used: ["n8n-nodes-base.googleSheets","n8n-nodes-base.gmail"]
categories: []
created_at: 2025-05-19T06:09:58.904Z
updated_at: 2025-05-19T06:09:58.904Z
url: https://n8n.io/workflows/4214
scraped_at: 2025-07-06 21:16:30
description:
  This workflow automates personalized cold email outreach by pulling lead data from a Google Sheet, sending emails via Gmail, and updating the sheet to track who has been contacted.

  Features
  Automated Scheduling* – Runs daily at a specified hour via the *Schedule Trigger** node.
  Google Sheets Integration** – Fetches leads whose "Is Email Sent" value is empty.
  Batch Processing** – Processes leads in manageable batches.
  Personalized Gmail Outreach** – Sends custom emails using a pre-written template.
  Status Tracking** – Updates each lead’s row after an email is sent to prevent duplicates.

  Requirements

  Google Sheets OAuth2 credentials**
  Gmail account with OAuth2**
  Access to n8n with a deployed instance

  Setup Instructions

  1. Connect Accounts

  Authenticate Google Sheets and Gmail nodes via OAuth2 in your n8n credentials settings.

  2. Prepare Your Google Sheet

  Your Google Sheet must contain the following columns:


  Email
  Name (or WF Full Name (metadata))
  Is Email Sent

  Example:

  | Email               | Name          | Is Email Sent |
  |--------------------|---------------|----------------|
  | test@example.com   | John Doe      |                |
  | jane@company.com   | Jane Smith    | yes            |

  Only rows where "Is Email Sent" is not marked as "yes" will be processed.

  3. Customize the Email Template

  Open the “Send Personalized Email” node and update the message field. You can use variables like:

  {{ $json.Name }}
  {{ $json['WF Full Name (metadata)'] }}

  Example Message:

  Hello {{ $json.Name || $json['WF Full Name (metadata)'] }},

  I’m a software developer and automation expert. I work with businesses and individuals to build websites, mobile apps, and powerful digital solutions that help save time and grow online.

  I offer a range of services including:
  Website & App Development
  SEO & Digital Marketing
  Business Process Automation

  If you’re looking to start a new project or improve your current setup, I’d love to connect and see how I can help.

  Are you interested in discussing any of these services?

  Best regards,  
  Software Developer | Automation Expert

  4. Schedule the Workflow

  Edit the Schedule Trigger node to your preferred time (currently set to 2 PM daily):

  Customization Tips

  Replace the email copy with your branding or offer.
  Add more fields (like company or industry) and update the message for deeper personalization.
  Modify the batch size in the Split In Batches node for rate control.

  Notes & Limitations

  Gmail Quotas:** Gmail has sending limits (e.g., 500 emails/day for free accounts).
  OAuth2 Scope Approval:** Ensure the necessary scopes (e.g., Gmail send and Sheets read/write) are granted.
  Rate Limiting:** If working with large lists, consider time delays or throttle controls.

  Google Sheet Template

  You can make a copy of this sample Google Sheet to get started.

workflow_json:
  {"meta":{"instanceId":"fae057ee2d891478d0c2072cd4fb64f7da69a0dd189c9cf4fd08c30e50dba628","templateCredsSetupCompleted":true},"nodes":[{"id":"07cbdd82-2df1-41eb-80f3-cfe762ce1d5e","name":"Schedule Trigger","type":"n8n-nodes-base.scheduleTrigger","position":[-40,40],"parameters":{},"typeVersion":1.2},{"id":"bbc2f2fe-8f33-4a92-80ab-408655000baa","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-160,-200],"parameters":{"content":""},"typeVersion":1},{"id":"166afe50-aa7b-4e46-8ebc-bd964d670e34","name":"Batch Processing of Leads","type":"n8n-nodes-base.splitInBatches","position":[400,40],"parameters":{},"typeVersion":3},{"id":"0284614d-d43e-42a1-85cf-2677e06fc1f4","name":"Send Personalized Email","type":"n8n-nodes-base.gmail","position":[680,-60],"webhookId":"ad8c804e-857d-4a94-b722-65b0776f1d10","parameters":{},"typeVersion":2.1},{"id":"ae48ba04-d428-4aa3-9212-fb49af92c7ae","name":"Fetch Leads","type":"n8n-nodes-base.googleSheets","position":[180,40],"parameters":{},"typeVersion":4.5},{"id":"62e831c3-c67c-4b0c-a0bd-5e4a8fcb23f6","name":"Update Lead Status","type":"n8n-nodes-base.googleSheets","position":[880,40],"parameters":{},"typeVersion":4.5}],"connections":{"Fetch Leads":{"main":[[{"node":"Batch Processing of Leads","type":"main","index":0}]]},"Schedule Trigger":{"main":[[{"node":"Fetch Leads","type":"main","index":0}]]},"Update Lead Status":{"main":[[{"node":"Batch Processing of Leads","type":"main","index":0}]]},"Send Personalized Email":{"main":[[{"node":"Update Lead Status","type":"main","index":0}]]},"Batch Processing of Leads":{"main":[[],[{"node":"Send Personalized Email","type":"main","index":0}]]}}}


name: Context-Aware Google Calendar Management with MCP Protocol
author_name: Simeon
author_username: simealdana
nodes_used: ["n8n-nodes-base.googleCalendar","@n8n/n8n-nodes-langchain.toolWorkflow"]
categories: []
created_at: 2025-05-19T19:53:44.325Z
updated_at: 2025-05-19T19:53:44.325Z
url: https://n8n.io/workflows/4231
scraped_at: 2025-07-06 21:16:30
description:
  Google Calendar MCP – Context-Aware Calendar Operations

  This n8n template implements an MCP (Model Context Protocol)-compliant module for managing Google Calendar events in a context-aware, conflict-free manner.

  🧠 What It Does

  This MCP enables structured interaction with Google Calendar based on context and intent, ensuring reliable, reusable operations with awareness of existing data and state.

  ✅ Core Capabilities

  Context-aware event creation**  
    Prevents overlapping by validating time availability before creating new events.

  Gap validation**  
    Checks if a time range is busy or free, enabling smarter scheduling decisions.

  Conditional updates**  
    Only updates events after confirming their existence and current state.

  Safe deletion**  
    Removes events using MCP principles of validation and traceability.

  🚀 How to Use

  To use this MCP in your context-aware systems:

  Deploy the template in your n8n instance.
  Locate the Server node in the workflow — it exposes a Server-Sent Events (SSE) URL.
  Copy that SSE URL.
  Use that URL as the entry point for your MCP client or orchestrator.

  This URL acts as the communication bridge, allowing you to interact with the MCP-compliant Google Calendar logic using standard MCP semantics.

workflow_json:
  {"id":"aiKrExd0rAxJO6xi","meta":{"instanceId":"f8eaf8bef1c6467fb3687216a5c1296ee5e886fb01cb197574b7f8e91332a8d8","templateCredsSetupCompleted":true},"name":"MCP_google_calendar","tags":[],"nodes":[{"id":"17ccfdbf-d121-4ff0-95d4-bb38644d2bb1","name":"MCP Server Trigger","type":"@n8n/n8n-nodes-langchain.mcpTrigger","position":[80,-40],"webhookId":"c734cf98-3d5a-4cbd-af97-8ad2da760944","parameters":{"path":"c734cf98-3d5a-4cbd-af97-8ad2da760944"},"typeVersion":1},{"id":"174a13be-04f1-417c-8510-26798dae3447","name":"When Executed by Another Workflow","type":"n8n-nodes-base.executeWorkflowTrigger","position":[1060,220],"parameters":{"workflowInputs":{"values":[{"name":"operation"},{"name":"startDate"},{"name":"endDate"},{"name":"eventId"},{"name":"timeZone"}]}},"typeVersion":1.1},{"id":"f74799f0-67b4-4247-905c-46adb1be4739","name":"Operation","type":"n8n-nodes-base.switch","position":[1460,180],"parameters":{"rules":{"values":[{"outputKey":"getEvent","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"81b134bc-d671-4493-b3ad-8df9be3f49a6","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.operation }}","rightValue":"getEvent"}]},"renameOutput":true},{"outputKey":"deleteEvent","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"8d57914f-6587-4fb3-88e0-aa1de6ba56c1","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.operation }}","rightValue":"deleteEvent"}]},"renameOutput":true},{"outputKey":"createEvent","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"7c38f238-213a-46ec-aefe-22e0bcb8dffc","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.operation }}","rightValue":"createEvent"}]},"renameOutput":true},{"outputKey":"updateEvent","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"ee9b6783-a0f2-4848-9166-aba6645c1ebc","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.operation }}","rightValue":"updateEvent"}]},"renameOutput":true},{"outputKey":"getEventData","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"9ea6980d-a7be-4dec-8ddf-d2fcffb00af1","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"getEventData","rightValue":"getEventData"}]},"renameOutput":true}]},"options":{}},"typeVersion":3.2},{"id":"b8007362-0d41-4875-872b-877f33b74bf8","name":"validate_busy_time","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[-80,240],"parameters":{"name":"validate_busy_time","workflowId":{"__rl":true,"mode":"list","value":"aiKrExd0rAxJO6xi","cachedResultName":"MCP_google_calendar"},"description":"Call this tool to validate if the gap of time is already busy. it is useful to validate before creating a new event","workflowInputs":{"value":{"endDate":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('endDate', ``, 'string') }}","eventId":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('eventId', ``, 'string') }}","timeZone":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('timeZone', ``, 'string') }}","operation":"=getEvent","startDate":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('startDate', ``, 'string') }}"},"schema":[{"id":"operation","type":"string","display":true,"removed":false,"required":false,"displayName":"operation","defaultMatch":false,"canBeUsedToMatch":true},{"id":"startDate","type":"string","display":true,"removed":false,"required":false,"displayName":"startDate","defaultMatch":false,"canBeUsedToMatch":true},{"id":"endDate","type":"string","display":true,"removed":false,"required":false,"displayName":"endDate","defaultMatch":false,"canBeUsedToMatch":true},{"id":"eventId","type":"string","display":true,"removed":false,"required":false,"displayName":"eventId","defaultMatch":false,"canBeUsedToMatch":true},{"id":"timeZone","type":"string","display":true,"removed":false,"required":false,"displayName":"timeZone","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false}},"typeVersion":2.1},{"id":"51f39673-4657-401b-b1bf-34e816318acf","name":"create_new_event","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[80,240],"parameters":{"name":"create_new_event","workflowId":{"__rl":true,"mode":"list","value":"aiKrExd0rAxJO6xi","cachedResultName":"MCP_google_calendar"},"description":"Use this tool to create a new event; always validate if the gap of time is available before creating a new event ","workflowInputs":{"value":{"endDate":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('endDate', ``, 'string') }}","eventId":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('eventId', ``, 'string') }}","timeZone":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('timeZone', ``, 'string') }}","operation":"createEvent","startDate":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('startDate', ``, 'string') }}"},"schema":[{"id":"operation","type":"string","display":true,"removed":false,"required":false,"displayName":"operation","defaultMatch":false,"canBeUsedToMatch":true},{"id":"startDate","type":"string","display":true,"removed":false,"required":false,"displayName":"startDate","defaultMatch":false,"canBeUsedToMatch":true},{"id":"endDate","type":"string","display":true,"removed":false,"required":false,"displayName":"endDate","defaultMatch":false,"canBeUsedToMatch":true},{"id":"eventId","type":"string","display":true,"removed":false,"required":false,"displayName":"eventId","defaultMatch":false,"canBeUsedToMatch":true},{"id":"timeZone","type":"string","display":true,"removed":false,"required":false,"displayName":"timeZone","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false}},"typeVersion":2.1},{"id":"3587c022-2f57-4bf6-8066-c292bcab5399","name":"delete_event","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[360,240],"parameters":{"name":"delete_event","workflowId":{"__rl":true,"mode":"list","value":"aiKrExd0rAxJO6xi","cachedResultName":"MCP_google_calendar"},"description":"Call this tool to delete a event, to delete a event you need the even id. it is required","workflowInputs":{"value":{"endDate":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('endDate', ``, 'string') }}","eventId":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('eventId', ``, 'string') }}","timeZone":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('timeZone', ``, 'string') }}","operation":"deleteEvent","startDate":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('startDate', ``, 'string') }}"},"schema":[{"id":"operation","type":"string","display":true,"removed":false,"required":false,"displayName":"operation","defaultMatch":false,"canBeUsedToMatch":true},{"id":"startDate","type":"string","display":true,"removed":false,"required":false,"displayName":"startDate","defaultMatch":false,"canBeUsedToMatch":true},{"id":"endDate","type":"string","display":true,"removed":false,"required":false,"displayName":"endDate","defaultMatch":false,"canBeUsedToMatch":true},{"id":"eventId","type":"string","display":true,"removed":false,"required":false,"displayName":"eventId","defaultMatch":false,"canBeUsedToMatch":true},{"id":"timeZone","type":"string","display":true,"removed":false,"required":false,"displayName":"timeZone","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false}},"typeVersion":2.1},{"id":"1da9a808-b478-47cd-b129-2a11d83d8735","name":"update_event","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[220,240],"parameters":{"name":"update_event","workflowId":{"__rl":true,"mode":"list","value":"aiKrExd0rAxJO6xi","cachedResultName":"MCP_google_calendar"},"description":"Call this tool to update the event name, startDate or endDate. Validate with validate_busy_time before any action","workflowInputs":{"value":{"endDate":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('endDate', ``, 'string') }}","eventId":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('eventId', ``, 'string') }}","timeZone":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('timeZone', ``, 'string') }}","operation":"updateEvent","startDate":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('startDate', ``, 'string') }}"},"schema":[{"id":"operation","type":"string","display":true,"removed":false,"required":false,"displayName":"operation","defaultMatch":false,"canBeUsedToMatch":true},{"id":"startDate","type":"string","display":true,"removed":false,"required":false,"displayName":"startDate","defaultMatch":false,"canBeUsedToMatch":true},{"id":"endDate","type":"string","display":true,"removed":false,"required":false,"displayName":"endDate","defaultMatch":false,"canBeUsedToMatch":true},{"id":"eventId","type":"string","display":true,"removed":false,"required":false,"displayName":"eventId","defaultMatch":false,"canBeUsedToMatch":true},{"id":"timeZone","type":"string","display":true,"removed":false,"required":false,"displayName":"timeZone","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false}},"typeVersion":2.1},{"id":"f3105e5b-0dec-44d0-ba5c-5bd91b0887d1","name":"validate_availability_event","type":"n8n-nodes-base.googleCalendar","position":[2100,-220],"parameters":{"options":{},"timeMax":"={{ $json.endDate }}","timeMin":"={{ $json.startDate }}","calendar":{"__rl":true,"mode":"list","value":"your-calendar@gmail.com","cachedResultName":"your-calendar@gmail.com"},"resource":"calendar"},"credentials":{"googleCalendarOAuth2Api":{"id":"google-api-id","name":"Google Calendar account"}},"typeVersion":1.3},{"id":"43f2125b-85ea-455d-92ed-b84d0eb4a566","name":"check_availability_to_create","type":"n8n-nodes-base.googleCalendar","position":[1780,220],"parameters":{"options":{},"timeMax":"={{ $('map_data').item.json.endDate }}","timeMin":"={{ $('map_data').item.json.startDate }}","calendar":{"__rl":true,"mode":"list","value":"your-calendar@gmail.com","cachedResultName":"your-calendar@gmail.com"},"resource":"calendar"},"credentials":{"googleCalendarOAuth2Api":{"id":"google-api-id","name":"Google Calendar account"}},"typeVersion":1.3},{"id":"7f2e1fef-79cb-4728-aa63-1afe038598ab","name":"If","type":"n8n-nodes-base.if","position":[2000,220],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"4ee8a84d-c48a-416f-aa31-0633ee59124b","operator":{"type":"boolean","operation":"true","singleValue":true},"leftValue":"={{ $json.available }}","rightValue":""}]}},"typeVersion":2.2},{"id":"b2523fe9-526b-4617-b404-59a0b0e6d0e0","name":"Stop and Error","type":"n8n-nodes-base.stopAndError","position":[2220,320],"parameters":{"errorMessage":"The time you are trying to create the event is busy"},"typeVersion":1},{"id":"c72026c4-820d-4be0-9bbd-37b9ec6d2bf1","name":"create_event","type":"n8n-nodes-base.googleCalendar","position":[2220,160],"parameters":{"end":"={{ $('map_data').item.json.endDate }}","start":"={{ $('map_data').item.json.startDate }}","calendar":{"__rl":true,"mode":"list","value":"your-calendar@gmail.com","cachedResultName":"your-calendar@gmail.com"},"additionalFields":{}},"credentials":{"googleCalendarOAuth2Api":{"id":"google-api-id","name":"Google Calendar account"}},"typeVersion":1.3},{"id":"61f84fdb-768e-4b5f-9df9-21316dfa7678","name":"delete_event1","type":"n8n-nodes-base.googleCalendar","position":[2120,-20],"parameters":{"eventId":"={{ $('map_data').item.json.eventId }}","options":{},"calendar":{"__rl":true,"mode":"list","value":"your-calendar@gmail.com","cachedResultName":"your-calendar@gmail.com"},"operation":"delete"},"credentials":{"googleCalendarOAuth2Api":{"id":"google-api-id","name":"Google Calendar account"}},"typeVersion":1.3},{"id":"2544e1e6-e620-4794-b1d4-898b2e9722ad","name":"Edit Fields","type":"n8n-nodes-base.set","position":[2320,-220],"parameters":{"options":{},"assignments":{"assignments":[{"id":"973dfb96-eeda-45be-bc93-668c9118677f","name":"available","type":"boolean","value":"={{ $json.available }}"}]}},"typeVersion":3.4},{"id":"966dc7bb-b2c8-40b1-95d9-ad10b232d1b2","name":"get_event_in_time_gap","type":"n8n-nodes-base.googleCalendar","position":[1860,700],"parameters":{"options":{},"timeMax":"={{ $('map_data').item.json.endDate }}","timeMin":"={{ $('map_data').item.json.startDate }}","calendar":{"__rl":true,"mode":"list","value":"your-calendar@gmail.com","cachedResultName":"your-calendar@gmail.com"},"operation":"getAll"},"credentials":{"googleCalendarOAuth2Api":{"id":"google-api-id","name":"Google Calendar account"}},"typeVersion":1.3,"alwaysOutputData":true},{"id":"7010b476-f500-4891-a795-30c75f0f077c","name":"update_calendar","type":"n8n-nodes-base.googleCalendar","position":[1860,480],"parameters":{"eventId":"={{ $json.eventId }}","calendar":{"__rl":true,"mode":"list","value":"your-calendar@gmail.com","cachedResultName":"your-calendar@gmail.com"},"operation":"update","updateFields":{"end":"={{ $json.endDate }}","start":"={{ $json.startDate }}"}},"credentials":{"googleCalendarOAuth2Api":{"id":"google-api-id","name":"Google Calendar account"}},"typeVersion":1.3},{"id":"933163a6-5597-48da-95de-7067dd55ad84","name":"get_events_in_gap_time","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[520,240],"parameters":{"name":"get_events_in_gap_time","workflowId":{"__rl":true,"mode":"list","value":"aiKrExd0rAxJO6xi","cachedResultName":"MCP_google_calendar"},"description":"Use this tool to get event data in a gap of time. but if you have just validate the availibity of the time use \"validate_busy_time\" tool this is tool is to get data","workflowInputs":{"value":{"endDate":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('endDate', ``, 'string') }}","eventId":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('eventId', ``, 'string') }}","timeZone":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('timeZone', ``, 'string') }}","operation":"getEventData","startDate":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('startDate', ``, 'string') }}"},"schema":[{"id":"operation","type":"string","display":true,"required":false,"displayName":"operation","defaultMatch":false,"canBeUsedToMatch":true},{"id":"startDate","type":"string","display":true,"required":false,"displayName":"startDate","defaultMatch":false,"canBeUsedToMatch":true},{"id":"endDate","type":"string","display":true,"required":false,"displayName":"endDate","defaultMatch":false,"canBeUsedToMatch":true},{"id":"eventId","type":"string","display":true,"required":false,"displayName":"eventId","defaultMatch":false,"canBeUsedToMatch":true},{"id":"timeZone","type":"string","display":true,"removed":false,"required":false,"displayName":"timeZone","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false}},"typeVersion":2.1},{"id":"01c9435e-0258-4048-a3ad-cf84424fad6c","name":"map_data","type":"n8n-nodes-base.set","position":[1240,220],"parameters":{"mode":"raw","options":{},"jsonOutput":"={\n  \"operation\": \"{{ $json.operation }}\",\n  \"startDate\": \"{{ DateTime.fromISO($json.startDate).setZone($json.timeZone).toISO() }}\",\n  \"endDate\": \"{{ DateTime.fromISO($json.endDate).setZone($json.timeZone).toISO() }}\",\n  \"eventId\": \"{{ $json.eventId }}\",\n  \"timeZone\": \"{{ $json.timeZone }}\"\n}\n"},"typeVersion":3.4},{"id":"0e3a8817-7485-499c-9692-7b920bb34b3f","name":"response_data_get_data","type":"n8n-nodes-base.set","position":[2080,700],"parameters":{"mode":"raw","options":{},"jsonOutput":"={\n  \"isAvailableTime\":{{$json.values().length === 0}},\n\"eventData\":{\nid:\"{{ $json.id }}\"\n}\n}\n"},"typeVersion":3.4}],"active":true,"settings":{"executionOrder":"v1"},"versionId":"fbb67adf-7d52-4b42-8b61-a3c01470a1f9","connections":{"If":{"main":[[{"node":"create_event","type":"main","index":0}],[{"node":"Stop and Error","type":"main","index":0}]]},"map_data":{"main":[[{"node":"Operation","type":"main","index":0}]]},"Operation":{"main":[[{"node":"validate_availability_event","type":"main","index":0}],[{"node":"delete_event1","type":"main","index":0}],[{"node":"check_availability_to_create","type":"main","index":0}],[{"node":"update_calendar","type":"main","index":0}],[{"node":"get_event_in_time_gap","type":"main","index":0}]]},"delete_event":{"ai_tool":[[{"node":"MCP Server Trigger","type":"ai_tool","index":0}]]},"update_event":{"ai_tool":[[{"node":"MCP Server Trigger","type":"ai_tool","index":0}]]},"create_new_event":{"ai_tool":[[{"node":"MCP Server Trigger","type":"ai_tool","index":0}]]},"validate_busy_time":{"ai_tool":[[{"node":"MCP Server Trigger","type":"ai_tool","index":0}]]},"get_event_in_time_gap":{"main":[[{"node":"response_data_get_data","type":"main","index":0}]]},"get_events_in_gap_time":{"ai_tool":[[{"node":"MCP Server Trigger","type":"ai_tool","index":0}]]},"validate_availability_event":{"main":[[{"node":"Edit Fields","type":"main","index":0}]]},"check_availability_to_create":{"main":[[{"node":"If","type":"main","index":0}]]},"When Executed by Another Workflow":{"main":[[{"node":"map_data","type":"main","index":0}]]}}}


name: Translate & Repost Twitter Threads in Multiple Languages with OpenAI
author_name: enes cingoz
author_username: ecingoz
categories: []
created_at: 2025-05-19T21:51:46.647Z
updated_at: 2025-05-19T21:51:46.647Z
url: https://n8n.io/workflows/4233
scraped_at: 2025-07-06 21:16:30
description:
  Twitter Thread (Flood) Translator & Poster

  What it does

  Thread Extraction:** Automatically detects and extracts all tweets from a provided Twitter thread (flood) link.
  Translation:** Translates each extracted tweet into your target language using OpenAI.
  Rewriting:** Rewrites each translated tweet to maintain the original meaning while improving clarity or style.
  Automated Posting:** Posts the rewritten tweets as a new thread on Twitter using twitterapi.io, preserving the original thread structure.

  How it works

  Accepts a Twitter thread (flood) link as input.
  Extracts all tweets from the thread in their original order.
  Each tweet is sent to OpenAI for translation into your desired language.
  The translated tweets are then rewritten for clarity and natural flow, while keeping the original meaning intact.
  The processed tweets are automatically posted as a new thread on your Twitter account via twitterapi.io.

  Setup Steps

  Create a Notion Database:  
     Set up a database page in Notion to store and manage your Twitter links and workflow data.
  Configure Notion Integration:  
     Add the created database page ID to the Notion nodes in your workflow.
  Set Twitter API Credentials:  
     Add your twitterapi.io API key to the relevant nodes.
  Add Twitter Account Details:  
     Enter your Twitter account username/email and password for authentication.
  Set Up OpenAI Credentials:  
     Provide your OpenAI API credentials to enable translation and rewriting.
  Subworkflow Integration:  
     Create a separate workflow for subworkflow logic and call it using the Execute Workflow node for modular automation.
  Set Desired Language & Thread Link:  
     Change the target language and Twitter thread (flood) link directly in the Manual Trigger node to customize each run.

  Benefits

  Ultra Low Cost:* *Total cost for a 15-tweet thread (flood) is just $0.016 USD* ($0.015 for twitterapi.io + $0.001 for OpenAI API). *(Actual cost may vary depending on the density of tweets in the thread.)
  End-to-End Automation:** Go from thread extraction to translation, rewriting, and reposting-all in one workflow.
  Multilingual Support:** Effortlessly translate and republish Twitter threads in any supported language.



  &gt; Note: Detailed configuration instructions and node explanations are included as sticky notes within the workflow canvas.

  Ideal for:  
  Content creators looking to reach new audiences by translating and republishing Twitter threads  
  Social media managers automating multilingual content workflows  
  Anyone wanting to streamline the process of thread extraction, translation, and posting

  Notes

  This workflow is not able to post images or videos to Twitter-it handles text-only threads.

nodes_used:
  ["n8n-nodes-base.httpRequest","n8n-nodes-base.twitter","n8n-nodes-base.notion","n8n-nodes-base.code","@n8n/n8n-nodes-langchain.agent","@n8n/n8n-nodes-langchain.lmChatOpenAi"]

workflow_json:
  {"id":"IBfjTnWypBRXCPvj","meta":{"instanceId":"98efd8f034313c65d85cf0927667bbf93252214bae7096a8dd3c1d18b0b96a02"},"name":"Twitter Thread (Flood) Translator & Poster","tags":[],"nodes":[{"id":"72df7ac0-9e65-41f2-bdf4-180f3ed6f1e9","name":"When clicking ‘Test workflow’","type":"n8n-nodes-base.manualTrigger","position":[920,-20],"parameters":{},"typeVersion":1},{"id":"5716837e-9709-4ec8-b41d-1f17c4fe1f4b","name":"Execute Workflow","type":"n8n-nodes-base.executeWorkflow","position":[1440,-20],"parameters":{},"typeVersion":1.2},{"id":"aa0f1d55-f9fc-4932-8109-fdbc3aaf36ea","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[1360,-180],"parameters":{"content":""},"typeVersion":1},{"id":"a54bc9c6-3120-49eb-b779-e3af80f5813a","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[1060,-180],"parameters":{"content":""},"typeVersion":1},{"id":"5fdb1ec4-315f-4361-a069-5e9e25dc3934","name":"config","type":"n8n-nodes-base.code","position":[1140,-20],"parameters":{},"typeVersion":2},{"id":"174bc61b-1fb1-4772-bcf6-d0b223f0a57b","name":"Translator_openai","type":"@n8n/n8n-nodes-langchain.agent","position":[2140,160],"parameters":{},"typeVersion":1.7},{"id":"083b6c06-1944-49a9-bdc2-750810c2861d","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[2220,400],"parameters":{},"typeVersion":1.2},{"id":"88a7b3be-1128-4e46-a6fa-b0872b5970db","name":"Rewriter","type":"@n8n/n8n-nodes-langchain.agent","position":[2520,160],"parameters":{},"typeVersion":1.8},{"id":"59ca4c7a-2c45-4abc-b118-43303f830c8f","name":"Sticky Note10","type":"n8n-nodes-base.stickyNote","position":[2480,100],"parameters":{"content":""},"typeVersion":1},{"id":"ec8bcd97-54a5-45aa-ac2c-3306f428e0f1","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[2080,100],"parameters":{"content":""},"typeVersion":1},{"id":"4e9f7da0-bd52-4de4-aad1-3f917d3dfda5","name":"Login Twitter","type":"n8n-nodes-base.httpRequest","position":[3560,640],"parameters":{},"typeVersion":4.2},{"id":"3ee576d3-e73e-4c1f-9fa9-446e6dc1da53","name":"Wait for 2fa code","type":"n8n-nodes-base.wait","position":[4060,640],"webhookId":"edf03471-76bd-4d9a-8c3e-7c18b0e4f039","parameters":{},"typeVersion":1.1},{"id":"d26e7f0f-8763-4c0d-ab0e-2e83816d0025","name":"Login Twitter with 2fa","type":"n8n-nodes-base.httpRequest","position":[4300,640],"parameters":{},"typeVersion":4.2},{"id":"7e92ad78-4d8f-45e4-942b-8613bc93d101","name":"Check login","type":"n8n-nodes-base.if","position":[4520,640],"parameters":{},"typeVersion":2.2},{"id":"335637cf-cea6-4bb2-a2c8-16cf11a1525d","name":"Check session data","type":"n8n-nodes-base.if","position":[3160,540],"parameters":{},"typeVersion":2.2},{"id":"48c94aa1-8077-4c08-ad42-4fa70bca37d0","name":"Set first tweet id and session","type":"n8n-nodes-base.set","position":[5180,620],"parameters":{},"typeVersion":3.4},{"id":"3a768947-083a-493e-a080-b5daa7f7c2b9","name":"Post first tweet","type":"n8n-nodes-base.httpRequest","position":[5440,620],"parameters":{},"typeVersion":4.2},{"id":"54f189cc-0dcb-4c9f-8324-0c671db903ca","name":"Check posting","type":"n8n-nodes-base.if","position":[5660,620],"parameters":{},"typeVersion":2.2},{"id":"c5e56b2b-0250-4fb2-9662-1398d139b83e","name":"Authorization Error","type":"n8n-nodes-base.if","position":[5880,760],"parameters":{},"typeVersion":2.2},{"id":"96149e63-37be-4148-8b66-d84ebc74715f","name":"Update twitter session","type":"n8n-nodes-base.notion","position":[4800,600],"parameters":{},"typeVersion":2.2},{"id":"c8ff5ba5-a9a3-46f6-847b-0d6521c6fd1f","name":"Get twitter session","type":"n8n-nodes-base.notion","position":[2940,540],"parameters":{},"typeVersion":2.2},{"id":"c30a3783-46f4-4aea-bf3b-6bae0feaea03","name":"login_2fa error","type":"n8n-nodes-base.if","position":[3880,920],"parameters":{},"typeVersion":2.2},{"id":"d34a6dbb-1a42-489f-8778-06f1493c329a","name":"Check login status","type":"n8n-nodes-base.if","position":[3720,640],"parameters":{},"typeVersion":2.2},{"id":"9cab075a-55f0-4754-9015-3c22b65caee0","name":"First tweet or thread","type":"n8n-nodes-base.if","position":[4840,200],"parameters":{},"typeVersion":2.2},{"id":"8234f0ee-7184-4aea-ba3a-0197dca248e2","name":"Set tweet infos","type":"n8n-nodes-base.set","position":[5160,-240],"parameters":{},"typeVersion":3.4},{"id":"64257a36-2fd5-48fa-ad94-3e3bee2fdbbc","name":"Check posting1","type":"n8n-nodes-base.if","position":[5680,-240],"parameters":{},"typeVersion":2.2},{"id":"d5788735-40be-46cc-8aa9-eba78cce3bb9","name":"Authorization Error1","type":"n8n-nodes-base.if","position":[5820,-80],"parameters":{},"typeVersion":2.2},{"id":"8c0a7f58-51af-44fe-acb9-a3d5048b226b","name":"Post reply tweet","type":"n8n-nodes-base.httpRequest","position":[5420,-240],"parameters":{},"typeVersion":4.2},{"id":"e6b16945-b9d2-43cb-a6a2-d82a892fb185","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[2880,480],"parameters":{"content":""},"typeVersion":1},{"id":"d9712b4b-c340-4e8c-a447-7aefe0315490","name":"set_iteration_outputs","type":"n8n-nodes-base.code","position":[6220,200],"parameters":{},"typeVersion":2},{"id":"e90d235e-ca52-44f7-ae11-80ebf8871f32","name":"MAIN_LOOP","type":"n8n-nodes-base.splitInBatches","position":[1900,-20],"parameters":{},"typeVersion":3},{"id":"952d5f9d-9db9-42ff-a00c-166bc2023c3a","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[5100,540],"parameters":{"content":""},"typeVersion":1},{"id":"44e8e0ea-d063-4a58-9c64-4f38c9af3efe","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[5100,-320],"parameters":{"content":""},"typeVersion":1},{"id":"c299b7bf-ebff-4908-8020-3d3707406bcc","name":"Extract tweets list","type":"n8n-nodes-base.code","position":[1660,-20],"parameters":{},"typeVersion":2},{"id":"aec16371-e942-4be9-9b00-809ca0d54e84","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[1060,-360],"parameters":{"content":""},"typeVersion":1},{"id":"4f42b137-0150-44d1-b628-b5f945d8a259","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[1360,-360],"parameters":{"content":""},"typeVersion":1},{"id":"9b936b1c-f594-453e-9a43-be8e655debd1","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[2080,-100],"parameters":{"content":""},"typeVersion":1},{"id":"2cac2fc1-d3ff-42c2-ba1a-f65daf439ea5","name":"Sticky Note11","type":"n8n-nodes-base.stickyNote","position":[2480,-100],"parameters":{"content":""},"typeVersion":1},{"id":"dd6dc5c9-5950-4e8e-8810-941ee1e3fa4c","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[2880,1080],"parameters":{"content":""},"typeVersion":1},{"id":"1837647c-8619-41b3-8635-18ba646d6bd6","name":"Send error message","type":"n8n-nodes-base.noOp","position":[4760,920],"parameters":{},"typeVersion":1},{"id":"3828dc13-6ed4-4ca8-a1fc-1e26700a71fb","name":"Sticky Note12","type":"n8n-nodes-base.stickyNote","position":[5100,1020],"parameters":{"content":""},"typeVersion":1},{"id":"9637b6f0-5792-42ff-adf1-96f96a8ed389","name":"Sticky Note13","type":"n8n-nodes-base.stickyNote","position":[5100,-560],"parameters":{"content":""},"typeVersion":1},{"id":"9aa336df-7dec-4eb9-a3f7-5f1844497147","name":"DONE","type":"n8n-nodes-base.noOp","position":[2100,-280],"parameters":{},"typeVersion":1},{"id":"99d86957-c9f7-4f5c-a7c9-8d8cb4bfd78f","name":"Merge first tweet and others","type":"n8n-nodes-base.merge","position":[2940,2120],"parameters":{},"typeVersion":3.1},{"id":"69946d5e-1730-4b33-98f0-474507c7740b","name":"When Executed by Another Workflow","type":"n8n-nodes-base.executeWorkflowTrigger","position":[1160,2120],"parameters":{},"typeVersion":1.1},{"id":"2c8025d2-fade-45bf-b5bf-184766b1ec79","name":"No Operation, do nothing","type":"n8n-nodes-base.noOp","position":[3400,2120],"parameters":{},"typeVersion":1},{"id":"15e79dd7-cce8-4c22-a6e7-b0326218147b","name":"Extract Tweet ID and Username","type":"n8n-nodes-base.function","position":[1520,2240],"parameters":{},"typeVersion":1},{"id":"5d476c98-feb5-4c4e-97f5-64e23798432c","name":"Get first tweet","type":"n8n-nodes-base.httpRequest","position":[1740,2020],"parameters":{},"typeVersion":4.2},{"id":"81a08de6-85d6-4f57-9602-7484d696b431","name":"Extract Conversation and Author ID","type":"n8n-nodes-base.function","position":[1960,2120],"parameters":{},"typeVersion":1},{"id":"efe5470a-618b-4c19-8da3-a49cfeb4aea0","name":"Merge all tweet infos","type":"n8n-nodes-base.merge","position":[2180,2240],"parameters":{},"typeVersion":3.1},{"id":"2b02d409-d36d-4c13-9380-0e7e24f35e37","name":"Get Tweet Replies","type":"n8n-nodes-base.httpRequest","onError":"continueRegularOutput","position":[2400,2240],"parameters":{},"typeVersion":4.2},{"id":"833c0d80-fa81-4db9-a720-cf4626445c46","name":"Fetch tweets which are connected to first tweet","type":"n8n-nodes-base.code","position":[2620,2240],"parameters":{},"typeVersion":2},{"id":"90b985e7-8e14-4801-a315-e52e52d57cac","name":"Filter empty ones","type":"n8n-nodes-base.filter","position":[3160,2120],"parameters":{},"typeVersion":2.2},{"id":"da5309da-bc63-4157-b790-102728307f4e","name":"Sticky Note14","type":"n8n-nodes-base.stickyNote","position":[1460,1960],"parameters":{"content":""},"typeVersion":1},{"id":"b6a229b1-a4db-4d32-a46c-5dda58885597","name":"Sticky Note15","type":"n8n-nodes-base.stickyNote","position":[1920,1960],"parameters":{"content":""},"typeVersion":1},{"id":"e0919f2e-6771-4df3-9d72-88333ef2a717","name":"Sticky Note16","type":"n8n-nodes-base.stickyNote","position":[2780,1960],"parameters":{"content":""},"typeVersion":1},{"id":"c8a1b8e9-23b6-4561-aa55-6471e47f9703","name":"Sticky Note17","type":"n8n-nodes-base.stickyNote","position":[1460,1800],"parameters":{"content":""},"typeVersion":1},{"id":"fe98b5de-7600-47fc-8b6f-4487646d7c35","name":"Sticky Note18","type":"n8n-nodes-base.stickyNote","position":[1920,1800],"parameters":{"content":""},"typeVersion":1},{"id":"c468ca50-25c1-4467-9065-46a1a69dd253","name":"Sticky Note19","type":"n8n-nodes-base.stickyNote","position":[2780,1800],"parameters":{"content":""},"typeVersion":1},{"id":"22d1bd3b-ce0b-455f-b750-321f322be192","name":"Sticky Note20","type":"n8n-nodes-base.stickyNote","position":[1000,1800],"parameters":{"content":""},"typeVersion":1},{"id":"2bd70d81-4345-4f4b-99df-a030269a6168","name":"Sticky Note21","type":"n8n-nodes-base.stickyNote","position":[1000,1660],"parameters":{"content":""},"typeVersion":1},{"id":"bf8de65a-d7b2-42ea-89e9-d89c3bae92a3","name":"REMOVE THIS NODE","type":"n8n-nodes-base.twitter","position":[2320,-280],"parameters":{},"typeVersion":2}],"active":false,"settings":{"timezone":"Europe/London","callerPolicy":"workflowsFromSameOwner","executionOrder":"v1"},"versionId":"156bf779-c9ab-4cae-b275-cdf7dd5b57e3","connections":{"DONE":{"main":[[{"node":"REMOVE THIS NODE","type":"main","index":0}]]},"config":{"main":[[{"node":"Execute Workflow","type":"main","index":0}]]},"Rewriter":{"main":[[{"node":"Get twitter session","type":"main","index":0}]]},"MAIN_LOOP":{"main":[[{"node":"DONE","type":"main","index":0}],[{"node":"Translator_openai","type":"main","index":0}]]},"Check login":{"main":[[{"node":"Update twitter session","type":"main","index":0}],[{"node":"Send error message","type":"main","index":0}]]},"Check posting":{"main":[[{"node":"set_iteration_outputs","type":"main","index":0}],[{"node":"Authorization Error","type":"main","index":0}]]},"Login Twitter":{"main":[[{"node":"Check login status","type":"main","index":0}]]},"Check posting1":{"main":[[{"node":"set_iteration_outputs","type":"main","index":0}],[{"node":"Authorization Error1","type":"main","index":0}]]},"Get first tweet":{"main":[[{"node":"Extract Conversation and Author ID","type":"main","index":0},{"node":"Merge first tweet and others","type":"main","index":0}]]},"Set tweet infos":{"main":[[{"node":"Post reply tweet","type":"main","index":0}]]},"login_2fa error":{"main":[[{"node":"Login Twitter with 2fa","type":"main","index":0}],[{"node":"Wait for 2fa code","type":"main","index":0}]]},"Execute Workflow":{"main":[[{"node":"Extract tweets list","type":"main","index":0}]]},"Post first tweet":{"main":[[{"node":"Check posting","type":"main","index":0}]]},"Post reply tweet":{"main":[[{"node":"Check posting1","type":"main","index":0}]]},"Filter empty ones":{"main":[[{"node":"No Operation, do nothing","type":"main","index":0}]]},"Get Tweet Replies":{"main":[[{"node":"Fetch tweets which are connected to first tweet","type":"main","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"Translator_openai","type":"ai_languageModel","index":0},{"node":"Rewriter","type":"ai_languageModel","index":0}]]},"Translator_openai":{"main":[[{"node":"Rewriter","type":"main","index":0}]]},"Wait for 2fa code":{"main":[[{"node":"Login Twitter with 2fa","type":"main","index":0}]]},"Check login status":{"main":[[{"node":"Get twitter session","type":"main","index":0}],[{"node":"login_2fa error","type":"main","index":0}]]},"Check session data":{"main":[[{"node":"First tweet or thread","type":"main","index":0}],[{"node":"Login Twitter","type":"main","index":0}]]},"Authorization Error":{"main":[[{"node":"Login Twitter","type":"main","index":0}]]},"Extract tweets list":{"main":[[{"node":"MAIN_LOOP","type":"main","index":0}]]},"Get twitter session":{"main":[[{"node":"Check session data","type":"main","index":0}]]},"Authorization Error1":{"main":[[],[{"node":"Get twitter session","type":"main","index":0}]]},"First tweet or thread":{"main":[[{"node":"Set tweet infos","type":"main","index":0}],[{"node":"Set first tweet id and session","type":"main","index":0}]]},"Merge all tweet infos":{"main":[[{"node":"Get Tweet Replies","type":"main","index":0}]]},"set_iteration_outputs":{"main":[[{"node":"MAIN_LOOP","type":"main","index":0}]]},"Login Twitter with 2fa":{"main":[[{"node":"Check login","type":"main","index":0}]]},"Update twitter session":{"main":[[{"node":"Get twitter session","type":"main","index":0}]]},"Merge first tweet and others":{"main":[[{"node":"Filter empty ones","type":"main","index":0}]]},"Extract Tweet ID and Username":{"main":[[{"node":"Get first tweet","type":"main","index":0},{"node":"Merge all tweet infos","type":"main","index":1}]]},"Set first tweet id and session":{"main":[[{"node":"Post first tweet","type":"main","index":0}]]},"When Executed by Another Workflow":{"main":[[{"node":"Extract Tweet ID and Username","type":"main","index":0}]]},"When clicking ‘Test workflow’":{"main":[[{"node":"config","type":"main","index":0}]]},"Extract Conversation and Author ID":{"main":[[{"node":"Merge all tweet infos","type":"main","index":0}]]},"Fetch tweets which are connected to first tweet":{"main":[[{"node":"Merge first tweet and others","type":"main","index":1}]]}}}


name: Dynamic AI Model Router for Query Optimization with OpenRouter
author_name: Davide
author_username: n3witalia
categories: []
created_at: 2025-05-20T07:40:19.495Z
updated_at: 2025-05-20T07:40:19.495Z
url: https://n8n.io/workflows/4237
scraped_at: 2025-07-06 21:16:30
description:
  The Agent Decisioner is a dynamic, AI-powered routing system that automatically selects the most appropriate large language model (LLM) to respond to a user's query based on the query’s content and purpose.

  This workflow ensures dynamic, optimized AI responses by intelligently routing queries to the best-suited model.

  Advantages

  🔁 Automatic Model Routing:**
    Automatically selects the best model for the job, improving efficiency and relevance of responses.

  🎯 Optimized Use of Resources:**
    Avoids overuse of expensive models like GPT-4 by routing simpler queries to lightweight models.

  📚 Model-Aware Reasoning:**
    Uses detailed metadata about model capabilities (e.g., reasoning, coding, web search) for intelligent selection.

  📥 Modular and Extendable:**
    Easy to integrate with other tools or expand by adding more models or custom decision logic.

  👨‍💻 Ideal for RAG and Multi-Agent Systems:**
    Can serve as the brain behind more complex agent frameworks or Retrieval-Augmented Generation pipelines.

  How It Works  

  Chat Trigger: The workflow starts when a user sends a message, triggering the Routing Agent.  
  Model Selection: The AI Agent analyzes the query and selects the best-suited model from the available options (e.g., Claude 3.7 Sonnet for coding, Perplexity/Sonar for web searches, GPT-4o Mini for reasoning).  
  Structured Output: The agent returns a JSON response with the user’s prompt and the chosen model.  
  Execution: The selected model processes the query and generates a response, ensuring optimal performance for the task.  

  Set Up Steps  

  Configure Nodes:  
     Chat Trigger: Set up the webhook to receive user messages.  
     Routing Agent (AI Agent): Define the system message with model strengths and JSON output rules.  
     OpenRouter Chat Model: Connect to OpenRouter for model access.  
     Structured Output Parser: Ensure it validates the JSON response format (prompt + model).  
     Execution Agent (AI Agent1): Configure it to forward the prompt to the selected model.  

  Connect Nodes:  
     Link the Chat Trigger to the Routing Agent.  
     Connect the OpenRouter Chat Model and Output Parser to the Routing Agent.  
     Route the parsed JSON to the Execution Agent, which uses the chosen model via OpenRouter Chat Model1.  

  Credentials:  
     Ensure OpenRouter API credentials are correctly set for both chat model nodes.  

  Test & Deploy:  
     Activate the workflow and test with sample queries to verify model selection logic.  
     Adjust the routing rules if needed for better accuracy.  

  Need help customizing?  
  Contact me for consulting and support or add me on Linkedin. 

nodes_used:
  ["@n8n/n8n-nodes-langchain.agent","@n8n/n8n-nodes-langchain.lmChatOpenAi","@n8n/n8n-nodes-langchain.outputParserAutofixing","@n8n/n8n-nodes-langchain.outputParserStructured","@n8n/n8n-nodes-langchain.lmChatOpenRouter"]

workflow_json:
  {"id":"uNLWQ7BSozpoehpU","meta":{"instanceId":"a4bfc93e975ca233ac45ed7c9227d84cf5a2329310525917adaf3312e10d5462","templateCredsSetupCompleted":true},"name":"Automated AI Routing with OpenRouter","tags":[],"nodes":[{"id":"25903a04-24d2-41f9-bf34-5d6234e642e5","name":"When chat message received","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[-180,-180],"webhookId":"a0032740-26d8-491b-93f9-2250906d0e17","parameters":{"options":{}},"typeVersion":1.1},{"id":"fabffdee-3c1e-47db-a4e9-f6473a6e9257","name":"OpenRouter Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenRouter","position":[0,40],"parameters":{"options":{}},"credentials":{"openRouterApi":{"id":"pb06rfB4xmxzVe3Q","name":"OpenRouter"}},"typeVersion":1},{"id":"c53fe672-92cb-4d88-b4f6-f413fb00ad6a","name":"Structured Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[340,280],"parameters":{"schemaType":"manual","inputSchema":"{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"prompt\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"model\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t}\n}"},"typeVersion":1.2},{"id":"d60a9d61-c611-4813-bf85-e8f8faaa21b6","name":"OpenRouter Chat Model1","type":"@n8n/n8n-nodes-langchain.lmChatOpenRouter","position":[420,40],"parameters":{"model":"={{ $json.output.model }}","options":{}},"credentials":{"openRouterApi":{"id":"pb06rfB4xmxzVe3Q","name":"OpenRouter"}},"typeVersion":1},{"id":"ef9ceacb-55e4-4795-aa18-976997ec3717","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-180,-420],"parameters":{"width":840,"height":180,"content":"## Dynamic Model Selector for Optimal AI Responses\n\nThe **Agent Decisioner** is a dynamic, AI-powered routing system that automatically selects the most appropriate large language model (LLM) to respond to a user's query based on the query’s content and purpose.\n\nThis workflow ensures **dynamic, optimized AI responses** by intelligently routing queries to the best-suited model."},"typeVersion":1},{"id":"4d688ad7-b463-4e72-9b79-4b9142f022d2","name":"Routing Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[40,-180],"parameters":{"options":{"systemMessage":"=You are a **Routing Agent**.\n\nYour task is to analyze user queries and determine the most appropriate model to handle each specific use case.\n\n## Available Models\n\nYou have access to the following models:\n\n1. **perplexity/sonar**\n2. **openai/gpt-4o-mini**\n3. **anthropic/claude-3.7-sonnet**\n4. **meta-llama/llama-3-70b-instruct**\n5. **google/gemini-2.5-pro-preview**\n6. **qwen/qwen-qwq-32b**\n7. **openai/codex-mini**\n8. **openai/o1-pro**\n\n## Model Strengths\n\n### 1. perplexity/sonar\n- Built-in web search capability\n- Provides citations and customizable sources\n- Ideal for retrieving live, up-to-date information from the web\n\n### 2. openai/gpt-4o-mini\n- Cost-efficient language model optimized for advanced reasoning tasks\n- Excels in science and mathematics\n- Best suited for problems requiring careful, well-thought-out responses involving multiple variables or connections\n\n### 3. anthropic/claude-3.7-sonnet\n- High proficiency in coding tasks, scoring ~94% on SWE-Bench Verified\n- Enhances data science expertise by navigating unstructured data and utilizing multiple tools for insights\n- Handles very long documents and maintains coherence over extended conversations or analyses\n- Performs well in creative writing tasks such as storytelling, dialogue generation, and summarization\n- Tends to produce responses that are more aligned with safety and ethical guidelines\n\n### 4. meta-llama/llama-3-70b-instruct\n- Strong performance in coding and reasoning tasks\n- Suitable for complex programming and technical problem-solving\n- Supports long context windows, making it ideal for extended analyses\n\n### 5. google/gemini-2.5-pro-preview\n- Advanced multimodal capabilities, handling both text and images\n- Excels in tasks requiring integration of visual and textual information\n- Ideal for complex problem-solving involving diverse data types\n\n### 6. qwen/qwen-qwq-32b\n- Specialized in reasoning and problem-solving tasks\n- Effective in handling logical puzzles and complex analytical queries\n\n### 7. openai/codex-mini\n- Optimized for code generation and completion tasks\n- Suitable for lightweight coding tasks and quick code snippets\n\n### 8. openai/o1-pro\n- Designed for complex reasoning with enhanced computational resources\n- Performs well in STEM-related tasks, including physics, chemistry, and biology\n- Capable of handling large context windows, making it suitable for in-depth analyses\n\n## Output Format\n\nYour output must always be a valid JSON object in the following format:\n\n```json\n{\n  \"prompt\": \"user query goes here\",\n  \"model\": \"selected-model-name\"\n}\n```\n\n- The **\"prompt\"** field should contain the exact query to be sent to the selected model.\n- The **\"model\"** field should contain the model name (one of: perplexity/sonar, openai/gpt-4o-mini, anthropic/claude-3.7-sonnet, meta-llama/llama-3-70b-instruct, google/gemini-2.5-pro-preview, qwen/qwen-qwq-32b, openai/codex-mini, openai/o1-pro).\n\n**Important:** Only return the JSON object. Do not include any explanations or additional text."},"hasOutputParser":true},"typeVersion":1.9},{"id":"94c49c22-9697-4230-ba35-5159041cfdc7","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[400,-180],"parameters":{"text":"={{ $json.output.prompt }}","options":{},"promptType":"define"},"typeVersion":1.9},{"id":"54c4278e-c185-4ab4-b21e-d8e837b14818","name":"Auto-fixing Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserAutofixing","position":[140,60],"parameters":{"options":{"prompt":"Instructions:\n--------------\n{instructions}\n--------------\nCompletion:\n--------------\n{completion}\n--------------\n\nAbove, the Completion did not satisfy the constraints given in the Instructions.\nError:\n--------------\n{error}\n--------------\n\nPlease try again. Please only respond with an answer that satisfies the constraints laid out in the Instructions:"}},"typeVersion":1},{"id":"2813da6b-423b-41d6-8eb4-664f616ca8d5","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[140,220],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"TefveNaDaMERl1hY","name":"OpenAi account (Eure)"}},"typeVersion":1.2}],"active":false,"settings":{"executionOrder":"v1"},"versionId":"bb8e8d46-ce32-49e0-a843-496c6e026902","connections":{"Routing Agent":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"Auto-fixing Output Parser","type":"ai_languageModel","index":0}]]},"OpenRouter Chat Model":{"ai_languageModel":[[{"node":"Routing Agent","type":"ai_languageModel","index":0}]]},"OpenRouter Chat Model1":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"Auto-fixing Output Parser","type":"ai_outputParser","index":0}]]},"Auto-fixing Output Parser":{"ai_outputParser":[[{"node":"Routing Agent","type":"ai_outputParser","index":0}]]},"When chat message received":{"main":[[{"node":"Routing Agent","type":"main","index":0}]]}}}


name: Invoice Processor & Validator with OCR, AI & Google Sheets
author_name: Dhrumil Patel
author_username: itechdp
categories: []
created_at: 2025-05-20T19:58:32.680Z
updated_at: 2025-05-20T19:58:32.680Z
url: https://n8n.io/workflows/4247
scraped_at: 2025-07-06 21:16:30
description:
  📝 Say goodbye to manual invoice checking! 
  This smart workflow automates your entire invoice processing pipeline using AI, OCR, and Google Sheets.

  ⚙️ What This Workflow Does:

  📥 1. Reads an invoice PDF
  — Select a local PDF invoice from your machine.

  🔍 2. Extracts raw text using OCR
  — Converts scanned or digital PDFs into readable text.

  🧠 3. AI Agent processes the text
  — Transforms messy raw text into clean JSON using natural language understanding.

  🧱 4. Structures and refines the JSON
  — Converts AI output into a structured, usable format.

  🔄 5. Splits item-wise data
  — Extracts individual invoice line items with all details.

  🆔 6. Generates unique keys
  — Creates a unique identifier for each item for tracking.

  📊 7. Updates Google Sheet
  — Adds extracted items to your designated sheet automatically.

  📂 8. Fetches master item data
  — Loads your internal product master to validate against.

  ✅ 9. Validates item name & cost
  — Compares extracted items with your official records to verify accuracy.

  📌 10. Updates results per item
  — Marks each item as Valid or Invalid in the sheet based on matching.

  💼 Use Case:

  Perfect for businesses, freelancers, or operations teams who receive invoices and want to automate validation, detect billing errors, and log everything seamlessly in Google Sheets — all using the power of AI + n8n.

  &gt; 🔁 Fast. Accurate. Zero manual work.

  #OCR #AI #Invoices #Automation.

nodes_used:
  ["n8n-nodes-base.googleSheets","n8n-nodes-base.code","@n8n/n8n-nodes-langchain.agent","@n8n/n8n-nodes-langchain.lmChatOpenRouter"]

workflow_json:
  {"meta":{"instanceId":"761a3dddae2bb21eb8973ffca0ba97d5b4f499405873760164a536f547546882","templateCredsSetupCompleted":true},"nodes":[{"id":"0d426dc6-d9ff-44cd-82f0-9d87bda8821a","name":"When clicking ‘Test workflow’","type":"n8n-nodes-base.manualTrigger","position":[-200,405],"parameters":{},"typeVersion":1},{"id":"2722d720-22e9-488b-9b39-4273fe88257c","name":"OpenRouter Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenRouter","position":[548,625],"parameters":{"model":"deepseek/deepseek-chat-v3-0324","options":{}},"credentials":{"openRouterApi":{"id":"ykjF5geNxohYAYJ9","name":"OpenRouter account - sentiimenta.ai"}},"typeVersion":1},{"id":"6992dfda-d65e-4694-8261-2328a7d0bc09","name":"Split Out","type":"n8n-nodes-base.splitOut","position":[1276,280],"parameters":{"options":{},"fieldToSplitOut":"line_items"},"typeVersion":1},{"id":"06e91f54-fbc3-4161-949c-779ecd7924b9","name":"Post-Processing","type":"n8n-nodes-base.code","position":[880,380],"parameters":{"jsCode":"const output = $input.first().json.output;\nlet raw = output.result || output.completion || output.text || JSON.stringify(output);\n\n// Step 1: Remove backticks if present\nraw = raw.trim();\nif (raw.startsWith(\"```json\")) {\n  raw = raw.replace(/^```json\\s*/, '').replace(/```$/, '').trim();\n} else if (raw.startsWith(\"```\")) {\n  raw = raw.replace(/^```\\s*/, '').replace(/```$/, '').trim();\n}\n\n// Step 2: Find full JSON block from first { to last }\nconst start = raw.indexOf('{');\nconst end = raw.lastIndexOf('}');\nif (start === -1 || end === -1 || end <= start) {\n  return [{\n    json: {\n      error: \"No valid JSON block found\",\n      raw_output: raw\n    }\n  }];\n}\n\nlet jsonCandidate = raw.substring(start, end + 1).trim();\n\n// Step 3: Unescape characters\njsonCandidate = jsonCandidate\n  .replace(/\\\\n/g, '')\n  .replace(/\\\\t/g, '')\n  .replace(/\\\\\"/g, '\"')\n  .replace(/\\\\'/g, \"'\")\n  .replace(/\\\\\\\\/g, '\\\\');\n\n// Step 4: Parse JSON safely\ntry {\n  let parsed = JSON.parse(jsonCandidate);\n\n  // Only double-parse if it looks like stringified JSON\n  if (typeof parsed === \"string\" && parsed.trim().startsWith('{') && parsed.trim().endsWith('}')) {\n    parsed = JSON.parse(parsed);\n  }\n\n  return [{ json: parsed }];\n} catch (e) {\n  return [{\n    json: {\n      error: \"JSON parsing failed\",\n      raw_output: raw,\n      attempted_extraction: jsonCandidate,\n      message: e.message\n    }\n  }];\n}\n"},"typeVersion":2},{"id":"34f5988b-9c83-4828-a13d-1ff33615e509","name":"Text Extractor","type":"@n8n/n8n-nodes-langchain.agent","position":[460,420],"parameters":{"text":"=- You must respond ONLY with valid raw rendered JSON.\n- Do NOT include the word \"json\".\n- Do NOT include the word \"```json\".\n- Do NOT use triple backticks or markdown formatting.\n- Do NOT wrap the response in any key like \"output\".\n- Do NOT write anything starting at output directly start with valid root-level JSON.\n- Only respond with a valid, root-level JSON object.\n- Do NOT skip any line item. Continue extracting all line items until the sum of all line_total values exactly equals the total sale amount extracted from the invoice. This verification ensures that all items are fully extracted and no entries are missed. If the totals do not match, keep parsing and extracting additional line items until they do. Only then stop.\n\nText to convert: {{ $json.text }}","options":{"systemMessage":"=You are a document parsing assistant designed to extract structured data from invoice PDFs for automated uploading and validation in a financial system.\n\nExtract the following fields from the invoice text:\n\ninvoice_number: Extract from the 'Invoice No' field.\n\nvendor_name: Company name issuing the invoice.\n\ninvoice_date: Format as DD/MM/YYYY.\n\npo_number: Extract the PO number or return null if not found.\n\npo_date: Extract the PO date in DD/MM/YYYY format or return null if not found.\n\ntotal_amount: Extract the invoice total as a float.\n\ntax_details: Include total CGST, total SGST.\n\nline_items: List of all items in the invoice. For each item, extract:\n\n  Serial No.: Item Serial No. In invoice.\n\n  code: The TWW word and its postfix only (e.g., TWW, TWW-Cover, TWW-HPCN). Do not include HSN code or numbers. This field must always be present.\n\n  description: Item description, never include HSN code of product in product description.\n\n  last character: This is a single word/character string found just after or around the line item, typically at the end of the price line or just on the next line. It will never be a number, HSN code, GST %, or unit (like PCS). Examples: G, C, S, 5C, .C If nothing is present (only digits or blank), return \"\". Check the next 1–2 lines after each item if it's not found on the same line.\n\n  quantity: Quantity value.\n\n  unit_price: Price per unit.\n\n  line_total: Total price for the line.\n\n  hsn_code: HSN code of the item.\n\n  cgst: Only extract the CGST percentage (e.g., 9%, 6%) as written in the invoice. Do not calculate based on line total.\n\n  sgst: Only extract the SGST percentage (e.g., 9%, 6%) as written in the invoice. Do not calculate based on line total.\n\nImportant: Double-check that all line items are extracted without omission.\n\nDo NOT skip any line item. Continue extracting all line items until the sum of all line_total values exactly equals the total_amount extracted from the invoice. This verification ensures that all items are fully extracted and no entries are missed. If the totals do not match, keep parsing and extracting additional line items until they do. Only then stop."},"promptType":"define"},"typeVersion":1.8},{"id":"3446d02e-2c94-4575-9062-455dbd71ecd8","name":"Read/Write Files from Disk","type":"n8n-nodes-base.readWriteFile","position":[20,405],"parameters":{"options":{},"fileSelector":"=E:/SentIImenta AI/SentIImenta AI Website/White Willow/Invoice Validator/May Invoices/Jumax TWW Daily PO Invoices 05_05_2025/661.pdf"},"typeVersion":1},{"id":"95e99fb0-a12f-40e6-9126-d84cf2b0c493","name":"Extract from File","type":"n8n-nodes-base.extractFromFile","position":[240,405],"parameters":{"options":{},"operation":"pdf"},"typeVersion":1},{"id":"ce0a9035-c99f-4cc3-9ec3-b2be2158623e","name":"If","type":"n8n-nodes-base.if","position":[1100,340],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"e73c23b4-39e9-4719-8a72-53808eefe607","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.error }}","rightValue":"JSON parsing failed"},{"id":"b3b7d3d4-c709-40fe-8782-ffd34180ba8b","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.error }}","rightValue":"No valid JSON block found"}]}},"typeVersion":2.2},{"id":"6675d752-7230-4335-9c68-387396728e7f","name":"Send Raw Text Again","type":"n8n-nodes-base.set","position":[1340,520],"parameters":{"options":{},"assignments":{"assignments":[{"id":"18f61f00-03e8-4fd4-b305-f3742bb32d17","name":"text","type":"string","value":"={{ $('Extract from File').item.json.text }}"}]}},"typeVersion":3.4},{"id":"7706b71b-25dc-4f61-b975-51322d7b9d32","name":"Validation","type":"n8n-nodes-base.code","position":[2156,280],"parameters":{"jsCode":"// --- Helper: Levenshtein Distance ---\nfunction levenshtein(a, b) {\n  const matrix = Array.from({ length: b.length + 1 }, (_, i) => [i]);\n  for (let j = 0; j <= a.length; j++) matrix[0][j] = j;\n\n  for (let i = 1; i <= b.length; i++) {\n    for (let j = 1; j <= a.length; j++) {\n      const cost = a[j - 1] === b[i - 1] ? 0 : 1;\n      matrix[i][j] = Math.min(\n        matrix[i - 1][j] + 1,\n        matrix[i][j - 1] + 1,\n        matrix[i - 1][j - 1] + cost\n      );\n    }\n  }\n  return matrix[b.length][a.length];\n}\n\n// --- Helper: Clean String ---\nfunction cleanString(str) {\n  if (str && typeof str === 'string') {\n    return str\n      .replace(/(^\"|\"$|\\[|\\])/g, '') // remove unwanted chars\n      .replace(/\\s{2,}/g, ' ')       // replace multiple spaces with one\n      .toLowerCase()\n      .trim();\n  }\n  return '';\n}\n\n// --- 1. Get all SKUs from \"Split Out\" and corresponding Unique Keys ---\nconst splitOutItems = $items('Split Out');\nconst uniqueKeyItems = $items('Generate Unique Key');\n\nconst inputSKUs = splitOutItems.map((item, index) => {\n  const uniqueKeyItem = uniqueKeyItems[index];\n\n  const code = cleanString(item.json.code);\n  const description = cleanString(item.json.description);\n  // handle both possible keys for last character\n  const lastCharacter = cleanString(item.json['last_character'] ?? item.json['last character'] ?? '');\n\n  let sku = `${code} ${description}`;\n\n  if (lastCharacter) {\n    if (/^[a-z0-9]+$/i.test(lastCharacter)) {\n      // Append directly without space if alphanumeric postfix\n      sku += lastCharacter;\n    } else {\n      // Otherwise, add a space\n      sku += ` ${lastCharacter}`;\n    }\n  }\n  \n  sku = sku.trim().replace(/\\s{2,}/g, ' ');\n\n  return {\n    Unique_Key: uniqueKeyItem ? uniqueKeyItem.json['Unique Key'] || uniqueKeyItem.json.Unique_Key || '' : '',\n    serial_no: item.json['Serial No.'] ?? item.json['Serial_No.'] ?? '',\n    sku,\n    quantity: item.json.quantity,\n    unit_price: item.json.unit_price,\n    line_total: item.json.line_total,\n    hsn_code: item.json.hsn_code,\n    cgst: item.json.cgst,\n    sgst: item.json.sgst\n  };\n});\n\n// --- 2. Get all rows from \"Google Sheets\" ---\nconst sheetRows = $items('Fetch Master Data').map(i => i.json);\n\n// --- 3. Set Levenshtein match threshold ---\nconst threshold = 5;\nconst results = [];\n\nfor (const inputSKU of inputSKUs) {\n  let bestMatch = null;\n  let lowestDistance = Infinity;\n\n  for (const row of sheetRows) {\n    const descriptionRaw = row['Jumax PDF Description'] || '';\n    const description = cleanString(descriptionRaw);\n    if (!description) continue;\n\n    const distance = levenshtein(inputSKU.sku, description);\n\n    if (distance < lowestDistance) {\n      lowestDistance = distance;\n      bestMatch = row;\n    }\n  }\n\n  if (bestMatch && lowestDistance <= threshold) {\n    const jumaxASIN = cleanString(bestMatch['ASIN']);\n    const tASIN = cleanString(bestMatch['TWW ASIN']);\n    const cost = Number(bestMatch['Cost '] || bestMatch['Cost'] || bestMatch['Rate']);\n    const unitPrice = Number(inputSKU.unit_price);\n\n    const asinMatch = jumaxASIN === tASIN;\n    const costMatch = cost === unitPrice;\n    const allConditionsMet = asinMatch && costMatch;\n\n    results.push({\n      json: {\n        Unique_Key: inputSKU.Unique_Key,\n        serial_no: inputSKU.serial_no,\n        matchedSKU: inputSKU.sku,\n        matchedRow: bestMatch,\n        distance: lowestDistance,\n        Jumax_ASIN: jumaxASIN,\n        T_ASIN: tASIN,\n        asinMatch,\n        costMatch,\n        quantity: inputSKU.quantity,\n        unit_price: inputSKU.unit_price,\n        costFromSheet: cost,\n        line_total: inputSKU.line_total,\n        hsn_code: inputSKU.hsn_code,\n        cgst: inputSKU.cgst,\n        sgst: inputSKU.sgst,\n        message: allConditionsMet\n          ? '✅ Match found, ASINs match, and Cost matches Unit Price'\n          : asinMatch\n            ? '⚠️ ASINs match but Cost does not match Unit Price'\n            : '❌ Match found but ASINs do not match',\n        All_Conditions_Met: allConditionsMet\n      }\n    });\n  } else {\n    results.push({\n      json: {\n        Unique_Key: inputSKU.Unique_Key,\n        serial_no: inputSKU.serial_no,\n        matchedSKU: inputSKU.sku,\n        matchedRow: null,\n        message: `❌ No match found for SKU: ${inputSKU.sku}`,\n        closestDistance: lowestDistance,\n        quantity: inputSKU.quantity,\n        unit_price: inputSKU.unit_price,\n        line_total: inputSKU.line_total,\n        hsn_code: inputSKU.hsn_code,\n        cgst: inputSKU.cgst,\n        sgst: inputSKU.sgst,\n        All_Conditions_Met: false\n      }\n    });\n  }\n}\n\n// --- 4. Return final results ---\nreturn results;\n"},"typeVersion":2},{"id":"34e482d2-9658-496b-ad2f-fc376f3490ff","name":"Send Invoice Data","type":"n8n-nodes-base.googleSheets","position":[1716,280],"parameters":{"columns":{"value":{"HSN":"={{ $('Split Out').item.json.hsn_code }}","Qty":"={{ $('Split Out').item.json.quantity }}","CGST%":"={{ $('Split Out').item.json.cgst }}","SGST%":"={{ $('Split Out').item.json.sgst }}","SR No.":"={{ $('Split Out').item.json['serial_no'] }}","PO Date":"={{ $('Post-Processing').item.json.po_date }}","PO Number":"={{ $('Post-Processing').item.json.po_number }}","Unique Key":"={{ $json['Unique Key'] }}","Invoice No.":"={{ $('Post-Processing').item.json.invoice_number }}","Sale Amount":"={{ $('Split Out').item.json.line_total }}","Invoice Date":"={{ $('Post-Processing').item.json.invoice_date }}","Rate (Vendor)":"={{ $('Split Out').item.json.unit_price }}","TWW Description":"={{ \n  $node[\"Split Out\"].json[\"code\"] + \" \" + \n  $node[\"Split Out\"].json[\"description\"] + \" \" + \n  ($node[\"Split Out\"].json[\"last character\"] ?? $node[\"Split Out\"].json[\"last_character\"] ?? \"\") \n}}"},"schema":[{"id":"SR No.","type":"string","display":true,"removed":false,"required":false,"displayName":"SR No.","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Invoice No.","type":"string","display":true,"required":false,"displayName":"Invoice No.","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Unique Key","type":"string","display":true,"removed":false,"required":false,"displayName":"Unique Key","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Invoice Date","type":"string","display":true,"required":false,"displayName":"Invoice Date","defaultMatch":false,"canBeUsedToMatch":true},{"id":"PO Number","type":"string","display":true,"required":false,"displayName":"PO Number","defaultMatch":false,"canBeUsedToMatch":true},{"id":"PO Date","type":"string","display":true,"required":false,"displayName":"PO Date","defaultMatch":false,"canBeUsedToMatch":true},{"id":"TWW Description","type":"string","display":true,"required":false,"displayName":"TWW Description","defaultMatch":false,"canBeUsedToMatch":true},{"id":"HSN","type":"string","display":true,"required":false,"displayName":"HSN","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Qty","type":"string","display":true,"required":false,"displayName":"Qty","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Rate (Vendor)","type":"string","display":true,"required":false,"displayName":"Rate (Vendor)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Sale Amount","type":"string","display":true,"required":false,"displayName":"Sale Amount","defaultMatch":false,"canBeUsedToMatch":true},{"id":"CGST%","type":"string","display":true,"required":false,"displayName":"CGST%","defaultMatch":false,"canBeUsedToMatch":true},{"id":"SGST%","type":"string","display":true,"required":false,"displayName":"SGST%","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Matched Cost (Actual Price)","type":"string","display":true,"removed":true,"required":false,"displayName":"Matched Cost (Actual Price)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Matched Unit Price (Vendor Price)","type":"string","display":true,"removed":true,"required":false,"displayName":"Matched Unit Price (Vendor Price)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Price Difference (₹)","type":"string","display":true,"removed":true,"required":false,"displayName":"Price Difference (₹)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Total Loss/Gain (₹)","type":"string","display":true,"removed":true,"required":false,"displayName":"Total Loss/Gain (₹)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Mismatch Note","type":"string","display":true,"removed":true,"required":false,"displayName":"Mismatch Note","defaultMatch":false,"canBeUsedToMatch":true},{"id":"SKU Matched","type":"string","display":true,"removed":false,"required":false,"displayName":"SKU Matched","defaultMatch":false,"canBeUsedToMatch":true},{"id":"ASIN","type":"string","display":true,"removed":false,"required":false,"displayName":"ASIN","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Taxable Amount","type":"string","display":true,"removed":false,"required":false,"displayName":"Taxable Amount","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Invoice Amount","type":"string","display":true,"removed":false,"required":false,"displayName":"Invoice Amount","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Total Quantity","type":"string","display":true,"removed":false,"required":false,"displayName":"Total Quantity","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1L2DN1aGp1uhLhNm7TrI54tC0Yuk4ER9y2DU-jbHrSrk/edit#gid=0","cachedResultName":"Sheet1"},"documentId":{"__rl":true,"mode":"list","value":"1L2DN1aGp1uhLhNm7TrI54tC0Yuk4ER9y2DU-jbHrSrk","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1L2DN1aGp1uhLhNm7TrI54tC0Yuk4ER9y2DU-jbHrSrk/edit?usp=drivesdk","cachedResultName":"Invoice Validation"}},"credentials":{"googleSheetsOAuth2Api":{"id":"vRHrArbX33qgxWfK","name":"Google Sheets account 3"}},"typeVersion":4.5},{"id":"3e30f4f1-15e1-41d9-a7f3-bf49d6273c02","name":"Fetch Master Data","type":"n8n-nodes-base.googleSheets","position":[1980,280],"parameters":{"options":{},"sheetName":{"__rl":true,"mode":"list","value":305288444,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1ZBODB_mwa17Amtxnme5l8MxyEcWHYy9SSjQ6atPJXhc/edit#gid=305288444","cachedResultName":"Cost-Priority sheet-GPT"},"documentId":{"__rl":true,"mode":"list","value":"1ZBODB_mwa17Amtxnme5l8MxyEcWHYy9SSjQ6atPJXhc","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1ZBODB_mwa17Amtxnme5l8MxyEcWHYy9SSjQ6atPJXhc/edit?usp=drivesdk","cachedResultName":"Mapping Sheet Final"}},"credentials":{"googleSheetsOAuth2Api":{"id":"vRHrArbX33qgxWfK","name":"Google Sheets account 3"}},"executeOnce":true,"typeVersion":4.5},{"id":"7a46cfd3-3e2f-4818-80cd-e2776d0303a5","name":"Update Results","type":"n8n-nodes-base.googleSheets","position":[2460,280],"parameters":{"columns":{"value":{"Unique Key":"={{ $json.Unique_Key }}","Mismatch Note":"={{ $('Validation').item.json.message }}","Total Loss/Gain (₹)":"={{ ($json.unit_price - $json.costFromSheet) * $json.quantity}}","Price Difference (₹)":"={{ $json.unit_price - $json.costFromSheet }}","Matched Cost (Actual Price)":"={{ $json.costFromSheet }}","Matched Unit Price (Vendor Price)":"={{ $('Validation').item.json.unit_price }}"},"schema":[{"id":"SR No.","type":"string","display":true,"removed":true,"required":false,"displayName":"SR No.","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Invoice No.","type":"string","display":true,"removed":true,"required":false,"displayName":"Invoice No.","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Unique Key","type":"string","display":true,"removed":false,"required":false,"displayName":"Unique Key","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Invoice Date","type":"string","display":true,"removed":true,"required":false,"displayName":"Invoice Date","defaultMatch":false,"canBeUsedToMatch":true},{"id":"PO Number","type":"string","display":true,"removed":true,"required":false,"displayName":"PO Number","defaultMatch":false,"canBeUsedToMatch":true},{"id":"PO Date","type":"string","display":true,"removed":true,"required":false,"displayName":"PO Date","defaultMatch":false,"canBeUsedToMatch":true},{"id":"TWW Description","type":"string","display":true,"removed":true,"required":false,"displayName":"TWW Description","defaultMatch":false,"canBeUsedToMatch":true},{"id":"HSN","type":"string","display":true,"removed":true,"required":false,"displayName":"HSN","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Qty","type":"string","display":true,"removed":true,"required":false,"displayName":"Qty","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Rate (Vendor)","type":"string","display":true,"removed":true,"required":false,"displayName":"Rate (Vendor)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Sale Amount","type":"string","display":true,"removed":true,"required":false,"displayName":"Sale Amount","defaultMatch":false,"canBeUsedToMatch":true},{"id":"CGST%","type":"string","display":true,"removed":true,"required":false,"displayName":"CGST%","defaultMatch":false,"canBeUsedToMatch":true},{"id":"SGST%","type":"string","display":true,"removed":true,"required":false,"displayName":"SGST%","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Matched Cost (Actual Price)","type":"string","display":true,"removed":false,"required":false,"displayName":"Matched Cost (Actual Price)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Matched Unit Price (Vendor Price)","type":"string","display":true,"required":false,"displayName":"Matched Unit Price (Vendor Price)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Price Difference (₹)","type":"string","display":true,"required":false,"displayName":"Price Difference (₹)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Total Loss/Gain (₹)","type":"string","display":true,"required":false,"displayName":"Total Loss/Gain (₹)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Mismatch Note","type":"string","display":true,"required":false,"displayName":"Mismatch Note","defaultMatch":false,"canBeUsedToMatch":true},{"id":"row_number","type":"string","display":true,"removed":false,"readOnly":true,"required":false,"displayName":"row_number","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":["Unique Key"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"update","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1L2DN1aGp1uhLhNm7TrI54tC0Yuk4ER9y2DU-jbHrSrk/edit#gid=0","cachedResultName":"Sheet1"},"documentId":{"__rl":true,"mode":"list","value":"1L2DN1aGp1uhLhNm7TrI54tC0Yuk4ER9y2DU-jbHrSrk","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1L2DN1aGp1uhLhNm7TrI54tC0Yuk4ER9y2DU-jbHrSrk/edit?usp=drivesdk","cachedResultName":"Invoice Validation"}},"credentials":{"googleSheetsOAuth2Api":{"id":"vRHrArbX33qgxWfK","name":"Google Sheets account 3"}},"typeVersion":4.5},{"id":"d9752205-2712-46d0-9058-86857f28e470","name":"Generate Unique Key","type":"n8n-nodes-base.set","position":[1496,280],"parameters":{"options":{},"assignments":{"assignments":[{"id":"1907451f-cc09-45d7-a04f-113f8f94d918","name":"Unique Key","type":"string","value":"={{ $('If').item.json.invoice_number + \"-\" + $itemIndex }}"}]}},"typeVersion":3.4},{"id":"52a2b54a-69e8-4a83-9861-5931a51a7162","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-240,320],"parameters":{"color":7,"width":620,"height":280,"content":"## Reading Invoice's PDF File Locally"},"typeVersion":1},{"id":"67d04fa9-3ad7-4613-89f0-511f9ee32f1d","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[400,320],"parameters":{"color":7,"width":380,"height":280,"content":"## Extracting Details From Invoice PDF"},"typeVersion":1},{"id":"4465dff2-ea51-4392-8aa7-8a780a73c33e","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[800,320],"parameters":{"color":7,"height":220,"content":"## Processing Output"},"typeVersion":1},{"id":"c4ed886e-3e16-451b-b554-badb5f130623","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[1280,460],"parameters":{"color":7,"width":220,"height":220,"content":"## Fallback On Error"},"typeVersion":1},{"id":"159dd4d1-f052-4401-a426-0621af19d300","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[1240,220],"parameters":{"color":7,"width":400,"height":220,"content":"## Extracting Line Items"},"typeVersion":1},{"id":"b90a3aba-a18a-4846-a22d-cbd72aac8e6d","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[1660,200],"parameters":{"color":7,"width":220,"height":240,"content":"## Sending Data To G-Sheet"},"typeVersion":1},{"id":"69e4f146-394f-4dc2-ab70-22337a3031e9","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[1900,200],"parameters":{"color":7,"width":440,"height":240,"content":"## Fetch Master Data & Validating Invoice Extracted Data"},"typeVersion":1},{"id":"23c130e3-1727-48a2-b050-a4fdc07749f1","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[2360,200],"parameters":{"color":7,"width":300,"height":240,"content":"## Update Validation Result"},"typeVersion":1}],"connections":{"If":{"main":[[{"node":"Send Raw Text Again","type":"main","index":0}],[{"node":"Split Out","type":"main","index":0}]]},"Split Out":{"main":[[{"node":"Generate Unique Key","type":"main","index":0}]]},"Validation":{"main":[[{"node":"Update Results","type":"main","index":0}]]},"Text Extractor":{"main":[[{"node":"Post-Processing","type":"main","index":0}]]},"Post-Processing":{"main":[[{"node":"If","type":"main","index":0}]]},"Extract from File":{"main":[[{"node":"Text Extractor","type":"main","index":0}]]},"Fetch Master Data":{"main":[[{"node":"Validation","type":"main","index":0}]]},"Send Invoice Data":{"main":[[{"node":"Fetch Master Data","type":"main","index":0}]]},"Generate Unique Key":{"main":[[{"node":"Send Invoice Data","type":"main","index":0}]]},"Send Raw Text Again":{"main":[[{"node":"Text Extractor","type":"main","index":0}]]},"OpenRouter Chat Model":{"ai_languageModel":[[{"node":"Text Extractor","type":"ai_languageModel","index":0}]]},"Read/Write Files from Disk":{"main":[[{"node":"Extract from File","type":"main","index":0}]]},"When clicking ‘Test workflow’":{"main":[[{"node":"Read/Write Files from Disk","type":"main","index":0}]]}}}


name: Web Site Scraper for LLMs with Airtop
author_name: Airtop
author_username: cesar-at-airtop
categories: []
created_at: 2025-05-21T00:17:56.473Z
updated_at: 2025-05-21T00:17:56.473Z
url: https://n8n.io/workflows/4252
scraped_at: 2025-07-06 21:16:30
description:
  Recursive Web Scraping 

  Use Case  
  Automating web scraping with recursive depth is ideal for collecting content across multiple linked pages—perfect for content aggregation, lead generation, or research projects.

  What This Automation Does  
  This automation reads a list of URLs from a Google Sheet, scrapes each page, stores the content in a document, and adds newly discovered links back to the sheet. It continues this process for a specified number of iterations based on the defined scraping depth.

  Input Parameters:
  Seed URL: The starting URL to begin the scraping process.  
    Example: https://example.com/
  Links must contain: Restricts the links to those that contain this specified string.  
    Example: https://example.com/
  Depth: The number of iterations (layers of links) to scrape beyond the initial set.  
    Example: 3

  How It Works  
  Starts by reading the Seed URL from the Google Sheet.
  Scrapes each page and saves its content to the specified document.
  Extracts new links from each page that match the Links must contain string, appends them to the Google Sheet.
  Repeats steps 2–3 for the number of times specified by Depth - 1.

  Setup Requirements  
  Airtop API Key — free to generate.  
  Credentials set up for Google Docs (requires creating a project on Google Console). Read how to.  
  Credentials set up for Google Spreadsheet.

  Next Steps  
  Add Filtering Rules**: Filter which links to follow based on domain, path, or content type.  
  Combine with Scheduler**: Run this automation on a schedule to continuously explore newly discovered pages.  
  Export Structured Data**: Extend the process to store extracted data in a CSV or database for analysis.

  Read more about website scraping for LLMS

nodes_used:
  ["n8n-nodes-base.googleSheets","n8n-nodes-base.googleDocs","n8n-nodes-base.code","n8n-nodes-base.airtop"]

workflow_json:
  {"id":"3SNBO1RAF0ZIyido","meta":{"instanceId":"28a947b92b197fc2524eaba16e57560338657b2b0b5796300b2f1cedc1d0d355","templateCredsSetupCompleted":true},"name":"Website scraper","tags":[],"nodes":[{"id":"aaa5bf43-bf76-4433-93c7-7e168f2e140c","name":"On form submission","type":"n8n-nodes-base.formTrigger","position":[-400,-200],"webhookId":"6c508326-84d3-4155-9f2e-fe7ddb50f14a","parameters":{"options":{},"formTitle":"Website scraper","formFields":{"values":[{"fieldLabel":"Seed url","requiredField":true},{"fieldLabel":"Links must contain","requiredField":true},{"fieldType":"number","fieldLabel":"Depth","requiredField":true}]}},"typeVersion":2.2},{"id":"5f862a6f-8079-4d24-a2ae-7442c45c8f04","name":"Info to upload into spreadsheet","type":"n8n-nodes-base.set","position":[260,-100],"parameters":{"options":{},"assignments":{"assignments":[{"id":"5970bab1-0bfb-4212-a8f2-df6b2e003800","name":"URL","type":"string","value":"={{ $('Unify params').item.json[\"Seed url\"] }}"},{"id":"5c941ad3-70bf-4fba-8cf3-1f79c1b20d3a","name":"Scraped","type":"string","value":""}]}},"typeVersion":3.4},{"id":"556e5da4-4454-46cd-b17d-bd8695515670","name":"Load info to spreadsheet","type":"n8n-nodes-base.googleSheets","position":[480,-100],"parameters":{"columns":{"value":{},"schema":[{"id":"URL","type":"string","display":true,"removed":false,"required":false,"displayName":"URL","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"autoMapInputData","matchingColumns":["URL"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"name","value":"={{ $('Create Spreadsheet').item.json.sheets[0].properties.title }}"},"documentId":{"__rl":true,"mode":"id","value":"={{ $('Create Spreadsheet').item.json.spreadsheetId }}"}},"credentials":{"googleSheetsOAuth2Api":{"id":"DdxyhUJLGcclD2YO","name":"Google sheets Andres"}},"typeVersion":4.5},{"id":"4592ada8-8f21-4117-a0ee-8906922f5685","name":"Scrape webpage","type":"n8n-nodes-base.airtop","position":[700,-100],"parameters":{"url":"={{ $json.URL }}","resource":"extraction","operation":"scrape","profileName":"=","sessionMode":"new"},"credentials":{"airtopApi":{"id":"Yi4YPNnovLVUjFn5","name":"Airtop Official Org"}},"typeVersion":1},{"id":"74a1399d-a335-455c-a3dd-167624b4a5f2","name":"Create Google Docs","type":"n8n-nodes-base.googleDocs","position":[920,-100],"parameters":{"title":"=Site to File - {{ $('Unify params').item.json[\"Seed url\"] }}","folderId":"default"},"credentials":{"googleDocsOAuth2Api":{"id":"pDMGILToKi9P4taJ","name":"Andres Google Docs"}},"typeVersion":2},{"id":"1e69e40f-0465-430b-85ec-c6a71e1cb4a4","name":"Write scraped content","type":"n8n-nodes-base.googleDocs","position":[1140,-100],"parameters":{"actionsUi":{"actionFields":[{"text":"=The entire content from {{ $('Info to upload into spreadsheet').item.json.URL }} up to {{ $('Unify params').item.json.Depth }} levels deep.\n---------------------------------------------  \n{{ $('Scrape webpage').item.json.data.modelResponse.scrapedContent.text }}\n---------------------------------------------","action":"insert"}]},"operation":"update","documentURL":"={{ $json.id }}"},"credentials":{"googleDocsOAuth2Api":{"id":"pDMGILToKi9P4taJ","name":"Andres Google Docs"}},"typeVersion":2},{"id":"49e9b38c-c2d4-49f3-bf3f-531b10257db4","name":"Should scrape more?","type":"n8n-nodes-base.if","position":[1380,-100],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"707d2bae-e834-478b-a4f6-9e6bbfa47530","operator":{"type":"number","operation":"lt"},"leftValue":"={{ $runIndex }}","rightValue":"={{ $('Unify params').first().json.Depth - 1 }}"},{"id":"cc763610-f775-4dcb-ae29-a3235b011b75","operator":{"type":"number","operation":"gt"},"leftValue":"={{ Number($('Unify params').first().json.Depth) }}","rightValue":1}]}},"typeVersion":2.2},{"id":"239b2a02-bd66-4805-8ad3-b4ef6daa5e60","name":"Read scraped webpages","type":"n8n-nodes-base.googleSheets","position":[1580,-175],"parameters":{"options":{},"sheetName":{"__rl":true,"mode":"name","value":"={{ $('Create Spreadsheet').first().json.sheets[0].properties.title }}"},"documentId":{"__rl":true,"mode":"id","value":"={{ $('Create Spreadsheet').first().json.spreadsheetId }}"}},"credentials":{"googleSheetsOAuth2Api":{"id":"DdxyhUJLGcclD2YO","name":"Google sheets Andres"}},"typeVersion":4.5},{"id":"029d7de1-9043-424e-9c22-aed436436e6a","name":"Retrieve links to scrape","type":"n8n-nodes-base.airtop","position":[1800,-175],"parameters":{"url":"={{ $json.URL }}","prompt":"Extract the list of links that lead to other pages in the same domain","resource":"extraction","operation":"query","sessionMode":"new","additionalFields":{"outputSchema":"{\n  \"type\": \"object\",\n  \"properties\": {\n    \"internal_links\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\",\n        \"description\": \"A URL that leads to another page within the airtop.ai domain\"\n      },\n      \"description\": \"A list of URLs that lead to other pages within the airtop.ai domain\"\n    }\n  },\n  \"required\": [\n    \"internal_links\"\n  ],\n  \"additionalProperties\": false,\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\"\n}"}},"credentials":{"airtopApi":{"id":"Yi4YPNnovLVUjFn5","name":"Airtop Official Org"}},"typeVersion":1},{"id":"57f2a3ee-40c9-4e72-99f4-739fff04667a","name":"Filter links to insert to Sheets","type":"n8n-nodes-base.code","position":[2020,-180],"parameters":{"jsCode":"const modelResponse = $('Retrieve links to scrape').first().json.data.modelResponse;\nconst containsString = $('Unify params').first().json[\"Links must contain\"];\nconst parsed = JSON.parse(modelResponse);\nconst links = [...new Set(parsed.internal_links)]; \nconst sheetsLinks = $input.all().map(item => item.json.URL)\nlet response; \n\nif(containsString === \"\"){\n  response = links\n    .map(item =>(\n        { json: { link: item.split('?')[0] } }\n    ))\n} else {\n  response = links\n    .map(item =>\n      item.includes(containsString)\n        ? { json: { link: item.split('?')[0] } }\n        : null\n    )\n    .filter(item => item !== null);\n}\nconst dedupeBetweenSheetsAndModel = response.filter(item => !sheetsLinks.includes(item.json.link));\nconst deduped = [...new Map(dedupeBetweenSheetsAndModel.map(item => [item.json.link, item])).values()]\nreturn deduped\n"},"typeVersion":2},{"id":"6a0f20e8-df45-4799-8162-21d427e19e49","name":"Insert new links","type":"n8n-nodes-base.googleSheets","position":[2240,-175],"parameters":{"columns":{"value":{"URL":"={{ $json.link }}"},"schema":[{"id":"URL","type":"string","display":true,"removed":false,"required":false,"displayName":"URL","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Scraped","type":"string","display":true,"removed":false,"required":false,"displayName":"Scraped","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"name","value":"={{ $('Create Spreadsheet').first().json.sheets[0].properties.title }}"},"documentId":{"__rl":true,"mode":"id","value":"={{ $('Create Spreadsheet').first().json.spreadsheetId }}"}},"credentials":{"googleSheetsOAuth2Api":{"id":"DdxyhUJLGcclD2YO","name":"Google sheets Andres"}},"typeVersion":4.5},{"id":"9433ab9e-b562-4aa3-a311-ae2a355ce774","name":"Scrape webpage1","type":"n8n-nodes-base.airtop","position":[2460,-175],"parameters":{"url":"={{ $json.URL }}","resource":"extraction","operation":"scrape","sessionMode":"new"},"credentials":{"airtopApi":{"id":"Yi4YPNnovLVUjFn5","name":"Airtop Official Org"}},"typeVersion":1},{"id":"704c25cf-b690-492d-a759-7b24a870edf4","name":"Update with new scraped content","type":"n8n-nodes-base.googleDocs","position":[2680,-175],"parameters":{"actionsUi":{"actionFields":[{"text":"=-------------------------  \n{{ $json.data.modelResponse.scrapedContent.text }}\n-------------------------","action":"insert"}]},"operation":"update","documentURL":"={{ $('Create Google Docs').first().json.id }}"},"credentials":{"googleDocsOAuth2Api":{"id":"pDMGILToKi9P4taJ","name":"Andres Google Docs"}},"typeVersion":2},{"id":"14f1465d-3d7d-4b7a-87d2-2552b9514e37","name":"Flag scraped link","type":"n8n-nodes-base.set","position":[2900,-175],"parameters":{"options":{},"assignments":{"assignments":[{"id":"72c9cd92-fd01-4339-b9fe-52477b691df3","name":"URL","type":"string","value":"={{ $('Insert new links').item.json.URL }}"},{"id":"a817116e-6ae5-4e0a-b210-4fd27f5a455a","name":"Scraped","type":"string","value":"={{ $runIndex }}"}]}},"typeVersion":3.4},{"id":"364513e7-39c0-47af-83bd-475ffb0ae2a0","name":"Insert flag","type":"n8n-nodes-base.googleSheets","position":[3120,-100],"parameters":{"columns":{"value":{"URL":"={{ $('Insert new links').item.json.URL }}"},"schema":[{"id":"URL","type":"string","display":true,"removed":false,"required":false,"displayName":"URL","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Scraped","type":"string","display":true,"removed":false,"required":false,"displayName":"Scraped","defaultMatch":false,"canBeUsedToMatch":true},{"id":"row_number","type":"string","display":true,"removed":false,"readOnly":true,"required":false,"displayName":"row_number","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"autoMapInputData","matchingColumns":["URL"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"update","sheetName":{"__rl":true,"mode":"name","value":"={{ $('Create Spreadsheet').first().json.sheets[0].properties.title }}"},"documentId":{"__rl":true,"mode":"id","value":"={{ $('Create Spreadsheet').first().json.spreadsheetId }}"}},"credentials":{"googleSheetsOAuth2Api":{"id":"DdxyhUJLGcclD2YO","name":"Google sheets Andres"}},"typeVersion":4.5},{"id":"bd799398-e6c6-4cd4-a8a9-d189acabb194","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-20,-220],"parameters":{"width":660,"height":280,"content":"## Create Spreadsheet\nCreate a spreadsheet to track all the links found on the webpage."},"typeVersion":1},{"id":"7a5aeddd-9c0f-4ea2-8452-35dd14e6963a","name":"Create Spreadsheet","type":"n8n-nodes-base.googleSheets","position":[40,-100],"parameters":{"title":"=Site map -  {{ $json[\"Seed url\"] }} (Depth - {{ $json.Depth }})","options":{},"resource":"spreadsheet"},"credentials":{"googleSheetsOAuth2Api":{"id":"DdxyhUJLGcclD2YO","name":"Google sheets Andres"}},"typeVersion":4.5},{"id":"19a6c42b-8be5-4599-bc60-99f0b09e3623","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[660,-220],"parameters":{"color":4,"width":180,"height":280,"content":"## Scrape webpage"},"typeVersion":1},{"id":"5de141f9-9e1e-4159-8611-06d23ee7b476","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[860,-220],"parameters":{"width":440,"height":280,"content":"## Create Doc\nCreate a document to store all the information scraped from the webpage."},"typeVersion":1},{"id":"a9108190-01d9-4c9a-a7b0-9ea582026acb","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[1320,-280],"parameters":{"width":1980,"height":380,"content":"## Recursive Scraping Process\nReads a list of URLs from a Google Sheet, scrapes each page, saves the content to a doc, and adds new links back to the sheet. Repeats the process for each depth level, up to the defined scraping depth minus one."},"typeVersion":1},{"id":"bec8b412-51e1-45df-95b5-ae4e4aeb1fc2","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-1160,-540],"parameters":{"color":7,"width":660,"height":940,"content":"README\n# Recursive Web Scraping \n\n## Use Case  \nAutomating web scraping with recursive depth is ideal for collecting content across multiple linked pages—perfect for content aggregation, lead generation, or research projects.\n\n## What This Automation Does  \nThis automation reads a list of URLs from a Google Sheet, scrapes each page, stores the content in a document, and adds newly discovered links back to the sheet. It continues this process for a specified number of iterations based on the defined scraping depth.\n\n### Input Parameters:\n- `Seed URL`: The starting URL to begin the scraping process.  \n  Example: `https://example.com/`\n- `Links must contain`: Restricts the links to those that contain this specified string.  \n  Example: `https://example.com/`\n- `Depth`: The number of iterations (layers of links) to scrape beyond the initial set.  \n  Example: `3`\n\n## How It Works  \n1. Starts by reading the `Seed URL` from the Google Sheet.\n2. Scrapes each page and saves its content to the specified document.\n3. Extracts new links from each page that match the `Links must contain` string, appends them to the Google Sheet.\n4. Repeats steps 2–3 for the number of times specified by `Depth - 1`.\n\n## Setup Requirements  \n1. [Airtop API Key](https://portal.airtop.ai/api-keys) — free to generate.  \n2. Credentials set up for Google Docs (requires creating a project on Google Console). Read [how to](https://docs.n8n.io/integrations/builtin/credentials/google/).  \n3. Credentials set up for Google Spreadsheet.\n\n## Next Steps  \n- **Add Filtering Rules**: Filter which links to follow based on domain, path, or content type.  \n- **Combine with Scheduler**: Run this automation on a schedule to continuously explore newly discovered pages.  \n- **Export Structured Data**: Extend the process to store extracted data in a CSV or database for analysis.\n"},"typeVersion":1},{"id":"ef3cfdbf-bd61-4452-bad0-d0154bbd893b","name":"When Executed by Another Workflow","type":"n8n-nodes-base.executeWorkflowTrigger","position":[-400,0],"parameters":{"workflowInputs":{"values":[{"name":"Seed url"},{"name":"Links must contain"},{"name":"Depth","type":"number"}]}},"typeVersion":1.1},{"id":"16d54958-18b6-497f-af9e-5953a39ae0bb","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-440,-300],"parameters":{"width":400,"height":460,"content":"## Input Parameters\nRun this workflow using a form or from another workflow"},"typeVersion":1},{"id":"99cc34ec-37eb-423a-9cc5-7c1b7736d352","name":"Unify params","type":"n8n-nodes-base.set","position":[-180,-100],"parameters":{"options":{},"assignments":{"assignments":[{"id":"18e3200c-ab2a-44da-b401-eace47a3ccc0","name":"Seed url","type":"string","value":"={{ $json[\"Seed url\"] }}"},{"id":"cb21aa86-bf75-427f-bf07-70d4f2d83894","name":"Links must contain","type":"string","value":"={{ $json[\"Links must contain\"] }}"},{"id":"80bb934f-816d-43f0-9432-170047fa02a3","name":"Depth","type":"number","value":"={{ $json.Depth }}"}]}},"typeVersion":3.4}],"active":false,"settings":{"executionOrder":"v1"},"versionId":"dffadb4b-7c72-42ec-802c-26d4f96b5ec7","connections":{"Insert flag":{"main":[[{"node":"Should scrape more?","type":"main","index":0}]]},"Unify params":{"main":[[{"node":"Create Spreadsheet","type":"main","index":0}]]},"Scrape webpage":{"main":[[{"node":"Create Google Docs","type":"main","index":0}]]},"Scrape webpage1":{"main":[[{"node":"Update with new scraped content","type":"main","index":0}]]},"Insert new links":{"main":[[{"node":"Scrape webpage1","type":"main","index":0}]]},"Flag scraped link":{"main":[[{"node":"Insert flag","type":"main","index":0}]]},"Create Google Docs":{"main":[[{"node":"Write scraped content","type":"main","index":0}]]},"Create Spreadsheet":{"main":[[{"node":"Info to upload into spreadsheet","type":"main","index":0}]]},"On form submission":{"main":[[{"node":"Unify params","type":"main","index":0}]]},"Should scrape more?":{"main":[[{"node":"Read scraped webpages","type":"main","index":0}],[]]},"Read scraped webpages":{"main":[[{"node":"Retrieve links to scrape","type":"main","index":0}]]},"Write scraped content":{"main":[[{"node":"Should scrape more?","type":"main","index":0}]]},"Load info to spreadsheet":{"main":[[{"node":"Scrape webpage","type":"main","index":0}]]},"Retrieve links to scrape":{"main":[[{"node":"Filter links to insert to Sheets","type":"main","index":0}]]},"Info to upload into spreadsheet":{"main":[[{"node":"Load info to spreadsheet","type":"main","index":0}]]},"Update with new scraped content":{"main":[[{"node":"Flag scraped link","type":"main","index":0}]]},"Filter links to insert to Sheets":{"main":[[{"node":"Insert new links","type":"main","index":0}]]},"When Executed by Another Workflow":{"main":[[{"node":"Unify params","type":"main","index":0}]]}}}


name: Extract Linkedin Company data with Airtop
author_name: Airtop
author_username: cesar-at-airtop
nodes_used: ["n8n-nodes-base.airtop"]
categories: []
created_at: 2025-05-21T01:48:51.083Z
updated_at: 2025-05-21T01:48:51.083Z
url: https://n8n.io/workflows/4261
scraped_at: 2025-07-06 21:16:30
description:
  Automating LinkedIn Company Data Extraction

  Use Case

  This automation extracts detailed company insights from a LinkedIn company page, including identity, scale, classification, and funding data. Ideal for investors, sales teams, and market researchers.

  What This Automation Does

  This automation accepts the following inputs:

  Company's LinkedIn URL**: The public LinkedIn page URL of the company.
  Airtop Profile (connected to LinkedIn)**: Your Airtop Profile authenticated on LinkedIn.

  It then extracts and returns structured data with:

  1. Company Identity
  Full name
  Tagline
  Headquarters location (city, state, country)
  About section
  Website

  2. Company Scale
  Current employee count
  Employee size bracket: [0-9], [10-150], [150+]

  3. Business Classification
  Is the company an automation agency? (true/false)
  AI implementation level: Low / Medium / High
  Technical sophistication: Basic / Intermediate / Advanced / Expert

  4. Funding Profile
  Most recent funding round
  Total amount raised
  Key investors
  Last funding update date

  How It Works

  Creates an Airtop session using the provided profile.
  Navigates to the company LinkedIn page.
  Executes an Airtop query to extract data.
  Outputs the result in a standardized JSON schema.

  Setup Requirements

  Airtop API Key
  A LinkedIn-authenticated Airtop Profile

  Next Steps

  Feed into CRM**: Enrich your accounts with detailed LinkedIn data.
  Prioritize Leads**: Use classification and funding data to prioritize outreach.
  Combine with People Data**: Integrate with individual-level enrichment for full context.

  Read more about how to extract company data from Linkedin with Airtop and n8n

workflow_json:
  {"id":"yWtpgGwGgspx1A1W","meta":{"instanceId":"28a947b92b197fc2524eaba16e57560338657b2b0b5796300b2f1cedc1d0d355","templateCredsSetupCompleted":true},"name":"Extract LinkedIn Company Information","tags":[],"nodes":[{"id":"cc28eede-9e0b-450f-9637-8bf45aa4046a","name":"On form submission","type":"n8n-nodes-base.formTrigger","position":[0,40],"webhookId":"5a5f0133-0b83-4839-bcfb-53499390b99a","parameters":{"options":{},"formTitle":"Company information","formFields":{"values":[{"fieldLabel":"Company's LinkedIn URL","placeholder":"https://www.linkedin.com/company/airtop-ai/","requiredField":true},{"fieldLabel":"Airtop Profile (connected to Linkedin)","requiredField":true}]},"formDescription":"=This Airtop Studio automation simplifies LinkedIn data extraction by automatically providing structured, reliable, and easily actionable data—saving significant effort, reducing errors, and enabling fast analysis and decision-making."},"typeVersion":2.2},{"id":"2f698c15-0513-49ef-842f-250d7cb10b6a","name":"When Executed by Another Workflow","type":"n8n-nodes-base.executeWorkflowTrigger","position":[0,240],"parameters":{"workflowInputs":{"values":[{"name":"company_linkedin"},{"name":"airtop_profile"}]}},"typeVersion":1.1},{"id":"dabdf295-fad9-4069-9408-82d56f1c7ed8","name":"Unify Params","type":"n8n-nodes-base.set","position":[220,140],"parameters":{"options":{},"assignments":{"assignments":[{"id":"f4bd4165-2af4-413b-8c47-dbdadda687f0","name":"company_linkedin","type":"string","value":"={{ $json.company_linkedin || $json[\"Company's LinkedIn URL\"] }}"},{"id":"eeb0f94d-750b-407d-a94c-d7aa9a1782f3","name":"airtop_profile","type":"string","value":"={{ $json.airtop_profile || $json[\"Airtop Profile (connected to Linkedin)\"] }}"}]}},"typeVersion":3.4},{"id":"49b490b3-2449-49b2-9447-c789f3c14161","name":"Extract Company's information","type":"n8n-nodes-base.airtop","position":[440,140],"parameters":{"url":"={{ $json.company_linkedin }}","prompt":"=# LinkedIn Company Analysis Prompt\n\nExtract and analyze the following information from the provided LinkedIn company page. Present the results in a structured JSON format.\n\n## Required Data Points\n\n### 1. Company Identity\n- Full company name (including suffixes like Inc., LLC, etc.)\n- Brand tagline/headline (directly under company name)\n- Global headquarters location \n- Company description (full \"About\" section text)\n- Primary website URL (excluding social media links)\n\n### 2. Company Scale\n- Current employee count (from LinkedIn \"X employees\" metric)\n- Employee range bracket: [0-9], [10-150], [150+]\n\n### 3. Business Classification\nEvaluate the following characteristics based on company description, recent posts, and featured content:\n\n#### Automation Agency Status\n- Boolean (true/false) classification\n- Criteria for \"true\":\n  * Company explicitly offers automation services to clients\n  * Core business model involves developing/implementing automations\n  * Primary revenue from automation consulting/development\n\n#### AI Implementation Level\nClassify as [Low/Medium/High] based on:\n- Low: No evidence of AI/automation/scraping usage\n- Medium: Uses AI/automation tools or mentions them as supplementary capabilities\n- High: Core business involves AI development, automation creation, or data harvesting services\n\n### 4. Technical Sophistication\nEvaluate overall technical capabilities as [Basic/Intermediate/Advanced/Expert] based on:\n- Technology stack mentioned\n- Technical job postings\n- Products/services complexity\n- Engineering team size\n- Technical achievements highlighted\n\n### 5. Investment Profile\nIf available, document:\n- Most recent funding round\n- Total funding amount\n- Key investors\n- Last funding date\nMark as \"Not publicly disclosed\" if information unavailable\n\n## Output Format\nReturn data in the following JSON structure, with all fields required, make sure the response contains only the json.\n\n{\n  \"company_profile\": {\n    \"name\": string,\n    \"tagline\": string,\n    \"location\": {\n      \"city\": string,\n      \"state\": string,\n      \"country\": string\n    },\n    \"overview\": string,\n    \"website\": string\n  },\n  \"scale\": {\n    \"employee_count\": number,\n    \"size_bracket\": string\n  },\n  \"classification\": {\n    \"is_automation_agency\": boolean,\n    \"ai_focus_level\": string,\n    \"technical_tier\": string\n  },\n  \"funding\": {\n    \"latest_round\": string,\n    \"total_raised\": string,\n    \"investors\": [string],\n    \"last_updated\": string\n  }\n}","resource":"extraction","operation":"query","profileName":"={{ $json.airtop_profile }}","sessionMode":"new","additionalFields":{"outputSchema":"{\n  \"type\": \"object\",\n  \"properties\": {\n    \"company_profile\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"name\": {\n          \"type\": \"string\",\n          \"description\": \"Full company name including suffixes like Inc., LLC, etc.\"\n        },\n        \"tagline\": {\n          \"type\": \"string\",\n          \"description\": \"Brand tagline or headline directly under company name.\"\n        },\n        \"location\": {\n          \"type\": \"object\",\n          \"properties\": {\n            \"city\": {\n              \"type\": \"string\"\n            },\n            \"state\": {\n              \"type\": \"string\"\n            },\n            \"country\": {\n              \"type\": \"string\"\n            }\n          },\n          \"required\": [\n            \"city\",\n            \"state\",\n            \"country\"\n          ],\n          \"additionalProperties\": false,\n          \"description\": \"Global headquarters location.\"\n        },\n        \"overview\": {\n          \"type\": \"string\",\n          \"description\": \"Full 'About' section text of the company.\"\n        },\n        \"website\": {\n          \"type\": \"string\",\n          \"description\": \"Primary website URL excluding social media links.\"\n        }\n      },\n      \"required\": [\n        \"name\",\n        \"tagline\",\n        \"location\",\n        \"overview\",\n        \"website\"\n      ],\n      \"additionalProperties\": false\n    },\n    \"scale\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"employee_count\": {\n          \"type\": \"integer\",\n          \"description\": \"Current employee count from LinkedIn 'X employees' metric.\"\n        },\n        \"size_bracket\": {\n          \"type\": \"string\",\n          \"description\": \"Employee range bracket.\"\n        }\n      },\n      \"required\": [\n        \"employee_count\",\n        \"size_bracket\"\n      ],\n      \"additionalProperties\": false\n    },\n    \"classification\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"is_automation_agency\": {\n          \"type\": \"boolean\",\n          \"description\": \"Boolean classification if the company is an automation agency.\"\n        },\n        \"ai_focus_level\": {\n          \"type\": \"string\",\n          \"description\": \"AI implementation level based on company activities.\"\n        },\n        \"technical_tier\": {\n          \"type\": \"string\",\n          \"description\": \"Overall technical capabilities.\"\n        }\n      },\n      \"required\": [\n        \"is_automation_agency\",\n        \"ai_focus_level\",\n        \"technical_tier\"\n      ],\n      \"additionalProperties\": false\n    },\n    \"funding\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"latest_round\": {\n          \"type\": \"string\",\n          \"description\": \"Most recent funding round.\"\n        },\n        \"total_raised\": {\n          \"type\": \"string\",\n          \"description\": \"Total funding amount.\"\n        },\n        \"investors\": {\n          \"type\": \"array\",\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"description\": \"Key investors.\"\n        },\n        \"last_updated\": {\n          \"type\": \"string\",\n          \"description\": \"Last funding date.\"\n        }\n      },\n      \"required\": [\n        \"latest_round\",\n        \"total_raised\",\n        \"investors\",\n        \"last_updated\"\n      ],\n      \"additionalProperties\": false\n    }\n  },\n  \"required\": [\n    \"company_profile\",\n    \"scale\",\n    \"classification\",\n    \"funding\"\n  ],\n  \"additionalProperties\": false,\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\"\n}"}},"credentials":{"airtopApi":{"id":"Yi4YPNnovLVUjFn5","name":"Airtop Official Org"}},"typeVersion":1},{"id":"baeb6e4d-da47-4503-a2f9-234ad7aec245","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-60,-60],"parameters":{"width":400,"height":460,"content":"## Input Parameters\nRun this workflow using a form or from another workflow"},"typeVersion":1},{"id":"7e884f82-249b-4d2e-bbbf-a7391d9fe7b4","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[360,-60],"parameters":{"color":4,"width":480,"height":460,"content":"## Extract company information from LinkedIn"},"typeVersion":1},{"id":"cc01b24b-5d27-4500-bb1d-abea5dd67b45","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[-780,-580],"parameters":{"width":700,"height":1480,"content":"README\n\n# Automating LinkedIn Company Data Extraction\n\n## Use Case\n\nThis automation extracts detailed company insights from a LinkedIn company page, including identity, scale, classification, and funding data. Ideal for investors, sales teams, and market researchers.\n\n## What This Automation Does\n\nThis automation accepts the following inputs:\n\n- **Company's LinkedIn URL**: The public LinkedIn page URL of the company.\n- **Airtop Profile (connected to LinkedIn)**: Your [Airtop Profile](https://portal.airtop.ai/browser-profiles) authenticated on LinkedIn.\n\nIt then extracts and returns structured data with:\n\n### 1. Company Identity\n- Full name\n- Tagline\n- Headquarters location (city, state, country)\n- About section\n- Website\n\n### 2. Company Scale\n- Current employee count\n- Employee size bracket: [0-9], [10-150], [150+]\n\n### 3. Business Classification\n- Is the company an automation agency? (true/false)\n- AI implementation level: Low / Medium / High\n- Technical sophistication: Basic / Intermediate / Advanced / Expert\n\n### 4. Funding Profile\n- Most recent funding round\n- Total amount raised\n- Key investors\n- Last funding update date\n\n## How It Works\n\n1. Creates an Airtop session using the provided profile.\n2. Navigates to the company LinkedIn page.\n3. Executes an Airtop query to extract data.\n4. Outputs the result in a standardized JSON schema.\n\n## Setup Requirements\n\n1. [Airtop API Key](https://portal.airtop.ai/api-keys)\n2. A [LinkedIn-authenticated Airtop Profile](https://portal.airtop.ai/browser-profiles)\n\n## Next Steps\n\n- **Feed into CRM**: Enrich your accounts with detailed LinkedIn data.\n- **Prioritize Leads**: Use classification and funding data to prioritize outreach.\n- **Combine with People Data**: Integrate with individual-level enrichment for full context.\n"},"typeVersion":1},{"id":"2173abea-5684-4111-92a9-4c538fa14edc","name":"Map output","type":"n8n-nodes-base.set","position":[660,140],"parameters":{"mode":"raw","options":{},"jsonOutput":"={{ $json.data.modelResponse }}\n"},"typeVersion":3.4}],"active":false,"settings":{"executionOrder":"v1"},"versionId":"d90f923d-0b38-4b5f-b404-c89a6f811d74","connections":{"Unify Params":{"main":[[{"node":"Extract Company's information","type":"main","index":0}]]},"On form submission":{"main":[[{"node":"Unify Params","type":"main","index":0}]]},"Extract Company's information":{"main":[[{"node":"Map output","type":"main","index":0}]]},"When Executed by Another Workflow":{"main":[[{"node":"Unify Params","type":"main","index":0}]]}}}


name: Convert boring images to stunning photos and videos
author_name: Rish
author_username: b2brish
nodes_used: ["n8n-nodes-base.httpRequest","n8n-nodes-base.telegram"]
categories: []
created_at: 2025-05-21T08:28:17.337Z
updated_at: 2025-05-21T08:28:17.337Z
url: https://n8n.io/workflows/4275
scraped_at: 2025-07-06 21:16:30
description:
  AI Image Editor with Telegram Bot



  Tutorial Video:
  https://www.youtube.com/watch?v=imi7xKQvKh8

  ✨ Transform ordinary photos into AI masterpieces
  This powerful workflow creates a complete AI image editing system that your Telegram contacts can use with a simple message. Let users send images with creative instructions and watch as cutting-edge AI transforms their ideas into reality.

  🤖 What This Workflow Does
  Connect your Telegram bot to OpenAI and Replicate's advanced image models to:

  Edit photos based on text descriptions
  Generate creative variations of original images
  Deliver professional-quality results in seconds
  Handle the entire process automatically

  🎨 Perfect For

  Digital creators seeking quick design iterations
  Photography enthusiasts wanting AI enhancements
  Product marketers creating concept visualizations
  Community managers offering image editing services
  Anyone looking to explore AI image capabilities

  🔧 Easy Setup
  Just configure your API credentials, customize a few prompts, and your Telegram bot becomes a powerful AI image editor. The workflow handles all the technical complexity including file conversions, API communications, and asynchronous processing.

  💡 Expandable Design
  Built with flexibility in mind, you can easily:

  Add additional AI models
  Implement image moderation
  Create branching paths based on user requests
  Integrate with other services like cloud storage

  Elevate your image editing capabilities with this seamless blend of messaging and AI technology!

workflow_json:
  {"meta":{"instanceId":"e5aa7986ab694604988fd614f16d3dd8cb275c306d75d6a818e14c909713473c"},"nodes":[{"id":"0db7b2f0-dfb2-4c92-98c8-d5eb27ca54f3","name":"Telegram Bot Trigger","type":"n8n-nodes-base.telegramTrigger","position":[-280,380],"webhookId":"ab3c5adb-2300-4fcc-9d5c-7402e7456415","parameters":{},"description":"Listens for incoming messages with images from a Telegram bot","typeVersion":1.2},{"id":"434d739e-54d7-4f75-955f-e1181ff23db8","name":"Workflow Start Documentation","type":"n8n-nodes-base.stickyNote","position":[-380,-20],"parameters":{"content":""},"typeVersion":1},{"id":"dc5ddb08-76b8-4a1f-a2fb-315c64199157","name":"Workflow Overview","type":"n8n-nodes-base.stickyNote","position":[-1000,-220],"parameters":{"content":""},"typeVersion":1},{"id":"b4682f5b-4c6e-4ba0-a40b-c2851c64bfef","name":"OpenAI API Documentation","type":"n8n-nodes-base.stickyNote","position":[60,-240],"parameters":{"content":""},"typeVersion":1},{"id":"a7266711-bee5-40a2-afc2-86affd226abc","name":"Conversion Documentation","type":"n8n-nodes-base.stickyNote","position":[460,-120],"parameters":{"content":""},"typeVersion":1},{"id":"f651bd6f-dc2f-4d60-b896-2c860ef0673f","name":"Edit Image (OpenAI)","type":"n8n-nodes-base.httpRequest","position":[160,280],"parameters":{},"description":"Sends image to OpenAI for AI-powered editing based on the caption","typeVersion":4.2},{"id":"8e50ff8a-6c4b-486e-9307-9624fc7ff274","name":"Convert to Binary Image","type":"n8n-nodes-base.convertToFile","position":[580,280],"parameters":{},"description":"Converts base64 encoded image to binary format for sending","typeVersion":1.1},{"id":"e8096804-b5a7-4f2f-943b-e4a5db0929fb","name":"Send Edited Image","type":"n8n-nodes-base.telegram","position":[880,740],"webhookId":"6d8b80b6-8450-49c9-98dc-0f34e14da588","parameters":{},"description":"Sends the edited image back to the user via Telegram","typeVersion":1.2},{"id":"d33a7637-4046-40a9-90e6-6d8b8fc2f4b6","name":"Replicate Documentation","type":"n8n-nodes-base.stickyNote","position":[1460,120],"parameters":{"content":""},"typeVersion":1},{"id":"d0894342-ab6a-473c-9ad0-667987801a9f","name":"Wait Node Documentation","type":"n8n-nodes-base.stickyNote","position":[2000,180],"parameters":{"content":""},"typeVersion":1},{"id":"5f0417a3-7682-481c-b642-c2b45142839e","name":"File Retrieval Documentation","type":"n8n-nodes-base.stickyNote","position":[1100,-40],"parameters":{"content":""},"typeVersion":1},{"id":"906ba4d2-445c-477f-8732-be7e9d828ba0","name":"Generate Variation (Replicate)","type":"n8n-nodes-base.httpRequest","position":[1620,640],"parameters":{},"description":"Sends the original image to Replicate for AI-powered variation","typeVersion":4.2},{"id":"ab244f36-31e3-4dea-9c8e-e4935335810a","name":"Retrieve Generated Image","type":"n8n-nodes-base.httpRequest","position":[2540,840],"parameters":{},"description":"Gets the final generated image from Replicate after processing","typeVersion":4.2},{"id":"fee42f2b-09d2-47f9-842a-52139e8c8de6","name":"Send Variation Image","type":"n8n-nodes-base.telegram","position":[2740,280],"webhookId":"c2af49c2-2c87-4020-928a-ce18f14e557f","parameters":{},"description":"Sends the AI-generated variation back to the user","typeVersion":1.2},{"id":"93c43617-3c40-451f-b3b5-eb1d276db1ba","name":"Get File Path","type":"n8n-nodes-base.httpRequest","position":[1220,340],"parameters":{},"description":"Retrieves the file path from Telegram's servers","typeVersion":4.2},{"id":"71391d58-693a-4c6e-9180-a7b5819bdd3f","name":"Wait for Processing","type":"n8n-nodes-base.wait","position":[2080,600],"webhookId":"eb746bd1-bead-4d9c-b5d5-6c1a1b605c20","parameters":{},"description":"Waits for Replicate to complete the image generation (45 seconds)","typeVersion":1.1},{"id":"736f5bc9-3785-486d-a93a-d6e9cbd5e45b","name":"Setup Documentation","type":"n8n-nodes-base.stickyNote","position":[-1000,380],"parameters":{"content":""},"typeVersion":1},{"id":"2873e80c-d160-4bbc-88e7-89097adaa0bd","name":"Note: Send Replicate Output","type":"n8n-nodes-base.stickyNote","position":[2640,20],"parameters":{"content":""},"typeVersion":1},{"id":"65e13c0b-cf11-4c15-8de4-a6633e621a43","name":"Note: Get Replicate Result","type":"n8n-nodes-base.stickyNote","position":[2420,580],"parameters":{"content":""},"typeVersion":1},{"id":"d6f4bd9c-6016-45a1-9318-c37aa5786e34","name":"Note: Send Edited Image","type":"n8n-nodes-base.stickyNote","position":[800,500],"parameters":{"content":""},"typeVersion":1}],"connections":{"Get File Path":{"main":[[{"node":"Generate Variation (Replicate)","type":"main","index":0}]]},"Send Edited Image":{"main":[[{"node":"Get File Path","type":"main","index":0}]]},"Edit Image (OpenAI)":{"main":[[{"node":"Convert to Binary Image","type":"main","index":0}]]},"Wait for Processing":{"main":[[{"node":"Retrieve Generated Image","type":"main","index":0}]]},"Telegram Bot Trigger":{"main":[[{"node":"Edit Image (OpenAI)","type":"main","index":0}]]},"Convert to Binary Image":{"main":[[{"node":"Send Edited Image","type":"main","index":0}]]},"Retrieve Generated Image":{"main":[[{"node":"Send Variation Image","type":"main","index":0}]]},"Generate Variation (Replicate)":{"main":[[{"node":"Wait for Processing","type":"main","index":0}]]}}}


name: Real Estate Intelligence Tracker with Bright Data & OpenAI
author_name: Ranjan Dailata
author_username: ranjancse
categories: []
created_at: 2025-05-21T13:33:31.376Z
updated_at: 2025-05-21T13:33:31.376Z
url: https://n8n.io/workflows/4281
scraped_at: 2025-07-06 21:16:30
description:
  Who this is for
  The Real Estate Intelligence Tracker is a powerful automated workflow designed for real estate analysts, investors, proptech startups, and market researchers who need to collect and analyze structured data from real estate listings across the web at scale.

  This workflow is tailored for:

  Real Estate Analysts** - Tracking property prices, locations, and market trends

  Investment Firms** - Sourcing high-opportunity listings for portfolio decisions

  PropTech Developers** - Automating listing insights for SaaS platforms

  Market Researchers** - Extracting insights from competitive housing data

  Growth Teams** - Monitoring geographic property trends and pricing fluctuations

  What problem is this workflow solving?
  Collecting structured real estate listing data from property websites is difficult due to bot protections and unstructured HTML content. Manual data collection is slow and error-prone, and traditional scrapers often get blocked or miss context.

  This workflow solves:

  Automated bypass of anti-bot protection using Bright Data Web Unlocker

  Conversion of unstructured HTML content into clean text using a Markdown-to-text LLM pipeline

  Structured extraction of key listing data like price, location, property type, and features using OpenAI

  Aggregation and delivery of insights to Google Sheets, local storage, and webhook-based alerts

  What this workflow does

  Convert to Text: Transforms scraped HTML/markdown into clean text using a Basic LLM Chain

  Structured Data Extraction: Uses OpenAI GPT-4o with the Information Extractor node to parse property attributes (price, address, area, type, etc.)

  Aggregate & Merge: Combines data from multiple pages or listings into a cohesive structure

  Outbound Data Handling:

  Google Sheets** – Appends the structured real estate data for further analysis

  Save to Disk** – Persists structured JSON/text data locally

  Webhook Notification** – Sends data alerts or summaries to any third-party platform

  Pre-conditions

  You need to have a Bright Data account and do the necessary setup as mentioned in the "Setup" section below.
  You need to have an OpenAI Account.

  Setup
  Sign up at Bright Data.
  Navigate to Proxies & Scraping and create a new Web Unlocker zone by selecting Web Unlocker API under Scraping Solutions.
  In n8n, configure the Header Auth account under Credentials (Generic Auth Type: Header Authentication).

  The Value field should be set with the
  Bearer XXXXXXXXXXXXXX. The XXXXXXXXXXXXXX should be replaced by the Web Unlocker Token.
  In n8n, Configure the Google Sheet Credentials with your own account. Follow this documentation - Set Google Sheet Credential
  In n8n, configure the OpenAi account credentials.
  Ensure the URL and Bright Data zone name are correctly set in the Set URL, Filename and Bright Data Zone node.
  Set the desired local path in the Write a file to disk node to save the responses.

  How to customize this workflow to your needs

  Target Multiple Sites or Locations

  Update the Bright Data URL node dynamically with a list of regional real estate websites

  Loop through different city/state filter URLs

  Customize Extracted Fields

  Modify the Information Extractor prompt to extract fields like:

  Property size, number of bedrooms/bathrooms

  Days on market

  Nearby amenities or schools

  Agent contact details

  Integrate with More Destinations

  Add nodes to export data to Notion, Airtable, HubSpot, or your custom database

  Generate automated reports using PDF generators and email them

  Data Quality and Logging

  Add validation checks (e.g., missing price or address)

  Save intermediate files (markdown, raw HTML, JSON output) to disk for audit purposes

nodes_used:
  ["n8n-nodes-base.googleSheets","n8n-nodes-base.httpRequest","@n8n/n8n-nodes-langchain.chainLlm","@n8n/n8n-nodes-langchain.lmChatOpenAi","@n8n/n8n-nodes-langchain.informationExtractor"]

workflow_json:
  {"id":"M3htaKFJfCuko2uB","meta":{"instanceId":"885b4fb4a6a9c2cb5621429a7b972df0d05bb724c20ac7dac7171b62f1c7ef40","templateCredsSetupCompleted":true},"name":"Real Estate Intelligence Tracker with Bright Data & OpenAI","tags":[{"id":"Kujft2FOjmOVQAmJ","name":"Engineering","createdAt":"2025-04-09T01:31:00.558Z","updatedAt":"2025-04-09T01:31:00.558Z"},{"id":"ZOwtAMLepQaGW76t","name":"Building Blocks","createdAt":"2025-04-13T15:23:40.462Z","updatedAt":"2025-04-13T15:23:40.462Z"},{"id":"ddPkw7Hg5dZhQu2w","name":"AI","createdAt":"2025-04-13T05:38:08.053Z","updatedAt":"2025-04-13T05:38:08.053Z"}],"nodes":[{"id":"7dc6c3d9-55e0-4f32-b00d-96c92482eca8","name":"When clicking ‘Test workflow’","type":"n8n-nodes-base.manualTrigger","position":[-1700,-210],"parameters":{},"typeVersion":1},{"id":"196a1630-ca74-4fee-a7bf-0555a3693908","name":"Set URL and Bright Data Zone","type":"n8n-nodes-base.set","position":[-1480,-210],"parameters":{"options":{},"assignments":{"assignments":[{"id":"3aedba66-f447-4d7a-93c0-8158c5e795f9","name":"url","type":"string","value":"https://www.redfin.com/IL/Chicago/5814-W-Roscoe-St-60634/home/13464782"},{"id":"4e7ee31d-da89-422f-8079-2ff2d357a0ba","name":"zone","type":"string","value":"web_unlocker1"}]}},"typeVersion":3.4},{"id":"80131d8e-b359-4b2a-8291-faf9c4e8892f","name":"Perform Bright Data Web Request","type":"n8n-nodes-base.httpRequest","position":[-1260,-210],"parameters":{"url":"https://api.brightdata.com/request","method":"POST","options":{},"sendBody":true,"sendHeaders":true,"authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"zone","value":"={{ $json.zone }}"},{"name":"url","value":"={{ $json.url }}"},{"name":"format","value":"raw"},{"name":"data_format","value":"markdown"}]},"genericAuthType":"httpHeaderAuth","headerParameters":{"parameters":[{}]}},"credentials":{"httpHeaderAuth":{"id":"kdbqXuxIR8qIxF7y","name":"Header Auth account"}},"typeVersion":4.2},{"id":"2b0c3867-3c8d-4dc2-b9e9-fc9f074efaea","name":"Markdown to Textual Data Extractor","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[-1040,-210],"parameters":{"text":"=You need to analyze the below markdown and convert to textual data. Please do not output with your own thoughts. Make sure to output with textual data only with no links, scripts, css etc.\n\n{{ $json.data }}","messages":{"messageValues":[{"message":"You are a markdown expert"}]},"promptType":"define"},"typeVersion":1.6},{"id":"52dc4add-92e6-4118-948e-63c4a706a017","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-1720,-640],"parameters":{"width":400,"height":320,"content":"## Note\n\nDeals with the Realestate data extraction by utilizing the Bright Data Web Unlocker Product.\n\n**Please make sure to set the Real-estate website URL with the Bright Data zone name. Also update the Webhook Notification URL of your interest**"},"typeVersion":1},{"id":"0b64779e-d4c6-4c67-8b67-fcddac760db6","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-1260,-640],"parameters":{"width":480,"height":320,"content":"## LLM Usages\n\nOpenAI GPT 4o model is being used.\n\nBasic LLM Chain for converting the markdown to textual content.\n\nInformation Extractor is being used for the structured data extraction."},"typeVersion":1},{"id":"9d4eaebe-eb56-4d57-abe6-7d2beaff5af0","name":"Review Data Extractor","type":"@n8n/n8n-nodes-langchain.informationExtractor","position":[-500,-560],"parameters":{"text":"=Extract all the reviews from the provided content\n\n {{ $json.text }}","options":{},"schemaType":"fromJson","jsonSchemaExample":"[{\n      \"@type\": \"Review\",\n      \"datePublished\": \"2025-04-29\",\n      \"review\": \"Incredible support and empathy. Shemi truly listened and understood my concerns. Outstanding service!\",\n      \"rating\": {\n        \"@type\": \"Rating\",\n        \"value\": \"5\"\n      }\n    }]"},"typeVersion":1},{"id":"84473d2e-4243-402a-98b3-b80179b9a5ae","name":"Structured Data Extractor","type":"@n8n/n8n-nodes-langchain.informationExtractor","position":[-500,-100],"parameters":{"text":"=Extract structured data from the provided content\n\n {{ $json.text }}","options":{},"schemaType":"fromJson","jsonSchemaExample":"{\n  \"@context\": \"https://schema.org\",\n  \"@type\": \"Offer\",\n  \"itemOffered\": {\n    \"@type\": \"SingleFamilyResidence\",\n    \"name\": \"Luxury 4BHK Villa with Pool in Herzliya\",\n    \"description\": \"A stunning 4-bedroom villa featuring private pool, garden, smart-home automation, and ocean views. Located in one of Herzliya’s premium neighborhoods.\",\n    \"address\": {\n      \"@type\": \"PostalAddress\",\n      \"streetAddress\": \"456 Seaside Road\",\n      \"addressLocality\": \"Herzliya\",\n      \"postalCode\": \"4685105\",\n      \"addressCountry\": \"IL\"\n    },\n    \"floorSize\": {\n      \"@type\": \"QuantitativeValue\",\n      \"value\": 300,\n      \"unitCode\": \"MTK\"\n    },\n    \"numberOfRooms\": 7,\n    \"numberOfBedrooms\": 4,\n    \"numberOfBathroomsTotal\": 3,\n    \"amenityFeature\": [\n      {\n        \"@type\": \"LocationFeatureSpecification\",\n        \"name\": \"Swimming Pool\",\n        \"value\": true\n      },\n      {\n        \"@type\": \"LocationFeatureSpecification\",\n        \"name\": \"Smart Home Enabled\",\n        \"value\": true\n      },\n      {\n        \"@type\": \"LocationFeatureSpecification\",\n        \"name\": \"Sea View\",\n        \"value\": true\n      }\n    ],\n    \"image\": [\n      \"https://brightrealty.com/listings/villa1_front.jpg\",\n      \"https://brightrealty.com/listings/villa1_pool.jpg\",\n      \"https://brightrealty.com/listings/villa1_living.jpg\"\n    ],\n    \"petsAllowed\": \"Yes\",\n    \"url\": \"https://brightrealty.com/properties/luxury-4bhk-villa-herzliya\"\n  },\n  \"priceCurrency\": \"ILS\",\n  \"price\": \"8500000\",\n  \"availability\": \"https://schema.org/InStock\",\n  \"seller\": {\n    \"@type\": \"RealEstateAgent\",\n    \"name\": \"Bright Realty Services\",\n    \"url\": \"https://brightrealty.com\",\n    \"telephone\": \"+972-3-1234567\",\n    \"email\": \"sales@brightrealty.com\",\n    \"address\": {\n      \"@type\": \"PostalAddress\",\n      \"streetAddress\": \"123 Main St\",\n      \"addressLocality\": \"Tel Aviv\",\n      \"postalCode\": \"6100000\",\n      \"addressCountry\": \"IL\"\n    }\n  }\n}"},"typeVersion":1},{"id":"d1b44002-2a50-4c0c-bf55-bf57a994bd2b","name":"Google Sheets","type":"n8n-nodes-base.googleSheets","position":[460,-520],"parameters":{"columns":{"value":{"data":"={{ $json.data }}"},"schema":[{"id":"data","type":"string","display":true,"removed":false,"required":false,"displayName":"data","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":["data"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"appendOrUpdate","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1DGx_-sZ59wZlrhQRfj-qyMFMF6Z1IxpJrSNHD8rTZR8/edit#gid=0","cachedResultName":"Sheet1"},"documentId":{"__rl":true,"mode":"list","value":"1DGx_-sZ59wZlrhQRfj-qyMFMF6Z1IxpJrSNHD8rTZR8","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1DGx_-sZ59wZlrhQRfj-qyMFMF6Z1IxpJrSNHD8rTZR8/edit?usp=drivesdk","cachedResultName":"Real-estate data"}},"credentials":{"googleSheetsOAuth2Api":{"id":"Zjoxh2BUZ6VXGQhA","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"9f203292-0806-48a9-a409-f64706b1b0b6","name":"Create a binary data for Structured Data Extract","type":"n8n-nodes-base.function","position":[460,-320],"parameters":{"functionCode":"items[0].binary = {\n  data: {\n    data: new Buffer(JSON.stringify(items[0].json, null, 2)).toString('base64')\n  }\n};\nreturn items;"},"typeVersion":1},{"id":"9a64deed-1f56-4e10-9e11-31bfcfd6abac","name":"Write the structured content to disk","type":"n8n-nodes-base.readWriteFile","position":[680,-320],"parameters":{"options":{},"fileName":"=d:\\Realestate-StructuredData.json","operation":"write"},"typeVersion":1},{"id":"83e7f6d7-216c-496b-9011-47d0b95561ba","name":"Merge the responses","type":"n8n-nodes-base.merge","position":[20,-320],"parameters":{},"typeVersion":3.1},{"id":"cf515b99-e139-48f8-9878-7950fa352d1e","name":"Aggregate the responses","type":"n8n-nodes-base.aggregate","position":[240,-320],"parameters":{"options":{},"aggregate":"aggregateAllItemData"},"typeVersion":1},{"id":"a93e59ab-f384-4b05-90f8-71b305a3bfb7","name":"Initiate a Webhook Notification for the Structured Data","type":"n8n-nodes-base.httpRequest","position":[460,-120],"parameters":{"url":"https://webhook.site/7b5380a0-0544-48dc-be43-0116cb2d52c2","options":{},"sendBody":true,"bodyParameters":{"parameters":[{"name":"summary","value":"={{ $json.data }}"}]}},"typeVersion":4.2},{"id":"a2f0de15-7d1d-42bb-aa22-1a3bd359ead5","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-1720,-1100],"parameters":{"color":7,"width":400,"height":400,"content":"## Logo\n\n\n![logo](https://images.seeklogo.com/logo-png/43/1/brightdata-logo-png_seeklogo-439974.png)\n"},"typeVersion":1},{"id":"6ecb7f50-2d16-43e2-b999-98492ec81668","name":"OpenAI Chat Model for Markdown to Textual","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-960,20],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"vPKynKbDzJ5ZU4cU","name":"OpenAi account"}},"typeVersion":1.2},{"id":"fe6f00e3-efaa-4d57-8abd-1fbc789152a9","name":"OpenAI Chat Model for Structured Data","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-420,120],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"vPKynKbDzJ5ZU4cU","name":"OpenAi account"}},"typeVersion":1.2},{"id":"4ce2647e-9796-4bfd-8dc2-0aa7f7466824","name":"OpenAI Chat Model for Review Data Extractor","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-420,-340],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"vPKynKbDzJ5ZU4cU","name":"OpenAi account"}},"typeVersion":1.2},{"id":"fad15f6e-0ccb-4810-94d6-bc4f42527071","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-60,-640],"parameters":{"color":3,"width":1000,"height":760,"content":"## Outbound Data Push\nOutbound data handling by merging, aggregating the data and pushing the same to multiple sources such as Google Sheets, Save to Disk, Webhook Notification"},"typeVersion":1}],"active":false,"settings":{"executionOrder":"v1"},"versionId":"db35bf88-1a4c-482e-abfd-49349b35952b","connections":{"Merge the responses":{"main":[[{"node":"Aggregate the responses","type":"main","index":0}]]},"Review Data Extractor":{"main":[[{"node":"Merge the responses","type":"main","index":0}]]},"Aggregate the responses":{"main":[[{"node":"Google Sheets","type":"main","index":0},{"node":"Initiate a Webhook Notification for the Structured Data","type":"main","index":0},{"node":"Create a binary data for Structured Data Extract","type":"main","index":0}]]},"Structured Data Extractor":{"main":[[{"node":"Merge the responses","type":"main","index":1}]]},"Set URL and Bright Data Zone":{"main":[[{"node":"Perform Bright Data Web Request","type":"main","index":0}]]},"Perform Bright Data Web Request":{"main":[[{"node":"Markdown to Textual Data Extractor","type":"main","index":0}]]},"When clicking ‘Test workflow’":{"main":[[{"node":"Set URL and Bright Data Zone","type":"main","index":0}]]},"Markdown to Textual Data Extractor":{"main":[[{"node":"Review Data Extractor","type":"main","index":0},{"node":"Structured Data Extractor","type":"main","index":0}]]},"OpenAI Chat Model for Structured Data":{"ai_languageModel":[[{"node":"Structured Data Extractor","type":"ai_languageModel","index":0}]]},"OpenAI Chat Model for Markdown to Textual":{"ai_languageModel":[[{"node":"Markdown to Textual Data Extractor","type":"ai_languageModel","index":0}]]},"OpenAI Chat Model for Review Data Extractor":{"ai_languageModel":[[{"node":"Review Data Extractor","type":"ai_languageModel","index":0}]]},"Create a binary data for Structured Data Extract":{"main":[[{"node":"Write the structured content to disk","type":"main","index":0}]]}}}


name: Automatically Delete Spam Emails in Gmail on Schedule
author_name: Bao Duy Nguyen
author_username: duynb
nodes_used: ["n8n-nodes-base.gmail"]
categories: []
created_at: 2025-05-21T14:19:52.816Z
updated_at: 2025-05-21T14:19:52.816Z
url: https://n8n.io/workflows/4285
scraped_at: 2025-07-06 21:16:30
description:
  Who is this for?
  If you hate SPAM emails or don't want to clean them up frequently.

  What problem is this workflow solving?
  It automatically deletes SPAM emails for you, so you don't have to. Save a bit of your time.

  What this workflow does
  You can specify when to execute the workflow: daily, weekly, or monthly.

  Setup
  Select the preferred execution time
  Configure credentials for Gmail OAuth2

  How to customize this workflow to your needs
  There's no need. It just works!

workflow_json:
  {"id":"DzNTc1Td148ti7RU","meta":{"instanceId":"e76981884963d13b9deb7bc5a6b15daf6838937e1dd529f22f2c146d8b79cae4","templateCredsSetupCompleted":true},"name":"Automatically delete SPAM emails","tags":[{"id":"yjDYtffFaPyJlYcC","name":"template","createdAt":"2025-05-21T14:11:32.813Z","updatedAt":"2025-05-21T14:11:32.813Z"}],"nodes":[{"id":"a4fa3e50-5b63-4e69-97eb-534b1170ebab","name":"Trigger at Sunday midnight","type":"n8n-nodes-base.scheduleTrigger","position":[-260,-20],"parameters":{"rule":{"interval":[{"field":"weeks"}]}},"typeVersion":1.2},{"id":"286e5c34-18ab-46da-b184-cfabf796b21d","name":"Delete SPAM emails","type":"n8n-nodes-base.gmail","position":[160,-20],"webhookId":"46b0fe0f-cc00-4994-8364-9048c888e9ef","parameters":{"messageId":"={{ $json.id }}","operation":"delete"},"credentials":{"gmailOAuth2":{"id":"yz4iqcG5X1s5wlgS","name":"Gmail account"}},"typeVersion":2.1},{"id":"b755451e-7fc3-4c3b-b669-69d700c38fa4","name":"Get all SPAM emails","type":"n8n-nodes-base.gmail","position":[-60,-20],"webhookId":"c47419de-278c-40d1-a5da-c9414d3f89c6","parameters":{"filters":{"labelIds":["SPAM"]},"operation":"getAll","returnAll":true},"credentials":{"gmailOAuth2":{"id":"yz4iqcG5X1s5wlgS","name":"Gmail account"}},"typeVersion":2.1},{"id":"cc3c9d36-a26e-47cb-bb74-3a1027b996cd","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-580,-260],"parameters":{"color":7,"width":340,"height":200,"content":"## Automatically delete your SPAM emails on frequent basis\n\nThis automation will run repeatedly at a particular time to delete all your SPAM emails\n\n"},"typeVersion":1},{"id":"86749abf-16c8-4406-9394-b22a384b4e89","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-280,140],"parameters":{"color":7,"width":150,"height":200,"content":"## :point_up: UPDATE ME\nSelect when to trigger the workflow"},"typeVersion":1}],"active":false,"settings":{"executionOrder":"v1"},"versionId":"f47d2f29-89d0-4719-a47b-55b43e84466b","connections":{"Get all SPAM emails":{"main":[[{"node":"Delete SPAM emails","type":"main","index":0}]]},"Trigger at Sunday midnight":{"main":[[{"node":"Get all SPAM emails","type":"main","index":0}]]}}}


name: Automate Business Lead Scraping from Apify to Google Sheets with Data Cleaning
author_name: David Olusola
author_username: dae221
nodes_used: ["n8n-nodes-base.googleSheets","n8n-nodes-base.httpRequest","n8n-nodes-base.code"]
categories: []
created_at: 2025-05-21T18:47:26.249Z
updated_at: 2025-05-21T18:47:26.249Z
url: https://n8n.io/workflows/4295
scraped_at: 2025-07-06 21:16:30
description:
  🚀 Automated Lead Scraper Workflow (Apify + n8n + Google Sheets)

  🧠 What It Does

  This n8n workflow automates the process of scraping leads using Apify, cleaning the extracted data, and exporting it to Google Sheets—ready for use in outreach, prospecting, or CRM pipelines.

  🔄 Workflow Steps

  ✅ Start – Manually triggers the workflow.
  🧩 Set Variables – Stores required Apify credentials:

     APIFY_TOKEN: Your Apify token.
     APIFY_TASK_ID: The Apify task to run.
  🕸️ Run Apify Scraper – Launches the scraper and fetches the dataset.
  🧹 Clean Data – Processes scraped results to:

     ✂️ Strip non-numeric characters from phone numbers.
     ✉️ Format emails (lowercase + trimmed).
  📊 Export to Google Sheets – Appends clean data to your spreadsheet:

     🏢 company name → from title
     📞 phone → cleaned number
     📍 address → from scraped info

  🛠️ Requirements

  🕷️ Apify Account

    A valid APIFY_TOKEN
    An existing Apify task (APIFY_TASK_ID)

  📗 Google Sheets Access

    OAuth2 credentials set up in n8n (e.g., "Google Sheets account 2")

  🚦 How to Use

  ⚙️ Open the Variables node and plug in your Apify credentials.
  📄 Confirm the Google Sheets node points to your desired spreadsheet.
  ▶️ Run the workflow manually from the Start node.

  📥 Output

  A ready-to-use sheet of cleaned lead data containing:

  Company names
  Phone numbers
  Addresses

  💼 Perfect For:

  Sales teams doing outbound prospecting
  Marketers building lead lists
  Agencies running data aggregation tasks

workflow_json:
  {"id":"8dpOtivR6zGMa8Nf","meta":{"instanceId":"2000c64071c20843606b95c63795bb0797c41036047055a6586498e855b96efc","templateCredsSetupCompleted":true},"name":"Automated Lead Scraper: Apify to Google Sheets","tags":[],"nodes":[{"id":"331e904a-362e-4b18-ac01-60bd138a7ee1","name":"Manual Trigger","type":"n8n-nodes-base.manualTrigger","position":[-1740,-300],"parameters":{},"typeVersion":1},{"id":"c8c72d6e-4558-4ab1-9c19-2b8e3cefc856","name":"Run Apify Scraper","type":"n8n-nodes-base.httpRequest","position":[-1280,-300],"parameters":{"url":"={{ 'https://api.apify.com/v2/actor-tasks/' + $json.APIFY_TASK_ID + '/run-sync-get-dataset-items?token=' +$json.APIFY_TOKEN}}","options":{"splitIntoItems":true}},"typeVersion":1},{"id":"fb61d5a9-0352-4079-a00f-c42df06bb09e","name":"Clean Data","type":"n8n-nodes-base.code","position":[-1080,-300],"parameters":{"jsCode":"// Clean scraped data before LLM processing\nreturn $input.all().map(item => ({\n  ...item.json,\n  phone: item.json.phone?.replace(/[^\\d+]/g, '') || '',\n  email: item.json.email?.toLowerCase().trim() || ''\n}));"},"typeVersion":2},{"id":"a6988139-87e5-423c-bec9-ce155f617dab","name":"Export to Google Sheets","type":"n8n-nodes-base.googleSheets","position":[-760,-300],"parameters":{"columns":{"value":{"phone":"={{ $json.phone }}","Address":"={{ $json.address }}","company name":"={{ $json.title }}"},"schema":[{"id":"company name","type":"string","display":true,"required":false,"displayName":"company name","defaultMatch":false,"canBeUsedToMatch":true},{"id":"website","type":"string","display":true,"required":false,"displayName":"website","defaultMatch":false,"canBeUsedToMatch":true},{"id":"phone","type":"string","display":true,"required":false,"displayName":"phone","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Address","type":"string","display":true,"required":false,"displayName":"Address","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"list","value":"Sheet1","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1UHkd_OuK1Xzc0ZXo7FPrsd5M1JlsIY9pJDC3fsJ3oq8/edit#gid=0","cachedResultName":"Sheet1"},"documentId":{"__rl":true,"mode":"list","value":"YOUR_GOOGLE_SHEET_ID","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1UHkd_OuK1Xzc0ZXo7FPrsd5M1JlsIY9pJDC3fsJ3oq8/edit?usp=drivesdk","cachedResultName":"leas list solar"}},"typeVersion":4.5},{"id":"f4398fd2-bff0-4e9c-ae1b-f5950be0a384","name":"Variables","type":"n8n-nodes-base.set","position":[-1500,-300],"parameters":{"options":{},"assignments":{"assignments":[{"id":"4486360c-2296-41ad-a48f-706e24c49a4f","name":"APIFY_TOKEN","type":"string","value":"YOUR_APIFY_API_TOKEN"},{"id":"6e56b0e3-36ae-4f1e-b0e5-38767bbe8af9","name":"APIFY_TASK_ID","type":"string","value":"YOUR_APIFY_TASK_ID"}]}},"typeVersion":3.4},{"id":"04a980cf-365b-4cc3-8439-fd71cb1f05a3","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-1860,-820],"parameters":{"color":7,"width":1660,"height":780,"content":"## Automated Business Lead Scraper with Apify to Google Sheets\n**Purpose:** Automates scraping business leads using Apify, cleaning the data, and exporting them to Google Sheets.\n\n**Workflow Steps:**\n1. **Manual Trigger**: Starts the workflow manually.\n2. **Set API Credentials**: Add your `APIFY_TOKEN` and `APIFY_TASK_ID`.\n3. **Run Apify Scraper**: Fetches leads using Apify HTTP API.\n4. **Clean Data**: Formats phone numbers and emails.\n5. **Export to Google Sheets**: Appends data to your spreadsheet.\n\n**Google Sheet Requirements:**\n- Sheet name: `Sheet1`\n- Columns: `company name`, `phone`, `Address`\n\n**Customization Tips:**\n- Add more fields like `email`, `website` in Clean Data and mapping.\n- Add conditions or filters before exporting.\n- Add email alerts if needed.\n"},"typeVersion":1}],"active":false,"settings":{"executionOrder":"v1"},"versionId":"47bf9abd-67aa-49c8-81c9-761e75ee731f","connections":{"Start":{"main":[[{"node":"Variables","type":"main","index":0}]]},"Variables":{"main":[[{"node":"Run Apify Scraper","type":"main","index":0}]]},"Clean Data":{"main":[[{"node":"Export to Google Sheets","type":"main","index":0}]]},"Run Apify Scraper":{"main":[[{"node":"Clean Data","type":"main","index":0}]]}}}


name: TradingView Signal Extractor with Gmail, Google Sheets & Telegram Notifications
author_name: Dhrumil Patel
author_username: itechdp
categories: []
created_at: 2025-05-23T07:57:01.872Z
updated_at: 2025-05-23T07:57:01.872Z
url: https://n8n.io/workflows/4334
scraped_at: 2025-07-06 21:16:30
description:
  Stay ahead in your trading game with this powerful n8n automation workflow. Designed for real-time efficiency, this setup continuously scans your Gmail inbox for trading alerts from TradingView and ensures you never miss a signal.

  Every minute, this workflow will:

  📩 Check Gmail for new messages using a trigger.
  🔍 Identify emails coming specifically from TradingView.
  📊 Extract key trading signals like BUY or SELL along with the company name.
  🕒 Capture the exact date and time of the alert.
  📄 Log all extracted signals neatly into a Google Sheet for easy tracking and analysis.
  📲 Instantly notify you on Telegram with a custom message so you can act fast.

  Perfect for traders who want an automated assistant to handle alerts, record them for analysis, and provide timely updates — all without lifting a finger.

nodes_used:
  ["n8n-nodes-base.googleSheets","n8n-nodes-base.telegram","n8n-nodes-base.gmail","n8n-nodes-base.code"]

workflow_json:
  {"meta":{"instanceId":"761a3dddae2bb21eb8973ffca0ba97d5b4f499405873760164a536f547546882","templateCredsSetupCompleted":true},"nodes":[{"id":"a5f53559-6b91-45a9-8822-53439b9c306d","name":"Clean Email","type":"n8n-nodes-base.code","position":[-160,180],"parameters":{"jsCode":"// Make sure From exists and is a string\nconst rawFrom = $input.first().json.From;\n\nlet cleanEmail = \"\";\n\n// Proceed only if rawFrom is a valid string\nif (typeof rawFrom === \"string\" && rawFrom.trim() !== \"\") {\n  const match = rawFrom.match(/<(.+?)>/);\n  cleanEmail = match ? match[1] : rawFrom.trim();\n} else {\n  cleanEmail = \"[Missing From field]\";\n}\n\nreturn [\n  {\n    json: {\n      cleanEmail\n    }\n  }\n];\n"},"typeVersion":2},{"id":"e6a332b0-529d-489c-9d67-8d7d06bc8044","name":"Gmail","type":"n8n-nodes-base.gmail","position":[-160,-20],"webhookId":"0c25cbb3-b954-4c3a-aabc-9f4473b9f733","parameters":{"messageId":"={{ $json.id }}","operation":"markAsRead"},"credentials":{"gmailOAuth2":{"id":"6I8sq2IhPgySI6XX","name":"Gmail account 2 - infodpatel15"}},"typeVersion":2.1},{"id":"032629d7-d41b-4d8f-b545-e98df9cf796c","name":"Send Message","type":"n8n-nodes-base.telegram","position":[1380,180],"webhookId":"836270b1-beef-4520-b024-30b72af1582a","parameters":{"text":"=KITE 11: {{ $('Get Email').item.json.snippet }}","chatId":"1520681602","additionalFields":{}},"credentials":{"telegramApi":{"id":"bAaBU3SFXiLAdyvU","name":"Telegram account"}},"typeVersion":1.2},{"id":"f7e47b44-5ea8-43fa-9054-539e710d3a39","name":"Verify Mail","type":"n8n-nodes-base.if","position":[60,180],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"7f6c2c11-6204-4f36-8e57-dcc9efc93433","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.cleanEmail }}","rightValue":"=noreply@tradingview.com"}]}},"typeVersion":2.2},{"id":"66b91b39-49f7-44cc-8d9a-f4392c11ff77","name":"Extract Company Name","type":"n8n-nodes-base.code","position":[500,180],"parameters":{"jsCode":"// Get subject from previous node (e.g., IMAP Email node)\nconst subject = $input.first().json.Subject;\n\nconst stockSymbol = subject.split('for ')[1]?.trim() || '';\n\nreturn [\n  {\n    json: {\n      symbol: stockSymbol,\n      originalSubject: subject,\n    }\n  }\n];\n"},"typeVersion":2},{"id":"ffbbff24-1959-4254-b05c-4a6327edec95","name":"Google Sheets","type":"n8n-nodes-base.googleSheets","position":[1160,180],"parameters":{"columns":{"value":{"Date":"={{ $json.formattedDate }}","Stock":"={{ $('Extract Company Name').item.json.symbol }}"},"schema":[{"id":"Date","type":"string","display":true,"required":false,"displayName":"Date","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Stock","type":"string","display":true,"required":false,"displayName":"Stock","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1PBvePZN2yvVg23hDIDB62e91ogTgbuNXVduZTai-bZc/edit#gid=0","cachedResultName":"Sheet1"},"documentId":{"__rl":true,"mode":"list","value":"1PBvePZN2yvVg23hDIDB62e91ogTgbuNXVduZTai-bZc","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1PBvePZN2yvVg23hDIDB62e91ogTgbuNXVduZTai-bZc/edit?usp=drivesdk","cachedResultName":"KITE FINAL 11"}},"credentials":{"googleSheetsOAuth2Api":{"id":"9NecV5qrcx7kjh5f","name":"Google Sheets account 2"}},"typeVersion":4.5},{"id":"dde99d76-79fe-4650-b7a2-948047b62a16","name":"Current Date & Time","type":"n8n-nodes-base.dateTime","position":[720,180],"parameters":{"options":{"timezone":"Asia/kolkata"}},"typeVersion":2},{"id":"7a60d22e-8027-423c-9927-aa2e0759744d","name":"Formatted Date & Time","type":"n8n-nodes-base.dateTime","position":[940,180],"parameters":{"date":"={{ $json.currentDate }}","format":"custom","options":{},"operation":"formatDate","customFormat":"DD"},"typeVersion":2},{"id":"288dec30-51c9-4206-a0d8-5bca9317ec57","name":"Get Email","type":"n8n-nodes-base.gmail","position":[300,180],"webhookId":"1fd0763d-5989-4fc4-aa5f-191eb8ee51bc","parameters":{"messageId":"={{ $('Email Received').item.json.id }}","operation":"get"},"credentials":{"gmailOAuth2":{"id":"6I8sq2IhPgySI6XX","name":"Gmail account 2 - infodpatel15"}},"typeVersion":2.1},{"id":"20ac9cda-60e1-4a52-a41d-e83485f2c76f","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-400,-80],"parameters":{"color":7,"width":380,"height":400,"content":"## Read Emails"},"typeVersion":1},{"id":"9a8cae5e-9601-4500-bde6-8a84837fc378","name":"Email Received","type":"n8n-nodes-base.gmailTrigger","position":[-380,80],"parameters":{"filters":{},"pollTimes":{"item":[{"mode":"everyMinute"}]}},"credentials":{"gmailOAuth2":{"id":"6I8sq2IhPgySI6XX","name":"Gmail account 2 - infodpatel15"}},"typeVersion":1.2},{"id":"ff7bbb0d-29a1-458d-8437-089fb0bb4ef4","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[20,120],"parameters":{"color":7,"width":180,"height":200,"content":"## Identify Email"},"typeVersion":1},{"id":"70ed236c-3d55-48ec-884c-8bf707139f61","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[240,80],"parameters":{"color":7,"width":400,"height":260,"content":"## Get Email Data - Extract Buy or Sell Signal"},"typeVersion":1},{"id":"a86e1c5f-9059-4971-835c-3e39dc176a3e","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[660,120],"parameters":{"color":7,"width":440,"height":220,"content":"## Get Current Date & Time"},"typeVersion":1},{"id":"84d9bbe3-ebe6-4edb-b02b-f37c3dfdabdf","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[1120,120],"parameters":{"color":7,"width":420,"height":220,"content":"## Update Data On Sheet & Notify"},"typeVersion":1}],"connections":{"Get Email":{"main":[[{"node":"Extract Company Name","type":"main","index":0}]]},"Clean Email":{"main":[[{"node":"Verify Mail","type":"main","index":0}]]},"Verify Mail":{"main":[[{"node":"Get Email","type":"main","index":0}]]},"Send Message":{"main":[[]]},"Google Sheets":{"main":[[{"node":"Send Message","type":"main","index":0}]]},"Email Received":{"main":[[{"node":"Gmail","type":"main","index":0},{"node":"Clean Email","type":"main","index":0}]]},"Current Date & Time":{"main":[[{"node":"Formatted Date & Time","type":"main","index":0}]]},"Extract Company Name":{"main":[[{"node":"Current Date & Time","type":"main","index":0}]]},"Formatted Date & Time":{"main":[[{"node":"Google Sheets","type":"main","index":0}]]}}}


name: Webhook-enabled AI PDF analyzer
author_name: n8n Team
author_username: n8n-team
categories: []
created_at: 2025-05-23T09:04:13.777Z
updated_at: 2025-05-23T09:04:13.777Z
url: https://n8n.io/workflows/4336
scraped_at: 2025-07-06 21:16:30
description:
  Who this template is for

  This template is for researchers, students, professionals, or content creators who need to quickly extract and summarize key insights from PDF documents using AI-powered analysis.

  Use case

  Converting lengthy PDF documents into structured, digestible summaries organized by topic with key insights. This is particularly useful for processing research papers, reports, whitepapers, or any document where you need to quickly understand the main topics and extract actionable insights without reading the entire document.

  How this workflow works

  Document Upload: Receives PDF files through a POST endpoint at /ai_pdf_summariser
  File Validation: Checks that the PDF is under 10MB and has fewer than 20 pages to meet API limits
  Content Extraction: Extracts text content from the PDF file
  AI Analysis: Uses OpenAI's GPT-4o-mini to analyze the document and break it down into distinct topics
  Insight Generation: For each topic, generates 3 key insights with titles and detailed explanations
  Format Response: Converts the structured data into markdown format for easy reading
  Return Results: Provides the formatted summary along with document metadata (file hash)

  Set up steps

  Configure OpenAI API: Set up your OpenAI credentials for the GPT-4o-mini model
  Deploy Webhook: The workflow automatically creates a POST endpoint at /ai_pdf_summariser
  Test Upload: Send a PDF file to the endpoint using a multipart/form-data request
  Adjust Limits: Modify the file size (10MB) and page count (20) validation limits if needed based on your requirements
  Customize Prompts: Update the system prompt in the Information Extractor node to change how topics and insights are generated

  The workflow includes comprehensive error handling for file validation failures (400 error) and processing errors (500 error), ensuring reliable operation even with problematic documents.

nodes_used:
  ["n8n-nodes-base.crypto","n8n-nodes-base.code","@n8n/n8n-nodes-langchain.lmChatOpenAi","@n8n/n8n-nodes-langchain.informationExtractor"]

workflow_json:
  {"meta":{"instanceId":"ff412ab2a6cd55af5dedbbab9b8e43f0f3a0cb16fb794fa8d3837f957b771ad2","templateCredsSetupCompleted":true},"nodes":[{"id":"505f25b4-eaa7-4d42-98d9-2154d7d4cc81","name":"File Ref","type":"n8n-nodes-base.noOp","position":[-1360,280],"parameters":{},"typeVersion":1},{"id":"59721669-a3a9-48ab-8cb0-29ea0af84f6d","name":"Success1","type":"n8n-nodes-base.respondToWebhook","onError":"continueRegularOutput","position":[620,-20],"parameters":{"options":{"responseCode":200,"responseHeaders":{"entries":[{"name":"Content-Type","value":"application/json"}]}},"respondWith":"json","responseBody":"={{\n{\n  \"error\": null,\n  \"meta\": {\n    \"hash\": $('Get File Hash').first().json.data,\n  },\n  \"result\": $json.response\n}\n}}"},"typeVersion":1.1},{"id":"16479572-c3a6-4127-9bf2-db7380bd734c","name":"Is Valid File?","type":"n8n-nodes-base.if","position":[-660,280],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"a277fc5c-6873-49d5-b67b-39df0efc8a61","operator":{"type":"number","operation":"lte"},"leftValue":"={{ $('Get Filesize').item.json.filesize_in_bytes }}","rightValue":"={{ 10000000 }}"},{"id":"d908d5a9-3550-45ce-8645-19c08d3e5982","operator":{"type":"number","operation":"lte"},"leftValue":"={{ $json.numpages }}","rightValue":20}]}},"typeVersion":2.2},{"id":"d35868fb-2a0b-4f07-a942-216a8d226b46","name":"Get Filesize","type":"n8n-nodes-base.code","position":[-980,280],"parameters":{"mode":"runOnceForEachItem","jsCode":"function convertToBytes(size) {\n    const units = {\n        b: 1,\n        bytes: 1,\n        kb: 1024,\n        mb: 1024 * 1024,\n        gb: 1024 * 1024 * 1024,\n    };\n\n    // Extract the number and unit using regex\n    const regex = /([\\d.]+)\\s*(bytes|b|kb|mb|gb)/i;\n    const match = size.match(regex);\n\n    if (!match) {\n        throw new Error(`Invalid size format: \"${size}\"`);\n    }\n\n    const value = parseFloat(match[1]);\n    const unit = match[2].toLowerCase();\n\n    // Calculate the size in bytes\n    const factor = units[unit];\n    if (!factor) {\n        throw new Error(`Unsupported unit: \"${unit}\"`);\n    }\n\n    return Math.round(value * factor);\n}\n\nconst data = $('File Ref').first().binary.data;\n\nreturn {\n  json: { filesize_in_bytes: convertToBytes(data.fileSize) },\n  binary: { data }\n}"},"typeVersion":2},{"id":"87e6b82c-4099-4435-b47f-647ae0b97d39","name":"Extract from File","type":"n8n-nodes-base.extractFromFile","position":[-820,280],"parameters":{"options":{},"operation":"pdf"},"typeVersion":1},{"id":"e4f623cd-418b-49f1-bc1b-2e804a089617","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-1040,140],"parameters":{"color":7,"width":720,"height":480,"content":"### 2. Validate PDF File\nWe need to add validation here to meet service limits of our LLM. Here, we need to get for filesize and number of pages. "},"typeVersion":1},{"id":"ece12347-4205-447a-85cd-298bfa7595e0","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-280,-120],"parameters":{"color":7,"width":600,"height":480,"content":"### 3. Document Parsing with Gemini API \nGoogle Gemini is used to breakdown the PDF into topics and provide insights for each. The number of topics and insights are not set and can be variable."},"typeVersion":1},{"id":"c7197f2f-7ac9-4c97-bd58-859c1d0950f0","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[340,-120],"parameters":{"color":7,"width":480,"height":280,"content":"### 5. Format Response\nFinally, we'll format the output to return the summary as markdown."},"typeVersion":1},{"id":"9ef4b032-de21-48bd-ad3a-fb1cf391fe77","name":"Information Extractor","type":"@n8n/n8n-nodes-langchain.informationExtractor","onError":"continueErrorOutput","position":[-180,40],"parameters":{"text":"=Document as follows:\n{{ $json.text }}","options":{"systemPromptTemplate":"You are a note-taking agent helping the user to summarise this PDF in note form. Breakdown the document into distinct topics and provide a 3 paragraph summary of each topic discussed in the document."},"schemaType":"manual","inputSchema":"{\n  \"type\": \"array\",\n  \"items\": {\n    \"type\": \"object\",\n     \"properties\": {\n       \"topic\": { \"type\": \"string\" },\n       \"insights\": {\n         \"type\": \"array\",\n         \"items\": {\n           \"type\": \"object\",\n           \"properties\": {\n             \"title\": { \"type\": \"string\" },\n             \"body\": { \"type\": \"string\" }\n           }\n         }\n       }\n     }\n  }\n}"},"typeVersion":1},{"id":"4d9f3117-972b-417b-9dee-4098bbd71102","name":"Format Response","type":"n8n-nodes-base.set","position":[440,-20],"parameters":{"options":{},"assignments":{"assignments":[{"id":"10335d9e-7e0a-4ee1-a275-71d2f75b6bba","name":"response","type":"string","value":"={{\n$json.output.map(item => {\nreturn\n`## ${item.topic}\n${item.insights.map(insight =>\n`- **${insight.title}**: ${insight.body}`\n).join('\\n')}\n`;\n}).join('\\n\\n');\n}}"}]}},"typeVersion":3.4},{"id":"db32ecb9-79d0-45ee-aced-05aca99c9f27","name":"400 Error","type":"n8n-nodes-base.respondToWebhook","position":[-480,440],"parameters":{"options":{"responseCode":400},"respondWith":"json","responseBody":"{\n  \"error\": \"Unable to parse document. Please ensure file is less than 10mb with maximum of 20 pages.\",\n  \"result\": []\n}"},"typeVersion":1.1},{"id":"61d6e5e7-dcd7-4cdc-82be-8fec58f26e5a","name":"500 Error","type":"n8n-nodes-base.respondToWebhook","position":[140,120],"parameters":{"options":{"responseCode":500},"respondWith":"json","responseBody":"{\n  \"error\": \"Unable to parse document. An unknown error occurred.\",\n  \"result\": []\n}"},"typeVersion":1.1},{"id":"732d7d7b-f7f5-4342-93b7-e8b49d381dfb","name":"Get File Hash","type":"n8n-nodes-base.crypto","disabled":true,"position":[-1180,280],"parameters":{"value":"={{ $('File Ref').first().binary }}"},"typeVersion":1},{"id":"e6221a49-d4d8-4aa5-bbd8-69b885ff7254","name":"POST /ai_pdf_summariser","type":"n8n-nodes-base.webhook","position":[-1520,280],"webhookId":"a452fbcb-c7c4-4c0b-b435-b1829d411e7a","parameters":{"path":"ai_pdf_summariser","options":{"ignoreBots":false},"httpMethod":"POST","responseMode":"responseNode"},"typeVersion":2},{"id":"3d605049-571f-45d2-b1ba-914f0c9d68f4","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[-1680,140],"parameters":{"width":280,"height":100,"content":"### POST /ai_pdf_summariser\nCall this endpoint to upload a document for summarising."},"typeVersion":1},{"id":"d79d5cf3-2f7c-459c-9977-9e0a77ed8d7b","name":"OpenAI Chat Model1","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-100,220],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"pY9tCO8MgTcBYqdJ","name":"OpenAi account Tutorial from docs"}},"typeVersion":1.2}],"connections":{"File Ref":{"main":[[{"node":"Get File Hash","type":"main","index":0}]]},"Get Filesize":{"main":[[{"node":"Extract from File","type":"main","index":0}]]},"Get File Hash":{"main":[[{"node":"Get Filesize","type":"main","index":0}]]},"Is Valid File?":{"main":[[{"node":"Information Extractor","type":"main","index":0}],[{"node":"400 Error","type":"main","index":0}]]},"Format Response":{"main":[[{"node":"Success1","type":"main","index":0}]]},"Extract from File":{"main":[[{"node":"Is Valid File?","type":"main","index":0}]]},"OpenAI Chat Model1":{"ai_languageModel":[[{"node":"Information Extractor","type":"ai_languageModel","index":0}]]},"Information Extractor":{"main":[[{"node":"Format Response","type":"main","index":0}],[{"node":"500 Error","type":"main","index":0}]]},"POST /ai_pdf_summariser":{"main":[[{"node":"File Ref","type":"main","index":0}]]}}}


name: AI-Powered Multi-Social Media Post Automation: Google Trends & Perplexity AI
author_name: Gerald Denor
author_username: dominixai
categories: []
created_at: 2025-05-24T00:42:22.300Z
updated_at: 2025-05-24T00:42:22.300Z
url: https://n8n.io/workflows/4352
scraped_at: 2025-07-06 21:16:30
description:
  Overview
  This comprehensive n8n workflow automatically transforms trending Google search queries into engaging LinkedIn posts using AI. The system runs autonomously, discovering viral topics, researching content, and publishing professionally formatted posts to grow your social media presence.

  Workflow Description
  Automate your entire social media content pipeline - from trend discovery to publication. This workflow monitors Google Trends, selects high-potential topics, creates human-like content using advanced AI, and publishes across multiple social platforms with built-in tracking.

  Key Features
  Automated Trend Discovery**: Pulls trending topics from Google Trends API with customizable filters
  Intelligent Topic Selection**: AI chooses the most relevant trending topic for your niche
  Multi-AI Content Generation**: Combines Perplexity for research and OpenAI for content curation
  Human-Like Writing**: Advanced prompts eliminate AI detection markers
  LinkedIn Optimization**: Proper formatting with Unicode characters, emojis, and engagement hooks
  Multi-Platform Support**: Ready for LinkedIn, Twitter/X, and Facebook posting
  Automated Scheduling**: Configurable posting times (default: 6 AM & 6 PM daily)
  Performance Tracking**: Automatic logging to Google Sheets with timestamps and metrics
  Error Handling**: Built-in delays and retry mechanisms for API stability

  Technical Implementation

  Workflow Architecture
  Schedule Trigger: Automated execution at specified intervals
  Google Trends API: Fetches trending search queries with geographical filtering
  Data Processing: JavaScript code node filters high-volume keywords (30+ search volume)
  Topic Selection: OpenAI GPT-3.5 evaluates and selects optimal trending topic
  Content Research: Perplexity AI researches selected topic for current information
  Content Generation: Advanced prompt engineering creates LinkedIn-optimized posts
  Content Distribution: Multi-platform posting with platform-specific formatting
  Analytics Tracking: Google Sheets integration for performance monitoring

  Node Breakdown
  Schedule Trigger**: Configurable timing for automated execution
  HTTP Request (Google Trends)**: SerpAPI integration for trend data
  Set Node**: Structures trending data for processing
  Code Node**: JavaScript filtering for high-volume keywords
  OpenAI Node**: Intelligent topic selection based on relevance and trend strength
  HTTP Request (Perplexity)**: Advanced AI research with anti-detection prompts
  Wait Node**: Rate limiting and API respect
  Split Out**: Prepares content for multi-platform distribution
  LinkedIn Node**: Authenticated posting with community management
  Google Sheets Node**: Automated tracking and analytics
  Social Media Nodes**: Twitter/X, LinkedIn and Facebook ready for activation

  Use Cases
  Content Creators**: Maintain consistent posting schedules with trending content
  Marketing Agencies**: Scale content creation across multiple client accounts
  Business Development**: Build thought leadership with timely industry insights
  Personal Branding**: Establish authority by commenting on trending topics
  SEO Professionals**: Create content around high-search-volume keywords

  Configuration Requirements

  API Integrations
  SerpAPI**: Google Trends data access
  Perplexity AI**: Advanced content research capabilities
  OpenAI**: Content curation and topic selection
  LinkedIn Community Management API**: Professional posting access
  Google Sheets API**: Analytics and tracking

  Authentication Setup
  LinkedIn OAuth2 community management credentials
  Google Sheets OAuth2 integration
  HTTP header authentication for AI services

  Customization Options
  Industry Targeting**: Modify prompts for specific business verticals
  Posting Schedule**: Adjust timing based on audience activity
  Content Tone**: Customize voice and style through prompt engineering
  Platform Selection**: Enable/disable specific social media channels
  Trend Filtering**: Adjust search volume thresholds and geographic targeting
  Content Length**: Modify character limits for different platforms

  Advanced Features
  Anti-AI Detection**: Sophisticated prompts create human-like content
  Rate Limit Management**: Built-in delays prevent API throttling
  Error Recovery**: Robust error handling with retry mechanisms
  Content Deduplication**: Prevents posting duplicate content
  Engagement Optimization**: LinkedIn-specific formatting for maximum reach

  Performance Metrics
  Time Savings**: Eliminates 10+ hours of weekly content creation
  Consistency**: Maintains regular posting schedule without manual intervention
  Relevance**: Content always based on current trending topics
  Engagement**: Optimized formatting increases social media interaction
  Scalability**: Single workflow manages multiple platform posting

  Installation Notes
  Import JSON workflow file into n8n instance
  Configure all required API credentials
  Set up Google Sheets tracking document
  Test workflow execution with manual trigger
  Enable schedule trigger for automated operation

  Best Practices
  Monitor API usage to stay within rate limits
  Regularly update prompts based on content performance
  Review and adjust trending topic filters for your niche
  Maintain backup of workflow configuration
  Test content output before enabling automation

  Support & Updates
  Comprehensive setup documentation included
  Configuration troubleshooting guide provided
  Regular workflow updates for API changes
  Community support through n8n forums

  Tags
  social-media content-automation linkedin ai-generation google-trends perplexity openai marketing trend-analysis content-creation

  Compatibility
  n8n Version: 1.0+
  Node Requirements: Standard n8n installation
  External Dependencies: API access to listed services
  Hosting: Compatible with cloud and self-hosted n8n instances

nodes_used:
  ["n8n-nodes-base.googleSheets","n8n-nodes-base.httpRequest","n8n-nodes-base.facebookGraphApi","n8n-nodes-base.twitter","n8n-nodes-base.linkedIn","n8n-nodes-base.code","@n8n/n8n-nodes-langchain.openAi"]

workflow_json:
  {"id":"vJw8YoQhdA5CXGeB","meta":{"instanceId":"f2cf6301a998e16084609c8635767c7f2fe71603e7ba21b5457aa517ce5164cb","templateCredsSetupCompleted":true},"name":"Social_media_post _automation_from_google_trends_and _perplexity copy","tags":[],"nodes":[{"id":"39b1272c-3700-4ce6-9aea-46b3a647fc26","name":"X1","type":"n8n-nodes-base.twitter","position":[-1500,0],"parameters":{"additionalFields":{}},"credentials":{"twitterOAuth2Api":{"id":"tNwQsAkmjk3b0Dp6","name":"X account"}},"typeVersion":2},{"id":"4bab1fd3-1c21-4438-8cc1-e0d0fdde390e","name":"Facebook Graph API1","type":"n8n-nodes-base.facebookGraphApi","position":[-1500,-400],"parameters":{"options":{},"httpRequestMethod":"POST"},"typeVersion":1},{"id":"ffcd9aa8-daef-41dc-8ad3-b9a55a817b8b","name":"LinkedIn1","type":"n8n-nodes-base.linkedIn","position":[-1480,-200],"parameters":{"text":"={{ $json['choices[0].message.content'] }}","person":"[CONFIGURE_YOUR_LINKEDIN_PERSON_ID]","authentication":"communityManagement","additionalFields":{}},"credentials":{"linkedInCommunityManagementOAuth2Api":{"id":null,"name":"[CONFIGURE_YOUR_LINKEDIN_CREDENTIALS]"}},"typeVersion":1},{"id":"a2c2c5e5-e9b1-4744-9883-c63cda3306c9","name":"Google Sheets2","type":"n8n-nodes-base.googleSheets","position":[-1280,-200],"parameters":{"columns":{"value":{"Topic":"={{ $('Choosing Topic').item.json.message.content }}","Status":"Posted","AI Output":"={{ $json['choices[0].message.content'] }}","Date Posted":"={{ $('Schedule Trigger').item.json.timestamp }}"},"schema":[{"id":"Topic","type":"string","display":true,"removed":false,"required":false,"displayName":"Topic","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Status","type":"string","display":true,"required":false,"displayName":"Status","defaultMatch":false,"canBeUsedToMatch":true},{"id":"AI Output","type":"string","display":true,"required":false,"displayName":"AI Output","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Date Posted","type":"string","display":true,"required":false,"displayName":"Date Posted","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":["Topic"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"appendOrUpdate","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"[YOUR_GOOGLE_SHEETS_URL]","cachedResultName":"Sheet1"},"documentId":{"__rl":true,"mode":"list","value":"[YOUR_GOOGLE_SHEETS_DOCUMENT_ID]","cachedResultUrl":"[YOUR_GOOGLE_SHEETS_URL]","cachedResultName":"LinkedIn Automation"}},"credentials":{"googleSheetsOAuth2Api":{"id":null,"name":"[CONFIGURE_YOUR_GOOGLE_SHEETS_CREDENTIALS]"}},"typeVersion":4.5},{"id":"51d3733a-004c-4938-9575-d227588140b7","name":"Split Out","type":"n8n-nodes-base.splitOut","position":[-1720,-200],"parameters":{"options":{},"fieldToSplitOut":"choices[0].message.content"},"typeVersion":1},{"id":"cc9b1e41-aaeb-43fb-a283-e3faf397cc73","name":"Schedule Trigger","type":"n8n-nodes-base.scheduleTrigger","position":[-3420,-200],"parameters":{"rule":{"interval":[{"triggerAtHour":6},{"triggerAtHour":18}]}},"typeVersion":1.2},{"id":"01d0a3b7-66db-4032-b7d7-7a7b273920a7","name":"Research Topic- Perplexity","type":"n8n-nodes-base.httpRequest","position":[-2160,-200],"parameters":{"url":"https://api.perplexity.ai/chat/completions","method":"POST","options":{},"jsonBody":"={\n  \"model\": \"sonar-pro\",\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"Act as a skilled editor revising AI-generated text to sound authentically human. Follow these rules:\\n\\n1. Punctuation Adjustments\\n   - Replace em dashes, semicolons, or rephrase sentences where appropriate.\\n   - Avoid semicolons in casual contexts; use periods or conjunctions (e.g., 'and,' 'but').\\n   - Remove mid-sentence ellipses unless mimicking deliberate hesitation.\\n   - Limit parenthetical asides; integrate explanations into the main sentence.\\n   - Use colons sparingly.\\n\\n2. Language\\n   - Replace hedging phrases with direct statements.\\n   - Avoid stock transitions.\\n   - Vary repetitive terms.\\n   - Use contractions in informal contexts.\\n   - Replace overly formal words with simpler alternatives.\\n\\n3. Style\\n   - Prioritize concise, varied sentence lengths.\\n   - Allow minor imperfections.\\n   - Maintain the core message but adjust tone to match the audience.\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"You are a researcher and expert copywriter in a business development team of an AI Automation Agency. Generate exactly one LinkedIn post that adheres to LinkedIn's API formatting guidelines and is easy for humans to read. Follow these rules:\\n\\nStructure:\\n1. Hook: Start with a bold opening line using Unicode characters (e.g., \\\"𝐁𝐎𝐋𝐃 𝐒𝐓𝐀𝐓𝐄𝐌𝐄𝐍𝐓\\\").\\n2. Body: Use short paragraphs (1-3 sentences) separated by \\\\n\\\\n.\\n3. Use bullet points (•) for key features or highlights.\\n4. End with a clear call-to-action (e.g., \\\"Comment below with your thoughts!\\\").\\n\\nFormatting Requirements:\\n- Remove all numeric citation brackets like [2], [3], [4] from the text.\\n- Instead of citation brackets, if needed, add a brief phrase like \\\"according to Google I/O 2025\\\" or \\\"as reported by DeepMind\\\" naturally within the sentence.\\n- No Markdown or rich text formatting.\\n- Use Unicode characters or emojis for emphasis (e.g., ★, 🚀).\\n- Include up to 3 relevant hashtags at the end (e.g., #AI #Automation).\\n- For URLs or references, use placeholders like [Link] instead of raw URLs.\\n- If mentioning users or companies, use official LinkedIn URN format (e.g., \\\"urn:li:organization:123456\\\").\\n\\nContent Rules:\\n- Max 1,200 characters.\\n- Avoid promotional language.\\n- Include one statistical claim or industry insight.\\n- Add one personal anecdote or professional observation.\\n\\nReturn the post as plain text without additional commentary.\\n\\nInput: {{ $json.message.content }}\"\n    }\n  ]\n}\n","sendBody":true,"specifyBody":"json","authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":null,"name":"[CONFIGURE_YOUR_PERPLEXITY_API_KEY]"}},"typeVersion":4.2},{"id":"1b226459-7dc7-46c2-9b02-769cd213e927","name":"2 Most Trending","type":"n8n-nodes-base.set","position":[-2980,-200],"parameters":{"mode":"raw","options":{},"jsonOutput":"={\n  \"most-trending\": {\n\n    \"#1\": { \n\n      \"query\":\"{{ $json.related_queries.rising[0].query }}\",\n      \"score\":\"{{ $json.related_queries.rising[0].extracted_value }}\"\n\n    },\n\n\n    \"#2\": { \n\n      \"query\":\"{{ $json.related_queries.rising[1].query }}\",\n      \"score\":\"{{ $json.related_queries.rising[1].extracted_value }}\"\n\n    }\n  }\n}"},"typeVersion":3.4},{"id":"75ccf42a-7dc8-4cc8-9d5d-202ff4b2b795","name":"High search volume keywords","type":"n8n-nodes-base.code","position":[-2760,-200],"parameters":{"jsCode":"// Get the top array from your JSON\nconst topItems = $('Google Trends').first().json.related_queries.top;\n\n// Filter the items to only include those with extracted_value > 30\nconst filtered = topItems.filter(item => item.extracted_value > 30);\n\n// Map the filtered items to their query values and join them with commas\nconst resultString = filtered.map(item => item.query).join(', ');\n\n// Return the result in a new JSON property\nreturn [{ json: { result: resultString } }];\n"},"typeVersion":2},{"id":"c85503d1-76e7-4dd7-a2e3-69966f69e0cd","name":"Choosing Topic","type":"@n8n/n8n-nodes-langchain.openAi","position":[-2540,-200],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-3.5-turbo","cachedResultName":"GPT-3.5-TURBO"},"options":{},"messages":{"values":[{"content":"=You are part of a team that creates world class blog posts. Your job is to choose the topic for each blog post. \n\nThe blog posts are posted on the website of a [COMPANY NAME + DESCRIPTION + PRODUCTS + TARGET MARKET]. The blog posts are mainly posted as part of an SEO campaign to get [YOUR_COMPANY] to rank high for its products and services.\n\nIn this instance, you are given a list of 2 keywords which have been trending the most on Google news search over the past few days. \n\nYour job is to pick one which you think would make for the most relevant blog post with the best SEO outcomes for the client. \n\nThe keywords have two attributes: \n\n1. query: This attribute determines the search query that users have been searching for which is trending. \n\n2. value: This attribute determines what percentage increase the keyword has seen compared to previous periods (i.e. the increase in search volume). \n\nYou must choose one out of the taking into consideration both the relevance of the keyword for [YOUR_COMPANY]'s SEO efforts and the comparative trendiness determined by the value attribute. \n\nOutput the keyword you decided to post a blog on and nothing else. Don't explain your reasoning. Just output the keyword. \n\nThis instance: \n\nKeyword 1:\n{{ $('2 Most Trending').item.json['most-trending']['#1'].toJsonString() }} \n\nKeyword2: \n{{ $('2 Most Trending').item.json['most-trending']['#2'].toJsonString() }} "}]}},"credentials":{"openAiApi":{"id":null,"name":"[CONFIGURE_YOUR_OPENAI_API_KEY]"}},"typeVersion":1.8},{"id":"37d7191c-878e-424e-90be-3fe2bdff625a","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-3240,-280],"parameters":{"width":400,"height":240,"content":"## Find Trend\n\n"},"typeVersion":1},{"id":"9987f2ae-0ec1-48b5-81f5-44a2f5a705b7","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-2820,-280],"parameters":{"width":200,"height":240,"content":"## High Volume Keywords\n\n"},"typeVersion":1},{"id":"f4a25815-10e6-409c-a89a-baa2efecb119","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-2580,-280],"parameters":{"width":340,"height":240,"content":"## Choosing Blog Topic\n\n\n"},"typeVersion":1},{"id":"c9206a42-1471-4a87-99ad-25bd5d318fb4","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-2200,-280],"parameters":{"width":600,"height":240,"content":"## Research\n\n\n"},"typeVersion":1},{"id":"089fdbf7-f1a0-4cd5-9769-caf94b05a939","name":"Google Trends","type":"n8n-nodes-base.httpRequest","position":[-3200,-200],"parameters":{"url":"https://serpapi.com/search","options":{},"sendQuery":true,"queryParameters":{"parameters":[{"name":"q","value":"=ai agents"},{"name":"geo","value":"US"},{"name":"hl","value":"en"},{"name":"date","value":"={{ $now.minus({ days: 3 }).format('yyyy-MM-dd') }} {{ $now.format('yyyy-MM-dd') }}"},{"name":"data_type","value":"RELATED_QUERIES"},{"name":"engine","value":"google_trends"},{"name":"api_key","value":"[YOUR_SERPAPI_KEY]"}]}},"typeVersion":4.2},{"id":"13f0ea49-1dbe-4b33-9c73-ebe9d3099003","name":"Wait","type":"n8n-nodes-base.wait","position":[-1940,-200],"webhookId":"[GENERATED_WEBHOOK_ID]","parameters":{"amount":10},"typeVersion":1.1},{"id":"c582949e-858f-4aa7-984b-0bd94212009f","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-1560,-540],"parameters":{"height":800,"content":"## Multi Social Media Posting"},"typeVersion":1},{"id":"77f592f4-fc6c-4633-ba2e-e671b18d6a1b","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-1300,-280],"parameters":{"height":260,"content":"## Status update"},"typeVersion":1}],"active":false,"settings":{"executionOrder":"v1"},"versionId":"9211dd42-49be-406b-94aa-297f48c13f3e","connections":{"Wait":{"main":[[{"node":"Split Out","type":"main","index":0}]]},"LinkedIn1":{"main":[[{"node":"Google Sheets2","type":"main","index":0}]]},"Split Out":{"main":[[{"node":"X1","type":"main","index":0},{"node":"Facebook Graph API1","type":"main","index":0},{"node":"LinkedIn1","type":"main","index":0}]]},"Google Trends":{"main":[[{"node":"2 Most Trending","type":"main","index":0}]]},"Choosing Topic":{"main":[[{"node":"Research Topic- Perplexity","type":"main","index":0}]]},"2 Most Trending":{"main":[[{"node":"High search volume keywords","type":"main","index":0}]]},"Schedule Trigger":{"main":[[{"node":"Google Trends","type":"main","index":0}]]},"Research Topic- Perplexity":{"main":[[{"node":"Wait","type":"main","index":0}]]},"High search volume keywords":{"main":[[{"node":"Choosing Topic","type":"main","index":0}]]}}}


name: AI-Powered Post-Sales Call Automated Proposal Generator
author_name: Gerald Denor
author_username: dominixai
categories: []
created_at: 2025-05-24T13:32:44.312Z
updated_at: 2025-05-24T13:32:44.312Z
url: https://n8n.io/workflows/4359
scraped_at: 2025-07-06 21:16:30
description:
  AI-Powered Proposal Generator - Sales Automation Workflow

  Overview

  This n8n workflow automates the entire proposal generation process using AI, transforming client requirements into professional, customized proposals delivered via email in seconds.

  Use Case
  Perfect for agencies, consultants, and sales teams who need to generate high-quality proposals quickly. Instead of spending hours writing proposals manually, this workflow captures client information through a web form and uses GPT-4 to generate contextually relevant, professional proposals.

  How It Works
  Form Trigger - Captures client information through a customizable web form
  OpenAI Integration - Processes form data and generates structured proposal content
  Google Drive - Creates a copy of your proposal template
  Google Slides - Populates the template with AI-generated content
  Gmail - Automatically sends the completed proposal to the client

  Key Features
  AI Content Generation**: Uses GPT-4 to create personalized proposal content
  Professional Templates**: Integrates with Google Slides for polished presentations
  Automated Delivery**: Sends proposals directly to clients via email
  Form Integration**: Captures all necessary client data through web forms
  Customizable Output**: Generates structured proposals with multiple sections

  Template Sections Generated
  Proposal title and description
  Problem summary analysis
  Three-part solution breakdown
  Project scope details
  Milestone timeline with dates
  Cost integration

  Requirements
  n8n instance** (cloud or self-hosted)
  OpenAI API key** for content generation
  Google Workspace account** for Slides and Gmail
  Basic n8n knowledge** for setup and customization

  Setup Complexity
  Intermediate - Requires API credentials setup and basic workflow customization

  Benefits
  Time Savings**: Reduces proposal creation from hours to minutes
  Consistency**: Ensures all proposals follow the same professional structure
  Personalization**: AI analyzes client needs for relevant content
  Automation**: Eliminates manual copy-paste and formatting work
  Scalability**: Handle multiple proposal requests simultaneously

  Customization Options
  Modify AI prompts for different industries or services
  Customize Google Slides template design
  Adjust form fields for specific information needs
  Personalize email templates and signatures
  Configure milestone templates for different project types

  Error Handling
  Includes basic error handling for API failures and form validation to ensure reliable operation.

  Security Notes
  All credentials have been removed from this template. Users must configure their own:
  OpenAI API credentials
  Google OAuth2 connections for Slides, Drive, and Gmail
  Form webhook configuration

  This workflow demonstrates practical AI integration in business processes and showcases n8n's capabilities for complex automation scenarios.

nodes_used:
  ["n8n-nodes-base.googleDrive","n8n-nodes-base.gmail","n8n-nodes-base.googleSlides","@n8n/n8n-nodes-langchain.openAi"]

workflow_json:
  {"meta":{"templateCredsSetupCompleted":false},"name":"AI Proposal Generator System","tags":[],"nodes":[{"id":"12f23b4f-a653-45ad-87b7-e60ba30e70cb","name":"Replace Text","type":"n8n-nodes-base.googleSlides","position":[1300,1100],"parameters":{"textUi":{"textValues":[{"text":"{{proposalTitle}}","replaceText":"={{ $('OpenAI').item.json.message.content.proposalTitle }}"},{"text":"{{descriptionName}}","replaceText":"={{ $('OpenAI').item.json.message.content.descriptionName }}"},{"text":"{{oneParagraphProblemSummary}}","replaceText":"={{ $('OpenAI').item.json.message.content.oneParagraphProblemSummary }}"},{"text":"{{solutionHeadingOne}}","replaceText":"={{ $('OpenAI').item.json.message.content.solutionHeadingOne }}"},{"text":"{{solutionHeadingTwo}}","replaceText":"={{ $('OpenAI').item.json.message.content.solutionHeadingTwo }}"},{"text":"{{solutionHeadingThree}}","replaceText":"={{ $('OpenAI').item.json.message.content.solutionHeadingThree }}"},{"text":"{{solutionDescriptionOne}}","replaceText":"={{ $('OpenAI').item.json.message.content.solutionDescriptionOne }}"},{"text":"{{solutionDescriptionTwo}}","replaceText":"={{ $('OpenAI').item.json.message.content.solutionDescriptionTwo }}"},{"text":"{{solutionDescriptionThree}}","replaceText":"={{ $('OpenAI').item.json.message.content.solutionDescriptionThree }}"},{"text":"{{shortScopeTitleOne}}","replaceText":"={{ $('OpenAI').item.json.message.content.shortScopeTitleOne }}"},{"text":"{{shortScopeTitleTwo}}","replaceText":"={{ $('OpenAI').item.json.message.content.shortScopeTitleTwo }}"},{"text":"{{shortScopeTitleThree}}","replaceText":"={{ $('OpenAI').item.json.message.content.shortScopeTitleThree }}"},{"text":"{{shortScopeDescriptionOne}}","replaceText":"={{ $('OpenAI').item.json.message.content.shortScopeDescriptionOne }}"},{"text":"{{shortScopeDescriptionTwo}}","replaceText":"={{ $('OpenAI').item.json.message.content.shortScopeDescriptionTwo }}"},{"text":"{{shortScopeDescriptionThree}}","replaceText":"={{ $('OpenAI').item.json.message.content.shortScopeDescriptionThree }}"},{"text":"{{milestoneOneDay}}","replaceText":"={{ $('OpenAI').item.json.message.content.milestoneOneDay }}"},{"text":"{{milestoneTwoDay}}","replaceText":"={{ $('OpenAI').item.json.message.content.milestoneTwoDay }}"},{"text":"{{milestoneThreeDay}}","replaceText":"={{ $('OpenAI').item.json.message.content.milestoneThreeDay }}"},{"text":"{{milestoneFourDay}}","replaceText":"={{ $('OpenAI').item.json.message.content.milestoneFourDay }}"},{"text":"{{milestoneDescriptionOne}}","replaceText":"={{ $('OpenAI').item.json.message.content.milestoneDescriptionOne }}"},{"text":"{{milestoneDescriptionTwo}}","replaceText":"={{ $('OpenAI').item.json.message.content.milestoneDescriptionTwo }}"},{"text":"{{milestoneDescriptionThree}}","replaceText":"={{ $('OpenAI').item.json.message.content.milestoneDescriptionThree }}"},{"text":"{{milestoneDescriptionFour}}","replaceText":"={{ $('OpenAI').item.json.message.content.milestoneDescriptionFour }}"},{"text":"{{cost}}","replaceText":"={{ $('On form submission').item.json.Cost }}"}]},"options":{},"operation":"replaceText","presentationId":"={{ $json.id }}"},"typeVersion":2},{"id":"da8060cf-ac55-439f-ab44-a973d5e4ee18","name":"OpenAI","type":"@n8n/n8n-nodes-langchain.openAi","position":[700,1100],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o","cachedResultName":"GPT-4O"},"options":{},"messages":{"values":[{"role":"system","content":"You are a helpful, intelligent writing assistant."},{"content":"Your task is to generate a proposal using input data from a form. This proposal should be highly customized, specific, and high-quality, considering we're going to be sending it immediately after you're done.\n\nContext: we are an automation/no-code agency that develops systems revolving around growth, revenue ops, etc.\n\nThe proposal template we're using has many fields. You must return these fields in one JSON object.\n\nUse this format:\n\n{\n  \"proposalTitle\": \"\",\n  \"descriptionName\": \"\",\n  \"oneParagraphProblemSummary\": \"\",\n  \"solutionHeadingOne\": \"\",\n  \"solutionDescriptionOne\": \"\",\n  \"solutionHeadingTwo\": \"\",\n  \"solutionDescriptionTwo\": \"\",\n  \"solutionHeadingThree\": \"\",\n  \"solutionDescriptionThree\":\"\",\n  \"shortScopeTitleOne\": \"\",\n  \"shortScopeTitleTwo\": \"\",\n  \"shortScopeTitleThree\": \"\",\n  \"shortScopeDescriptionOne\": \"\",\n  \"shortScopeDescriptionTwo\": \"\",\n  \"shortScopeDescriptionThree\": \"\",\n  \"milestoneOneDay\": \"\",\n  \"milestoneTwoDay\": \"\",\n  \"milestoneThreeDay\": \"\",\n  \"milestoneFourDay\": \"\",\n  \"milestoneDescriptionOne\": \"\",\n  \"milestoneDescriptionTwo\": \"\",\n  \"milestoneDescriptionThree\": \"\",\n  \"milestoneDescriptionFour\": \"\"\n}\n\nRules:\n1. Use a spartan, casual tone of voice.\n2. Be to-the-point but professional—assume you're writing to a sophisticated audience.\n3. Ensure that all fields are filled out. Do not miss a field or leave any variables empty.\n4. Keep things short. If a field contains the term \"Description\" it should be no more than fourteen words. For \"descriptionName\" do not use title case."},{"content":"{\n  \"companyName\":\"1SecondCopy\",\n  \"problem\": \"they can't generate leads. everything is referral based rn.\",\n  \"solution\": \"cold email lead gen system, client reactivation system, and best in class sales training for closing\",\n  \"scope\": \"1k/day cold email infra, 30k email leads, 4 weekly zoom sessions for sales training\",\n  \"currentDate\":\"Feb 4 2025\",\n  \"howSoon\": \"two months\",\n  \"depositCost\": \"$1,845\",\n}"},{"role":"assistant","content":"{\n  \"proposalTitle\": \"Lead Gen System for 1SecondCopy\n\",\n  \"descriptionName\": \"A simple, scalable lead generation system built to help grow your content efforts & connect you with the right people.\n\",\n  \"oneParagraphProblemSummary\": \"Right now, 1SecondCopy is struggling with an inability to generate qualified leads. The majority of your new clients are referral-based, which, while always nice to have, is not scalable nor is it reliable. Building an alternative strategy—one that allows you to take leads from cold -> close—is vital to the health and longevity of the company, and it's what we're going to help you with.\n\",\n  \"solutionHeadingOne\": \"Cold Outbound Lead Gen\",\n  \"solutionDescriptionOne\": \"We'll put in place a robust cold-email-based system for you using best practices.\",\n  \"solutionHeadingTwo\": \"Client Reactivation System\",\n  \"solutionDescriptionTwo\": \"We'll build a simple, but high-ROI reactivation system to let you extract value from pre-existing clients.\",\n  \"solutionHeadingThree\": \"Best-In-Class Sales Training\",\n  \"solutionDescriptionThree\": \"We'll train your team with world-class setting & closing mechanisms.\",\n  \"shortScopeTitleOne\": Cold email infrastructure that sends ~1K emails/day\",\n  \"shortScopeTitleTwo\": \"30K high-quality scraped email leads (included)\",\n  \"shortScopeTitleThree\": \"Four weekly one-hour sales training sessions over Zoom\",\n  \"shortScopeDescriptionOne\": \"12 domains, 36 mailboxes, DNS optimization, and warmups included.\",\n  \"shortScopeDescriptionTwo\": \"30,000 leads in your target market, delivered by CSV.\",\n  \"shortScopeDescriptionThree\": \"We'll take your sales team from 0->1.\",\n  \"milestoneOneDay\": \"February 8th, 2025\",\n  \"milestoneTwoDay\": \"February 28th, 2025\",\n  \"milestoneThreeDay\": \"March 10th, 2025\",\n  \"milestoneFourDay\":\"March 17th-April 1st, 2025\",\n  \"milestoneDescriptionOne\": \"Cold email system done & ready for warmup.\",\n  \"milestoneDescriptionTwo\": \"Cold email system fully warmed up & operational.\",\n  \"milestoneDescriptionThree\": \"10,000 outbound emails sent; analysis & training #1.\"\n  \"milestoneDescriptionFour\":\"One sales training per week alongside iteration & handoff.\"\n}"},{"content":"={\n  \"companyName\":\"{{ $json['Company Name'] }}\",\n  \"problem\": \"{{ $json.Problem }}\",\n  \"solution\": \"{{ $json.Solution}}\",\n  \"scope\": \"{{ $json.Scope }}\",\n  \"currentDate\":\"{{ $now.toLocaleString({ dateStyle: 'medium' }) }}\",\n  \"howSoon\": \"{{ $json['How soon?'] }}\",\n  \"depositCost\": \"{{ $json.Cost }}\",\n}"}]},"jsonOutput":true},"typeVersion":1.6},{"id":"7e52e4c7-49da-499a-a9ea-3e421611fb87","name":"Google Drive","type":"n8n-nodes-base.googleDrive","position":[1080,1100],"parameters":{"name":"={{ $json.message.content.proposalTitle }}","fileId":{"__rl":true,"mode":"id","value":"REPLACE_WITH_YOUR_GOOGLE_SLIDES_TEMPLATE_ID"},"options":{"copyRequiresWriterPermission":false},"operation":"copy"},"typeVersion":3},{"id":"5a0508ab-4eaa-49f0-96f9-a664a1e7a5eb","name":"Gmail","type":"n8n-nodes-base.gmail","position":[1520,1100],"webhookId":"WEBHOOK_ID_WILL_BE_GENERATED","parameters":{"sendTo":"={{ $('On form submission').item.json.Email }}","message":"=Hey {{ $('On form submission').item.json['First Name'] }},\n\nThanks for the great call earlier. I had a moment after our chat to put together a detailed proposal for you—please take a look at your earliest convenience and let me know your thoughts.\n\nYou'll find it here: https://docs.google.com/presentation/d/{{ $json.presentationId }}/edit\n\nIf you have any questions, just ask. I've also sent over an invoice for the project (just to keep things convenient) and we can get started anytime that's sorted.\n\nThanks,\n[YOUR NAME]","options":{"appendAttribution":false},"subject":"=Re: Proposal for  {{ $('On form submission').item.json['Company Name'] }}","emailType":"text"},"typeVersion":2.1},{"id":"5be2415f-96f1-4e05-b589-bc4992c2a231","name":"On form submission","type":"n8n-nodes-base.formTrigger","position":[480,1100],"webhookId":"WEBHOOK_ID_WILL_BE_GENERATED","parameters":{"options":{"appendAttribution":false},"formTitle":"Sales Call Logging Form","formFields":{"values":[{"fieldLabel":"First Name","requiredField":true},{"fieldLabel":"Last Name","requiredField":true},{"fieldLabel":"Company Name","requiredField":true},{"fieldType":"email","fieldLabel":"Email"},{"fieldLabel":"Website","requiredField":true},{"fieldType":"textarea","fieldLabel":"Problem","requiredField":true},{"fieldType":"textarea","fieldLabel":"Solution","requiredField":true},{"fieldType":"textarea","fieldLabel":"Scope","requiredField":true},{"fieldLabel":"Cost","requiredField":true},{"fieldLabel":"How soon?","requiredField":true}]},"formDescription":"This form logs a sales call & automatically generates a proposal."},"typeVersion":2.2},{"id":"4ae579fb-779d-4312-a163-d438507b8918","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[440,980],"parameters":{"width":1220,"height":280,"content":"## Google Slides AI Proposal Generator\n**This flow generates proposals using AI and the free Google Slides solution**."},"typeVersion":1}],"active":false,"settings":{"timezone":"UTC","callerPolicy":"workflowsFromSameOwner","executionOrder":"v1"},"connections":{"OpenAI":{"main":[[{"node":"Google Drive","type":"main","index":0}]]},"Google Drive":{"main":[[{"node":"Replace Text","type":"main","index":0}]]},"Replace Text":{"main":[[{"node":"Gmail","type":"main","index":0}]]},"On form submission":{"main":[[{"node":"OpenAI","type":"main","index":0}]]}}}


