# templates

name: Invoices from Gmail to Drive and Google Sheets
author_name: Juan Carlos Cavero Gracia
author_username: carlosgracia
categories: []
created_at: 2025-02-25T21:34:30.197Z
updated_at: 2025-02-25T21:34:30.197Z
url: https://n8n.io/workflows/3016
scraped_at: 2025-07-06 21:16:30
description:
  Attachments Gmail to Drive and Google Sheets

  Description
  Automatically process invoice emails by saving attachments to Google Drive and extracting key invoice data to Google Sheets using AI. This workflow monitors your Gmail for unread emails with attachments, saves PDFs to a specified Google Drive folder, and uses OpenAI's GPT-4o to extract invoice details (date, description, amount) into a structured spreadsheet.

  Use cases
  Invoice Management**: Automatically organize and track invoices received via email
  Financial Record Keeping**: Maintain a structured database of all invoice information
  Document Organization**: Keep digital copies of invoices organized in Google Drive
  Automated Data Entry**: Eliminate manual data entry for invoice processing

  Resources
  Gmail account
  Google Drive account
  Google Sheets account
  OpenAI API key

  Setup instructions

  Prerequisites
  Active Gmail, Google Drive, and Google Sheets accounts
  OpenAI API key (GPT-4o model access)
  n8n instance with credentials manager

  Steps
  Gmail and Google Drive Setup:
     Connect your Gmail account in n8n credentials
     Connect your Google Drive account with appropriate permissions
     Create a destination folder in Google Drive for invoice storage

  Google Sheets Setup:
     Connect your Google Sheets account
     Create a spreadsheet with columns: Invoice date, Invoice Description, Total price, and Fichero
     Copy your spreadsheet ID for configuration

  OpenAI Setup:
     Add your OpenAI API key to n8n credentials

  Configure Email Filter:
     Update the email filter node to match your specific sender requirements

  Benefits
  Time Saving**: Eliminates manual downloading, filing, and data entry
  Accuracy**: AI-powered data extraction reduces human error
  Organization**: Consistent file naming and storage structure
  Searchability**: Creates a searchable database of all invoice information
  Automation**: Runs every minute to process new emails as they arrive

  Related templates
  Email Parser to CRM
  Document Processing Workflow
  Financial Data Automation

nodes_used:
  ["n8n-nodes-base.googleSheets","n8n-nodes-base.httpRequest","n8n-nodes-base.googleDrive","n8n-nodes-base.gmail","@n8n/n8n-nodes-langchain.chainLlm","@n8n/n8n-nodes-langchain.lmOpenAi","@n8n/n8n-nodes-langchain.outputParserStructured"]

workflow_json:
  {"id":"XnGZZfT5u0Cw1X3p","meta":{"instanceId":"3378b0d68c3b7ebfc71b79896d94e1a044dec38e99a1160aed4e9c323910fbe2","templateCredsSetupCompleted":true},"name":"Attachments Gmail to drive and google sheets","tags":[],"nodes":[{"id":"0404ef0a-9750-495a-8798-98d4b059a083","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-580,-420],"parameters":{"height":440,"content":"## Setup\n1. Setup your **Gmail** and **Google Drive** credentials\n2. Setup your **Google Sheets** credentials\n3. Setup your **Openai** api key"},"typeVersion":1},{"id":"8751a7f1-aae4-4746-aae7-3d8563845b8c","name":"Gmail Trigger1","type":"n8n-nodes-base.gmailTrigger","position":[-640,120],"parameters":{"simple":false,"filters":{"readStatus":"unread"},"options":{"downloadAttachments":true},"pollTimes":{"item":[{"mode":"everyMinute"}]}},"credentials":{"gmailOAuth2":{"id":"v8YJP3VfeGtRk5la","name":"Gmail account"}},"typeVersion":1.1},{"id":"40f62192-5acb-4915-aa07-e5a0dfeb7581","name":"Setup1","type":"n8n-nodes-base.set","position":[-300,120],"parameters":{"options":{},"assignments":{"assignments":[{"id":"4cca07a2-6a70-4011-a025-65246e652fb9","name":"url_to_drive_folder","type":"string","value":"1fCWCdqrFP3WrjjLc-gJtxMaiaF5lh8Ko"}]},"includeOtherFields":true},"typeVersion":3.4},{"id":"d928e797-8851-4ab4-9199-cd555a40eae9","name":"Upload PDF to Drive1","type":"n8n-nodes-base.httpRequest","maxTries":5,"position":[220,0],"parameters":{"url":"https://www.googleapis.com/upload/drive/v3/files","method":"POST","options":{},"sendBody":true,"sendQuery":true,"contentType":"binaryData","authentication":"predefinedCredentialType","queryParameters":{"parameters":[{"name":"uploadType","value":"media"}]},"inputDataFieldName":"={{ $binary.attachment_0.mimeType === \"application/pdf\"\n     ? \"attachment_0\"\n     : \"attachment_1\" }}","nodeCredentialType":"googleDriveOAuth2Api"},"credentials":{"googleDriveOAuth2Api":{"id":"p5I6S4YkJps1zvwz","name":"Google Drive account 2"}},"retryOnFail":true,"typeVersion":4.2},{"id":"22df6933-a0c7-4cce-8114-5332038a14c3","name":"Rename file1","type":"n8n-nodes-base.googleDrive","position":[400,0],"parameters":{"fileId":{"__rl":true,"mode":"id","value":"={{ $json.id }}"},"options":{},"operation":"update","newUpdatedFileName":"={{ $('Setup1').item.json.subject }}_invoice_{{ $now.format('yyyy-MM-dd') }}.pdf"},"credentials":{"googleDriveOAuth2Api":{"id":"p5I6S4YkJps1zvwz","name":"Google Drive account 2"}},"typeVersion":3},{"id":"ce6a6a4c-17ba-4cf7-b07a-97b9d8d80844","name":"Move to the correct folder1","type":"n8n-nodes-base.googleDrive","position":[580,0],"parameters":{"fileId":{"__rl":true,"mode":"id","value":"={{ $json.id }}"},"driveId":{"__rl":true,"mode":"list","value":"My Drive","cachedResultUrl":"https://drive.google.com/drive/my-drive","cachedResultName":"My Drive"},"folderId":{"__rl":true,"mode":"list","value":"1fCWCdqrFP3WrjjLc-gJtxMaiaF5lh8Ko","cachedResultUrl":"","cachedResultName":"2025"},"operation":"move"},"credentials":{"googleDriveOAuth2Api":{"id":"p5I6S4YkJps1zvwz","name":"Google Drive account 2"}},"typeVersion":3},{"id":"e64aac5c-a314-46b6-b7db-fc0d6f450e1f","name":"Gmail","type":"n8n-nodes-base.gmail","position":[1240,0],"webhookId":"556cbee3-8de0-4645-9e91-e7c0c252f2ab","parameters":{"messageId":"={{ $('Gmail Trigger1').item.json.id }}","operation":"markAsRead"},"credentials":{"gmailOAuth2":{"id":"v8YJP3VfeGtRk5la","name":"Gmail account"}},"typeVersion":2.1},{"id":"ea74cfc1-0305-418d-9f5f-bffcfb3bb2c7","name":"Extract from File2","type":"n8n-nodes-base.extractFromFile","position":[1200,-180],"parameters":{"options":{},"operation":"pdf"},"typeVersion":1},{"id":"0398d982-78fd-4830-b5cf-271195af80fd","name":"Google Drive","type":"n8n-nodes-base.googleDrive","position":[800,0],"parameters":{"fileId":{"__rl":true,"mode":"id","value":"={{ $json.id }}"},"options":{},"operation":"download"},"credentials":{"googleDriveOAuth2Api":{"id":"p5I6S4YkJps1zvwz","name":"Google Drive account 2"}},"typeVersion":3},{"id":"3b4a96d4-a6ee-486a-a795-fe410ccc38b2","name":"OpenAI Model","type":"@n8n/n8n-nodes-langchain.lmOpenAi","position":[1740,20],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o","cachedResultName":"gpt-4o"},"options":{"temperature":0}},"credentials":{"openAiApi":{"id":"XJdxgMSXFgwReSsh","name":"n8n key"}},"typeVersion":1},{"id":"a7dd0d95-5e79-4bd2-a8a6-2178264d19fc","name":"Structured Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[1940,40],"parameters":{"jsonSchema":"{\n  \"Invoice date\": { \"type\": \"date\" },\n  \"Invoice description\": { \"type\": \"string\" },\n  \"Total price\": { \"type\": \"number\" },\n  \"Fichero\": { \"type\": \"string\" }\n}"},"typeVersion":1.1},{"id":"68d98f4c-e679-48e3-a1a1-529cda4e31a4","name":"Append to Reconciliation Sheet","type":"n8n-nodes-base.googleSheets","position":[2280,-140],"parameters":{"columns":{"value":{},"schema":[{"id":"Invoice date","type":"string","display":true,"removed":false,"required":false,"displayName":"Invoice date","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Invoice Description","type":"string","display":true,"removed":false,"required":false,"displayName":"Invoice Description","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Total price","type":"string","display":true,"removed":false,"required":false,"displayName":"Total price","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Fichero","type":"string","display":true,"removed":false,"required":false,"displayName":"Fichero","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"autoMapInputData","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"id","value":"gid=0"},"documentId":{"__rl":true,"mode":"list","value":"1gIUnjSWUhsoTOVVd4ZoVjARCGQfGE8s7FWcju3lNajM","cachedResultUrl":"","cachedResultName":"facturas"}},"credentials":{"googleSheetsOAuth2Api":{"id":"3IOU2VjBnR4hGohx","name":"Google Sheets account"}},"typeVersion":4.3},{"id":"80e1c8f4-b593-4c5f-b9e2-f3b7996ee6d4","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[1680,-400],"parameters":{"color":7,"width":805.0578351924228,"height":656.5014186128178,"content":"## 3. Use LLMs to Extract Values from Data\n[Read more about Basic LLM Chain](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.chainllm/)\n\nLarge language models are perfect for data extraction tasks as they can work across a range of document layouts without human intervention. The extracted data can then be sent to a variety of datastores such as spreadsheets, accounting systems and/or CRMs.\n\n**Tip:** The \"Structured Output Parser\" ensures the AI output can be\ninserted to our spreadsheet without additional clean up and/or formatting. "},"typeVersion":1},{"id":"3754e10e-a233-4ce0-bc79-bb5c01db9695","name":"Map Output","type":"n8n-nodes-base.set","position":[2080,-140],"parameters":{"mode":"raw","options":{},"jsonOutput":"={{ $json.output }}"},"typeVersion":3.3},{"id":"a42ff16f-d0df-4b6d-9a36-849f85d1facc","name":"Apply Data Extraction Rules","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[1740,-140],"parameters":{"text":"=Given the following invoice in the <invoice> xml tags, extract the following information as listed below.\nIf you cannot the information for a specific item, then leave blank and skip to the next. \n\n* Invoice date\n* Invoice Description: {{ $('Rename file1').item.json.name }}\n* Total price\n* Fichero: =HYPERLINK(\"https://drive.google.com/file/d/{{ $('Move to the correct folder1').item.json.id }}/view\", \"Ver Documento\")\n\n\n<invoice>{{ $json.text }}</invoice>","promptType":"define","hasOutputParser":true},"typeVersion":1.4},{"id":"f6de5d5a-d2dc-4590-8f46-3f250b8fca9f","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[1860,0],"parameters":{"width":192.26896179623753,"height":213.73043662572252,"content":"\n\n\n\n\n\n\n\n\n\n\n\n**Need more attributes?**\nChange it here!"},"typeVersion":1},{"id":"255fe8c1-5bd7-41cc-b1f9-c8956b5ad101","name":"Only invoice mails with attachments","type":"n8n-nodes-base.if","position":[0,120],"parameters":{"options":{},"conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"or","conditions":[{"id":"229200d1-ec13-4970-ae0e-2c8e17da0bdf","operator":{"type":"string","operation":"contains"},"leftValue":"={{ $('Gmail Trigger1').item.json.headers['content-type'] }}","rightValue":"multipart/mixed"},{"id":"new-condition","operator":{"type":"boolean","operation":"isNotEmpty"},"leftValue":"={{ $json.attachments }}"}]}},"typeVersion":2.1}],"active":true,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"eb152808-e993-4e18-9dd8-10f21df57bf1","connections":{"Gmail":{"main":[[]]},"Setup1":{"main":[[{"node":"Only invoice mails with attachments","type":"main","index":0}]]},"Map Output":{"main":[[{"node":"Append to Reconciliation Sheet","type":"main","index":0}]]},"Google Drive":{"main":[[{"node":"Extract from File2","type":"main","index":0}]]},"OpenAI Model":{"ai_languageModel":[[{"node":"Apply Data Extraction Rules","type":"ai_languageModel","index":0}]]},"Rename file1":{"main":[[{"node":"Move to the correct folder1","type":"main","index":0}]]},"Gmail Trigger1":{"main":[[{"node":"Setup1","type":"main","index":0}]]},"Extract from File2":{"main":[[{"node":"Apply Data Extraction Rules","type":"main","index":0}]]},"Upload PDF to Drive1":{"main":[[{"node":"Rename file1","type":"main","index":0}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"Apply Data Extraction Rules","type":"ai_outputParser","index":0}]]},"Apply Data Extraction Rules":{"main":[[{"node":"Map Output","type":"main","index":0}]]},"Move to the correct folder1":{"main":[[{"node":"Gmail","type":"main","index":0},{"node":"Google Drive","type":"main","index":0}]]},"Only invoice mails with attachments":{"main":[[{"node":"Upload PDF to Drive1","type":"main","index":0}],[{"node":"Gmail","type":"main","index":0}]]}}}


name: Automated Content Generation & Publishing - Wordpress
author_name: Sunny
author_username: xicpoywriter
categories: []
created_at: 2025-02-26T05:00:48.559Z
updated_at: 2025-02-26T05:00:48.559Z
url: https://n8n.io/workflows/3018
scraped_at: 2025-07-06 21:16:30
description:
  Workflow Description: Automated Content Publishing for WordPress
  This n8n workflow automates the entire process of content generation, image selection, and scheduled publishing to a self-hosted WordPress website. It is designed for bloggers, marketers, and businesses who want to streamline their content creation and posting workflow.

  🌟 Features
  ✅ AI-Powered Content Generation  
  Uses ChatGPT to generate engaging, market-ready blog articles  
  Dynamically incorporates high-search volume keywords  

  ✅ Automated Image Selection  
  Searches for relevant stock images from Pexels  
  Embeds images directly into posts  
  (Optional)* Supports *Featured Image from URL (FIFU) plugin** for WordPress  

  ✅ Scheduled & Randomized Posting  
  Automatically schedules posts at predefined intervals  
  Supports randomized delay (0-6 hours) for natural publishing  

  ✅ WordPress API Integration  
  Uses WordPress REST API to directly publish posts  
  Configures featured images, categories, and metadata  
  Supports SEO-friendly meta fields  

  ✅ Flexible & Customizable  
  Works with any WordPress website (self-hosted)  
  Can be modified for other CMS platforms  

  🔧 How It Works
  1️⃣ Trigger & Scheduling  
     Automatically runs at preset times or on-demand  
     Supports cron-like scheduling  

  2️⃣ AI Content Generation  
     Uses a well-crafted prompt to generate high-quality blog posts  
     Extracts relevant keywords for both SEO and image selection  

  3️⃣ Image Fetching from Pexels  
     Searches and retrieves high-quality images  
     Embeds image credits and ensures proper formatting  

  4️⃣ WordPress API Integration  
     Sends post title, content, image, and metadata via HTTP Request  
     Can include custom fields, categories, and tags  

  5️⃣ Randomized Delay Before Publishing  
     Ensures natural posting behavior  
     Avoids bulk publishing issues  

  📌 Requirements
  Self-hosted WordPress website* with *REST API enabled**  
  FIFU Plugin* (optional) for *external featured images**  
  n8n Self-Hosted or Cloud Instance**  

  🚀 Who Is This For?
  ✅ Bloggers who want to automate content publishing  
  ✅ Marketing teams looking to scale content production  
  ✅ Business owners who want to boost online presence  
  ✅ SEO professionals who need consistent, optimized content  

  💡 Ready to Automate?
  👉 Click here to get this workflow! (Replace with Purchase URL)

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

workflow_json:
  {"id":"YOUR_WORKFLOW_ID","meta":{"instanceId":"YOUR_INSTANCE_ID","templateCredsSetupCompleted":true},"name":"Automated Content Generation & Publishing - Wordpress","tags":[],"nodes":[{"id":"9cd63357-19dc-4420-baa9-1e1389c7120f","name":"Create posts on Wordpress","type":"n8n-nodes-base.wordpress","position":[1180,280],"parameters":{"title":"={{ $('Save to Sheet').item.json['title'] }}","additionalFields":{"status":"publish","content":"=<img src=\"{{ $('Automated Image Retrieval from Pexels').item.json.photos[0].src.landscape }}\" alt=\"image text\" style=\"width:100%; height:auto;\"><br><br>\n<br><br>\n{{ $node['Save to Sheet'].json['content'] }}"}},"credentials":{"wordpressApi":{"id":"YOUR_WORDPRESS_CREDENTIAL_ID","name":"Wordpress account 2"}},"typeVersion":1,"alwaysOutputData":false},{"id":"65f62f19-d10f-4ca1-a853-9cedb3506743","name":"Processing Delay","type":"n8n-nodes-base.code","position":[180,580],"parameters":{"jsCode":"const delay = Math.floor(Math.random() * (6 * 60 * 60 * 1000)); // random delay 0-6 hour\nreturn {\n  json: {\n    delay: delay,\n    delay_minutes: Math.round(delay / 60000),  // to minutes\n    delay_hours: (delay / 3600000).toFixed(2) // to hours\n  }\n};\n"},"typeVersion":2},{"id":"193d2876-c50e-4b9e-8856-9fd11baa025e","name":"Random Wait","type":"n8n-nodes-base.wait","position":[180,760],"webhookId":"61377399-ce9f-497a-80b1-aab29fc9fb69","parameters":{"amount":"={{$json[\"delay\"] / 1000}}"},"typeVersion":1.1},{"id":"cf510c21-7c19-4e84-a43a-62d170277cdf","name":"Save to Sheet","type":"n8n-nodes-base.googleSheets","position":[780,280],"parameters":{"columns":{"value":{"title":"={{ $json.message.content.title }}","content":"={{ $json.message.content.content }}","Image search keyword":"={{ $json.message.content.keywords.join(\"+\") }}"},"schema":[{"id":"title","type":"string","display":true,"removed":false,"required":false,"displayName":"title","defaultMatch":false,"canBeUsedToMatch":true},{"id":"content","type":"string","display":true,"required":false,"displayName":"content","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Image search keyword","type":"string","display":true,"required":false,"displayName":"Image search keyword","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[]},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"name","value":"Sheet1"},"documentId":{"__rl":true,"mode":"url","value":"YOURDOCUMENT_URL"}},"credentials":{"googleSheetsOAuth2Api":{"id":"YOUR_GOOGLE_SHEETS_CREDENTIAL_ID","name":"Google Sheets account_正確"}},"typeVersion":4.5},{"id":"1778f649-c09e-4ef9-b153-4160eed6805c","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-220,0],"parameters":{"width":607.503259452412,"height":892.7656453715782,"content":"## Automated Article Scheduling\n\n**1. Fast Bulk Article Generation**\nQuickly create multiple AI-generated articles.\nEfficiently streamline content creation.\nReduces manual effort while maintaining quality.\n\n**2. Workflow Testing Before Execution**\nManually test the workflow for debugging.\nEnsure each step runs as expected.\nOptimize before full automation.\n\n**3. Automated & Randomized Publishing**\nSchedule posts at predefined intervals.\nIntroduce random delays for a natural posting pattern.\nPrevents overly predictable publishing behavior."},"typeVersion":1},{"id":"6f385e8c-b3e6-4456-9738-e85ea2cbbea1","name":"1. Auto Start","type":"n8n-nodes-base.scheduleTrigger","disabled":true,"position":[180,20],"parameters":{"rule":{"interval":[{"field":"minutes","minutesInterval":1}]}},"typeVersion":1.2},{"id":"6d7712e8-9033-453b-ad52-09f718bcb701","name":"2. When clicking ‘Test workflow’","type":"n8n-nodes-base.manualTrigger","disabled":true,"position":[180,200],"parameters":{},"typeVersion":1},{"id":"0fd8fe8f-a0d5-42d9-b728-53340c6e4233","name":"3. Schedule Your Posts","type":"n8n-nodes-base.scheduleTrigger","position":[180,380],"parameters":{"rule":{"interval":[{"field":"weeks","triggerAtDay":[2,4,0],"triggerAtHour":"={{ 12 }}"}]}},"typeVersion":1.2},{"id":"16c26c36-fb8e-4903-a64c-57803fac83b9","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[400,440],"parameters":{"width":351.77682676671327,"height":271.4285686334568,"content":"## AI Content Generating\n\n**Automatic Content & Keyword Generation\n\n- Use your own prompt to start\n- ChatGPT generates full-length articles with structured headings.\n- Extracts relevant image search keywords for visual enhancement.\n- To implement this, add the following prompt (green note) below your workflow:\n"},"typeVersion":1},{"id":"921173fb-ae10-4f88-a1ab-15f063cd623f","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[400,740],"parameters":{"color":4,"width":349.47344203333904,"height":1277.4269457977707,"content":"(YOUR PROMPT)\n\n**Image Search Keywords (For Visual Alignment)**\n\n- Automatically generates 3-5 English keywords for image searches based on the article content.\n- Keywords should be specific objects, locations, or atmospheres rather than abstract concepts.\n\n**Article Formatting Requirements**\n\n1️⃣ Title (H1): Ensure unique and trend-driven headlines.\n2️⃣ H2 / H3 Subheadings: Structure content in an SEO-optimized format.\n3️⃣ Article Structure (Enhanced Readability)\n\n** Introduction **\n- Go straight to the point, avoiding excessive background.\n- Use question hooks or market trend data to engage readers.\n\n** Core Content **\n- Include at least three knowledge points to ensure depth.\n- Balance short and long sentences for better flow.\n\n** Conclusion **\n- Avoid generic AI-style summaries; instead, provide insights or actionable takeaways.\n- Optionally include a CTA (Call to Action).\n\n** HTML Formatting **\nEnsure the article is properly structured in HTML format:\n- Headings: Use <h1>, <h2>, <h3> appropriately.\n- Paragraphs: Enclose text within <p>.\n- Emphasized Words: Use <strong> to highlight key terms.\n- Lists: Use <ul> and <li> for bullet points.\n\nEnsure a clean, well-structured output instead of plain text.\n\n### **Final JSON Format\nEnsure the output follows this structure:\n\n{\n  \"title\": \"{Generate an H1 title that aligns with market trends, ensures high click-through rates, and follows keyword strategy}\",\n  \"content\": \"{Generate a complete HTML article including H1, H2, H3 headings, paragraphs, lists, etc.}\",\n  \"keywords\": [\"{Image search keyword 1}\", \"{Image search keyword 2}\", \"{Image search keyword 3}\", \"{Image search keyword 4}\", \"{Image search keyword 5}\"]\n}"},"typeVersion":1},{"id":"364b1ee1-4685-4b10-b988-1704dc65592b","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[760,440],"parameters":{"width":367.1064142931126,"height":267.17005729996885,"content":"## Google Sheet Setting\n**You need to set up these in your sheet column** \n- title\n- content\n- image search keyword\n\n**Mapping \"Values to Send\"**\n- {{ $json.message.content.title }}\n- {{ $json.message.content.content }}\n- {{ $json.message.content.keywords.join(\"+\") }}"},"typeVersion":1},{"id":"26876b53-aa27-4e16-991e-c3618e751c17","name":"Automated Image Retrieval from Pexels","type":"n8n-nodes-base.httpRequest","position":[980,280],"parameters":{"url":"=https://api.pexels.com/v1/search?per_page=1&orientation=landscape&query={{ $json[\"Image search keyword\"] }}\n","options":{},"sendQuery":true,"sendHeaders":true,"queryParameters":{"parameters":[{"name":"query","value":"={{ $json['Image search keyword'] }}"}]},"headerParameters":{"parameters":[{"name":"Authorization","value":"YOUR_PEXELS_API_KEY"},{"name":"Content-Type","value":"application/json"}]}},"typeVersion":4.2},{"id":"769638be-ee38-4e40-a508-f998b09ce1f4","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-220,-240],"parameters":{"color":3,"width":608.0701163493336,"height":211.65896369815192,"content":"## Introduction: WordPress automatically publishes posts and inserts the first image\n\nIt is **highly recommended to install the Featured Image from URL (FIFU) plugin** and enable:\n\n**Auto > Set Featured Media Automatically from Content.** before you generate contents."},"typeVersion":1},{"id":"37f3606f-f110-49d2-bcf5-1edc27149fee","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[400,229.99235545929986],"parameters":{"width":348.08256103956126,"height":170.00764454070014,"content":"Add your API credential"},"typeVersion":1},{"id":"2399a40d-4b79-400c-9e96-df7e683fd666","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[760,228.00611563256007],"parameters":{"width":150,"height":170.00764454070008,"content":"Add your API credential"},"typeVersion":1},{"id":"45e479a6-2eea-44a1-9096-9895a18904fd","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[920,226.01987580582022],"parameters":{"width":201.97095074533956,"height":172.00917344884022,"content":"Add your API credential"},"typeVersion":1},{"id":"e0489552-a7b5-4161-9553-95e23605a9d5","name":"Generate AI Content","type":"@n8n/n8n-nodes-langchain.openAi","position":[440,280],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o","cachedResultName":"GPT-4O"},"options":{},"messages":{"values":[{"content":"(YOUR PROMPT)\n(YOUR PROMPT)\n\n**Image Search Keywords (For Visual Alignment)**\n\n- Automatically generates 3-5 English keywords for image searches based on the article content.\n- Keywords should be specific objects, locations, or atmospheres rather than abstract concepts.\n\n**Article Formatting Requirements**\n\n1️⃣ Title (H1): Ensure unique and trend-driven headlines.\n2️⃣ H2 / H3 Subheadings: Structure content in an SEO-optimized format.\n3️⃣ Article Structure (Enhanced Readability)\n\n** Introduction **\n- Go straight to the point, avoiding excessive background.\n- Use question hooks or market trend data to engage readers.\n\n** Core Content **\n- Include at least three knowledge points to ensure depth.\n- Balance short and long sentences for better flow.\n\n** Conclusion **\n- Avoid generic AI-style summaries; instead, provide insights or actionable takeaways.\n- Optionally include a CTA (Call to Action).\n\n** HTML Formatting **\nEnsure the article is properly structured in HTML format:\n- Headings: Use <h1>, <h2>, <h3> appropriately.\n- Paragraphs: Enclose text within <p>.\n- Emphasized Words: Use <strong> to highlight key terms.\n- Lists: Use <ul> and <li> for bullet points.\n\nEnsure a clean, well-structured output instead of plain text.\n\n### **Final JSON Format\nEnsure the output follows this structure:\n\n{\n  \"title\": \"{Generate an H1 title that aligns with market trends, ensures high click-through rates, and follows keyword strategy}\",\n  \"content\": \"{Generate a complete HTML article including H1, H2, H3 headings, paragraphs, lists, etc.}\",\n  \"keywords\": [\"{Image search keyword 1}\", \"{Image search keyword 2}\", \"{Image search keyword 3}\", \"{Image search keyword 4}\", \"{Image search keyword 5}\"]\n}"}]},"jsonOutput":true},"credentials":{"openAiApi":{"id":"YOUR_OPENAI_CREDENTIAL_ID","name":"OpenAi account"}},"typeVersion":1.6}],"active":false,"pinData":{},"settings":{"timezone":"Asia/Taipei","callerPolicy":"workflowsFromSameOwner","executionOrder":"v1","executionTimeout":-1,"saveManualExecutions":true},"versionId":"YOUR_VERSION_ID","connections":{"Random Wait":{"main":[[{"node":"Generate AI Content","type":"main","index":0}]]},"Save to Sheet":{"main":[[{"node":"Automated Image Retrieval from Pexels","type":"main","index":0}]]},"Processing Delay":{"main":[[{"node":"Random Wait","type":"main","index":0}]]},"Generate AI Content":{"main":[[{"node":"Save to Sheet","type":"main","index":0}]]},"3. Schedule Your Posts":{"main":[[{"node":"Processing Delay","type":"main","index":0}]]},"Automated Image Retrieval from Pexels":{"main":[[{"node":"Create posts on Wordpress","type":"main","index":0}]]}}}


name: 🧠 Empower Your AI Chatbot with Long-Term Memory and Dynamic Tool Routing
author_name: Joseph LePage
author_username: joe
categories: []
created_at: 2025-02-27T00:45:40.068Z
updated_at: 2025-02-27T00:45:40.068Z
url: https://n8n.io/workflows/3025
scraped_at: 2025-07-06 21:16:30
description:
  Empower Your AI Chatbot with Long-Term Memory and Dynamic Tool Routing

  This n8n workflow equips your AI agent with long-term memory and a dynamic tools router, enabling it to provide intelligent, context-aware responses while managing tasks across multiple tools. By combining persistent memory and modular task routing, this workflow makes your AI smarter, more efficient, and highly adaptable.

  👥 Who Is This For?

  AI Developers & Automation Enthusiasts: Integrate advanced AI features like long-term memory and task routing without coding expertise.  
  Businesses & Teams: Automate tasks while maintaining personalized, context-aware interactions.  
  Customer Support Teams: Improve user experience with chatbots that remember past interactions.  
  Marketers & Content Creators: Streamline communication across platforms like Gmail and Telegram.  
  AI Researchers: Experiment with persistent memory and multi-tool integration.

  🚀 What Problem Does This Solve?

  This workflow simplifies the creation of intelligent AI systems that retain memory, manage tasks dynamically, and automate notifications across tools like Gmail and Telegram—saving time and improving efficiency.

  🛠️ What This Workflow Does

  Save & Retrieve Memories**: Uses Google Docs for long-term storage to recall past interactions or user preferences.  
  Dynamic Task Routing**: Routes tasks to the right tools (e.g., saving/retrieving memories or sending notifications).  
  AI-Powered Context Understanding**: Combines OpenAI GPT-based short-term memory with long-term memory for smarter responses.  
  Multi-Channel Notifications**: Sends updates via Gmail or Telegram.

  🔧 Setup

  API Credentials:
     Connect to OpenAI (AI processing), Google Docs (memory storage), Gmail/Telegram (notifications).  
  Customize Parameters:
     Adjust the AI agent's system message for your use case.
     Define task-routing rules in the tools router node.
  Test & Deploy:
     Verify memory saving/retrieval, task routing, and notification delivery.

  💡 How to Customize

  Modify the system message in the OpenAI node to tailor your agent’s behavior.
  Add or adjust routing rules for additional tools.
  Update notification settings to match your communication preferences.

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

workflow_json:
  {"id":"p7xESnT1xMZD2hRk","meta":{"instanceId":"31e69f7f4a77bf465b805824e303232f0227212ae922d12133a0f96ffeab4fef","templateCredsSetupCompleted":true},"name":"🧠 Give Your AI Agent Chatbot Long Term Memory Tools Router","tags":[],"nodes":[{"id":"d5947a9d-bad4-4db7-8cdb-dc277928565a","name":"When Executed by Another Workflow","type":"n8n-nodes-base.executeWorkflowTrigger","position":[320,-80],"parameters":{"inputSource":"passthrough"},"typeVersion":1.1},{"id":"c9e9715d-c691-4516-9e0c-cf393a18d814","name":"Save Long Term Memories","type":"n8n-nodes-base.googleDocs","position":[1020,-80],"parameters":{"actionsUi":{"actionFields":[{"text":"={\n  \"date\": \"{{ $now }}\",\n  \"memory\": \"{{ $json.query }}\"\n},\n","action":"insert"}]},"operation":"update","documentURL":"1YFTbVGlnpdYF5FuA6grfyvzmcdjcPviClAqbJ5HJIlc"},"credentials":{"googleDocsOAuth2Api":{"id":"YWEHuG28zOt532MQ","name":"Google Docs account"}},"typeVersion":2},{"id":"306272bf-e264-4cfb-b8b6-8c0af1de3f14","name":"Saved response","type":"n8n-nodes-base.set","position":[1200,-80],"parameters":{"options":{},"assignments":{"assignments":[{"id":"6b7e85d8-379b-4a0f-9799-9193a29f0447","name":"response","type":"string","value":"Memory saved"}]}},"typeVersion":3.4},{"id":"152b6922-8600-4fdb-8372-3b0102a7b73a","name":"Respond with long term memories","type":"n8n-nodes-base.set","position":[1200,220],"parameters":{"options":{},"assignments":{"assignments":[{"id":"6b7e85d8-379b-4a0f-9799-9193a29f0447","name":"response","type":"string","value":"={{ $json.content }}"}]}},"typeVersion":3.4},{"id":"147ddd8d-6e42-44c0-95ca-9ab791f9452f","name":"Retrieve Long Term Memories3","type":"n8n-nodes-base.googleDocs","position":[1020,900],"parameters":{"operation":"get","documentURL":"1YFTbVGlnpdYF5FuA6grfyvzmcdjcPviClAqbJ5HJIlc"},"credentials":{"googleDocsOAuth2Api":{"id":"YWEHuG28zOt532MQ","name":"Google Docs account"}},"typeVersion":2},{"id":"e3f1172b-ce33-4cce-8126-88e19afc53c6","name":"Send Success Message to Telegram","type":"n8n-nodes-base.telegram","position":[1540,520],"webhookId":"3ba1ee6d-1648-4421-823b-e68ae14d769b","parameters":{"text":"=n8n User Memories\n{{ $json.text }}","chatId":"={{ $env.TELEGRAM_CHAT_ID }}","additionalFields":{"parse_mode":"HTML","appendAttribution":false}},"credentials":{"telegramApi":{"id":"pAIFhguJlkO3c7aQ","name":"Telegram account"}},"typeVersion":1.2},{"id":"a77e8f01-889f-44b5-b4e1-493a97aa028c","name":"Email Workflow Stats","type":"n8n-nodes-base.gmail","position":[1540,900],"webhookId":"d9ef6f36-941f-4110-9b3e-9e54d9bc9581","parameters":{"sendTo":"={{ $env.EMAIL_ADDRESS_JOE }}","message":"={{ $json.text }}","options":{"appendAttribution":false},"subject":"n8n User Memories"},"credentials":{"gmailOAuth2":{"id":"1xpVDEQ1yx8gV022","name":"Gmail account"}},"typeVersion":2.1},{"id":"2481fe73-9ef8-4e95-b7e5-38634b55837c","name":"OpenAI Chat Model2","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[1320,660],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.2},{"id":"9a45e091-c91c-4505-a8df-7a2e1d079200","name":"OpenAI Chat Model3","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[1320,1040],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.2},{"id":"6d12369e-38de-44c1-b764-64d6d9a79a25","name":"📤Send Memories to Telegram","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[1360,-500],"parameters":{"name":"send_memories_to_telegram","fields":{"values":[{"name":"route","stringValue":"=send_memories_to_telegram"}]},"workflowId":{"__rl":true,"mode":"id","value":"={{ $workflow.id }}"},"description":"Call this tool to send memories to Telegram","jsonSchemaExample":""},"typeVersion":1.2},{"id":"f1d0b366-70d5-4da3-937b-ea08afd364e4","name":"📫Send Memories to Gmail","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[1620,-500],"parameters":{"name":"send_memories_to_gmail","fields":{"values":[{"name":"route","stringValue":"=send_memories_to_gmail"}]},"workflowId":{"__rl":true,"mode":"id","value":"={{ $workflow.id }}"},"description":"Call this tool to send memories to Gmail","jsonSchemaExample":""},"typeVersion":1.2},{"id":"25d99971-263a-44ef-abb0-b517743f72eb","name":"🧠Save Memories","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[840,-500],"parameters":{"name":"save_long_term_memory","fields":{"values":[{"name":"route","stringValue":"=save_memory"}]},"workflowId":{"__rl":true,"mode":"id","value":"={{ $workflow.id }}"},"description":"Call this tool to save long term memories","jsonSchemaExample":""},"typeVersion":1.2},{"id":"0c9738d3-176a-4074-8340-ecfa3d9f9f7d","name":"🔎Retrieve Memories","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[1100,-500],"parameters":{"name":"retrieve_long_term_memory","fields":{"values":[{"name":"route","stringValue":"=retrieve_memory"}]},"workflowId":{"__rl":true,"mode":"id","value":"={{ $workflow.id }}"},"description":"Call this tool to retrieve long term memories","jsonSchemaExample":""},"typeVersion":1.2},{"id":"7967ec27-432e-4d35-b7e0-89eb84120754","name":"🤯Window Buffer Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[520,-500],"parameters":{"contextWindowLength":10},"typeVersion":1.3},{"id":"5f24781e-4f9a-4e33-8d33-ce281f7bcc46","name":"🧠 AI Agent w/Long Term Memory","type":"@n8n/n8n-nodes-langchain.agent","position":[940,-920],"parameters":{"options":{"systemMessage":"=You are a highly capable and intelligent assistant designed to assist users by leveraging tools for long-term memory, contextual understanding, and real-time information retrieval.  You have excellent long term memory.  The current date and time is {{ $now }}\n\n## TOOLS\n-save_long_term_memory\n-retrieve_long_term_memory\n-send_memories_to_gmail\n-send_memories_to_telegram\n\n## RULES\n- If you do not know the answer then consider checking the long term memories.\n\n\n\n\n\n"}},"typeVersion":1.7},{"id":"ad644413-6587-415f-b7be-d58c05b94138","name":"🤖OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[260,-500],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.2},{"id":"076b0856-5ba4-498e-b279-21cf042f7f07","name":"Ⓜ️ When chat message received","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[380,-920],"webhookId":"2060403b-3fea-4fdf-a6d7-693bc477baaf","parameters":{"options":{}},"typeVersion":1.1},{"id":"fcf5872c-fcdc-445e-b095-f9cef14453b8","name":"Prepare Telegram Message","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[1200,520],"parameters":{"text":"=Format this content into a simple unformatted list that can be sent to Telegram: {{ $json.content }}.  Avoid any preamble or further explanation.","promptType":"define"},"typeVersion":1.5},{"id":"c1d05bb9-390b-43aa-820d-45115df07f5c","name":"Prepare Gmail Message","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[1200,900],"parameters":{"text":"=Format this content into a simple and modern HTML table that is max 800px wide that can be used as the content for an email: {{ $json.content }}.  Avoid any preamble or further explanation.  Remove all ``` and ```html from response.","promptType":"define"},"typeVersion":1.5},{"id":"98aa87af-8329-4af6-85da-fc97cb4ed9c3","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[760,-620],"parameters":{"color":4,"height":280,"content":"## 1️⃣ Save Memories"},"typeVersion":1},{"id":"677f62ba-b009-48da-988e-e58d5063d005","name":"Retrieve Long Term Memories","type":"n8n-nodes-base.googleDocs","position":[1020,220],"parameters":{"operation":"get","documentURL":"1YFTbVGlnpdYF5FuA6grfyvzmcdjcPviClAqbJ5HJIlc"},"credentials":{"googleDocsOAuth2Api":{"id":"YWEHuG28zOt532MQ","name":"Google Docs account"}},"typeVersion":2},{"id":"1c732f83-fb09-4a51-8aea-0f9d29d1cdfe","name":"Memory Tool Router","type":"n8n-nodes-base.switch","position":[640,-100],"parameters":{"rules":{"values":[{"outputKey":"1️⃣ Save","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.route }}","rightValue":"save_memory"}]},"renameOutput":true},{"outputKey":" 2️⃣Retrieve ","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"86d44336-bab7-422f-9266-fcb513252d19","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.route }}","rightValue":"retrieve_memory"}]},"renameOutput":true},{"outputKey":" 3️⃣Telegram","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"29f37628-6381-46af-babb-74bf00b4a849","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.route }}","rightValue":"send_memories_to_telegram"}]},"renameOutput":true},{"outputKey":"4️⃣Gmail","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"fdb7c8aa-4108-43f6-8f6b-71cd8f383d2a","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.route }}","rightValue":"send_memories_to_gmail"}]},"renameOutput":true}]},"options":{}},"typeVersion":3.2},{"id":"79de3862-b15a-4380-ab27-cfde66e8bb95","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[1280,-620],"parameters":{"color":6,"height":280,"content":"## 3️⃣ Send Memories to Telegram"},"typeVersion":1},{"id":"03df9947-9354-4f21-8b8a-fed130dcfc6a","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[1540,-620],"parameters":{"color":6,"height":280,"content":"## 4️⃣ Send Memories to Gmail"},"typeVersion":1},{"id":"9e8ee085-ec68-4f64-9098-877e166b1c37","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[1020,-620],"parameters":{"color":4,"height":280,"content":"## 2️⃣ Retrieve Memories"},"typeVersion":1},{"id":"9c3d6609-cc4a-4bf5-b914-ee57e085cecd","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[440,-620],"parameters":{"color":3,"height":280,"content":"## Short Term Chat Memory"},"typeVersion":1},{"id":"97f47b93-c1e1-4230-b84c-3b99aa140d55","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[180,-620],"parameters":{"color":5,"height":280,"content":"## Cloud LLM"},"typeVersion":1},{"id":"4758ad55-d5f2-4a87-a05a-be465d803ca1","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[120,-1100],"parameters":{"width":1740,"height":840,"content":"# 🧠 AI Agent Chatbot With Long Term Memory Tools"},"typeVersion":1},{"id":"eb74a05d-7f34-4ba0-ae98-c22bb3637c6b","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[720,-700],"parameters":{"color":7,"width":1100,"height":400,"content":"## 🛠️ Agentic Long Term Memory Management Tool Options"},"typeVersion":1},{"id":"d9d251d2-172b-4a8e-bec3-bf8f297628c6","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[280,-980],"parameters":{"color":4,"width":300,"height":240,"content":"## 👍Try Me!"},"typeVersion":1},{"id":"90554969-0b73-4d4d-87f2-37645b9f7f08","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[920,-160],"parameters":{"color":4,"width":560,"height":280,"content":"## 1️⃣ Save Long Term Memories Tool"},"typeVersion":1},{"id":"34cbb84d-48a5-480f-a7c3-81bbef24194a","name":"Sticky Note10","type":"n8n-nodes-base.stickyNote","position":[920,140],"parameters":{"color":4,"width":560,"height":280,"content":"## 2️⃣ Retrieve Long Term Memories Tool"},"typeVersion":1},{"id":"dc23d68e-0f93-495a-aaa0-e4bb6f18870d","name":"Sticky Note11","type":"n8n-nodes-base.stickyNote","position":[920,440],"parameters":{"color":6,"width":840,"height":360,"content":"## 3️⃣ Send Memories to Telegram Tool"},"typeVersion":1},{"id":"0ed43ec0-a39c-4323-9851-988e774302d7","name":"Retrieve Long Term Memories2","type":"n8n-nodes-base.googleDocs","position":[1020,520],"parameters":{"operation":"get","documentURL":"1YFTbVGlnpdYF5FuA6grfyvzmcdjcPviClAqbJ5HJIlc"},"credentials":{"googleDocsOAuth2Api":{"id":"YWEHuG28zOt532MQ","name":"Google Docs account"}},"typeVersion":2},{"id":"17d2cef6-765c-4fb4-8af0-1ebc868f6669","name":"Sticky Note12","type":"n8n-nodes-base.stickyNote","position":[920,820],"parameters":{"color":6,"width":840,"height":360,"content":"## 4️⃣ Send Memories to Gmail Tool"},"typeVersion":1},{"id":"03977fa0-a4cd-4cfe-8967-d6a5e3227200","name":"Sticky Note13","type":"n8n-nodes-base.stickyNote","position":[540,-220],"parameters":{"color":2,"width":300,"height":380,"content":"## Memory Tool Router"},"typeVersion":1},{"id":"994b124c-4f5b-44c6-845e-9886d7b5f07d","name":"Sticky Note14","type":"n8n-nodes-base.stickyNote","position":[240,-220],"parameters":{"color":7,"width":260,"height":380,"content":"## Receive Memory Tool Instructions from Agent"},"typeVersion":1},{"id":"7c400ccf-af37-4b5a-8dfe-431a7d52286b","name":"Sticky Note15","type":"n8n-nodes-base.stickyNote","position":[880,-220],"parameters":{"color":7,"width":920,"height":1440,"content":"## 🛠️ Long Term Memory Tool Kit"},"typeVersion":1},{"id":"0b00f892-f98b-41be-952c-570da546f9f7","name":"Sticky Note16","type":"n8n-nodes-base.stickyNote","position":[120,200],"parameters":{"width":720,"height":1300,"content":"## Enhance Your AI Workflow with Long-Term Memory and Dynamic Tool Routing\n\n#### This n8n workflow empowers your AI agent with **long-term memory** and a **dynamic tools router**, enabling it to provide intelligent, context-aware responses while seamlessly managing tasks across multiple tools. By combining memory persistence and modular tool routing, this solution enhances the capabilities of your AI agent, making it smarter, more efficient, and highly adaptable.\n\n## 🚀 How It Works\n\n#### 🧠 Long-Term Memory Management\n- The AI agent can **save** and **retrieve memories** using Google Docs as a storage system.\n- Persistent memory allows the agent to recall past interactions, user preferences, and contextual details for personalized responses.\n\n#### 🛠️ Tools Router for Dynamic Task Management\n- A **tools router** directs tasks to the appropriate tools based on the AI agent's instructions.\n- Supported tools include:\n  - **Save Memories**: Store important data for future reference.\n  - **Retrieve Memories**: Access stored information when needed.\n  - **Send Notifications via Gmail or Telegram**: Share insights or updates with stakeholders.\n\n#### 🤖 AI-Powered Contextual Understanding\n- The workflow integrates an OpenAI GPT-based model to process user inputs intelligently.\n- The AI agent uses a **window buffer memory** for short-term context and leverages long-term memory when necessary.\n\n#### 📤 Multi-Channel Notifications\n- Automatically send memory summaries or workflow updates via Gmail or Telegram for enhanced communication.\n\n---\n\n## 🔧 Setup Steps\n\n#### 🔑 Configure API Credentials\nSet up API connections for:\n- **OpenAI** (for AI processing).\n- **Google Docs** (for long-term memory storage).\n- **Gmail/Telegram** (for notifications).\n\n#### ⚙️ Customize Workflow Parameters\n- Adjust the AI agent's system message to align with your specific use case or tone.\n- Define routing rules in the tools router to suit your workflow needs.\n\n#### 🧪 Test & Deploy\n- Test the workflow by interacting with the AI agent and verifying:\n  - Accurate memory saving/retrieval.\n  - Correct task routing via the tools router.\n  - Seamless notification delivery.\n"},"typeVersion":1}],"active":false,"pinData":{},"settings":{"timezone":"America/Vancouver","callerPolicy":"workflowsFromSameOwner","executionOrder":"v1"},"versionId":"5d92d73f-0341-4ab1-937e-6be387f6ea52","connections":{"🧠Save Memories":{"ai_tool":[[{"node":"🧠 AI Agent w/Long Term Memory","type":"ai_tool","index":0}]]},"Memory Tool Router":{"main":[[{"node":"Save Long Term Memories","type":"main","index":0}],[{"node":"Retrieve Long Term Memories","type":"main","index":0}],[{"node":"Retrieve Long Term Memories2","type":"main","index":0}],[{"node":"Retrieve Long Term Memories3","type":"main","index":0}]]},"OpenAI Chat Model2":{"ai_languageModel":[[{"node":"Prepare Telegram Message","type":"ai_languageModel","index":0}]]},"OpenAI Chat Model3":{"ai_languageModel":[[{"node":"Prepare Gmail Message","type":"ai_languageModel","index":0}]]},"Prepare Gmail Message":{"main":[[{"node":"Email Workflow Stats","type":"main","index":0}]]},"🔎Retrieve Memories":{"ai_tool":[[{"node":"🧠 AI Agent w/Long Term Memory","type":"ai_tool","index":0}]]},"🤖OpenAI Chat Model":{"ai_languageModel":[[{"node":"🧠 AI Agent w/Long Term Memory","type":"ai_languageModel","index":0}]]},"Save Long Term Memories":{"main":[[{"node":"Saved response","type":"main","index":0}]]},"Prepare Telegram Message":{"main":[[{"node":"Send Success Message to Telegram","type":"main","index":0}]]},"🤯Window Buffer Memory":{"ai_memory":[[{"node":"🧠 AI Agent w/Long Term Memory","type":"ai_memory","index":0}]]},"📫Send Memories to Gmail":{"ai_tool":[[{"node":"🧠 AI Agent w/Long Term Memory","type":"ai_tool","index":0}]]},"Retrieve Long Term Memories":{"main":[[{"node":"Respond with long term memories","type":"main","index":0}]]},"Retrieve Long Term Memories2":{"main":[[{"node":"Prepare Telegram Message","type":"main","index":0}]]},"Retrieve Long Term Memories3":{"main":[[{"node":"Prepare Gmail Message","type":"main","index":0}]]},"📤Send Memories to Telegram":{"ai_tool":[[{"node":"🧠 AI Agent w/Long Term Memory","type":"ai_tool","index":0}]]},"When Executed by Another Workflow":{"main":[[{"node":"Memory Tool Router","type":"main","index":0}]]},"Ⓜ️ When chat message received":{"main":[[{"node":"🧠 AI Agent w/Long Term Memory","type":"main","index":0}]]}}}


name: Build Your First AI Data Analyst Chatbot
author_name: Solomon
author_username: solomon
categories: []
created_at: 2025-03-01T12:08:21.886Z
updated_at: 2025-03-01T12:08:21.886Z
url: https://n8n.io/workflows/3050
scraped_at: 2025-07-06 21:16:30
description:
  Enhance your data analysis by connecting an AI Agent to your dataset, using n8n tools.

  This template teaches you how to build an AI Data Analyst Chatbot that is capable of pulling data from your sources, using tools like Google Sheets or databases. It's designed to be easy and efficient, making it a good starting point for AI-driven data analysis.

  You can easily replace the current Google Sheets tools for databases like Postgres or MySQL.

  How It Works
  The core of the workflow is the AI Agent. It's connected to different data retrieval tools, to get data from Google Sheets (or your preferred database) in many different ways.

  Once the data is retrieved, the Calculator tool allows the AI to perform mathematical operations, making your data analysis precise.

  Who is this template for
  Data Analysts & Researchers:** Pull data from different sources and perform quick calculations.
  Developers & AI Enthusiasts:** Learn to build your first AI Agent with easy dataset access.
  Business Owners:** Streamline your data analysis with AI insights and automate repetitive tasks.
  Automation Experts:** Enhance your automation skills by integrating AI with your existing databases.

  How to Set Up
  You can find detailed instructions in the workflow itself.

  Check out my other templates
  👉 https://n8n.io/creators/solomon/

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

workflow_json:
  {"meta":{"instanceId":"d6b502dfa4d9dd072cdc5c2bb763558661053f651289291352a84403e01b3d1b","templateCredsSetupCompleted":true},"nodes":[{"id":"0951fd33-1811-4a89-b84f-f46dc9e6fde1","name":"When chat message received","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[20,-340],"webhookId":"cdc03fce-33b6-4eed-86b5-f628994e5e31","parameters":{"options":{}},"typeVersion":1.1},{"id":"699c2f89-5547-4d28-92a9-5e216aecb251","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[240,-340],"parameters":{"options":{"maxIterations":15,"systemMessage":"=You are a helpful assistant.\nCurrent timestamp is {{ $now }}"}},"typeVersion":1.7},{"id":"640c29f7-b67e-49f6-a864-c9b396c446b7","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[160,-100],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o","cachedResultName":"gpt-4o"},"options":{"temperature":0.2}},"credentials":{"openAiApi":{"id":"5LVOlVwHUgB8MAj2","name":"OpenAI - n8n project"}},"typeVersion":1.2},{"id":"807630b4-c138-4b66-a438-fb70eab12a07","name":"Calculator","type":"@n8n/n8n-nodes-langchain.toolCalculator","position":[840,60],"parameters":{},"typeVersion":1},{"id":"132a97a3-239c-403f-843f-55b652e3efc5","name":"Code","type":"n8n-nodes-base.code","position":[840,640],"parameters":{"jsCode":"// Ensure there's at least one input item.\nif (!items || items.length === 0) {\n  throw new Error(\"No input items found.\");\n}\n\n// Our input is expected to have a 'data' property containing the JSONP string.\nconst input = items[0].json;\n\nif (!input.data) {\n  throw new Error(\"Input JSON does not have a 'data' property.\");\n}\n\nconst rawData = input.data;\n\n// Use a regex to extract the JSON content from the Google Visualization JSONP response.\nconst regex = /google\\.visualization\\.Query\\.setResponse\\((.*)\\);?$/s;\nconst match = rawData.match(regex);\n\nif (!match) {\n  throw new Error(\"Input data does not match the expected Google Visualization JSONP format.\");\n}\n\nconst jsonString = match[1];\n\n// Parse the extracted JSON string.\nlet parsed;\ntry {\n  parsed = JSON.parse(jsonString);\n} catch (error) {\n  throw new Error(\"Failed to parse JSON: \" + error.message);\n}\n\n// Verify that the parsed JSON has the expected 'table' structure with 'cols' and 'rows'.\nif (!parsed.table || !Array.isArray(parsed.table.cols) || !Array.isArray(parsed.table.rows)) {\n  throw new Error(\"Parsed JSON does not have the expected 'table' structure with 'cols' and 'rows'.\");\n}\n\nconst cols = parsed.table.cols;\nconst rows = parsed.table.rows;\n\n// Helper function to convert date string from \"Date(YYYY,M,D)\" to \"YYYY-MM-DD\"\nfunction formatDate(dateStr) {\n  const match = dateStr.match(/^Date\\((\\d+),(\\d+),(\\d+)\\)$/);\n  if (!match) return dateStr;\n  const year = parseInt(match[1], 10);\n  const month = parseInt(match[2], 10) + 1; // JavaScript months are 0-indexed\n  const day = parseInt(match[3], 10);\n  // Format with leading zeros\n  return `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`;\n}\n\n// Map each row into an object using the column labels as keys.\nconst newItems = rows.map(row => {\n  const obj = {};\n  cols.forEach((col, index) => {\n    let value = row.c && row.c[index] ? row.c[index].v : null;\n    // If the column type is \"date\" and the value is a string that looks like \"Date(YYYY,M,D)\"\n    if (col.type === \"date\" && typeof value === \"string\") {\n      value = formatDate(value);\n    }\n    obj[col.label] = value;\n  });\n  return { json: obj };\n});\n\n// Return the new array of items.\nreturn newItems;\n"},"typeVersion":2},{"id":"3dc1e670-bfb1-4b63-b9c8-85656134c843","name":"When Executed by Another Workflow","type":"n8n-nodes-base.executeWorkflowTrigger","position":[280,640],"parameters":{"workflowInputs":{"values":[{"name":"start_date"},{"name":"end_date"},{"name":"status"}]}},"typeVersion":1.1},{"id":"52a26e43-12a5-4b4a-a224-d70cdabf6aaf","name":"Records by date","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[1020,-120],"parameters":{"name":"records_by_date_and_or_status","workflowId":{"__rl":true,"mode":"list","value":"a2BIIjr2gLBay06M","cachedResultName":"Template | Your first AI Data Analyst"},"description":"Use this tool to get records filtered by date. You can also filter by status at the same time, if you want.","workflowInputs":{"value":{"status":"={{ $fromAI(\"status\", \"Status of the transaction. Can be Completed, Refund or Error. Leave empty if you don't need this now.\", \"string\") }}","end_date":"={{ $fromAI(\"end_date\", \"End date in format YYYY-MM-DD\", \"string\") }}","start_date":"={{ $fromAI(\"start_date\", \"Start date in format YYYY-MM-DD\", \"string\") }}"},"schema":[{"id":"start_date","type":"string","display":true,"required":false,"displayName":"start_date","defaultMatch":false,"canBeUsedToMatch":true},{"id":"end_date","type":"string","display":true,"required":false,"displayName":"end_date","defaultMatch":false,"canBeUsedToMatch":true},{"id":"status","type":"string","display":true,"removed":false,"required":false,"displayName":"status","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false}},"typeVersion":2},{"id":"e1811519-8699-4243-8c64-0db1ab26004d","name":"Aggregate","type":"n8n-nodes-base.aggregate","position":[1280,640],"parameters":{"options":{},"aggregate":"aggregateAllItemData"},"typeVersion":1},{"id":"3b129abd-ac9a-460c-abb3-007e2c94e284","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[1220,400],"parameters":{"color":7,"width":220,"height":400,"content":"To send all the items back to the AI, we need to finish with everything aggregated into one single item.\n\nOtherwise it will respond with one item at a time, and the AI will only get the first item that arrives."},"typeVersion":1},{"id":"645ac0f9-8022-4f2c-8c6c-5aadd6cf09cc","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[460,400],"parameters":{"color":7,"width":300,"height":400,"content":"This node sends a custom HTTP Request to the Google Sheets API.\n\nFiltering by date range in the Google Sheets API is very complicated.\n\nThis node solves that problem.\n\nBut doing the same in a database is much simpler. A tool could do it without needing a sub-workflow."},"typeVersion":1},{"id":"14221a72-914d-4c75-866a-d64ba7f8109f","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[780,400],"parameters":{"color":7,"width":220,"height":400,"content":"The output from this complex request is also messy.\n\nSo we use some code generated by ChatGPT to transform the data into JSON objects."},"typeVersion":1},{"id":"f12668ea-b59d-4caf-a997-381f78b7cfe7","name":"Google Sheets request","type":"n8n-nodes-base.httpRequest","position":[560,640],"parameters":{"url":"https://docs.google.com/spreadsheets/d/18A4d7KYrk8-uEMbu7shoQe_UIzmbTLV1FMN43bjA7qc/gviz/tq","options":{},"sendQuery":true,"authentication":"predefinedCredentialType","queryParameters":{"parameters":[{"name":"sheet","value":"Sheet1"},{"name":"tq","value":"=SELECT * WHERE A >= DATE \"{{ $json.start_date }}\" AND A <= DATE \"{{ $json.end_date }}\""}]},"nodeCredentialType":"googleSheetsOAuth2Api"},"credentials":{"googleSheetsOAuth2Api":{"id":"YR4pbjuZM5Xs4CTD","name":"Google Sheets"}},"typeVersion":4.2},{"id":"f59a2606-0981-43d1-9a07-b802891b9220","name":"Get transactions by product name","type":"n8n-nodes-base.googleSheetsTool","position":[1020,-320],"parameters":{"options":{},"filtersUI":{"values":[{"lookupValue":"={{ $fromAI(\"product_name\", \"The product name\", \"string\") }}","lookupColumn":"Product"}]},"sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/18A4d7KYrk8-uEMbu7shoQe_UIzmbTLV1FMN43bjA7qc/edit#gid=0","cachedResultName":"Sheet1"},"documentId":{"__rl":true,"mode":"url","value":"https://docs.google.com/spreadsheets/d/18A4d7KYrk8-uEMbu7shoQe_UIzmbTLV1FMN43bjA7qc/edit?usp=sharing"},"descriptionType":"manual","toolDescription":"Find transactions by product.\nOur products are:\n- Widget A\n- Widget B\n- Widget C\n- Widget D"},"credentials":{"googleSheetsOAuth2Api":{"id":"YR4pbjuZM5Xs4CTD","name":"Google Sheets"}},"typeVersion":4.5},{"id":"1ed7168c-1639-4b3b-a3b4-ed162bcef880","name":"Get all transactions","type":"n8n-nodes-base.googleSheetsTool","position":[840,-120],"parameters":{"options":{},"sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/18A4d7KYrk8-uEMbu7shoQe_UIzmbTLV1FMN43bjA7qc/edit#gid=0","cachedResultName":"Sheet1"},"documentId":{"__rl":true,"mode":"url","value":"https://docs.google.com/spreadsheets/d/18A4d7KYrk8-uEMbu7shoQe_UIzmbTLV1FMN43bjA7qc/edit?usp=sharing"},"descriptionType":"manual","toolDescription":"Only use this as last resort, because it will pull all data at once."},"credentials":{"googleSheetsOAuth2Api":{"id":"YR4pbjuZM5Xs4CTD","name":"Google Sheets"}},"typeVersion":4.5},{"id":"798453da-8a65-4d14-ae0a-778d64ab02ad","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-360,-340],"parameters":{"color":4,"width":320,"height":340,"content":"## Some questions to try\nThere's a red button on this page that you can click to chat with the AI.\n\nTry asking it these questions:\n\n- How many refunds in January and what was the amount refunded?\n\n- How many successful sales did we have in January 2025 and what was the final income of those?\n\n- What is the most frequent reason for refunds?"},"typeVersion":1},{"id":"b8336f1a-3855-4247-9589-2f9aa35d211f","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-780,-340],"parameters":{"color":4,"width":400,"content":"## Copy this Sheets file to your Google Drive\nhttps://docs.google.com/spreadsheets/d/18A4d7KYrk8-uEMbu7shoQe_UIzmbTLV1FMN43bjA7qc/edit?gid=0#gid=0"},"typeVersion":1},{"id":"99a55b39-965b-4454-b416-d3991f0bdfbc","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[940,60],"parameters":{"color":7,"width":200,"height":140,"content":"### 👈\nThe Calculator is a tool that allows an agent to run mathematical calculations."},"typeVersion":1},{"id":"7ebebf56-e065-41c4-8270-f636785b0def","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[-780,-160],"parameters":{"color":4,"width":400,"content":"### How to connect to Google Sheets?\nTo connect your n8n to your Google Sheets you're gonna need Google OAuth credentials\n\nSee documentation **[here](https://docs.n8n.io/integrations/builtin/credentials/google/oauth-single-service/)**"},"typeVersion":1},{"id":"b64df0dd-6425-4fc2-9f60-8c5a85412d61","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[120,20],"parameters":{"color":7,"width":170,"height":260,"content":"## 👆\nYou can use many models here, including the free Google Gemini options.\n\nMake sure to test it thoroughly. Some models are better for data analysis."},"typeVersion":1},{"id":"23c7bb52-b189-45f1-949b-ea588f065583","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[340,20],"parameters":{"color":7,"width":150,"height":260,"content":"## 👆\nThis is a short term memory. It will remember the 5 previous interactions during the chat"},"typeVersion":1},{"id":"6097e5a1-139b-4329-81ff-4fda16ea5221","name":"Buffer Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[360,-100],"parameters":{},"typeVersion":1.3},{"id":"6de4a7f2-5c58-4401-bd7c-19c5a73ba775","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[1160,-320],"parameters":{"color":7,"width":340,"height":180,"content":"The **AI Tools Agent** has access to all the tools at the same time. It uses the name and description to decide when to use each tool.\n\nNotice I'm using `$fromAI` function in all of them.\n\nSee documentations **[here](https://docs.n8n.io/advanced-ai/examples/using-the-fromai-function/)**"},"typeVersion":1},{"id":"a308d895-bc18-4b2c-9567-78f6c29f79e8","name":"Sticky Note11","type":"n8n-nodes-base.stickyNote","position":[1160,-120],"parameters":{"color":7,"width":340,"height":320,"content":"## 👈 This is a special tool\nIt is used to call another workflow.\nThis concept is called sub-workflow.\n\nSee documentation [here](https://docs.n8n.io/flow-logic/subworkflows/).\n\nInstead of running a completely separate workflow, we are calling the one below.\n\nIt's contained in the same workflow, but we are using the trigger to define it will run only when called by this tool."},"typeVersion":1},{"id":"0a6d94bc-21e1-4949-b7f4-c93abbecf08c","name":"Sticky Note12","type":"n8n-nodes-base.stickyNote","position":[120,340],"parameters":{"color":7,"width":1380,"height":520,"content":"# Sub-workflow\nThe AI can call this sub-workflow anytime,\nby using the **Records by date** tool.\n\nThe sub-workflow automatically return\n the result of the last executed node to the AI."},"typeVersion":1},{"id":"3e424615-6e49-4bd3-b066-005b9f0f773e","name":"Filter by status","type":"n8n-nodes-base.filter","position":[1060,640],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"e50da873-bbbd-41d3-a418-83193907977c","operator":{"type":"string","operation":"contains"},"leftValue":"={{ $json.Status }}","rightValue":"={{ $('When Executed by Another Workflow').item.json.status }}"}]}},"typeVersion":2.2},{"id":"0ad0102c-adb9-4ec9-bdf3-b1ce425b88ba","name":"Get transactions by status","type":"n8n-nodes-base.googleSheetsTool","position":[840,-320],"parameters":{"options":{},"filtersUI":{"values":[{"lookupValue":"={{ $fromAI(\"transaction_status\", \"Transaction status can be Refund, Completed or Error\", \"string\") }}","lookupColumn":"Status"}]},"sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/18A4d7KYrk8-uEMbu7shoQe_UIzmbTLV1FMN43bjA7qc/edit#gid=0","cachedResultName":"Sheet1"},"documentId":{"__rl":true,"mode":"url","value":"https://docs.google.com/spreadsheets/d/18A4d7KYrk8-uEMbu7shoQe_UIzmbTLV1FMN43bjA7qc/edit?usp=sharing"},"descriptionType":"manual","toolDescription":"Find transactions by status"},"credentials":{"googleSheetsOAuth2Api":{"id":"YR4pbjuZM5Xs4CTD","name":"Google Sheets"}},"typeVersion":4.5},{"id":"5b80cb08-6e19-47b2-8146-c299e709a34a","name":"Sticky Note13","type":"n8n-nodes-base.stickyNote","position":[820,-540],"parameters":{"color":4,"width":300,"content":"## Change the URL of the Sheets file in all the Sheets tools 👇"},"typeVersion":1},{"id":"ddc1351e-0ad0-480f-9742-30f2aa860d61","name":"Sticky Note14","type":"n8n-nodes-base.stickyNote","position":[500,820],"parameters":{"color":4,"width":260,"height":100,"content":"## 👆 Change the URL of the Sheets file"},"typeVersion":1},{"id":"ab837a10-932f-4b14-8e2c-546077ca2c86","name":"Sticky Note10","type":"n8n-nodes-base.stickyNote","position":[-780,20],"parameters":{"color":7,"width":740,"height":640,"content":"# Author\n![Solomon](https://gravatar.com/avatar/79aa147f090807fe0f618fb47a1de932669e385bb0c84bf3a7f891ae7d174256?r=pg&d=retro&size=200)\n### Solomon\nFreelance consultant from Brazil, specializing in automations and data analysis. I work with select clients, addressing their toughest projects.\n\nFor business inquiries, email me at automations.solomon@gmail.com\nOr message me on [Telegram](https://t.me/salomaoguilherme) for a faster response.\n\n### Check out my other templates\n### 👉 https://n8n.io/creators/solomon/\n"},"typeVersion":1},{"id":"e58351b3-3b18-4c03-9435-27ba853d03bb","name":"Sticky Note15","type":"n8n-nodes-base.stickyNote","position":[-780,680],"parameters":{"width":740,"height":180,"content":"# Need help?\nFor getting help with this workflow, please create a topic on the community forums here:\nhttps://community.n8n.io/c/questions/"},"typeVersion":1},{"id":"4519d880-7448-4fb3-b2dc-ccea787729be","name":"Sticky Note16","type":"n8n-nodes-base.stickyNote","position":[-760,560],"parameters":{"color":4,"width":700,"height":80,"content":"### 💡 **Want to learn advanced n8n skills and earn money building workflows?**\n‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎Check out [Scrapes Academy](https://www.skool.com/scrapes/about?ref=21f10ad99f4d46ba9b8aaea8c9f58c34)"},"typeVersion":1}],"pinData":{},"connections":{"Code":{"main":[[{"node":"Filter by status","type":"main","index":0}]]},"Calculator":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Buffer Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Records by date":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Filter by status":{"main":[[{"node":"Aggregate","type":"main","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Get all transactions":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Google Sheets request":{"main":[[{"node":"Code","type":"main","index":0}]]},"Get transactions by status":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"When chat message received":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Get transactions by product name":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"When Executed by Another Workflow":{"main":[[{"node":"Google Sheets request","type":"main","index":0}]]}}}


name: ✨🤖Automate Multi-Platform Social Media Content Creation with AI
author_name: Joseph LePage
author_username: joe
categories: []
created_at: 2025-03-03T03:47:15.283Z
updated_at: 2025-03-03T03:47:15.283Z
url: https://n8n.io/workflows/3066
scraped_at: 2025-07-06 21:16:30
description:
  Automate Multi-Platform Social Media Content Creation with AI

  Who is this for?  
  Social Media Managers and Digital Marketers seeking to streamline content production across 7+ platforms (X/Twitter, Instagram, LinkedIn, Facebook, TikTok, Threads, YouTube Shorts) using AI-powered automation.

  What problem does this solve?  
  Creating platform-optimized content at scale while maintaining brand consistency across multiple channels, reducing manual work by 80% through AI generation and automated publishing.

  What this workflow does  
  AI Content Generation:  
     Uses GPT-4/Gemini to create platform-specific posts  
     Automatically generates hashtags, CTAs, and emoji placement  
     Supports image/video suggestions and image creation using OpenAI or Pollinations.ai
     Uses SERP api to search for relavent content

  Approval Workflow:  
     Sends formatted HTML emails for human review  
     Implements double-approval system with Gmail integration  

  Cross-Platform Publishing:  
     One-click deployment to:  
       Instagram/Facebook (via Graph API)  
       X/Twitter (Official API)  
       LinkedIn (Sales Navigator integration)  

  Setup  
  Credentials:  
     OpenAI API key  
     Google Gemini API  
     Social media platform tokens (X, LinkedIn, Facebook)  
     ImgBB for image hosting  
     Gmail
     SERP API
     Telegram

  Configuration:  
     Update all "your-unique-id" placeholders in API nodes  
     Set email recipients in Gmail nodes  
     Customize AI prompts 

  Customization:  
     Adjust character limits per platform  
     Modify approval thresholds  
     Add/remove social platforms as needed  

  How to customize  
  Content Style**: Edit prompt templates in the "Social Media Content Factory" agent node  
  Approval Process**: Modify email templates  
  Analytics**: Connect to Google Sheets for performance tracking  
  Image Generation**: Switch between Pollinations.ai/DALL-E/Midjourney  

nodes_used:
  ["n8n-nodes-base.httpRequest","n8n-nodes-base.telegram","n8n-nodes-base.facebookGraphApi","n8n-nodes-base.twitter","n8n-nodes-base.gmail","n8n-nodes-base.linkedIn","n8n-nodes-base.code","@n8n/n8n-nodes-langchain.agent","@n8n/n8n-nodes-langchain.lmChatOpenAi","@n8n/n8n-nodes-langchain.outputParserStructured","@n8n/n8n-nodes-langchain.toolSerpApi","@n8n/n8n-nodes-langchain.openAi","@n8n/n8n-nodes-langchain.lmChatGoogleGemini"]

workflow_json:
  {"id":"CfdF2XtXC68iJ6Hr","meta":{"instanceId":"31e69f7f4a77bf465b805824e303232f0227212ae922d12133a0f96ffeab4fef","templateCredsSetupCompleted":true},"name":"✨🤖Automated AI Powered Social Media Content Factory for  X + Facebook + Instagram + LinkedIn","tags":[],"nodes":[{"id":"1e77584f-76b4-420b-b6b0-99132d6c0151","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-300,-900],"parameters":{"color":4,"width":360,"height":360,"content":"# 🧑‍🦱 User Input for Social Media Posts \n💡 Unpin default data to get started"},"typeVersion":1},{"id":"dc92fcf1-3618-4188-a30f-6c2205cc3266","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[100,-940],"parameters":{"color":6,"width":640,"height":600,"content":"# 🛠️ Social Media Content Factory\n- LinkedIn\n- Instagram\n- Facebook\n- X\n- TikTok\n- Threads\n- YouTube Shorts\n"},"typeVersion":1},{"id":"02429ea7-be59-49e3-9d85-c1678ee64abd","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[1840,-700],"parameters":{"color":4,"width":400,"height":360,"content":"# 👍 Approve Content Before Proceeding"},"typeVersion":1},{"id":"fa38e25c-89e9-4d9b-be78-03aeb6965e30","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[1300,-900],"parameters":{"color":5,"width":500,"height":560,"content":"# ✉️ Prepare & Format Approval Email"},"typeVersion":1},{"id":"9b6e2038-9f65-4e0f-b13d-6c09e8224ed6","name":"Social Media Content","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[560,-540],"parameters":{"schemaType":"manual","inputSchema":"{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"name\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"description\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"platform_posts\": {\n\t\t\t\"type\": \"object\",\n\t\t\t\"properties\": {\n\t\t\t\t\"LinkedIn\": {\n\t\t\t\t\t\"type\": \"object\",\n\t\t\t\t\t\"properties\": {\n                        \"image_suggestion\": {\n                  \t\t\t\"type\": \"string\"\n                  \t\t},\n\t\t\t\t\t\t\"post\": {\n\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"hashtags\": {\n\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"call_to_action\": {\n\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t\"Instagram\": {\n\t\t\t\t\t\"type\": \"object\",\n\t\t\t\t\t\"properties\": {\n\t\t\t\t\t\t\"image_suggestion\": {\n\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"caption\": {\n\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"hashtags\": {\n\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"emojis\": {\n\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"call_to_action\": {\n\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t\"Facebook\": {\n\t\t\t\t\t\"type\": \"object\",\n\t\t\t\t\t\"properties\": {\n\t\t\t\t\t\t\"post\": {\n\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"hashtags\": {\n\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"call_to_action\": {\n\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"image_suggestion\": {\n\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t\"X-Twitter\": {\n\t\t\t\t\t\"type\": \"object\",\n\t\t\t\t\t\"properties\": {\n                        \"video_suggestion\": {\n                \t\t\t\"type\": \"string\"\n                \t\t},\n                        \"image_suggestion\": {\n\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"post\": {\n\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"hashtags\": {\n\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"character_limit\": {\n\t\t\t\t\t\t\t\"type\": \"integer\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n                \"TikTok\": {\n                \t\"type\": \"object\",\n                \t\"properties\": {\n                \t\t\"video_suggestion\": {\n                \t\t\t\"type\": \"string\"\n                \t\t},\n                \t\t\"caption\": {\n                \t\t\t\"type\": \"string\"\n                \t\t},\n                \t\t\"hashtags\": {\n                \t\t\t\"type\": \"array\",\n                \t\t\t\"items\": {\n                \t\t\t\t\"type\": \"string\"\n                \t\t\t}\n                \t\t},\n                \t\t\"call_to_action\": {\n                \t\t\t\"type\": \"string\"\n                \t\t}\n                \t}\n                },\n                \"Threads\": {\n                \t\"type\": \"object\",\n                \t\"properties\": {\n                       \"image_suggestion\": {\n\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t},\n                \t\t\"text_post\": {\n                \t\t\t\"type\": \"string\"\n                \t\t},\n                \t\t\"hashtags\": {\n                \t\t\t\"type\": \"array\",\n                \t\t\t\"items\": {\n                \t\t\t\t\"type\": \"string\"\n                \t\t\t}\n                \t\t},\n                \t\t\"call_to_action\": {\n                \t\t\t\"type\": \"string\"\n                \t\t}\n                \t}\n                },\n                \"YouTube_Shorts\": {\n                  \t\"type\": \"object\",\n                  \t\"properties\": {\n                  \t\t\"video_suggestion\": {\n                  \t\t\t\"type\": \"string\"\n                  \t\t},\n                  \t\t\"title\": {\n                  \t\t\t\"type\": \"string\"\n                  \t\t},\n                          \"description\": {\n                              \"type\": \"string\"\n                          },\n                          \"hashtags\": {\n                              \"type\": \"array\",\n                              \"items\": {\n                                  \"type\": \"string\"\n                              }\n                          },\n                          \"call_to_action\": {\n                              \"type\": \"string\"\n                          }\n                      }\n                  }\n\t\t\t}\n\t\t},\n\t\t\"additional_notes\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t}\n}\n"},"typeVersion":1.2},{"id":"a1211873-05ca-48c7-aa93-57d80b37174b","name":"Google Gemini LLM","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","disabled":true,"position":[320,-540],"parameters":{"options":{"temperature":0.4},"modelName":"models/gemini-2.0-flash-exp"},"credentials":{"googlePalmApi":{"id":"L9UNQHflYlyF9Ngd","name":"Google Gemini(PaLM) Api account"}},"typeVersion":1},{"id":"14327277-1e66-401d-9c74-8fdb6d76445f","name":"gpt-4o-mini","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[1360,-540],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"gpt-4o-mini"},"options":{"responseFormat":"text"}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.2},{"id":"9a49454b-f518-4388-82a7-2529addae3e5","name":"gpt-4o","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","disabled":true,"position":[1500,-540],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o","cachedResultName":"gpt-4o"},"options":{"responseFormat":"text"}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.2},{"id":"56eb9c72-87fc-42b2-b576-be68b3a8c7d2","name":"gpt-4o LLM","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[180,-540],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o","cachedResultName":"gpt-4o"},"options":{"responseFormat":"text"}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.2},{"id":"bf4e6d41-b2be-44fc-8fc7-6dc6bc4ee69a","name":"pollinations.ai","type":"n8n-nodes-base.httpRequest","disabled":true,"position":[980,780],"parameters":{"url":"=https://image.pollinations.ai/prompt/{{$('Social Media Content Factory').item.json.output.description.replaceAll(' ','-').replaceAll(',','').replaceAll('.','') }}","options":{}},"typeVersion":4.2},{"id":"5a950645-8e74-4be8-bad2-73d9f827a6b8","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[880,620],"parameters":{"width":300,"height":340,"content":"## Create Post Image\nhttps://pollinations.ai/\nhttps://image.pollinations.ai/prompt/[your image description]\n\n(alternative)"},"typeVersion":1},{"id":"7b5b53eb-85c6-4a90-b209-7bd8d638f237","name":"Merge","type":"n8n-nodes-base.merge","position":[700,20],"parameters":{"mode":"combine","options":{"includeUnpaired":true},"combineBy":"combineByPosition"},"typeVersion":3},{"id":"daa6773e-0e15-4994-bcee-b3d996655855","name":"Save Image to imgbb.com3","type":"n8n-nodes-base.httpRequest","position":[360,-140],"parameters":{"url":"https://api.imgbb.com/1/upload","method":"POST","options":{"redirect":{"redirect":{}}},"sendBody":true,"sendQuery":true,"contentType":"multipart-form-data","bodyParameters":{"parameters":[{"name":"image","parameterType":"formBinaryData","inputDataFieldName":"data"}]},"queryParameters":{"parameters":[{"name":"expiration","value":"0"},{"name":"key","value":"={{ $env.IMGBB_API_KEY}} "}]}},"typeVersion":4.2},{"id":"af06853c-258e-4dfb-a579-3168c8de96bd","name":"Instagram Image","type":"n8n-nodes-base.httpRequest","onError":"continueRegularOutput","position":[1700,-60],"parameters":{"url":"https://graph.facebook.com/v20.0/[your-unique-id]/media","method":"POST","options":{},"sendQuery":true,"authentication":"predefinedCredentialType","queryParameters":{"parameters":[{"name":"image_url","value":"={{ $json.data.medium.url }}"},{"name":"caption","value":"={{ $('Social Media Content Factory').item.json.output.platform_posts.Instagram.caption }}"}]},"nodeCredentialType":"facebookGraphApi"},"credentials":{"facebookGraphApi":{"id":"PzDfmiwB7GPtmSaP","name":"Facebook Graph account"}},"typeVersion":4.2},{"id":"6ee72138-a8ec-4fbd-8f14-fd6e881edfd1","name":"Instragram Post","type":"n8n-nodes-base.facebookGraphApi","onError":"continueRegularOutput","position":[1700,160],"parameters":{"edge":"media_publish","node":"[your-unique-id]","options":{"queryParameters":{"parameter":[{"name":"creation_id","value":"={{ $json.id }}"},{"name":"caption","value":"={{ $('Social Media Content Factory').item.json.output.platform_posts.Instagram.caption }}"}]}},"graphApiVersion":"v20.0","httpRequestMethod":"POST"},"credentials":{"facebookGraphApi":{"id":"PzDfmiwB7GPtmSaP","name":"Facebook Graph account"}},"typeVersion":1,"alwaysOutputData":true},{"id":"9e168865-1eae-4e53-99c9-91b041426ecb","name":"X Post","type":"n8n-nodes-base.twitter","onError":"continueRegularOutput","position":[1700,380],"parameters":{"text":"={{ $('Social Media Content Factory').item.json.output.platform_posts['X-Twitter'].post }}","additionalFields":{}},"credentials":{"twitterOAuth2Api":{"id":"wRDruLTCqjQ7C5jq","name":"X account"}},"typeVersion":2,"alwaysOutputData":true},{"id":"4ee55c94-7251-445e-8ce7-15eee7165010","name":"Facebook Post","type":"n8n-nodes-base.facebookGraphApi","onError":"continueRegularOutput","position":[1700,600],"parameters":{"edge":"photos","node":"[your-unique-id]","options":{"queryParameters":{"parameter":[{"name":"message","value":"={{ $('Social Media Content Factory').item.json.output.platform_posts.Facebook.post }}\n\n{{ $('Social Media Content Factory').item.json.output.platform_posts.Facebook.call_to_action }}\n"},{"name":"link","value":"={{ $('Social Media Content Factory').item.json.output.platform_posts.Facebook.call_to_action }}"}]}},"sendBinaryData":true,"graphApiVersion":"v20.0","httpRequestMethod":"POST","binaryPropertyName":"data"},"credentials":{"facebookGraphApi":{"id":"PzDfmiwB7GPtmSaP","name":"Facebook Graph account"}},"typeVersion":1,"alwaysOutputData":true},{"id":"3a015f3f-a162-411a-85e8-e1f042d9c653","name":"LinkedIn Post","type":"n8n-nodes-base.linkedIn","onError":"continueRegularOutput","position":[1700,780],"parameters":{"text":"={{ $('Social Media Content Factory').item.json.output.platform_posts.LinkedIn.post }}\n{{ $('Social Media Content Factory').item.json.output.platform_posts.LinkedIn.call_to_action }}\n{{ $('Social Media Content Factory').item.json.output.platform_posts.LinkedIn.hashtags }}\n{{ $('Social Media Content Factory').item.json.output.platform_posts.LinkedIn.call_to_action }}","postAs":"organization","organization":"12345678","additionalFields":{},"binaryPropertyName":"=data","shareMediaCategory":"IMAGE"},"credentials":{"linkedInOAuth2Api":{"id":"WMm6pzAEgNd4wJdO","name":"LinkedIn account"}},"typeVersion":1,"alwaysOutputData":true},{"id":"8ab03d75-b4c5-4271-8fa9-830f449a3a3c","name":"OpenAI","type":"@n8n/n8n-nodes-langchain.openAi","position":[40,-20],"parameters":{"prompt":"={{ $('Social Media Content Factory').item.json.output.platform_posts.Instagram.caption }}","options":{},"resource":"image"},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.8,"alwaysOutputData":true},{"id":"d1ac29b1-128d-4615-b828-89f1f64d1b15","name":"Merge1","type":"n8n-nodes-base.merge","position":[1440,-60],"parameters":{"mode":"combine","options":{},"combineBy":"combineByPosition"},"typeVersion":3},{"id":"71eebce8-027a-4b12-b07e-692121de9a68","name":"Merge2","type":"n8n-nodes-base.merge","position":[1440,680],"parameters":{"mode":"combine","options":{"includeUnpaired":true},"combineBy":"combineByPosition"},"typeVersion":3},{"id":"140cff41-a619-4111-8dc9-3ec8fc45e061","name":"Aggregate","type":"n8n-nodes-base.aggregate","position":[-240,520],"parameters":{"options":{},"aggregate":"aggregateAllItemData"},"typeVersion":1},{"id":"3e96bfac-dad5-4b75-b51b-50329892ee70","name":"gpt-4o-mini1","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-20,540],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"gpt-4o-mini"},"options":{"responseFormat":"text"}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.2},{"id":"4d73d59f-bb8c-481b-877a-bf4dc64f3277","name":"gpt-4o-mini2","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-20,820],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"gpt-4o-mini"},"options":{"responseFormat":"text"}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.2},{"id":"aaef70d7-6029-4fae-afc1-72a6a0019b03","name":"Gmail User for Approval","type":"n8n-nodes-base.gmail","position":[2000,-540],"webhookId":"c46cf421-ddb6-45a8-b83b-80b381666f0e","parameters":{"sendTo":"={{ $env.EMAIL_ADDRESS_JOE }} ","message":"={{ $json.output }}","options":{"limitWaitTime":{"values":{"resumeUnit":"minutes","resumeAmount":45}}},"subject":"=🔥FOR APPROVAL🔥{{ $('Social Media Content Factory').item.json.output.name }} - {{ $('Social Media Content Factory').item.json.output.description }}","operation":"sendAndWait","approvalOptions":{"values":{"approvalType":"double"}}},"credentials":{"gmailOAuth2":{"id":"1xpVDEQ1yx8gV022","name":"Gmail account"}},"typeVersion":2.1},{"id":"44e3bada-7665-4268-bb79-12ffb377552e","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[1600,-140],"parameters":{"color":6,"width":300,"height":1100,"content":"## Publish to Social Media"},"typeVersion":1},{"id":"75bfc1f4-0afa-4d8d-b5cc-83e29b6570f9","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[1940,80],"parameters":{"color":5,"width":300,"height":880,"content":"## Format Results"},"typeVersion":1},{"id":"ff5d050a-111c-4467-bc61-e51444943cb5","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[-360,240],"parameters":{"color":7,"width":1020,"height":760,"content":"# Step 4️⃣: Send Final Results of Social Media Factory"},"typeVersion":1},{"id":"26a684cc-72d9-40c8-bd30-1d074d914328","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[-40,-100],"parameters":{"color":3,"width":260,"height":260,"content":"## Create Post Image"},"typeVersion":1},{"id":"930e76ac-6e9c-4a3f-9229-28ba18de25a3","name":"Approve Final Post Content","type":"n8n-nodes-base.gmail","disabled":true,"position":[980,380],"webhookId":"c46cf421-ddb6-45a8-b83b-80b381666f0e","parameters":{"sendTo":"={{ $env.EMAIL_ADDRESS_JOE }} ","message":"=<html>\n<body style=\"margin:0; padding:0; font-family: Arial, sans-serif; background-color: #f5f5f5;\">\n  <div style=\"max-width: 600px; margin: 0 auto; padding: 20px;\">\n\n    <h2 style=\"font-size:20px; color:#333; margin:0 0 15px 0;\">LinkedIn</h2>\n      \n    <!-- LinkedIn Card -->\n    <div style=\"background: #ffffff; border-radius: 8px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);\">\n\n      <!-- Card Header Image -->\n      <div style=\"height: 200px; overflow: hidden; border-radius: 8px 8px 0 0;\">\n        <img src=\"{{ $json.data.medium.url }}\" alt=\"Featured Image\" style=\"width: 100%; height: 100%; object-fit: cover;\">\n      </div>\n\n      <!-- Card Content -->\n      <div style=\"padding: 25px;\">\n\n        <p style=\"font-size:16px; color:#555; line-height: 1.6; margin-bottom: 15px;\">\n          {{ $('Social Media Content Factory').item.json.output.platform_posts.LinkedIn.post }}\n        </p>\n        \n        <div style=\"margin: 15px 0;\">\n          <span style=\"display: inline-block; background: #f0f0f0; padding: 4px 8px; margin: 2px; border-radius: 4px; font-size:12px; color:#333;\">\n            {{ $('Social Media Content Factory').item.json.output.platform_posts.LinkedIn.hashtags }}\n          </span>\n        </div>\n\n        <p style=\"font-size:14px; color:#1a0dab; font-weight: 600; margin:15px 0 0 0;\">\n          {{ $('Social Media Content Factory').item.json.output.platform_posts.LinkedIn.call_to_action }}\n        </p>\n      </div>\n    </div>\n  </div>\n</body>\n</html>\n","options":{"limitWaitTime":{"values":{"resumeUnit":"minutes","resumeAmount":45}}},"subject":"=🔥FOR APPROVAL🔥 New LinkedIn Post","operation":"sendAndWait","approvalOptions":{"values":{"approvalType":"double"}}},"credentials":{"gmailOAuth2":{"id":"1xpVDEQ1yx8gV022","name":"Gmail account"}},"typeVersion":2.1},{"id":"051b7ff6-febb-4aba-9790-bc977c11e645","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[880,240],"parameters":{"width":300,"height":340,"content":"## Final Approval before Publishing to Social Feeds\n(optional)"},"typeVersion":1},{"id":"b42df164-47ae-4e08-9099-d0958dd41c8f","name":"Is Approved?","type":"n8n-nodes-base.if","position":[1160,20],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"efe337a1-63e0-4513-873d-421bf41e4868","operator":{"type":"boolean","operation":"true","singleValue":true},"leftValue":"={{ $json.data.approved }}","rightValue":""}]}},"typeVersion":2.2},{"id":"e3193aef-d115-4c3b-87b2-b8ebd5bb0c05","name":"Instagram Result","type":"n8n-nodes-base.set","position":[2040,160],"parameters":{"options":{},"assignments":{"assignments":[{"id":"5c6edc76-1e3b-45b0-8baa-33a14c678150","name":"Instagram Post Result","type":"string","value":"={{ $json }}"}]}},"typeVersion":3.4},{"id":"6f8b248f-5c79-412c-81ef-3c52bef7f257","name":"X Result","type":"n8n-nodes-base.set","position":[2040,380],"parameters":{"options":{},"assignments":{"assignments":[{"id":"5c6edc76-1e3b-45b0-8baa-33a14c678150","name":"X Post Result","type":"string","value":"={{ $json }}"}]}},"typeVersion":3.4},{"id":"4c1ee118-aba1-4632-bd48-27cef9d5e272","name":"Facebook Result","type":"n8n-nodes-base.set","position":[2040,600],"parameters":{"options":{},"assignments":{"assignments":[{"id":"5c6edc76-1e3b-45b0-8baa-33a14c678150","name":"Facebook Post Result","type":"string","value":"={{ $json }}"}]}},"typeVersion":3.4},{"id":"490223f9-9b6a-4617-8829-c8e4b130feb7","name":"LinkedIn Result","type":"n8n-nodes-base.set","position":[2040,780],"parameters":{"options":{},"assignments":{"assignments":[{"id":"5c6edc76-1e3b-45b0-8baa-33a14c678150","name":"LinkedIn Post Result","type":"string","value":"={{ $json }}"}]}},"typeVersion":3.4},{"id":"9732c12e-903e-49ac-8d29-ffc4d78c7ff8","name":"Submit Social Post Details","type":"n8n-nodes-base.formTrigger","position":[-180,-740],"webhookId":"3e762442-715e-47e1-a65e-ae92085857ae","parameters":{"options":{"buttonLabel":"Automatically Generate Social Media Content"},"formTitle":"workflows.diy","formFields":{"values":[{"fieldLabel":"Topic","placeholder":"Provide a concise and clear title or main topic for your post (e.g., \"New Product Launch,\" \"Exciting Company Update\"). This helps the AI accurately capture the focus of your content.","requiredField":true},{"fieldLabel":"Keywords or Hashtags (optional)","placeholder":"Include any specific keywords or hashtags you'd like the AI to incorporate into the post. This ensures the content aligns with your branding and campaign objectives.","requiredField":"={{ false }}"},{"fieldLabel":"Link (optional)","placeholder":"=Provide the URL of any product, service, form, support page, or other resource. This link will be included in the generated post to direct your audience to the relevant content.\n"}]},"responseMode":"lastNode","formDescription":"=Welcome to the workflows.diy AI-Powered Assistant!\n\nThis tool is designed to streamline and enhance your social media content creation process.\n\nSimply provide key inputs like a topic or title and an optional image, and our intelligent agent will generate engaging, platform-specific post descriptions tailored to your audience. \n\nWhether you're a marketer, business owner, or influencer, this assistant saves you time while delivering professional-quality content optimized for maximum impact.\n\n"},"typeVersion":2.2},{"id":"899f658f-4faa-4ba7-ae02-cc8fb1d22c71","name":"Sticky Note10","type":"n8n-nodes-base.stickyNote","position":[-360,-1060],"parameters":{"color":7,"width":2640,"height":760,"content":"# Step 1️⃣: Create Social Media Written Content\nNote:  \nYou could use the output of step 1 to create your written content and manually post if required.  \nYou so not have to implement step 2."},"typeVersion":1},{"id":"a8075b2a-4cd0-4b0c-9b19-8bd58de449c0","name":"Sticky Note11","type":"n8n-nodes-base.stickyNote","position":[-360,-260],"parameters":{"color":7,"width":1020,"height":460,"content":"# Step 2️⃣: Create Image or Upload Image for Social Post"},"typeVersion":1},{"id":"1da28ef3-9061-4e83-84e0-3502d254d63a","name":"Sticky Note12","type":"n8n-nodes-base.stickyNote","position":[840,-260],"parameters":{"color":7,"width":1680,"height":1260,"content":"# Step 3️⃣: Publish Final Social Media Posts"},"typeVersion":1},{"id":"1955b762-b9c4-4704-955b-093686e827bd","name":"Merge Results","type":"n8n-nodes-base.merge","onError":"continueRegularOutput","position":[2340,780],"parameters":{"numberInputs":4},"typeVersion":3,"alwaysOutputData":true},{"id":"6dc47749-eb49-4351-89aa-50f2b6c035bb","name":"Social Media Content Factory","type":"@n8n/n8n-nodes-langchain.agent","position":[300,-740],"parameters":{"text":"=You are a **content creation AI** for workflows.diy, a leading creator of **n8n workflow automation solutions and AI Agentic workflows**.\n\nYour goal is to craft **engaging, platform-specific content** for LinkedIn, Instagram, Facebook, Twitter (X), TikTok, Threads, and YouTube Shorts. Each post must align with the platform’s audience preferences, tone, and style while reflecting workflows.diy's expertise. The content should provide **value-driven insights**, tutorials, reviews, and discussions that resonate with tech professionals, automation enthusiasts, businesses, and n8n users.\n\n### Key Objectives:\n1. **Platform Optimization**: Tailor content format, tone, and hashtags to suit each platform’s algorithm and audience engagement patterns.\n2. **SEO & Hashtags**: Use a mix of general automation hashtags and trending platform-specific hashtags to maximize reach.\n3. **Engagement Focus**: Create content that sparks interaction through tutorials, comparisons, reviews, or thought-provoking discussions.\n4. **Consistency**: Maintain a professional yet approachable tone across all platforms while adapting to audience needs.\n5. **Data-Driven Strategy**: Analyze trends and performance data to refine content strategy and hashtag usage.\n\n### General Hashtags:\n#workflowsdiy #n8n #automation #AIWorkflows #WorkflowAutomation #TechSolutions\n\n---\n\n### Platform-Specific Guidelines:\n\n#### 1. LinkedIn\n   - **Style**: Professional and insightful.\n   - **Tone**: Business-oriented; focus on automation use cases, industry insights, and community impact.\n   - **Content Length**: 3-4 sentences; concise but detailed.\n   - **Hashtags**: #Innovation #Automation #WorkflowSolutions #DigitalTransformation #Leadership\n   - **Call to Action (CTA)**: Encourage comments or visits to workflows.diy’s website for more insights.\n\n#### 2. Instagram\n   - **Style**: Visual storytelling with creative captions.\n   - **Tone**: Inspirational and engaging; use emojis for relatability.\n   - **Content Length**: 2-3 sentences paired with eye-catching visuals (e.g., infographics or workflow demos).\n   - **Visuals**: Showcase milestones (e.g., new workflow launches), tutorials, or product highlights.\n   - **CTA**: Use phrases like \"Swipe to learn more,\" \"Tag your team,\" or \"Check out the link below!\"\n   - **Link Placement**: Add the provided link before hashtags; if no link is provided, use \"Visit our website: https://workflows.diy.\"\n   - **Hashtags**: #AutomationLife #TechInnovation #WorkflowTips #Programming #Engineering\n\n#### 3. Facebook\n   - **Style**: Friendly and community-focused.\n   - **Tone**: Relatable; highlight user success stories or company achievements in automation.\n   - **Content Length**: 2-3 sentences; conversational yet professional.\n   - **Hashtags**: #SmallBusinessAutomation #Entrepreneurship #Leadership #WorkflowInnovation\n   - **CTA**: Encourage likes, shares, comments (e.g., “What’s your favorite automation tip?”).\n\n#### 4. Twitter (X)\n   - **Style**: Concise and impactful.\n   - **Tone**: Crisp and engaging; spark curiosity in 150 characters or less.\n   - **Hashtags**: #WorkflowTrends #AIWorkflows #AutomationTips #NoCodeSolutions\n   - **CTA**: Drive quick engagement through retweets or replies (e.g., “What’s your go-to n8n workflow?”).\n\n#### 5. TikTok\n   - **Style**: Short-form video content with trending audio or effects.\n   - **Tone**: Fun yet informative; focus on quick workflow demos or automation tips.\n   - **Content Length**: 15-60 seconds with captions summarizing the key message.\n   - **Hashtags**: Use trending tech-related hashtags relevant to TikTok’s audience (e.g., #n8nTips).\n   - **CTA**: Encourage viewers to follow workflows.diy for more automation hacks.\n\n#### 6. Threads\n   - **Style**: Conversational and community-driven posts.\n   - **Tone**: Casual yet informative; encourage discussions around automation trends or innovations.\n   - **Content Length**: 1-2 short paragraphs with a question or thought-provoking statement at the end.\n   - **Hashtags**: Similar to Instagram but tailored for trending Threads topics related to automation.\n\n#### 7. YouTube Shorts\n   - **Style**: Short-form video content showcasing quick workflow tutorials or use cases.\n   - **Tone**: Authoritative yet approachable; establish workflows.diy as a leader in n8n automation solutions.\n   - Content Length:\n     - Tutorials/Reviews (long-form): 5-10 minutes\n     - Shorts/Highlights (short-form): Under 1 minute\n   - CTA:** Encourage subscriptions**, likes, comments (e.g., “Subscribe for more workflow tips!”).\n\n---\n\n### Content Creation Workflow:\nFor every post:\n1. Use the following input fields:\n    - Topic/About the Post: {{ $json.Topic }}\n    - Keywords/Focus Areas: {{ $json.formMode }}\n    - Link (optional): {{ $json['Link (optional)'] }}\n2. Adapt the tone/style based on the platform guidelines above.\n\nEnsure every post reflects workflows.diy's mission of delivering high-quality automation insights while maximizing engagement across platforms.\n\nFollow the provided JSON schema for your reponse.\n","options":{"systemMessage":"=Use the provided tools to research the topic based on latest information.  Todays date is {{ $now }}"},"promptType":"define","hasOutputParser":true},"retryOnFail":true,"typeVersion":1.7},{"id":"88c548bf-40e5-4b89-aef0-9233c3f5bc9c","name":"Prepare Content Review Email","type":"@n8n/n8n-nodes-langchain.agent","position":[1440,-740],"parameters":{"text":"=Generate clean, modern HTML email content from the provided JSON data with these requirements:\n- Use table-based layout with inline CSS for email compatibility\n- Create card sections for each platform containing:\n  • Title header (20px) \n  • Post content (16px) \n  • Video/image suggestions (italic 14px)\n  • Hashtag list (inline-block with # prefix)\n  • Emoji preservation where present\n  • Call-to-action (bold 14px)\n- Structure using:\n  • 600px max-width container\n  • 20px padding between cards\n  • Left-aligned text hierarchy\n  • Arial/sans-serif font stack\n  • Email-safe colors (#333 text, #555 secondary)\n- Include all platform-specific elements:\n  ▶ Video/image suggestions in italic\n  ▶ Hashtags as linked search terms\n  ▶ Emojis in original positions\n  ▶ Character limits for Twitter\n  ▶ Platform-specific CTAs\n  ▶ Visual quality reminders\n- Format hashtags as:\n  <span style=\"display: inline-block; background: #f0f0f0; padding: 2px 6px; margin: 2px; border-radius: 4px;\">#tag</span>\n\nInput data: {{ $json.output.toJsonString() }}\n\nRemove ALL code blocks and comments. Output ONLY the raw HTML with:\n- Platform cards in JSON order\n- All data elements represented\n- Mobile-responsive tables\n- W3C-valid markup\n\n## Example HTML:\n<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#fbfcfe;border:1px solid #dbdfe7;border-radius:8px\">\n\t\t<tbody><tr>\n\t\t\t<td align=\"center\" style=\"padding:24px 0\">\n\t\t\t\t<table width=\"448\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:100%;max-width:448px;background-color:#ffffff;border:1px solid #dbdfe7;border-radius:8px;padding:24px\">\n\t\t\t\t\t<tbody><tr>\n\t\t\t\t\t\t<td style=\"text-align:center;padding-top:8px;font-family:Arial,sans-serif;font-size:14px;color:#7e8186\">\n\t\t\t\t\t\t\t<p style=\"white-space:pre-line\"></p><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"max-width:600px;font-family:Arial,sans-serif;color:#333\"><tbody><tr><td style=\"padding:20px\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#f9f9f9;margin-bottom:20px;padding:20px;border-radius:8px\"><tbody><tr><td style=\"font-size:20px;font-weight:bold;padding-bottom:10px\">LinkedIn</td></tr><tr><td style=\"font-size:16px;padding-bottom:10px\">Discover why n8n stands out as the premier workflow automation tool. Its flexibility and open-source nature empower businesses to create custom solutions that drive efficiency and innovation.</td></tr><tr><td style=\"font-size:14px;font-style:italic;padding-bottom:10px\">Video/Image suggestion pending</td></tr><tr><td style=\"padding-bottom:10px\"><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#Innovation</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#Automation</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>WorkflowSolutions</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>DigitalTransformation</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>Leadership</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#workflowsdiy</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#n8n</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>AIWorkflows</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#WorkflowAutomation</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\"><wbr>#TechSolutions</span></td></tr><tr><td style=\"font-size:14px;font-weight:bold\">Visit workflows.diy to explore how n8n can transform your business processes!</td></tr></tbody></table><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#f9f9f9;margin-bottom:20px;padding:20px;border-radius:8px\"><tbody><tr><td style=\"font-size:20px;font-weight:bold;padding-bottom:10px\">Instagram</td></tr><tr><td style=\"font-size:14px;font-style:italic;padding-bottom:10px\">Eye-catching infographic comparing n8n to other automation tools, highlighting its unique features.</td></tr><tr><td style=\"font-size:16px;padding-bottom:10px\">n8n: The ultimate workflow automation tool! <img data-emoji=\"💡\" class=\"an1\" alt=\"💡\" aria-label=\"💡\" draggable=\"false\" src=\"https://fonts.gstatic.com/s/e/notoemoji/16.0/1f4a1/32.png\" loading=\"lazy\"> Unlock limitless possibilities with its open-source platform. Boost your productivity and streamline your processes. <img data-emoji=\"💤\" class=\"an1\" alt=\"💤\" aria-label=\"💤\" draggable=\"false\" src=\"https://fonts.gstatic.com/s/e/notoemoji/16.0/1f4a4/32.png\" loading=\"lazy\"></td></tr><tr><td style=\"padding-bottom:10px\"><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#AutomationLife</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#TechInnovation</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\"><wbr>#WorkflowTips</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#Programming</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>Engineering</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#workflowsdiy</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#n8n</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>AIWorkflows</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#WorkflowAutomation</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\"><wbr>#TechSolutions</span></td></tr><tr><td style=\"font-size:14px;font-weight:bold\">Visit our website: <a href=\"https://n8n.io/\" target=\"_blank\" data-saferedirecturl=\"https://www.google.com/url?q=https://n8n.io/&amp;source=gmail&amp;ust=1741030878129000&amp;usg=AOvVaw1Nr6ek3eGwe94zlbPaJrzT\">https://n8n.io/</a> #AutomationLife #TechInnovation #WorkflowTips #Programming #Engineering</td></tr></tbody></table><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#f9f9f9;margin-bottom:20px;padding:20px;border-radius:8px\"><tbody><tr><td style=\"font-size:20px;font-weight:bold;padding-bottom:10px\">Facebook</td></tr><tr><td style=\"font-size:16px;padding-bottom:10px\">See why businesses are choosing n8n for their workflow automation needs. From its user-friendly interface to its powerful customization options, n8n is revolutionizing how companies approach automation.</td></tr><tr><td style=\"font-size:14px;font-style:italic;padding-bottom:10px\">A visually appealing graphic showcasing n8n's key features and benefits.</td></tr><tr><td style=\"padding-bottom:10px\"><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#SmallBusinessAutomation</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>Entrepreneurship</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#Leadership</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>WorkflowInnovation</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>workflowsdiy</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#n8n</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#AIWorkflows</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>WorkflowAutomation</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>TechSolutions</span></td></tr><tr><td style=\"font-size:14px;font-weight:bold\">What's your favorite automation tip? Share in the comments!</td></tr></tbody></table><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#f9f9f9;margin-bottom:20px;padding:20px;border-radius:8px\"><tbody><tr><td style=\"font-size:20px;font-weight:bold;padding-bottom:10px\">Twitter</td></tr><tr><td style=\"font-size:16px;padding-bottom:10px\">n8n: The best #WorkflowAutomation tool! Open-source, customizable, and powerful. Transform your business processes today!</td></tr><tr><td style=\"padding-bottom:10px\"><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#WorkflowTrends</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#AIWorkflows</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>AutomationTips</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#NoCodeSolutions</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\"><wbr>#workflowsdiy</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#n8n</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>TechSolutions</span></td></tr></tbody></table><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#f9f9f9;margin-bottom:20px;padding:20px;border-radius:8px\"><tbody><tr><td style=\"font-size:20px;font-weight:bold;padding-bottom:10px\">TikTok</td></tr><tr><td style=\"font-size:14px;font-style:italic;padding-bottom:10px\">Quick demo showcasing how n8n simplifies complex workflows with its intuitive interface.</td></tr><tr><td style=\"font-size:16px;padding-bottom:10px\">n8n: Your go-to for effortless workflow automation! <img data-emoji=\"✨\" class=\"an1\" alt=\"✨\" aria-label=\"✨\" draggable=\"false\" src=\"https://fonts.gstatic.com/s/e/notoemoji/16.0/2728/32.png\" loading=\"lazy\"></td></tr><tr><td style=\"padding-bottom:10px\"><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#n8nTips</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#workflowsdiy</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#n8n</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>AIWorkflows</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#WorkflowAutomation</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\"><wbr>#TechSolutions</span></td></tr><tr><td style=\"font-size:14px;font-weight:bold\">Follow workflows.diy for more automation hacks!</td></tr></tbody></table><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#f9f9f9;margin-bottom:20px;padding:20px;border-radius:8px\"><tbody><tr><td style=\"font-size:20px;font-weight:bold;padding-bottom:10px\">Threads</td></tr><tr><td style=\"font-size:16px;padding-bottom:10px\">n8n is transforming the automation landscape. Its open-source nature and extensive integrations make it a top choice for businesses of all sizes. What are your thoughts on the future of workflow automation?</td></tr><tr><td style=\"padding-bottom:10px\"><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#workflowsdiy</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#n8n</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#AIWorkflows</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>WorkflowAutomation</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>TechSolutions</span></td></tr><tr><td style=\"font-size:14px;font-weight:bold\">Share your insights below!</td></tr></tbody></table><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#f9f9f9;margin-bottom:20px;padding:20px;border-radius:8px\"><tbody><tr><td style=\"font-size:20px;font-weight:bold;padding-bottom:10px\">YouTube Shorts</td></tr><tr><td style=\"font-size:14px;font-style:italic;padding-bottom:10px\">Short tutorial demonstrating how to build a simple automation workflow in n8n.</td></tr><tr><td style=\"font-size:16px;padding-bottom:10px\">Learn why n8n is the top choice for workflow automation. Its open-source platform and powerful features make it a game-changer for businesses.</td></tr><tr><td style=\"padding-bottom:10px\"><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#n8n</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#automation</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>workflowautomation</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#nocode</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>workflowsdiy</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#AIWorkflows</span><span style=\"display:inline-block;background:#f0f0f0;padding:2px 6px;margin:2px;border-radius:4px\">#<wbr>TechSolutions</span></td></tr><tr><td style=\"font-size:14px;font-weight:bold\">Subscribe for more workflow tips!</td></tr></tbody></table></td></tr></tbody></table><p></p>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody>\n</table>\n","agent":"conversationalAgent","options":{},"promptType":"define"},"typeVersion":1.7},{"id":"3b074887-262f-47ab-b69c-c51b3a513993","name":"Prepare Results Email","type":"@n8n/n8n-nodes-langchain.agent","position":[0,380],"parameters":{"text":"=Parse the social media post results and generate a modern single line HTML table showing platform statuses. For each entry:\n\n-Extract platform name from the JSON key\n-Identify status (Success/Error) based on statusCode or error presence\n-Capture error message if present\n-Format as responsive HTML table with professional styling\n-Ensure email client compatibility with inline CSS\n-Include error handling for invalid JSON formats\n-Remove all line breaks and \\n from response.\n-Avoid any preamble or further explanation and remove all ``` and ```html from response.\n\n## Implementation Example:\nThis solution uses the parsed results from your workflow to generate:\n<table style=\"border-collapse: collapse; width: 100%; font-family: Arial, sans-serif; margin: 20px 0; background-color: #f9f9f9; border: 1px solid #ddd;\">\n    <thead>\n        <tr style=\"background-color: #007bff; color: #fff;\">\n            <th style=\"border: 1px solid #ddd; padding: 12px; text-align: left;\">Platform</th>\n            <th style=\"border: 1px solid #ddd; padding: 12px; text-align: left;\">Status</th>\n            <th style=\"border: 1px solid #ddd; padding: 12px; text-align: left;\">Details</th>\n        </tr>\n    </thead>\n    <tbody>\n        <tr style=\"background-color: #ffffff;\">\n            <td style=\"border: 1px solid #ddd; padding: 12px;\">Instagram</td>\n            <td style=\"border: 1px solid #ddd; padding: 12px; color: #dc3545;\">✗ Error</td>\n            <td style=\"border: 1px solid #ddd; padding: 12px;\">Unsupported post request. Object with ID '[your-unique-id]' does not exist, cannot be loaded due to missing permissions.</td>\n        </tr>\n        <tr style=\"background-color: #f8f9fa;\">\n            <td style=\"border: 1px solid #ddd; padding: 12px;\">X (Twitter)</td>\n            <td style=\"border: 1px solid #ddd; padding: 12px; color: #dc3545;\">✗ Error</td>\n            <td style=\"border: 1px solid #ddd; padding: 12px;\">Unable to sign without access token</td>\n        </tr>\n        <tr style=\"background-color: #ffffff;\">\n            <td style=\"border: 1px solid #ddd; padding: 12px;\">Facebook</td>\n            <td style=\"border: 1px solid #ddd; padding: 12px; color: #dc3545;\">✗ Error</td>\n            <td style=\"border: 1px solid #ddd; padding: 12px;\">Unsupported post request. Object with ID '[your-unique-id]' does not exist, cannot be loaded due to missing permissions.</td>\n        </tr>\n        <tr style=\"background-color: #f8f9fa;\">\n            <td style=\"border: 1px solid #ddd; padding: 12px;\">LinkedIn</td>\n            <td style=\"border: 1px solid #ddd; padding: 12px; color: #dc3545;\">✗ Error</td>\n            <td style=\"border: 1px solid #ddd; padding: 12px;\">Unable to sign without access token</td>\n        </tr>\n    </tbody>\n</table>\n\n\nThis is the social media post results: \n{{ $json.data.toJsonString() }}\n","agent":"conversationalAgent","options":{},"promptType":"define"},"typeVersion":1.7},{"id":"abb3994f-bf23-43f8-9c46-28795cfd2017","name":"Prepare Results Message","type":"@n8n/n8n-nodes-langchain.agent","position":[0,660],"parameters":{"text":"=Parse the social media post results and generate a brief summary of the results.\n\nThis is the social media post results: \n{{ $json.data.toJsonString() }}\n\n## Example Response:\nThe social media post results indicate multiple errors when attempting to access or post content on various platforms. \n\n1. Instagram: The response shows a 400 status code with an error message indicating that the specific post request is unsupported due to missing permissions or an invalid object ID. \n\n2. X Post: Success\n\n3. Facebook: Success \n\n4. LinkedIn: Also returned an 'Unable to sign without access token' error. \n\nOverall, access token issues and unsupported requests are frequent problems across these social media platforms.\n","agent":"conversationalAgent","options":{},"promptType":"define"},"typeVersion":1.7},{"id":"b4a4838a-83b0-4f28-a9f3-dea915228325","name":"Image Choice","type":"n8n-nodes-base.form","disabled":true,"position":[-620,-120],"webhookId":"0dc811ef-b2e0-4213-a0c9-e9b5fb9fcbf1","parameters":{"options":{"formTitle":"Generate Post Image","buttonLabel":"Submit"},"formFields":{"values":[{"fieldType":"file","fieldLabel":"Upload Image (optional)","multipleFiles":false,"acceptFileTypes":".jpg, .png, .jpeg"},{"fieldType":"dropdown","fieldLabel":"Generate Custom Image using AI Image Generator","fieldOptions":{"values":[{"option":"Yes"},{"option":"No"}]},"requiredField":true}]}},"typeVersion":1},{"id":"1cf97c10-e60f-4584-b069-3d4506868d8e","name":"Gmail Results","type":"n8n-nodes-base.gmail","position":[360,380],"webhookId":"0a81b95a-cd82-465d-8450-cf38518a4cbb","parameters":{"sendTo":"={{ $env.EMAIL_ADDRESS_JOE }} ","message":"={{ $json.output }}","options":{"appendAttribution":false},"subject":"🔥RESULTS🔥 Social Media Factory"},"credentials":{"gmailOAuth2":{"id":"1xpVDEQ1yx8gV022","name":"Gmail account"}},"typeVersion":2.1},{"id":"c845ae46-9d37-472b-ae0f-49fc6940e685","name":"Telegram Results","type":"n8n-nodes-base.telegram","position":[360,660],"webhookId":"bb40ede7-03cf-493d-b051-196b96725925","parameters":{"text":"={{ $json.output }}","chatId":"={{ $env.TELEGRAM_CHAT_ID }}","additionalFields":{"appendAttribution":false}},"credentials":{"telegramApi":{"id":"pAIFhguJlkO3c7aQ","name":"Telegram account"}},"typeVersion":1.2},{"id":"a33f9431-bede-4f66-ae0d-1e686a3092b7","name":"Sticky Note13","type":"n8n-nodes-base.stickyNote","position":[-320,340],"parameters":{"color":4,"width":940,"height":620,"content":""},"typeVersion":1},{"id":"643b94c6-4535-4876-9660-d82ff69cbcf6","name":"Is Content Approved?","type":"n8n-nodes-base.if","position":[-240,-20],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"e32d270f-f258-4522-94e1-2cb7ee4e8d2a","operator":{"type":"boolean","operation":"true","singleValue":true},"leftValue":"={{ $json.data.approved }}","rightValue":""}]}},"typeVersion":2.2},{"id":"fb7108e2-21cf-4df4-ab20-fe75b15b0a24","name":"Set Default True 2","type":"n8n-nodes-base.set","position":[980,20],"parameters":{"options":{},"assignments":{"assignments":[{"id":"f150aa79-2d20-4869-b60a-350d49a215a5","name":"data","type":"object","value":"={\n  \"approved\": true\n}"}]}},"typeVersion":3.4},{"id":"66364a53-c2fc-43fd-be92-683b373652df","name":"Sticky Note14","type":"n8n-nodes-base.stickyNote","position":[-700,-260],"parameters":{"width":300,"height":580,"content":"## Alternative User Uploaded Image\n(optional)"},"typeVersion":1},{"id":"d0025029-1f6f-4b27-8495-00966f1dae12","name":"Sticky Note15","type":"n8n-nodes-base.stickyNote","position":[880,-140],"parameters":{"width":460,"height":340,"content":"## Implement Additional Approval Here\n(optional)"},"typeVersion":1},{"id":"0a10bca0-c3a8-496b-a22e-120928ad7736","name":"SerpAPI","type":"@n8n/n8n-nodes-langchain.toolSerpApi","position":[460,-540],"parameters":{"options":{}},"credentials":{"serpApi":{"id":"DfdkTTaZtPp0iHYv","name":"SerpAPI account"}},"typeVersion":1},{"id":"fa765062-22ef-4f26-9f02-099235edc771","name":"Sticky Note16","type":"n8n-nodes-base.stickyNote","position":[780,-900],"parameters":{"width":480,"height":500,"content":"### 💡Notes\n\nAdjust the Social Media Content Factory prompts to suit your personal or business requirements.\n\nUpdate Credentials for:\n- OpenAI API Key\nhttps://auth.openai.com/log-in\n\n- Google Studio API\nhttps://aistudio.google.com/app/apikey\n\n- SERP API Key\nhttps://serpapi.com/\n\n- Gmail OAuth\nhttps://docs.n8n.io/integrations/builtin/credentials/google/\n\n- Telegram Bot (Optional)\nhttps://docs.n8n.io/integrations/builtin/credentials/telegram/\n\n- imgbb\nhttps://imgbb.com/"},"typeVersion":1},{"id":"5ffc2b16-61af-4395-a57b-20d1cd125488","name":"Sticky Note17","type":"n8n-nodes-base.stickyNote","position":[1940,-140],"parameters":{"width":300,"height":180,"content":"💡Notes\n\nUpdate all Social Media Platform Credentials as required.\n\nAdjust parameters and content for each platform to suit your needs."},"typeVersion":1},{"id":"b21f527c-5674-49d0-a114-866d669e7ad6","name":"Rename Binary File","type":"n8n-nodes-base.code","position":[-620,120],"parameters":{"jsCode":"$input.first().binary.data = $input.first().binary.Upload_Image__optional_\ndelete $input.first().binary.Upload_Image__optional_\nreturn $input.first()"},"typeVersion":2,"alwaysOutputData":true}],"active":false,"pinData":{"Submit Social Post Details":[{"json":{"Topic":"Why n8n is the Best Workflow Automation Tool","formMode":"test","submittedAt":"2025-03-02T13:32:20.807-05:00","Link (optional)":"https://n8n.io/","Keywords or Hashtags (optional)":"n8n, AIWorkflows, workflows.diy"}}]},"settings":{"executionOrder":"v1"},"versionId":"d44bf3b1-5ba6-48e2-8ab6-1cbe93a260e4","connections":{"Merge":{"main":[[{"node":"Set Default True 2","type":"main","index":0}]]},"Merge1":{"main":[[{"node":"Instagram Image","type":"main","index":0}]]},"Merge2":{"main":[[{"node":"Facebook Post","type":"main","index":0},{"node":"LinkedIn Post","type":"main","index":0}]]},"OpenAI":{"main":[[{"node":"Save Image to imgbb.com3","type":"main","index":0},{"node":"Merge","type":"main","index":1},{"node":"Merge2","type":"main","index":1}]]},"X Post":{"main":[[{"node":"X Result","type":"main","index":0}],[]]},"SerpAPI":{"ai_tool":[[{"node":"Social Media Content Factory","type":"ai_tool","index":0}]]},"X Result":{"main":[[{"node":"Merge Results","type":"main","index":1}]]},"Aggregate":{"main":[[{"node":"Prepare Results Email","type":"main","index":0},{"node":"Prepare Results Message","type":"main","index":0}]]},"gpt-4o LLM":{"ai_languageModel":[[{"node":"Social Media Content Factory","type":"ai_languageModel","index":0}]]},"gpt-4o-mini":{"ai_languageModel":[[{"node":"Prepare Content Review Email","type":"ai_languageModel","index":0}]]},"Image Choice":{"main":[[{"node":"Rename Binary File","type":"main","index":0}]]},"Is Approved?":{"main":[[{"node":"X Post","type":"main","index":0},{"node":"Merge1","type":"main","index":1},{"node":"Merge2","type":"main","index":0}],[]]},"gpt-4o-mini1":{"ai_languageModel":[[{"node":"Prepare Results Email","type":"ai_languageModel","index":0}]]},"gpt-4o-mini2":{"ai_languageModel":[[{"node":"Prepare Results Message","type":"ai_languageModel","index":0}]]},"Facebook Post":{"main":[[{"node":"Facebook Result","type":"main","index":0}],[]]},"LinkedIn Post":{"main":[[{"node":"LinkedIn Result","type":"main","index":0}],[]]},"Merge Results":{"main":[[{"node":"Aggregate","type":"main","index":0}]]},"Facebook Result":{"main":[[{"node":"Merge Results","type":"main","index":2}]]},"Instagram Image":{"main":[[{"node":"Instragram Post","type":"main","index":0}]]},"Instragram Post":{"main":[[{"node":"Instagram Result","type":"main","index":0}],[]]},"LinkedIn Result":{"main":[[{"node":"Merge Results","type":"main","index":3}]]},"pollinations.ai":{"main":[[]]},"Instagram Result":{"main":[[{"node":"Merge Results","type":"main","index":0}]]},"Google Gemini LLM":{"ai_languageModel":[[]]},"Set Default True 2":{"main":[[{"node":"Is Approved?","type":"main","index":0}]]},"Is Content Approved?":{"main":[[{"node":"OpenAI","type":"main","index":0}]]},"Social Media Content":{"ai_outputParser":[[{"node":"Social Media Content Factory","type":"ai_outputParser","index":0}]]},"Prepare Results Email":{"main":[[{"node":"Gmail Results","type":"main","index":0}]]},"Gmail User for Approval":{"main":[[{"node":"Is Content Approved?","type":"main","index":0}]]},"Prepare Results Message":{"main":[[{"node":"Telegram Results","type":"main","index":0}]]},"Save Image to imgbb.com3":{"main":[[{"node":"Merge","type":"main","index":0},{"node":"Merge1","type":"main","index":0}]]},"Approve Final Post Content":{"main":[[]]},"Submit Social Post Details":{"main":[[{"node":"Social Media Content Factory","type":"main","index":0}]]},"Prepare Content Review Email":{"main":[[{"node":"Gmail User for Approval","type":"main","index":0}]]},"Social Media Content Factory":{"main":[[{"node":"Prepare Content Review Email","type":"main","index":0}]]}}}


name: Automate SEO-Optimized WordPress Posts with AI & Google Sheets
author_name: Davide
author_username: n3witalia
categories: []
created_at: 2025-03-05T10:24:42.805Z
updated_at: 2025-03-05T10:24:42.805Z
url: https://n8n.io/workflows/3085
scraped_at: 2025-07-06 21:16:30
description:
  This workflow automates the process of creating a complete SEO-optimized blog post, including generating content, titles, images, and meta tags, and publishing it on WordPress. It leverages AI models (like DeepSeek and OpenRouter) for content generation and SEO optimization, and integrates with Google Sheets, WordPress, and OpenAI for image generation. 

  This is a powerful tool for automating the creation and optimization of blog posts, saving time and ensuring high-quality, SEO-friendly content. It integrates multiple tools and AI models to deliver a seamless content creation experience.

  Below is a breakdown of the workflow:

  1. How It Works
  The workflow is designed to streamline the creation of SEO-friendly blog posts. Here's how it works:

  Trigger: The workflow starts with a Manual Trigger node, which initiates the process when the user clicks "Test workflow."
  Fetch Context: The Google Sheets node retrieves the blog post context (e.g., topic, keywords) from a predefined Google Sheet.
  Generate Content:
     The Generate Article node uses an AI model (DeepSeek) to create an SEO-friendly blog post based on the fetched context.
     The Generate Title node creates a compelling, keyword-rich title for the blog post.
  Publish to WordPress:
     The Add Draft to WP node creates a draft post in WordPress with the generated content and title.
  Generate and Upload Image:
     The Generate Image node uses OpenAI to create a realistic, blog-appropriate image.
     The Upload Image node uploads the image to WordPress media.
     The Set Image node associates the uploaded image as the featured image for the blog post.
  SEO Optimization:
     The SEO Expert node analyzes the blog post and generates optimized meta titles and descriptions using an AI model (OpenRouter).
     The Set Metatag node updates the WordPress post with the generated meta tags.
  Update Google Sheets:
     The Update Sheet and Finish Work nodes update the Google Sheet with the post's details, including the URL, title, and metadata.

  2. Set Up Steps
  To set up and use this workflow in n8n, follow these steps:

  Google Sheets Setup:
     Create a Google Sheet with columns for ID POST, PROMPT, TITLE, URL, METATITLE, and METADESCRIPTION.
     Link the Google Sheet to the Get Context node by providing the Document ID and Sheet Name.

  WordPress Integration:
     Set up WordPress credentials in n8n for the Add Draft to WP, Upload Image, and Set Image nodes.
     Ensure the WordPress site is accessible via its REST API.

  AI Model Configuration:
     Configure the DeepSeek and OpenRouter credentials in n8n for the Generate Article, Generate Title, and SEO Expert nodes.
     Ensure the AI models are correctly set up to generate content and meta tags.

  Image Generation:
     Set up OpenAI credentials for the Generate Image node to create blog post images.

  Meta Tag Optimization:
     The SEO Expert node uses OpenRouter to generate meta titles and descriptions. Ensure the node is configured to analyze the blog post content and produce SEO-friendly tags.

  Workflow Execution:
     Click the "Test workflow" button to trigger the workflow.
     The workflow will:
       Fetch the blog post context from Google Sheets.
       Generate the article, title, and image.
       Publish the draft to WordPress.
       Upload and set the featured image.
       Generate and apply meta tags.
       Update the Google Sheet with the post details.

  Optional Customization:
     Modify the workflow to include additional SEO optimizations, such as internal linking, keyword density analysis, or social media sharing.

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

nodes_used:
  ["n8n-nodes-base.googleSheets","n8n-nodes-base.httpRequest","n8n-nodes-base.wordpress","@n8n/n8n-nodes-langchain.chainLlm","@n8n/n8n-nodes-langchain.outputParserStructured","@n8n/n8n-nodes-langchain.openAi","@n8n/n8n-nodes-langchain.lmChatOpenRouter"]

workflow_json:
  {"id":"Mbuax8L8jEmBBYkz","meta":{"instanceId":"a4bfc93e975ca233ac45ed7c9227d84cf5a2329310525917adaf3312e10d5462","templateCredsSetupCompleted":true},"name":"The Ultimate Guide to Optimize WordPress Blog Posts with AI","tags":[{"id":"2VG6RbmUdJ2VZbrj","name":"Google Drive","createdAt":"2024-12-04T16:50:56.177Z","updatedAt":"2024-12-04T16:50:56.177Z"},{"id":"kH2Zf266Nh4c1aga","name":"DeepSeek","createdAt":"2025-01-02T15:24:47.534Z","updatedAt":"2025-01-02T15:24:47.534Z"},{"id":"sAbYDJMthctD4UVJ","name":"Wordpress","createdAt":"2024-12-17T17:37:24.345Z","updatedAt":"2024-12-17T17:37:24.345Z"}],"nodes":[{"id":"5c88bf7d-cd9d-4b76-8233-6e5927692e7a","name":"When clicking ‘Test workflow’","type":"n8n-nodes-base.manualTrigger","position":[-540,-80],"parameters":{},"typeVersion":1},{"id":"d3fc9ed5-9ddc-480d-9fa8-f0a66bb69520","name":"Get context","type":"n8n-nodes-base.googleSheets","position":[-320,-80],"parameters":{"options":{"returnFirstMatch":true},"filtersUI":{"values":[{"lookupColumn":"ID POST"}]},"sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1WlmjnObleBuHRno_axjc-GjV7Wg9gCoIsOK1PD4TxGU/edit#gid=0","cachedResultName":"Foglio1"},"documentId":{"__rl":true,"mode":"list","value":"1WlmjnObleBuHRno_axjc-GjV7Wg9gCoIsOK1PD4TxGU","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1WlmjnObleBuHRno_axjc-GjV7Wg9gCoIsOK1PD4TxGU/edit?usp=drivesdk","cachedResultName":"Complete Plan Blog post"}},"credentials":{"googleSheetsOAuth2Api":{"id":"JYR6a64Qecd6t8Hb","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"27a1aaf2-435f-4fcc-b7be-f88f2e51a6c7","name":"Set context","type":"n8n-nodes-base.set","position":[-100,-80],"parameters":{"options":{},"assignments":{"assignments":[{"id":"3e8d2523-66aa-46fe-adcc-39dc78b9161e","name":"prompt","type":"string","value":"={{ $json.PROMPT }}"}]}},"typeVersion":3.4},{"id":"b2f0a242-ef9f-42d9-974b-e823f23bf37f","name":"Generate title","type":"@n8n/n8n-nodes-langchain.openAi","position":[360,-80],"parameters":{"modelId":{"__rl":true,"mode":"id","value":"=deepseek-chat"},"options":{"maxTokens":2048},"messages":{"values":[{"content":"=You are an SEO Copywriter and you need to find a title of maximum 60 characters for the following article:\n{{ $json.message.content }}\n\nInstructions:\n- Use keywords contained in the article\n- Do not use any HTML characters\n- Output only the string containing the title.\n- Do not use quotes. The only characters allowed are: and ,"}]}},"credentials":{"openAiApi":{"id":"97Cz4cqyiy1RdcQL","name":"DeepSeek"}},"typeVersion":1.8},{"id":"b3b30328-0dfe-4471-9195-d411e737df5e","name":"Generate article","type":"@n8n/n8n-nodes-langchain.openAi","position":[140,-80],"parameters":{"modelId":{"__rl":true,"mode":"id","value":"=deepseek-chat"},"options":{"maxTokens":2048},"messages":{"values":[{"content":"=an SEO-friendly article on these topics:\n{{ $json.prompt }}\n\nInstructions:\n- In the introduction, introduce the topic that will be covered in more detail in the rest of the text\n- The introduction should be about 60 words\n- The conclusion should be about 60 words\n- Use the conclusion to summarize everything said in the article and offer a conclusion to the reader\n- Write a maximum of 2-3 chapters.\n- Chapters should follow a logical flow and not repeat the same ideas.\n- Chapters should be related to each other and not isolated blocks of text. The text should flow and follow a linear logic.\n- Do not start chapters with \"Chapter 1\", \"Chapter 2\", \"Chapter 3\" ... write only the chapter title\n- For the text, use HTML for formatting, but limit yourself to bold, italics, paragraphs and lists.\n- Do not put the output between ```html but only the text\n- Do not use markdown for formatting.\n- Go deeper into the topic you are talking about, don't just throw superficial information out there\n- I only want HTML format in output"}]}},"credentials":{"openAiApi":{"id":"97Cz4cqyiy1RdcQL","name":"DeepSeek"}},"typeVersion":1.8},{"id":"e3f7d28b-ac23-4192-bd46-127491240ee2","name":"Add draft to WP","type":"n8n-nodes-base.wordpress","position":[620,-80],"parameters":{"title":"={{ $json.message.content }}","additionalFields":{"status":"draft","content":"={{ $('Generate article').item.json.message.content }}"}},"credentials":{"wordpressApi":{"id":"OE4AgquSkMWydRqn","name":"Wordpress (wp.test.7hype.com)"}},"typeVersion":1},{"id":"3ebcf40b-7a3b-43fa-a075-0e6dfaa2665e","name":"Generate image","type":"@n8n/n8n-nodes-langchain.openAi","position":[-540,200],"parameters":{"prompt":"=Generate a real photo image used as a blog post cover:\n\nImage prompt:\n{{ $('Generate title').item.json.message.content }}, photography, realistic, sigma 85mm f/1.4","options":{"size":"1024x1024","style":"natural","quality":"hd"},"resource":"image"},"credentials":{"openAiApi":{"id":"CDX6QM4gLYanh0P4","name":"OpenAi account"}},"typeVersion":1.8},{"id":"2eedf2db-660b-4e1e-a38d-34ad2ddb1314","name":"Upload image","type":"n8n-nodes-base.httpRequest","position":[-320,200],"parameters":{"url":"https://URL/wp-json/wp/v2/media","method":"POST","options":{},"sendBody":true,"contentType":"binaryData","sendHeaders":true,"authentication":"predefinedCredentialType","headerParameters":{"parameters":[{"name":"Content-Disposition","value":"=attachment; filename=\"copertina-{{ $('Add draft to WP').item.json.id }}.jpg\""}]},"inputDataFieldName":"data","nodeCredentialType":"wordpressApi"},"credentials":{"wordpressApi":{"id":"OE4AgquSkMWydRqn","name":"Wordpress (wp.test.7hype.com)"}},"typeVersion":4.2},{"id":"58e3aa00-a1d7-4b19-916e-4d07dd7c2009","name":"Set image","type":"n8n-nodes-base.httpRequest","position":[-120,200],"parameters":{"url":"=https://URL/wp-json/wp/v2/posts/{{ $('Add draft to WP').item.json.id }}","method":"POST","options":{},"sendQuery":true,"authentication":"predefinedCredentialType","queryParameters":{"parameters":[{"name":"featured_media","value":"={{ $json.id }}"}]},"nodeCredentialType":"wordpressApi"},"credentials":{"wordpressApi":{"id":"OE4AgquSkMWydRqn","name":"Wordpress (wp.test.7hype.com)"}},"typeVersion":4.2},{"id":"6f9277be-26c4-4d01-9e61-acf3ab90739d","name":"Update Sheet","type":"n8n-nodes-base.googleSheets","position":[140,200],"parameters":{"columns":{"value":{"URL":"={{ $('Add draft to WP').item.json.guid.rendered }}","DATA":"={{ $now.format('dd/LL/yyyy') }}","TITLE":"={{ $('Add draft to WP').item.json.title.rendered }}","ID POST":"={{ $('Add draft to WP').item.json.id }}","row_number":"={{ $('Get context').item.json.row_number }}"},"schema":[{"id":"DATA","type":"string","display":true,"required":false,"displayName":"DATA","defaultMatch":false,"canBeUsedToMatch":true},{"id":"PROMPT","type":"string","display":true,"required":false,"displayName":"PROMPT","defaultMatch":false,"canBeUsedToMatch":true},{"id":"TITLE","type":"string","display":true,"removed":false,"required":false,"displayName":"TITLE","defaultMatch":false,"canBeUsedToMatch":true},{"id":"ID POST","type":"string","display":true,"required":false,"displayName":"ID POST","defaultMatch":false,"canBeUsedToMatch":true},{"id":"URL","type":"string","display":true,"removed":false,"required":false,"displayName":"URL","defaultMatch":false,"canBeUsedToMatch":true},{"id":"METATITLE","type":"string","display":true,"removed":false,"required":false,"displayName":"METATITLE","defaultMatch":false,"canBeUsedToMatch":true},{"id":"METADESCRIPTION","type":"string","display":true,"removed":false,"required":false,"displayName":"METADESCRIPTION","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":["row_number"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"update","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/16VFeCrE5BkMBoA_S5HD-9v7C0sxcXAUiDbq5JvkDqnI/edit#gid=0","cachedResultName":"Foglio1"},"documentId":{"__rl":true,"mode":"list","value":"1WlmjnObleBuHRno_axjc-GjV7Wg9gCoIsOK1PD4TxGU","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1WlmjnObleBuHRno_axjc-GjV7Wg9gCoIsOK1PD4TxGU/edit?usp=drivesdk","cachedResultName":"Complete Plan Blog post"}},"credentials":{"googleSheetsOAuth2Api":{"id":"JYR6a64Qecd6t8Hb","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"1d880c40-af32-4c78-9fa2-fb6b120039d3","name":"SEO Expert","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[500,200],"parameters":{"text":"=Create metatitle and metadescription in the language of the following product:\n- Title: {{ $('Add draft to WP').item.json.title.rendered }}\n- Content: {{ $('Add draft to WP').item.json.content.rendered }}\n- Excerpt: {{ $('Add draft to WP').item.json.excerpt.rendered }}","messages":{"messageValues":[{"message":"=You are an expert SEO content optimizer specialized in creating meta tags for both web pages and blog articles. Your task is to analyze the provided content and generate optimized meta tags based on the content type.\n\nMETA TAG REQUIREMENTS:\n\n1. Meta Title (max 60 characters):\n   - Include primary keyword near the beginning\n   - State the main value proposition\n   - Include brand name when relevant\n   - Use action-oriented language for commercial pages\n   - Format: Primary Keyword | Main Benefit | Brand (if applicable)\n\n2. Meta Description (max 160 characters):\n   - Lead with unique selling proposition\n   - Include primary and secondary keywords naturally\n   - Add clear call-to-action\n   - Highlight key benefits or features\n   - Address user pain points\n   - Tease the main insights or findings\n   - Mention key topics covered\n   - Use engaging question or statement\n   - Include expertise indicators\n   - Promise value or solution\n\nANALYSIS PROCESS:\n1. Content Assessment:\n   - Identify content type and purpose\n   - Extract main topic and keywords\n   - Determine search intent\n   - Identify target audience\n   - Note key differentiators\n\n2. Optimization Strategy:\n   - Align with search intent\n   - Consider competition level\n   - Factor in brand guidelines\n   - Account for content freshness\n   - Optimize for click-through rate\n\nOUTPUT FORMAT:\nPlease provide meta tags in the required format\n\nVALIDATION CHECKLIST:\n- Title length ≤ 60 characters\n- Description length ≤ 160 characters\n- Primary keyword included in both\n- Matches identified search intent\n- Appropriate for content type\n- Clear value proposition\n- Compelling call-to-action\n- Natural keyword placement\n- Proper grammar and spelling\n- Mobile display optimized\n- Don't use placeholder\n\nBEST PRACTICES:\n- Avoid clickbait or misleading content\n- Use power words appropriately\n- Maintain brand voice and tone\n- Ensure mobile snippet optimization\n- Consider local SEO when relevant\n- Keep seasonal content timely\n- Use numbers and data when available\n- Include price/offers if applicable\n- Add emotional triggers when appropriate\n- Consider SERP feature optimization\n\nTECHNICAL GUIDELINES:\n- No double quotes in meta description\n- Avoid unnecessary special characters\n- Use UTF-8 encoding\n- Capitalize properly\n- Avoid keyword cannibalization\n- Respect brand guidelines\n- Consider local market variations\n- Update meta tags for seasonal content\n- Monitor CTR performance\n- A/B test when possible\n\nRemember: The goal is to create meta tags that serve both search engines and users effectively while maintaining specificity for the content type and maximizing organic click-through rates."}]},"promptType":"define","hasOutputParser":true},"typeVersion":1.5},{"id":"d26e13c4-e26d-4f3c-9977-82d32879530e","name":"OpenRouter Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenRouter","position":[480,440],"parameters":{"model":"google/gemini-2.0-flash-exp:free","options":{}},"credentials":{"openRouterApi":{"id":"pb06rfB4xmxzVe3Q","name":"OpenRouter"}},"typeVersion":1},{"id":"c4833efe-1b43-42e7-a5ec-cca1908f327b","name":"Structured Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[700,440],"parameters":{"schemaType":"manual","inputSchema":"{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"metatitle\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"metadescription\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t}\n}"},"typeVersion":1.2},{"id":"962e5d6f-df35-4e5c-b46e-9c2164a3648d","name":"Set metatag","type":"n8n-nodes-base.httpRequest","position":[-540,480],"parameters":{"url":"=https://URL/wp-json/wp/v2/posts/{{ $('Add draft to WP').item.json.id }}","method":"PUT","options":{},"jsonBody":"={\n  \"meta\":{\n    \"_yoast_wpseo_title\":\"{{ $json.output.metatitle }}\",\n    \"_yoast_wpseo_metadesc\":\"{{ $json.output.metadescription }}\"\n  }\n}","sendBody":true,"sendHeaders":true,"specifyBody":"json","authentication":"genericCredentialType","genericAuthType":"httpBasicAuth","headerParameters":{"parameters":[{"name":"Content-Type","value":"application/json"}]}},"credentials":{"httpBasicAuth":{"id":"WCjOvm7HOMwGEMWs","name":"WP (wp.test.7hype.com)"}},"typeVersion":4.2},{"id":"55e8e3c3-2270-4227-863c-e7cf1337c13b","name":"Finish work","type":"n8n-nodes-base.googleSheets","position":[-320,480],"parameters":{"columns":{"value":{"METATITLE":"={{ $('SEO Expert').item.json.output.metatitle }}","row_number":"={{ $('Update Sheet').item.json.row_number }}","METADESCRIPTION":"={{ $('SEO Expert').item.json.output.metadescription }}"},"schema":[{"id":"DATA","type":"string","display":true,"required":false,"displayName":"DATA","defaultMatch":false,"canBeUsedToMatch":true},{"id":"PROMPT","type":"string","display":true,"required":false,"displayName":"PROMPT","defaultMatch":false,"canBeUsedToMatch":true},{"id":"TITLE","type":"string","display":true,"required":false,"displayName":"TITLE","defaultMatch":false,"canBeUsedToMatch":true},{"id":"ID POST","type":"string","display":true,"required":false,"displayName":"ID POST","defaultMatch":false,"canBeUsedToMatch":true},{"id":"URL","type":"string","display":true,"required":false,"displayName":"URL","defaultMatch":false,"canBeUsedToMatch":true},{"id":"METATITLE","type":"string","display":true,"required":false,"displayName":"METATITLE","defaultMatch":false,"canBeUsedToMatch":true},{"id":"METADESCRIPTION","type":"string","display":true,"required":false,"displayName":"METADESCRIPTION","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":["row_number"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"update","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1WlmjnObleBuHRno_axjc-GjV7Wg9gCoIsOK1PD4TxGU/edit#gid=0","cachedResultName":"Foglio1"},"documentId":{"__rl":true,"mode":"list","value":"1WlmjnObleBuHRno_axjc-GjV7Wg9gCoIsOK1PD4TxGU","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1WlmjnObleBuHRno_axjc-GjV7Wg9gCoIsOK1PD4TxGU/edit?usp=drivesdk","cachedResultName":"Complete Plan Blog post"}},"credentials":{"googleSheetsOAuth2Api":{"id":"JYR6a64Qecd6t8Hb","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"f50be61f-7502-4186-9952-22e740de896e","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-360,-160],"parameters":{"width":180,"height":240,"content":"Fetches the context of the article you want to generate via AI"},"typeVersion":1},{"id":"149e3535-60fb-4547-8dad-567a47f9bc4b","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[540,-160],"parameters":{"width":280,"height":240,"content":"Create the draft post on Wordpress with the article text and the title that were previously generated"},"typeVersion":1},{"id":"779e3a0d-1429-4973-9757-fa1645796cbd","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-360,140],"parameters":{"width":400,"height":220,"content":"Upload the generated image to Wordpress media and then associate it with the newly created article"},"typeVersion":1},{"id":"9b375c3e-3c3a-44e9-b234-2538e6f33d32","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[400,140],"parameters":{"width":420,"height":220,"content":"The SEO expert analyzes the created article and generates the appropriate meta title and meta description"},"typeVersion":1},{"id":"d4c503c9-9d0f-4411-a3a6-bdd77f782a77","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-600,420],"parameters":{"width":220,"height":200,"content":"The generated metadata is associated with the post"},"typeVersion":1},{"id":"8d7a1d61-3fbe-4d76-9f2d-68b4c9de23bb","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-560,-460],"parameters":{"color":3,"width":820,"content":"## Optimize WordPress Blog Posts with AI\n\nThis is a powerful tool for automating the creation and optimization of blog posts, saving time and ensuring high-quality, SEO-friendly content for Wordpress with Yoast plugin. \n\n[Clone this Sheet](https://docs.google.com/spreadsheets/d/1WlmjnObleBuHRno_axjc-GjV7Wg9gCoIsOK1PD4TxGU/edit?usp=sharing) and in the \"Prompt\" column write the topic that will then be developed by the AI"},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"8d701d17-18ae-478c-881d-eedb422e9700","connections":{"Set image":{"main":[[{"node":"Update Sheet","type":"main","index":0}]]},"SEO Expert":{"main":[[{"node":"Set metatag","type":"main","index":0}]]},"Get context":{"main":[[{"node":"Set context","type":"main","index":0}]]},"Set context":{"main":[[{"node":"Generate article","type":"main","index":0}]]},"Set metatag":{"main":[[{"node":"Finish work","type":"main","index":0}]]},"Update Sheet":{"main":[[{"node":"SEO Expert","type":"main","index":0}]]},"Upload image":{"main":[[{"node":"Set image","type":"main","index":0}]]},"Generate image":{"main":[[{"node":"Upload image","type":"main","index":0}]]},"Generate title":{"main":[[{"node":"Add draft to WP","type":"main","index":0}]]},"Add draft to WP":{"main":[[{"node":"Generate image","type":"main","index":0}]]},"Generate article":{"main":[[{"node":"Generate title","type":"main","index":0}]]},"OpenRouter Chat Model":{"ai_languageModel":[[{"node":"SEO Expert","type":"ai_languageModel","index":0}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"SEO Expert","type":"ai_outputParser","index":0}]]},"When clicking ‘Test workflow’":{"main":[[{"node":"Get context","type":"main","index":0}]]}}}


name: Publish WordPress Posts to Social Media X, Facebook, LinkedIn, Instagram with AI
author_name: Davide
author_username: n3witalia
categories: []
created_at: 2025-03-05T10:25:33.216Z
updated_at: 2025-03-05T10:25:33.216Z
url: https://n8n.io/workflows/3086
scraped_at: 2025-07-06 21:16:30
description:
  Workflow Description for n8n: Social Media Post from Ideas Copy

  This workflow automates the process of creating and publishing social media posts across multiple platforms (Twitter/X, Facebook, LinkedIn, and Instagram) based on content from a WordPress post. It uses AI models to generate platform-specific captions and images, and integrates with Google Sheets, WordPress, and various social media APIs. 

  Is a powerful tool for automating social media post creation and publishing, saving time and ensuring consistent, platform-optimized content across multiple channels.

  Below is a breakdown of the workflow:

  1. How It Works
  The workflow is designed to streamline the creation and publishing of social media posts. Here's how it works:

  Trigger:
     The workflow starts with a Manual Trigger node, which initiates the process when the user clicks "Test workflow."

  Fetch Data:
     The Google Sheets node retrieves the WordPress Post ID from a predefined Google Sheet.
     The Get Post node fetches the corresponding WordPress post content using the retrieved Post ID.

  Generate Social Media Content:
     The Social Media Manager node uses an AI model (OpenRouter) to analyze the WordPress post and generate platform-specific captions for Twitter/X, Facebook, LinkedIn, and Instagram.
     The AI ensures that each caption is tailored to the platform's audience, tone, and style, including hashtags and calls to action.

  Generate Images:
     The Image Instagram and Image Facebook e Linkedin nodes use OpenAI to generate platform-specific images for Instagram, Facebook, and LinkedIn posts.

  Publish on Social Media:
     The workflow publishes the generated content and images on the respective platforms:
       Publish on X: Posts the caption on Twitter/X.
       Publish on LinkedIn: Posts the caption and image on LinkedIn.
       Publish on Facebook: Posts the caption and image on Facebook.
       Publish on Instagram: Posts the caption and image on Instagram.

  Update Google Sheets:
     The workflow updates the Google Sheet to mark the posts as published (e.g., "X OK," "Facebook OK," "LinkedIn OK," "Instagram OK").

  2. Set Up Steps
  To set up and use this workflow in n8n, follow these steps:

  Google Sheets Setup:
     Create (or clone) a Google Sheet with columns for POST ID, TEXT, TWITTER, FACEBOOK, INSTAGRAM, and LINKEDIN.
     Link the Google Sheet to the Google Sheets node by providing the Document ID and Sheet Name.

  WordPress Integration:
     Set up WordPress credentials in n8n for the Get Post node.
     Ensure the WordPress site is accessible via its REST API.

  AI Model Configuration:
     Configure the OpenRouter credentials in n8n for the Social Media Manager node.
     Ensure the AI model is set up to generate platform-specific captions.

  Image Generation:
     Set up OpenAI credentials for the Image Instagram and Image Facebook e Linkedin nodes to generate images.

  Social Media API Integration:
     Set up credentials for each social media platform:
       Twitter/X: Configure the Publish on X node with Twitter OAuth2 credentials.
       LinkedIn: Configure the Publish on LinkedIn node with LinkedIn OAuth2 credentials.
       Facebook: Configure the Publish on Facebook and Publish on Instagram nodes with Facebook Graph API credentials.

  Test the Workflow:
     Click the "Test workflow" button in n8n to trigger the workflow.
     The workflow will:
       Fetch the WordPress post content.
       Generate platform-specific captions and images.
       Publish the posts on Twitter/X, Facebook, LinkedIn, and Instagram.
       Update the Google Sheet to mark the posts as published.

  Optional Customization:
     Modify the workflow to include additional platforms or customize the AI-generated content further.

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

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

workflow_json:
  {"id":"U9RofpXSIIUg12f9","meta":{"instanceId":"a4bfc93e975ca233ac45ed7c9227d84cf5a2329310525917adaf3312e10d5462","templateCredsSetupCompleted":true},"name":"AI Social Media Publisher from WordPress","tags":[{"id":"2VG6RbmUdJ2VZbrj","name":"Google Drive","createdAt":"2024-12-04T16:50:56.177Z","updatedAt":"2024-12-04T16:50:56.177Z"},{"id":"EtObDwELrdVvzOcI","name":"OpenRouter","createdAt":"2024-12-04T16:53:26.886Z","updatedAt":"2024-12-04T16:53:26.886Z"},{"id":"OVXRgoTzbRrrYmBB","name":"X","createdAt":"2025-02-24T15:47:38.855Z","updatedAt":"2025-02-24T15:47:38.855Z"},{"id":"PLbmcn8OyqnoHrYE","name":"Instagram","createdAt":"2025-02-24T15:47:48.325Z","updatedAt":"2025-02-24T15:47:48.325Z"},{"id":"QsjuqQbwRJaxuGB4","name":"Facebook","createdAt":"2025-02-24T15:47:42.574Z","updatedAt":"2025-02-24T15:47:42.574Z"},{"id":"oK8zaSe2Q5RG7qNe","name":"Linkedin","createdAt":"2025-02-24T15:47:45.129Z","updatedAt":"2025-02-24T15:47:45.129Z"},{"id":"paTcf5QZDJsC2vKY","name":"OpenAI","createdAt":"2024-12-04T16:52:10.768Z","updatedAt":"2024-12-04T16:52:10.768Z"}],"nodes":[{"id":"f5bb7898-44eb-45bf-b199-2146c8e901f6","name":"When clicking ‘Test workflow’","type":"n8n-nodes-base.manualTrigger","position":[-220,-80],"parameters":{},"typeVersion":1},{"id":"b1977304-fbbf-4bb5-924a-e5db036bca91","name":"Google Sheets","type":"n8n-nodes-base.googleSheets","position":[0,-80],"parameters":{"options":{"returnFirstMatch":true},"filtersUI":{"values":[{"lookupColumn":"TWITTER"}]},"sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1suPQNdgoAzrklleN4ok2mZnsq0GK1dt59oIHv8JWX5U/edit#gid=0","cachedResultName":"Foglio1"},"documentId":{"__rl":true,"mode":"list","value":"1suPQNdgoAzrklleN4ok2mZnsq0GK1dt59oIHv8JWX5U","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1suPQNdgoAzrklleN4ok2mZnsq0GK1dt59oIHv8JWX5U/edit?usp=drivesdk","cachedResultName":"Social Media post"}},"credentials":{"googleSheetsOAuth2Api":{"id":"JYR6a64Qecd6t8Hb","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"1451692d-8e8d-4da7-be3e-b4dd20319c7a","name":"OpenRouter Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenRouter","position":[400,140],"parameters":{"model":"google/gemini-2.0-flash-exp:free","options":{}},"credentials":{"openRouterApi":{"id":"pb06rfB4xmxzVe3Q","name":"OpenRouter"}},"typeVersion":1},{"id":"6768f867-666d-4c41-b77a-1bfb389b0329","name":"Structured Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[620,140],"parameters":{"schemaType":"manual","inputSchema":"{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"twitter\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"facebook\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n        \"linkedin\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n        \"instagram\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t}\n}"},"typeVersion":1.2},{"id":"05cf81ec-bb25-447a-9c54-183132b8804c","name":"Image Instagram","type":"@n8n/n8n-nodes-langchain.openAi","position":[940,280],"parameters":{"prompt":"={{ $json.output.instagram }}","options":{"size":"1024x1024","returnImageUrls":true},"resource":"image"},"credentials":{"openAiApi":{"id":"CDX6QM4gLYanh0P4","name":"OpenAi account"}},"typeVersion":1.8},{"id":"2ae8be2c-28a3-4f55-aee3-2fff3517b149","name":"Image Facebook e Linkedin","type":"@n8n/n8n-nodes-langchain.openAi","position":[940,-140],"parameters":{"prompt":"={{ $json.output.facebook }}","options":{"size":"1792x1024","returnImageUrls":false},"resource":"image"},"credentials":{"openAiApi":{"id":"CDX6QM4gLYanh0P4","name":"OpenAi account"}},"typeVersion":1.8},{"id":"583a8459-3574-44e6-85bf-a33b9a4bf9f4","name":"Social Media Manager","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[440,-80],"parameters":{"text":"=Generate social content from the following text with title \"{{ $json.title.rendered }}\" (in the same language):\n\n'''\n{{ $json.content.rendered }}\n'''","messages":{"messageValues":[{"message":"=Your goal is to create engaging and informative content for LinkedIn, Instagram, Facebook, Twitter (X) while ensuring each post aligns with the platform’s audience, tone, and style. Content should reflect the company’s expertise, providing value-driven insights, tutorials, reviews, and discussions that resonate with tech professionals, enthusiasts, and businesses.\n\nEach post should be optimized for engagement, using platform-specific hashtags to improve reach and SEO. Maintain a professional yet approachable tone that promotes trust and authority in the tech space.\n\nContent Creation Best Practices:\nPost Optimization: Adapt content format, style, and hashtags based on each social media platform’s algorithm and audience engagement patterns.\nSEO & Hashtags: Use a balanced mix of general hashtags and platform-specific trending hashtags to maximize reach.\nEngagement-driven content: Focus on tech tutorials, IT industry updates, comparisons, reviews, and in-depth discussions that spark engagement.\nConsistency: Maintain a consistent tone and visual identity across all platforms, while tailoring content to each audience.\nData-driven trends: Regularly analyze post performance and adjust your hashtag strategy to reflect trending discussions within your topic. High-quality, relevant, and engaging copy that appeals to professionals, businesses, and enthusiasts of your topic must be provided.\n\n### Platform-specific requirements:\n1. **LinkedIn**:\n- Style: Professional and informative.\n- Tone: Focus on business results, employee gratitude, and community impact.\n- Content length: 3-4 sentences, detailed and insightful.\n- Hashtags: Create hashtags that are compatible with your topic.\n- Call to action: Engage businesses and professionals by encouraging comments or visits to Al Ansari's website.\n\n2. **Instagram**:\n- Style: Visual storytelling.\n- Tone: Inspiring and engaging.\n- Content length: 2-3 sentences, paired with creative captions and emojis.\n- Images: Highlight events, giveaways, and milestones (e.g., 50th anniversary keychains, eco-friendly tote bags).\n- Call to action: Use phrases like “Swipe to see more,” “Tag your coworkers,” or “Celebrate with us!”\n- Hashtags: Create hashtags that resonate with your topic\n\n3. **Facebook**:\n- Style: Friendly and relevant.\n- Tone: Community-focused, sharing employee stories, accomplishments, or event updates.\n- Content length: 2-3 sentences, slightly informal but still reflective of your company’s values.\n- Call to Action: Encourage likes, shares, and comments from connected families and communities\n\n4. **Twitter (X)**:\n- Style: Concise and impactful.\n- Tone: Crisp, engaging, and catchy.\n- Content Length: 150 characters or less, including hashtags.\n- Create hashtags that are compatible with the topic being discussed\n- Call to Action: Focus on rapid engagement through retweets, likes, and replies.\n\nWith this guide, generate posts for all platforms for the inputs below by inserting them into the specified json structure;"}]},"promptType":"define","hasOutputParser":true},"typeVersion":1.5},{"id":"634af127-cd08-4beb-99a8-daa626793736","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-60,-160],"parameters":{"width":420,"height":260,"content":"Get the Post ID of the Wordpress article on which you want to generate the caption for social media"},"typeVersion":1},{"id":"dbdb39dc-02b2-4fe6-8b70-f38b86c9d9e3","name":"Linkedin OK","type":"n8n-nodes-base.googleSheets","position":[1480,-260],"parameters":{"columns":{"value":{"LINKEDIN":"x","row_number":"={{ $('Google Sheets').item.json.row_number }}"},"schema":[{"id":"POST ID","type":"string","display":true,"required":false,"displayName":"POST ID","defaultMatch":false,"canBeUsedToMatch":true},{"id":"TESTO","type":"string","display":true,"required":false,"displayName":"TESTO","defaultMatch":false,"canBeUsedToMatch":true},{"id":"TWITTER","type":"string","display":true,"required":false,"displayName":"TWITTER","defaultMatch":false,"canBeUsedToMatch":true},{"id":"FACEBOOK","type":"string","display":true,"removed":false,"required":false,"displayName":"FACEBOOK","defaultMatch":false,"canBeUsedToMatch":true},{"id":"INSTAGRAM","type":"string","display":true,"removed":false,"required":false,"displayName":"INSTAGRAM","defaultMatch":false,"canBeUsedToMatch":true},{"id":"LINKEDIN","type":"string","display":true,"removed":false,"required":false,"displayName":"LINKEDIN","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":["row_number"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"update","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1suPQNdgoAzrklleN4ok2mZnsq0GK1dt59oIHv8JWX5U/edit#gid=0","cachedResultName":"Foglio1"},"documentId":{"__rl":true,"mode":"list","value":"1suPQNdgoAzrklleN4ok2mZnsq0GK1dt59oIHv8JWX5U","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1suPQNdgoAzrklleN4ok2mZnsq0GK1dt59oIHv8JWX5U/edit?usp=drivesdk","cachedResultName":"Social Media post"}},"credentials":{"googleSheetsOAuth2Api":{"id":"JYR6a64Qecd6t8Hb","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"07aba718-fb10-48d4-bedb-0c19315acfe1","name":"Facebook Ok","type":"n8n-nodes-base.googleSheets","position":[1480,0],"parameters":{"columns":{"value":{"FACEBOOK":"x","row_number":"={{ $('Google Sheets').item.json.row_number }}"},"schema":[{"id":"POST ID","type":"string","display":true,"required":false,"displayName":"POST ID","defaultMatch":false,"canBeUsedToMatch":true},{"id":"TESTO","type":"string","display":true,"required":false,"displayName":"TESTO","defaultMatch":false,"canBeUsedToMatch":true},{"id":"TWITTER","type":"string","display":true,"required":false,"displayName":"TWITTER","defaultMatch":false,"canBeUsedToMatch":true},{"id":"FACEBOOK","type":"string","display":true,"removed":false,"required":false,"displayName":"FACEBOOK","defaultMatch":false,"canBeUsedToMatch":true},{"id":"INSTAGRAM","type":"string","display":true,"removed":false,"required":false,"displayName":"INSTAGRAM","defaultMatch":false,"canBeUsedToMatch":true},{"id":"LINKEDIN","type":"string","display":true,"removed":false,"required":false,"displayName":"LINKEDIN","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":["row_number"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"update","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1suPQNdgoAzrklleN4ok2mZnsq0GK1dt59oIHv8JWX5U/edit#gid=0","cachedResultName":"Foglio1"},"documentId":{"__rl":true,"mode":"list","value":"1suPQNdgoAzrklleN4ok2mZnsq0GK1dt59oIHv8JWX5U","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1suPQNdgoAzrklleN4ok2mZnsq0GK1dt59oIHv8JWX5U/edit?usp=drivesdk","cachedResultName":"Social Media post"}},"credentials":{"googleSheetsOAuth2Api":{"id":"JYR6a64Qecd6t8Hb","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"7fda8841-4b46-4f3b-9ba0-aa728ba7943f","name":"Instagram OK","type":"n8n-nodes-base.googleSheets","position":[1480,280],"parameters":{"columns":{"value":{"INSTAGRAM":"x","row_number":"={{ $('Google Sheets').item.json.row_number }}"},"schema":[{"id":"POST ID","type":"string","display":true,"required":false,"displayName":"POST ID","defaultMatch":false,"canBeUsedToMatch":true},{"id":"TESTO","type":"string","display":true,"required":false,"displayName":"TESTO","defaultMatch":false,"canBeUsedToMatch":true},{"id":"TWITTER","type":"string","display":true,"required":false,"displayName":"TWITTER","defaultMatch":false,"canBeUsedToMatch":true},{"id":"FACEBOOK","type":"string","display":true,"removed":false,"required":false,"displayName":"FACEBOOK","defaultMatch":false,"canBeUsedToMatch":true},{"id":"INSTAGRAM","type":"string","display":true,"removed":false,"required":false,"displayName":"INSTAGRAM","defaultMatch":false,"canBeUsedToMatch":true},{"id":"LINKEDIN","type":"string","display":true,"removed":false,"required":false,"displayName":"LINKEDIN","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":["row_number"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"update","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1suPQNdgoAzrklleN4ok2mZnsq0GK1dt59oIHv8JWX5U/edit#gid=0","cachedResultName":"Foglio1"},"documentId":{"__rl":true,"mode":"list","value":"1suPQNdgoAzrklleN4ok2mZnsq0GK1dt59oIHv8JWX5U","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1suPQNdgoAzrklleN4ok2mZnsq0GK1dt59oIHv8JWX5U/edit?usp=drivesdk","cachedResultName":"Social Media post"}},"credentials":{"googleSheetsOAuth2Api":{"id":"JYR6a64Qecd6t8Hb","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"fe599e8f-ff45-4aec-b70e-f0dc75b929d5","name":"Get Post","type":"n8n-nodes-base.wordpress","position":[220,-80],"parameters":{"postId":"={{ $json['POST ID'] }}","options":{},"operation":"get"},"credentials":{"wordpressApi":{"id":"OE4AgquSkMWydRqn","name":"Wordpress (wp.test.7hype.com)"}},"typeVersion":1},{"id":"09059725-47dd-44ff-bcbd-f83d3bb3941d","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[380,-160],"parameters":{"width":360,"height":260,"content":"The SMM Chain analyses the content of the post and creates the most suitable caption based on the destination social network.\n"},"typeVersion":1},{"id":"89a0deab-b55a-4eb6-8251-538f5f216d56","name":"Publish on X","type":"n8n-nodes-base.twitter","position":[1220,-500],"parameters":{"text":"={{ $json.output.twitter }}","additionalFields":{}},"credentials":{"twitterOAuth2Api":{"id":"qex5DVfLnCShvOC4","name":"X account"}},"typeVersion":2},{"id":"d0a618f3-48e0-4ba1-9525-e15663b38d9f","name":"X OK","type":"n8n-nodes-base.googleSheets","position":[1480,-500],"parameters":{"columns":{"value":{"TWITTER":"x","row_number":"={{ $('Google Sheets').item.json.row_number }}"},"schema":[{"id":"POST ID","type":"string","display":true,"required":false,"displayName":"POST ID","defaultMatch":false,"canBeUsedToMatch":true},{"id":"TESTO","type":"string","display":true,"required":false,"displayName":"TESTO","defaultMatch":false,"canBeUsedToMatch":true},{"id":"TWITTER","type":"string","display":true,"required":false,"displayName":"TWITTER","defaultMatch":false,"canBeUsedToMatch":true},{"id":"FACEBOOK","type":"string","display":true,"removed":false,"required":false,"displayName":"FACEBOOK","defaultMatch":false,"canBeUsedToMatch":true},{"id":"INSTAGRAM","type":"string","display":true,"removed":false,"required":false,"displayName":"INSTAGRAM","defaultMatch":false,"canBeUsedToMatch":true},{"id":"LINKEDIN","type":"string","display":true,"removed":false,"required":false,"displayName":"LINKEDIN","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":["row_number"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"update","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1suPQNdgoAzrklleN4ok2mZnsq0GK1dt59oIHv8JWX5U/edit#gid=0","cachedResultName":"Foglio1"},"documentId":{"__rl":true,"mode":"list","value":"1suPQNdgoAzrklleN4ok2mZnsq0GK1dt59oIHv8JWX5U","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1suPQNdgoAzrklleN4ok2mZnsq0GK1dt59oIHv8JWX5U/edit?usp=drivesdk","cachedResultName":"Social Media post"}},"credentials":{"googleSheetsOAuth2Api":{"id":"JYR6a64Qecd6t8Hb","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"8f19c32b-ab02-4098-a165-a3c9c6ff05c4","name":"Publish on LinkedIn","type":"n8n-nodes-base.linkedIn","position":[1220,-260],"parameters":{"text":"={{ $('Social Media Manager').item.json.output.linkedin }}","postAs":"organization","organization":"xxxxxxx","additionalFields":{},"shareMediaCategory":"IMAGE"},"credentials":{"linkedInOAuth2Api":{"id":"K5XMG4dK4jY43PJ3","name":"LinkedIn account"}},"typeVersion":1},{"id":"69324bfa-ce6e-42e7-9598-13d8dbd13ae7","name":"Publish on Facebook","type":"n8n-nodes-base.facebookGraphApi","position":[1220,0],"parameters":{"edge":"photos","node":"433770813646235","options":{"queryParameters":{"parameter":[{"name":"message","value":"={{ $('Social Media Manager').item.json.output.facebook }}"},{"name":"link","value":"={{ $('Get Post').item.json.link }}"}]}},"sendBinaryData":true,"graphApiVersion":"v21.0","httpRequestMethod":"POST","binaryPropertyName":"data"},"credentials":{"facebookGraphApi":{"id":"q5gZW6hdEvqTFPup","name":"Facebook Graph account (Fantaera)"}},"typeVersion":1},{"id":"ccc7bb23-2a26-42c6-9ac4-16a2cce77f66","name":"Publish on Instagram","type":"n8n-nodes-base.httpRequest","position":[1220,280],"parameters":{"url":"https://graph.facebook.com/v20.0/433770813646235/media","method":"POST","options":{},"sendQuery":true,"authentication":"predefinedCredentialType","queryParameters":{"parameters":[{"name":"image_url","value":"={{ $json.url }}"},{"name":"caption","value":"={{ $('Social Media Manager').item.json.output.instagram }}"}]},"nodeCredentialType":"facebookGraphApi"},"credentials":{"facebookGraphApi":{"id":"q5gZW6hdEvqTFPup","name":"Facebook Graph account (Fantaera)"}},"typeVersion":4.2},{"id":"687cf808-1355-4bec-aad3-2395efd5a41c","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-220,-680],"parameters":{"color":3,"width":960,"height":320,"content":"## STEP 1\n\nThis workflow automates the process of creating and publishing social media posts across multiple platforms (Twitter/X, Facebook, LinkedIn, and Instagram) based on content from a WordPress post. It uses AI models to generate platform-specific captions and images, and integrates with Google Sheets, WordPress, and various social media APIs.\n\nGet the API Keys of the social networks you want to publish on\n- [X (Twitter)](https://docs.x.com/x-api/getting-started/getting-access)\n- [Linkedin](https://learn.microsoft.com/en-us/linkedin/marketing/community-management/shares/posts-api?view=li-lms-2025-02&tabs=http)\n- [Facebook](https://developers.facebook.com/docs/facebook-login/guides/access-tokens#portabletokens)\n- [Instagram](https://developers.facebook.com/docs/instagram-platform/instagram-api-with-facebook-login/content-publishing/)\n\nAuthenticate on social media nodes with the access tokens obtained"},"typeVersion":1},{"id":"f74d071d-cb55-48f0-8cea-1cc24fa34061","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-220,-320],"parameters":{"color":3,"width":960,"height":100,"content":"## STEP 2\nClone [this Sheet](https://docs.google.com/spreadsheets/d/1suPQNdgoAzrklleN4ok2mZnsq0GK1dt59oIHv8JWX5U/edit?usp=sharing) and set ONLY the WordPress Post ID id in the right column\n"},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"31616cbf-fe93-445c-8224-ea0b3afc4696","connections":{"Get Post":{"main":[[{"node":"Social Media Manager","type":"main","index":0}]]},"Publish on X":{"main":[[{"node":"X OK","type":"main","index":0}]]},"Google Sheets":{"main":[[{"node":"Get Post","type":"main","index":0}]]},"Image Instagram":{"main":[[{"node":"Publish on Instagram","type":"main","index":0}]]},"Publish on Facebook":{"main":[[{"node":"Facebook Ok","type":"main","index":0}]]},"Publish on LinkedIn":{"main":[[{"node":"Linkedin OK","type":"main","index":0}]]},"Publish on Instagram":{"main":[[{"node":"Instagram OK","type":"main","index":0}]]},"Social Media Manager":{"main":[[{"node":"Image Instagram","type":"main","index":0},{"node":"Image Facebook e Linkedin","type":"main","index":0},{"node":"Publish on X","type":"main","index":0}]]},"OpenRouter Chat Model":{"ai_languageModel":[[{"node":"Social Media Manager","type":"ai_languageModel","index":0}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"Social Media Manager","type":"ai_outputParser","index":0}]]},"Image Facebook e Linkedin":{"main":[[{"node":"Publish on LinkedIn","type":"main","index":0},{"node":"Publish on Facebook","type":"main","index":0}]]},"When clicking ‘Test workflow’":{"main":[[{"node":"Google Sheets","type":"main","index":0}]]}}}


name: Parse and Extract Data from Documents/Images with Mistral OCR
author_name: Jimleuk
author_username: jimleuk
nodes_used: ["n8n-nodes-base.httpRequest","n8n-nodes-base.googleDrive"]
categories: []
created_at: 2025-03-06T23:17:34.872Z
updated_at: 2025-03-06T23:17:34.872Z
url: https://n8n.io/workflows/3102
scraped_at: 2025-07-06 21:16:30
description:
  Mistral OCR is a super convenient way to parse and extract data from multi-page PDFs or single images using AI.

  What makes it special and differs it from the competition is that Mistral OCR also performs document page splitting and markdown conversion. This helps reduce dependencies required for document parsing workflows where tools like StirlingPDF.

  Read the official documentation on Mistral OCR API here: https://docs.mistral.ai/capabilities/document/#tag/ocr/operation/ocr_v1_ocr_post

  How it works
  To access Mistral-OCR, you'll need to use Mistral Cloud API via the HTTP request node
  Mistral OCR can only accept 2 file types: PDF and Image. Here, we use 2 different request to the Mistral-OCR API to parse a bank statement PDF and an screenshot of a bank statement to extract the tables.
  Next, we explore a more secure method of uploading documents to the Mistral OCR API by using Mistral's cloud storage. In example 2, we first store a copy of our documents to Mistral cloud and then generate a signed URL to retreive the file before sending it to Mistral OCR. This ensures the file is not accessible publicly and protects it from unauthorised access.
  Finally, another way to use Mistral-OCR is via document understanding. This allows you to ask questions about the document rather than extract contents from it. In example 3, I demonstrate this use-case asking Mistral-small to tell me how many deposits are shown in the bank statement.

  How to use
  Ensure your documents are either publicly accessible for Mistral-OCR or upload them to Mistral Cloud. Alternatively, signed urls from AWS S3 or Cloudflare R2 should also work.

  Requirements
  Mistral Cloud account and API  Key. You'll also need credit on your account to use Mistral-OCR.

  Customising the workflow
  Mistral-OCR also works for images such as charts and diagrams so try using it on Financial Reports.
  Mistral-OCR is even cheaper with batching enabled. This returns your results within 24hrs but is half the price per page.

workflow_json:
  {"meta":{"instanceId":"408f9fb9940c3cb18ffdef0e0150fe342d6e655c3a9fac21f0f644e8bedabcd9","templateCredsSetupCompleted":true},"nodes":[{"id":"c499b8cc-7cc8-411d-9c22-d46c7654e169","name":"Mistral Upload","type":"n8n-nodes-base.httpRequest","position":[700,-20],"parameters":{"url":"https://api.mistral.ai/v1/files","method":"POST","options":{},"sendBody":true,"contentType":"multipart-form-data","authentication":"predefinedCredentialType","bodyParameters":{"parameters":[{"name":"purpose","value":"ocr"},{"name":"file","parameterType":"formBinaryData","inputDataFieldName":"data"}]},"nodeCredentialType":"mistralCloudApi"},"credentials":{"mistralCloudApi":{"id":"EIl2QxhXAS9Hkg37","name":"Mistral Cloud account"}},"typeVersion":4.2},{"id":"08cbe4b7-2adc-4ea0-8dfc-af107369b1dd","name":"When clicking ‘Test workflow’","type":"n8n-nodes-base.manualTrigger","position":[-540,-20],"parameters":{},"typeVersion":1},{"id":"965f294a-5d77-4190-ad4f-ff191aba0948","name":"Mistral Signed URL","type":"n8n-nodes-base.httpRequest","position":[900,-20],"parameters":{"url":"=https://api.mistral.ai/v1/files/{{ $json.id }}/url","options":{},"sendQuery":true,"sendHeaders":true,"authentication":"predefinedCredentialType","queryParameters":{"parameters":[{"name":"expiry","value":"24"}]},"headerParameters":{"parameters":[{"name":"Accept","value":"application/json"}]},"nodeCredentialType":"mistralCloudApi"},"credentials":{"mistralCloudApi":{"id":"EIl2QxhXAS9Hkg37","name":"Mistral Cloud account"}},"typeVersion":4.2},{"id":"7abfb1f8-f6c8-4fd0-a78e-9d4b97a4d6bc","name":"Import PDF","type":"n8n-nodes-base.googleDrive","position":[480,-20],"parameters":{"fileId":{"__rl":true,"mode":"id","value":"15BcE6nXto9lQDHPmwjm7y9JPerAVEutY"},"options":{},"operation":"download"},"credentials":{"googleDriveOAuth2Api":{"id":"yOwz41gMQclOadgu","name":"Google Drive account"}},"typeVersion":3},{"id":"8942c6bf-4d86-4a95-aa4a-c819008e2534","name":"Import Image","type":"n8n-nodes-base.googleDrive","position":[480,200],"parameters":{"fileId":{"__rl":true,"mode":"id","value":"1a2FcRDWHHncMO8CYxD80uNUBGH1Sy1k2"},"options":{},"operation":"download"},"credentials":{"googleDriveOAuth2Api":{"id":"yOwz41gMQclOadgu","name":"Google Drive account"}},"typeVersion":3},{"id":"94a1c3ca-1ca7-4bb1-9e7c-8314742423ab","name":"Mistral Upload1","type":"n8n-nodes-base.httpRequest","position":[700,200],"parameters":{"url":"https://api.mistral.ai/v1/files","method":"POST","options":{},"sendBody":true,"contentType":"multipart-form-data","authentication":"predefinedCredentialType","bodyParameters":{"parameters":[{"name":"purpose","value":"ocr"},{"name":"file","parameterType":"formBinaryData","inputDataFieldName":"data"}]},"nodeCredentialType":"mistralCloudApi"},"credentials":{"mistralCloudApi":{"id":"EIl2QxhXAS9Hkg37","name":"Mistral Cloud account"}},"typeVersion":4.2},{"id":"9d075eec-ba0e-41e1-8bdc-a732bc0f9229","name":"Mistral Signed URL1","type":"n8n-nodes-base.httpRequest","position":[900,200],"parameters":{"url":"=https://api.mistral.ai/v1/files/{{ $json.id }}/url","options":{},"sendQuery":true,"sendHeaders":true,"authentication":"predefinedCredentialType","queryParameters":{"parameters":[{"name":"expiry","value":"24"}]},"headerParameters":{"parameters":[{"name":"Accept","value":"application/json"}]},"nodeCredentialType":"mistralCloudApi"},"credentials":{"mistralCloudApi":{"id":"EIl2QxhXAS9Hkg37","name":"Mistral Cloud account"}},"typeVersion":4.2},{"id":"f623f066-fc70-40fa-b608-f28a75a8ac8c","name":"Mistral DOC OCR","type":"n8n-nodes-base.httpRequest","position":[1100,-20],"parameters":{"url":"https://api.mistral.ai/v1/ocr","method":"POST","options":{},"jsonBody":"={\n  \"model\": \"mistral-ocr-latest\",\n  \"document\": {\n    \"type\": \"document_url\",\n    \"document_url\": \"{{ $json.url }}\"\n  },\n  \"include_image_base64\": true\n}","sendBody":true,"specifyBody":"json","authentication":"predefinedCredentialType","nodeCredentialType":"mistralCloudApi"},"credentials":{"mistralCloudApi":{"id":"EIl2QxhXAS9Hkg37","name":"Mistral Cloud account"}},"typeVersion":4.2},{"id":"15913796-e7c8-451a-8e7b-da7a3b10db02","name":"Mistral IMAGE OCR","type":"n8n-nodes-base.httpRequest","position":[1100,200],"parameters":{"url":"https://api.mistral.ai/v1/ocr","method":"POST","options":{},"jsonBody":"={\n  \"model\": \"mistral-ocr-latest\",\n  \"document\": {\n    \"type\": \"image_url\",\n    \"image_url\": \"{{ $json.url }}\"\n  }\n}","sendBody":true,"specifyBody":"json","authentication":"predefinedCredentialType","nodeCredentialType":"mistralCloudApi"},"credentials":{"mistralCloudApi":{"id":"EIl2QxhXAS9Hkg37","name":"Mistral Cloud account"}},"typeVersion":4.2},{"id":"a79524ff-84f0-46db-bb8e-afc18f1ddd40","name":"Document URL","type":"n8n-nodes-base.set","position":[-160,-20],"parameters":{"options":{},"assignments":{"assignments":[{"id":"1eb5f18b-eb06-48df-8491-d60de75b4855","name":"url","type":"string","value":"=https://pub-d4aa9be14ae34d6ebcebe06f13af667b.r2.dev/multimodal_bank_statement_scan.pdf"}]}},"typeVersion":3.4},{"id":"72b89f33-a67c-4f73-9a78-e8ccd02fbc98","name":"Image URL","type":"n8n-nodes-base.set","position":[-160,200],"parameters":{"options":{},"assignments":{"assignments":[{"id":"1eb5f18b-eb06-48df-8491-d60de75b4855","name":"url","type":"string","value":"=https://pub-d4aa9be14ae34d6ebcebe06f13af667b.r2.dev/multimodal_bank_statement_2.png"}]}},"typeVersion":3.4},{"id":"808ccbb3-0dae-4e2c-9166-bf40c589824a","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-320,-160],"parameters":{"color":7,"width":680,"height":580,"content":"### Example 1. Publicly Hosted Files\nThe default way to use Mistral OCR is to give it a public URL of the file you want processed. Great for your own semi-private docs or other people's. If you rather not expose files due to privacy concerns, then you'd want to check out example 2."},"typeVersion":1},{"id":"b968d6ab-9582-495d-84af-f75833701e2a","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[400,-160],"parameters":{"color":7,"width":920,"height":560,"content":"### Example 2. Privately Hosted via Mistral Cloud\nGive Mistral OCR private and secure access to your files by uploading them to Mistral cloud first. Retrieve the file using a signed URL and pass this to Mistral OCR. Benefit of storing via Mistral could be faster cache access and reduced latency for repeat docs."},"typeVersion":1},{"id":"f2c0b30a-49be-4850-b102-f23d0feac0ec","name":"Mistral DOC OCR1","type":"n8n-nodes-base.httpRequest","position":[60,-20],"parameters":{"url":"https://api.mistral.ai/v1/ocr","method":"POST","options":{},"jsonBody":"={\n  \"model\": \"mistral-ocr-latest\",\n  \"document\": {\n    \"type\": \"document_url\",\n    \"document_url\": \"{{ $json.url }}\"\n  }\n}","sendBody":true,"specifyBody":"json","authentication":"predefinedCredentialType","nodeCredentialType":"mistralCloudApi"},"credentials":{"mistralCloudApi":{"id":"EIl2QxhXAS9Hkg37","name":"Mistral Cloud account"}},"typeVersion":4.2},{"id":"64a28537-e70b-48bc-b580-cc9d5a5a1b80","name":"Mistral IMAGE OCR1","type":"n8n-nodes-base.httpRequest","position":[60,200],"parameters":{"url":"https://api.mistral.ai/v1/ocr","method":"POST","options":{},"jsonBody":"={\n  \"model\": \"mistral-ocr-latest\",\n  \"document\": {\n    \"type\": \"image_url\",\n    \"image_url\": \"{{ $json.url }}\"\n  }\n}","sendBody":true,"specifyBody":"json","authentication":"predefinedCredentialType","nodeCredentialType":"mistralCloudApi"},"credentials":{"mistralCloudApi":{"id":"EIl2QxhXAS9Hkg37","name":"Mistral Cloud account"}},"typeVersion":4.2},{"id":"3caaa30b-21f2-4643-93dd-8dff6f3c1920","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-740,-440],"parameters":{"width":380,"height":640,"content":"## Document Parsing with Mistral OCR\nUp your structured document parsing game with Mistral's latest release... **Mistral-OCR**!\n* Designed to specifically parse PDF and image files.\n* Handles multiple-page documents and images up to 10k pixels.\n* Each page is conveniently transcribed as markdown only - there is no plain text output.\n* Incredible pricing at only $0.001 per page!\n\n### Requirements\n* You'll need a Mistral Cloud API Key\n* This template only works with the Mistral Cloud API for Mistral OCR."},"typeVersion":1},{"id":"bd4d0c9f-f4a6-4527-8f9d-5af90a2858c2","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[1360,-160],"parameters":{"color":7,"width":680,"height":580,"content":"### Example 3. No need for Extraction? Talk Directly with the File!\nIt seems Mistral were also able to integrate OCR capabilities into its text models which allows you to carry out tasks such as document classification and sentiment analysis really quickly. Unfortunately, it doesn't work the same way with images - you have to use Pixtral but the results are really bad!"},"typeVersion":1},{"id":"c9a9d4bb-4ee6-413a-9f08-97fdcee22bf2","name":"Document URL1","type":"n8n-nodes-base.set","position":[1520,-20],"parameters":{"options":{},"assignments":{"assignments":[{"id":"1eb5f18b-eb06-48df-8491-d60de75b4855","name":"url","type":"string","value":"=https://pub-d4aa9be14ae34d6ebcebe06f13af667b.r2.dev/multimodal_bank_statement_scan.pdf"},{"id":"c639fce3-6967-444d-be18-6c9ce802ef22","name":"query","type":"string","value":"what is the total number of deposits?"}]}},"typeVersion":3.4},{"id":"5de4d62c-af8f-4e6d-adbd-2f591a2165f7","name":"Document Understanding","type":"n8n-nodes-base.httpRequest","position":[1740,-20],"parameters":{"url":"https://api.mistral.ai/v1/chat/completions","method":"POST","options":{},"jsonBody":"={\n  \"model\": \"mistral-small-latest\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": [\n        {\n          \"type\": \"text\",\n          \"text\": \"{{ $json.query }}\"\n        },\n        {\n          \"type\": \"document_url\",\n          \"document_url\": \"{{ $json.url }}\"\n        }\n      ]\n    }\n  ],\n  \"document_image_limit\": 8,\n  \"document_page_limit\": 64\n}","sendBody":true,"specifyBody":"json","authentication":"predefinedCredentialType","nodeCredentialType":"mistralCloudApi"},"credentials":{"mistralCloudApi":{"id":"EIl2QxhXAS9Hkg37","name":"Mistral Cloud account"}},"typeVersion":4.2},{"id":"9a7bbff0-d446-469d-aa61-838e8c025ad5","name":"Image URL1","type":"n8n-nodes-base.set","position":[1520,200],"parameters":{"options":{},"assignments":{"assignments":[{"id":"1eb5f18b-eb06-48df-8491-d60de75b4855","name":"url","type":"string","value":"=https://pub-d4aa9be14ae34d6ebcebe06f13af667b.r2.dev/multimodal_bank_statement_2.png"},{"id":"639cd062-ebef-44ab-97a2-79ee388f8b41","name":"query","type":"string","value":"what is the total number of deposits?"}]}},"typeVersion":3.4},{"id":"ca43d437-a373-4938-a0a8-8087a98d46a8","name":"Document Mis-Understanding?","type":"n8n-nodes-base.httpRequest","position":[1740,200],"parameters":{"url":"https://api.mistral.ai/v1/chat/completions","method":"POST","options":{},"jsonBody":"={\n  \"model\": \"pixtral-large-latest\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": [\n        {\n          \"type\": \"text\",\n          \"text\": \"{{ $json.query }}\"\n        },\n        {\n          \"type\": \"image_url\",\n          \"image_url\": \"{{ $json.url }}\"\n        }\n      ]\n    }\n  ],\n  \"document_image_limit\": 8,\n  \"document_page_limit\": 64\n}","sendBody":true,"specifyBody":"json","authentication":"predefinedCredentialType","nodeCredentialType":"mistralCloudApi"},"credentials":{"mistralCloudApi":{"id":"EIl2QxhXAS9Hkg37","name":"Mistral Cloud account"}},"typeVersion":4.2}],"pinData":{},"connections":{"Image URL":{"main":[[{"node":"Mistral IMAGE OCR1","type":"main","index":0}]]},"Image URL1":{"main":[[{"node":"Document Mis-Understanding?","type":"main","index":0}]]},"Import PDF":{"main":[[{"node":"Mistral Upload","type":"main","index":0}]]},"Document URL":{"main":[[{"node":"Mistral DOC OCR1","type":"main","index":0}]]},"Import Image":{"main":[[{"node":"Mistral Upload1","type":"main","index":0}]]},"Document URL1":{"main":[[{"node":"Document Understanding","type":"main","index":0}]]},"Mistral Upload":{"main":[[{"node":"Mistral Signed URL","type":"main","index":0}]]},"Mistral Upload1":{"main":[[{"node":"Mistral Signed URL1","type":"main","index":0}]]},"Mistral DOC OCR1":{"main":[[]]},"Mistral Signed URL":{"main":[[{"node":"Mistral DOC OCR","type":"main","index":0}]]},"Mistral Signed URL1":{"main":[[{"node":"Mistral IMAGE OCR","type":"main","index":0}]]},"When clicking ‘Test workflow’":{"main":[[{"node":"Document URL","type":"main","index":0},{"node":"Image URL","type":"main","index":0}]]}}}


name: AI-Powered Short-Form Video Generator with OpenAI, Flux, Kling, and ElevenLabs
author_name: Cameron Wills
author_username: camerondwills
categories: []
created_at: 2025-03-10T10:25:20.937Z
updated_at: 2025-03-10T10:25:20.937Z
url: https://n8n.io/workflows/3121
scraped_at: 2025-07-06 21:16:30
description:
  Who is this for?
  Content creators, digital marketers, and social media managers who want to automate the creation of short-form videos for platforms like TikTok, YouTube Shorts, and Instagram Reels without extensive video editing skills.
  What problem does this workflow solve?
  Creating engaging short-form videos consistently is time-consuming and requires multiple tools and skills. This workflow automates the entire process from ideation to publishing, significantly reducing the manual effort needed while maintaining content quality.
  What this workflow does
  This all-in-one solution transforms ideas into fully produced short-form videos through a 5-step process:

  Generate video captions from ideas stored in a Google Sheet
  Create AI-generated images using Flux and the OpenAI API
  Convert images to videos using Kling's API
  Add voice-overs to your content with Eleven Labs
  Complete the video production with Creatomate by adding templates, transitions, and combining all elements

  The workflow handles everything from sourcing content ideas to rendering the final video, and even notifies you on Discord when videos are ready.
  Setup (Est. time: 20-30 minutes)
  Before getting started, you'll need:

  n8n installation (tested on version 1.81.4)
  OpenAI API Key (free trial credits available)
  PiAPI (free trial credits available)
  Eleven Labs (free account)
  Creatomate API Key (free trial credits available)
  Google Sheets API enabled in Google Cloud Console
  Google Drive API enabled in Google Cloud Console
  OAuth 2.0 Client ID and Client Secret from your Google Cloud Console Credentials

  How to customize this workflow to your needs

  Adjust the Google Sheet structure to include additional data like video length, duration, style, etc.
  Modify the prompt templates for each AI service to match your brand voice and content style
  Update the Creatomate template to reflect your visual branding
  Configure notification preferences in Discord to manage your workflow

  This workflow combines multiple AI technologies to create a seamless content production pipeline, saving you hours of work per video and allowing you to focus on strategy rather than production.

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

workflow_json:
  {"id":"aqLL3BAXqQIjeJDt","meta":{"instanceId":"dce6d05169adc9f802863a06c3edb9925b178c4fce2360953cce9c1b509705cc","templateCredsSetupCompleted":true},"name":"AI Automated TikTok/Youtube Shorts/Reels Generator","tags":[{"id":"meqQhJqB377UiY3s","name":"template","createdAt":"2025-03-10T07:30:05.424Z","updatedAt":"2025-03-10T07:30:05.424Z"}],"nodes":[{"id":"e5095169-dc78-4d90-9662-04cfc82c38d9","name":"Get image","type":"n8n-nodes-base.httpRequest","position":[220,40],"parameters":{"url":"=https://api.piapi.ai/api/v1/task/{{ $json.data.task_id }}","options":{},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"X-API-Key","value":"={{ $('Set API Keys').item.json['PiAPI Key'] }}"}]}},"typeVersion":4.2},{"id":"f477250a-fc8e-407e-a632-cffc0e564596","name":"Generate Image","type":"n8n-nodes-base.httpRequest","position":[-60,40],"parameters":{"url":"https://api.piapi.ai/api/v1/task","body":"={\n  \"model\": \"Qubico/flux1-dev\",\n  \"task_type\": \"txt2img\",\n  \"input\": {\n    \"prompt\": \"{{ $('Generate Image Prompts').item.json.choices[0].message.content }} realistic and casual as if taken by an iphone camera by a TikTok influencer\",\n    \"negative_prompt\": \"taking a photo of a room, recording a video of a room, photos app, video recorder, illegible text, blurry text, low quality text, DSLR, unnatural\",\n    \"width\": 540,\n    \"height\": 960\n  }\n}","method":"POST","options":{},"sendBody":true,"contentType":"raw","sendHeaders":true,"rawContentType":"application/json","headerParameters":{"parameters":[{"name":"X-API-Key","value":"={{ $('Set API Keys').item.json['PiAPI Key'] }}"}]}},"retryOnFail":false,"typeVersion":4.2},{"id":"622ce9f5-ad58-485b-a3c6-1265700b04da","name":"Image-to-Video","type":"n8n-nodes-base.httpRequest","position":[-420,560],"parameters":{"url":"https://api.piapi.ai/api/v1/task","body":"={\n  \"model\": \"kling\",\n  \"task_type\": \"video_generation\",\n  \"input\": {\n    \"prompt\": \"{{ $json.data.input.prompt }}\",\n    \"negative_prompt\": \"blurry motion, distorted faces, unnatural lighting, over produced, bad quality\",\n    \"cfg_scale\": 0.5,\n    \"duration\": 5,\n    \"mode\": \"pro\",\n    \"image_url\": \"{{ $json.data.output.image_url }}\",\n    \"version\": \"1.6\",\n    \"camera_control\": {\n      \"type\": \"simple\",\n      \"config\": {\n        \"horizontal\": 0,\n        \"vertical\": 0,\n        \"pan\": 0,\n        \"tilt\": 0,\n        \"roll\": 0,\n        \"zoom\": 5\n      }\n    }\n  },\n  \"config\": {}\n}","method":"POST","options":{},"sendBody":true,"contentType":"raw","sendHeaders":true,"rawContentType":"application/json","headerParameters":{"parameters":[{"name":"X-API-Key","value":"={{ $('Set API Keys').item.json['PiAPI Key'] }}"}]}},"typeVersion":4.2},{"id":"ed14eac3-1d63-481d-871c-a04c52977fc6","name":"Get Video","type":"n8n-nodes-base.httpRequest","position":[-160,560],"parameters":{"url":"=https://api.piapi.ai/api/v1/task/{{ $json.data.task_id }}","options":{},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"X-API-Key","value":"={{ $('Set API Keys').item.json['PiAPI Key'] }}"}]}},"typeVersion":4.2},{"id":"8b68100c-8a5a-405c-825e-d9e8a898f235","name":"List Elements","type":"n8n-nodes-base.code","position":[460,600],"parameters":{"jsCode":"return [\n  {\n    scene_titles: items.map(item => item.json.response.text),\n    video_urls: items.map(item => item.json.data.output.video_url),\n    input_tokens: $('Calculate Token Usage').first().json.total_prompt_tokens,\n    output_tokens: $('Calculate Token Usage').first().json.total_completion_tokens,\n    model: $('Generate Image Prompts').first().json.model\n  }\n];"},"typeVersion":2},{"id":"f8780885-508e-4dc9-b146-f367297d7b68","name":"Wait 10min","type":"n8n-nodes-base.wait","position":[-280,560],"webhookId":"1f9d716f-6544-4e4e-94ec-408ac3ea6e82","parameters":{"unit":"minutes","amount":10},"typeVersion":1.1},{"id":"6290bc91-0eb9-4053-bd93-961cb9e917c0","name":"Wait 3min","type":"n8n-nodes-base.wait","position":[80,40],"webhookId":"77cdee73-5e99-456a-b5e7-410b4d257669","parameters":{"unit":"minutes","amount":3},"typeVersion":1.1},{"id":"818a66ef-b9fa-4efc-85d1-b295300cbed8","name":"Wait 5min","type":"n8n-nodes-base.wait","position":[540,-40],"webhookId":"31d5b1a2-dbb5-4849-ae25-cb491539c16e","parameters":{"unit":"minutes"},"typeVersion":1.1},{"id":"afd66320-dfe0-4872-a09d-d53fe08152ce","name":"Generate voice","type":"n8n-nodes-base.httpRequest","position":[-60,1020],"parameters":{"url":"https://api.elevenlabs.io/v1/text-to-speech/onwK4e9ZLuTAKqWW03F9","method":"POST","options":{},"sendBody":true,"sendHeaders":true,"bodyParameters":{"parameters":[{"name":"text","value":"={{ $json.choices[0].message.content }}"}]},"headerParameters":{"parameters":[{"name":"xi-api-key","value":"={{ $('Set API Keys').item.json['ElevenLabs API Key'] }}"}]}},"retryOnFail":false,"typeVersion":4.2},{"id":"916f19e1-7928-4141-a5c5-ca39bd22b0a0","name":"List Elements1","type":"n8n-nodes-base.code","position":[460,820],"parameters":{"jsCode":"return [\n  {\n    sound_urls: items.map(item => $('Upload Voice Audio').first().json.webContentLink)\n  }\n];"},"typeVersion":2},{"id":"b95fd80c-ec7f-4d50-99ae-f3f544b8a111","name":"Fail check","type":"n8n-nodes-base.if","position":[-20,560],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"a920eb54-fc23-4b68-8f56-2eee907a5481","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"failed"}]}},"typeVersion":2.2},{"id":"7e3f5cda-1d49-4a59-956f-f639daf203e0","name":"Wait to retry","type":"n8n-nodes-base.wait","position":[120,520],"webhookId":"3b0fae8f-4419-45cd-8380-8f72eca05ff8","parameters":{"unit":"minutes"},"typeVersion":1.1},{"id":"48ec39c9-1802-4860-918d-9c660051f27b","name":"Generate Image Prompts","type":"@n8n/n8n-nodes-langchain.openAi","position":[-540,120],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"o3-mini","cachedResultName":"O3-MINI"},"options":{},"messages":{"values":[{"content":"=You are an advanced, unhinged, hilariously entertaining prompt-generation AI specializing in expanding short POV image prompt ideas into detailed, hyper-realistic prompts optimized for Qubico/flux1-dev. Your task is to take a brief input tied to job seeking, job hunting, or resume building and morph it into a cinematic, immersive prompt locked in a first-person perspective, making the viewer feel they’re living the scene.\n\nNEVER include quotation marks or emojis in your response—flux API will choke on them, and that’s a hard no.\n\nThe topic of this narrative is: {{ $('Load Google Sheet').item.json.idea }}\n\nThe short prompt idea to expand for this image generation is: {{ $json.response.text }}\n\nONLY GENERATE ONE PROMPT PER IDEA—NO COMBINING. In at least one scene, weave in this environment descriptor: {{ $('Load Google Sheet').first().json.environment_prompt }}, but go wild with unhinged, edgy, funny twists elsewhere (skip the cringe or cheesy garbage). Most job hunting happens on laptops or desktops, so prioritize those over phones. If a phone sneaks in, it’s only showing job-related content like email, LinkedIn, a resume, or a job posting—never a photo or video app.\n\nEvery prompt has two parts:\n\nForeground: Kick off with First person view POV GoPro shot of... and show the viewer’s hands, limbs, or feet locked in a job-related action.\n\nBackground: Start with In the background,... and paint the scenery, blending the environment descriptor when required, plus sensory zingers.\n\nTop Rules:\n\nNO quotation marks or emojis—EVER. This is life or death for flux.\nStick to first-person POV—the viewer’s in the driver’s seat, not watching from the sidelines.\nShow a limb (hands, feet) doing something job-focused—typing, holding a resume, adjusting a tie.\nKeep it dynamic, like a GoPro clip, with motion and depth mimicking human vision.\nIf tech’s involved (phone, computer), it’s displaying job-hunting gold—email, job boards, resumes—not random trash.\nNo off-topic actions like recording videos or snapping pics—job hunting only, fam.\nExtra Vibes:\n\nFull-body awareness: Drop hints of physical feels—cramping fingers, racing pulse, slumping shoulders.\nSensory overload: Hit sight, touch, sound, smell, temperature for max realism (coffee whiffs, keyboard clacks).\nWorld grip: Limbs interact with the scene—tapping keys, handing over papers, stepping up.\nKeep it under 1000 characters, one slick sentence, no fluff or formatting.\nMake it entertaining, relatable, with an Andrew Tate viral edge for the down-and-out job hustlers.\nExamples:\n\nInput: Updating a LinkedIn profile after a long day\n\nEnvironment_prompt: Tired, cluttered apartment, laptop glow\n\nOutput: First person view POV GoPro shot of my hands hammering a laptop, cheeto-dusted fingers aching from the grind, the screen flashing my LinkedIn profile with a fresh connection ping; in the background, a trashed apartment lit by the laptop’s ghostly glow, pizza boxes toppling, traffic humming outside, stale takeout stench hitting my nose as my back screams from the hustle.\n\nInput: Handing over a resume at a job fair\n\nEnvironment_prompt: Hopeful, busy convention hall, suits everywhere\n\nOutput: First person view POV GoPro shot of my hand thrusting out a crisp resume, fingers twitching with nerves as it brushes another palm; in the background, a buzzing convention hall packed with suits, coffee fumes and shoe polish in the air, chatter drowning my pounding heart as I lock eyes with the recruiter.\n\nNO QUOTATION MARKS. NO EMOJIS. EVER."}]},"simplify":false},"credentials":{"openAiApi":{"id":"UqJ11kHhHtyzaDWx","name":"OpenAi account"}},"typeVersion":1.8},{"id":"5c1b8dc8-4eb3-49fe-81c7-c811d73fac0d","name":"Calculate Token Usage","type":"n8n-nodes-base.code","position":[-240,120],"parameters":{"jsCode":"// Get all input items (the 5 LLM responses)\nconst items = $input.all();\n\n// Calculate total prompt tokens and total completion tokens\nconst totalPromptTokens = items.reduce((sum, item) => sum + item.json.usage.prompt_tokens, 0);\nconst totalCompletionTokens = items.reduce((sum, item) => sum + item.json.usage.completion_tokens, 0);\n\n// Create new items with original data plus the totals\nconst outputItems = items.map(item => ({\n  json: {\n    ...item.json,                   // Spread the original item data\n    total_prompt_tokens: totalPromptTokens,     // Add total prompt tokens\n    total_completion_tokens: totalCompletionTokens // Add total completion tokens\n  }\n}));\n\n// Return the modified items\nreturn outputItems;"},"typeVersion":2},{"id":"efc3d0dd-70dc-4fba-b040-22c773ed5602","name":"Check for failures","type":"n8n-nodes-base.if","position":[360,40],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"567d1fc9-0638-4a44-b5f5-30a9a6683794","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"failed"}]}},"typeVersion":2.2},{"id":"3161c993-5696-4419-9299-fde51719dfc7","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-560,-200],"parameters":{"color":5,"width":1260,"height":460,"content":"## 2. 🖼️Generate images with Flux using [PiAPI](https://piapi.ai/?via=n8n) \n### (total cost: $0.0948 approx. as of 3/9/25)\n1. OpenAI is used to generate 5 Flux image prompts based on the 5 captions generated. Edit this node to see/edit the prompt instructions. \n2. Next we use some custom javascript to total up how many tokens were used for each 5 generations so we can track our costs later.\n3. Then we generate an image with Flux using the [PiAPI service](https://piapi.ai/?via=n8n), waiting to check for failures and retrying if there are any.\n\nYou can change the image model used by editing the Generate Image node API call.\nFlux models available (as of 3/9/25):\n- Qubico/flux1-dev ($0.015) - Currently set\n- Qubico/flux1-schnell ($0.0015)\n- Qubico/flux1-advanced ($0.02)\n\nFor full list of API settings, see the [Flux API Documentation](https://piapi.ai/docs/flux-api/text-to-image?via=n8n)\n"},"typeVersion":1},{"id":"e5cdec7e-cb75-4200-a8e3-615621d20150","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-460,280],"parameters":{"color":6,"width":1040,"height":500,"content":"## 3. 🎬Generate videos with Kling using [PiAPI](https://piapi.ai/?via=n8n)\n### (total cost: $2.30 approx. as of 3/9/25)\n1. We use image-to-video with Kling using [PiAPI](https://piapi.ai/?via=n8n) to generate a video from each image.\n2. Then we wait to check for failures, and repeat the generations the failed if there are any.\n\nYou can edit the video model used in the Image-to-Video node. For testing, I'd recommend switching from pro to std for lower quality and cheaper price.\nKling models available (as of 3/9/25):\n- std (Standard) $0.26 per 5 second video\n- pro (Professional) $0.46 per 5 second video - Currently set\n\nFor full list of API settings, see the [Kling API Documentation](https://piapi.ai/docs/kling-api/create-task?via=n8n)\n"},"typeVersion":1},{"id":"8404a390-a402-4703-8cb5-4a54490dc7bd","name":"Generate Video Captions","type":"@n8n/n8n-nodes-langchain.openAi","position":[-980,780],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"GPT-4O-MINI"},"options":{},"messages":{"values":[{"role":"system","content":"DO NOT include any quotation marks in your response. Do not put a quote at the beginning or the end of your response.\n\nYou are a prompt-generation AI specializing in crafting unhinged, entertaining TikTok captions for a \"day in the life\" POV story about job hunting or resume writing. Generate five concise, action-driven captions (5-10 words each) that follow a Problem > Action > Reward structure. The first caption should be a shocking or funny hook, and the last should conclude with a satisfying reward. Use emojis sparingly—only one per caption at most, and only when they add impact; skip them if they don’t enhance the message.\n\nGuidelines:\n\nPerspective: Always first-person POV, immersing the viewer in the story.\nTone: Channel Andrew Tate mixed with Charlie Sheen—cursing and sexual innuendos are fair game.\nContent: Focus on job seeking, hunting, or resume building, spotlighting AI as the game-changer.\nNarrative: Start with the grind of unemployment or a shitty job, pivot to using AI for resumes and cover letters, and end with scoring the dream gig.\nScenes: Highlight raw, emotional moments—skip the boring stuff.\nYour captions should be wild and entertaining, not polished or professional. The first caption is the hook—make it shocking, hilarious, or ballsy, something Andrew Tate would growl. Use emojis sparingly—max one per caption, only if it hits harder with it.\n\nYour response should be a list of 5 items separated by \"\\n\" (for example: \"item1\\nitem2\\nitem3\\nitem4\\nitem5\")"},{"content":"={{ $json.idea }}"}]},"simplify":false},"credentials":{"openAiApi":{"id":"UqJ11kHhHtyzaDWx","name":"OpenAi account"}},"typeVersion":1.8},{"id":"f614c784-a3ee-4eb8-aee3-cc0ad3e87556","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-460,800],"parameters":{"color":4,"width":1040,"height":400,"content":"## 4. 🔉Generate voice overs with [Eleven Labs](https://try.elevenlabs.io/n8n)\n1. OpenAI API is used to generate a funny script that relates to the captions. Open this node to see/edit the prompt instructions. \n2. Then we use the [Eleven Labs API](https://try.elevenlabs.io/n8n) to generate the voiceover and upload it to our Google Drive so it can be accessed in the next step.\n\nTo replace the voice, find the voice ID of the voice you want to use in [Eleven Labs](https://try.elevenlabs.io/n8n), then change the URL in the Generate Voice node to: https://api.elevenlabs.io/v1/text-to-speech/{voice ID here}\n\nFor full list of API settings, see the [Eleven Labs API Documentation](https://elevenlabs.io/docs/api-reference/text-to-speech/convert)\n"},"typeVersion":1},{"id":"e59306c1-8efe-4d98-9391-10c68c17787b","name":"Match captions with videos","type":"n8n-nodes-base.merge","position":[300,600],"parameters":{"mode":"combine","options":{},"combineBy":"combineByPosition"},"typeVersion":3},{"id":"8da7e16e-691b-4335-bfc7-e196c36f982d","name":"Generate Script","type":"@n8n/n8n-nodes-langchain.openAi","position":[-420,1020],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"GPT-4O-MINI"},"options":{},"messages":{"values":[{"role":"system","content":"=You are an unhinged and hilarious TikTok influencer who's like a mix of Andrew Tate and Charlie Sheen. The user is going to provide you with a topic, and then 5 different parts of a story. Your task is to narrate the story as this hilarious character, who isn't afraid to be edgy or curse or use sexual innuendos. However keep each of the 5 talking points brief, as you only have about 5 seconds to speak during each. The entire length of your narration should be around 15 seconds.\n\nEach line item of the users message represents 1 5 second clip, so your response needs to be able to quickly and easily be spoken in those time constraints. Don't say extra things you don't need to. Just quickly tell the story, in order, and make it unhinged, funny, entertaining, and potentially controversially viral. Don't worry about offendeding anyone. Andrew Tate style it.\n\nDo not include any emojis, as your response will be converted from text to speech, so anything but text and punctuation isn't neccesary. Also, don't make your jokes overly corny, speak in a witty, edgy, funny way, but no corny dad jokes or anything cringe."},{"content":"={{ $('Generate Video Captions').item.json.choices[0].message.content }}"}]},"simplify":false},"credentials":{"openAiApi":{"id":"UqJ11kHhHtyzaDWx","name":"OpenAi account"}},"executeOnce":true,"typeVersion":1.8},{"id":"ad87317d-3ed0-4fdf-aea5-7b2fa60fb59f","name":"Upload Voice Audio","type":"n8n-nodes-base.googleDrive","position":[140,1020],"parameters":{"name":"={{ $('Load Google Sheet').item.json.id }}-voiceover.mp3","driveId":{"__rl":true,"mode":"list","value":"My Drive"},"options":{},"folderId":{"__rl":true,"mode":"list","value":"1w1EQ8xyth6w7AbX2wpDI3vInfYeRy8vH","cachedResultUrl":"https://drive.google.com/drive/folders/1w1EQ8xyth6w7AbX2wpDI3vInfYeRy8vH","cachedResultName":"Resume Studio"}},"credentials":{"googleDriveOAuth2Api":{"id":"ZvDuyVfbZJbDJXcS","name":"Google Drive account"}},"typeVersion":3},{"id":"eec529e9-2601-4f7b-b415-63d2ebba1574","name":"Set Access Permissions","type":"n8n-nodes-base.googleDrive","position":[320,1020],"parameters":{"fileId":{"__rl":true,"mode":"id","value":"={{ $json.id }}"},"options":{},"operation":"share","permissionsUi":{"permissionsValues":{"role":"writer","type":"anyone","allowFileDiscovery":true}}},"credentials":{"googleDriveOAuth2Api":{"id":"ZvDuyVfbZJbDJXcS","name":"Google Drive account"}},"typeVersion":3},{"id":"63e72d56-140e-47d8-9f72-b58c764deed9","name":"Pair Videos with Audio","type":"n8n-nodes-base.merge","position":[680,700],"parameters":{"mode":"combine","options":{},"combineBy":"combineByPosition"},"typeVersion":3},{"id":"60a80c6f-0385-48e6-9b71-c23a74cbc15c","name":"Render Final Video","type":"n8n-nodes-base.httpRequest","position":[860,700],"parameters":{"url":"https://api.creatomate.com/v1/renders","body":"={\n  \"template_id\": \"{{ $('Set API Keys').item.json['Creatomate Template ID'] }}\",\n  \"modifications\": {\n    \n    \"Video-1.source\": \"{{ $json.video_urls[0] }}\",\n    \"Video-2.source\": \"{{ $json.video_urls[1] }}\",\n    \"Video-3.source\": \"{{ $json.video_urls[2] }}\",\n    \"Video-4.source\": \"{{ $json.video_urls[3] }}\",\n    \"Video-5.source\": \"{{ $json.video_urls[4] }}\",\n\n    \"Audio-1.source\": \"{{ $json.sound_urls[0] }}\",\n\n    \"Text-1.text\": \"{{ $json.scene_titles[0] }}\",\n    \"Text-2.text\": \"{{ $json.scene_titles[1] }}\",\n    \"Text-3.text\": \"{{ $json.scene_titles[2] }}\",\n    \"Text-4.text\": \"{{ $json.scene_titles[3] }}\",\n    \"Text-5.text\": \"{{ $json.scene_titles[4] }}\"\n  }\n}","method":"POST","options":{},"sendBody":true,"contentType":"raw","sendHeaders":true,"rawContentType":"application/json","headerParameters":{"parameters":[{"name":"Authorization","value":"=Bearer {{ $('Set API Keys').item.json['Creatomate API Key'] }}"},{"name":"Content-Type","value":"application/json"}]}},"executeOnce":true,"typeVersion":4.2},{"id":"89c0e958-7690-4f3d-af49-3e9776f2c979","name":"Notify me on Discord","type":"n8n-nodes-base.discord","position":[1840,700],"webhookId":"1541bc50-06e4-48e8-8c76-23850ee4edf6","parameters":{"content":"=A new Resume Studio POV video has been created: {{ $json.final_output }}","options":{},"authentication":"webhook"},"credentials":{"discordWebhookApi":{"id":"rd9P3JURnEdrsFAZ","name":"Discord Webhook account"}},"typeVersion":2},{"id":"14a09794-5e02-4880-b33d-139a91726dda","name":"Once Per Day","type":"n8n-nodes-base.scheduleTrigger","position":[-1540,780],"parameters":{"rule":{"interval":[{"triggerAtHour":7}]}},"typeVersion":1.2},{"id":"4de1f1c7-52ad-4e00-ad22-b4c3c0f718d8","name":"Load Google Sheet","type":"n8n-nodes-base.googleSheets","position":[-1120,780],"parameters":{"options":{"returnFirstMatch":true},"filtersUI":{"values":[{"lookupValue":"for production","lookupColumn":"production"}]},"sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1cjd8p_yx-M-3gWLEd5TargtoB35cW-3y66AOTNMQrrM/edit#gid=0","cachedResultName":"Sheet1"},"documentId":{"__rl":true,"mode":"list","value":"1cjd8p_yx-M-3gWLEd5TargtoB35cW-3y66AOTNMQrrM","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1cjd8p_yx-M-3gWLEd5TargtoB35cW-3y66AOTNMQrrM/edit?usp=drivesdk","cachedResultName":"Sheet Template"}},"credentials":{"googleSheetsOAuth2Api":{"id":"CkBO4U0JY0QvkimY","name":"Google Sheets account"}},"typeVersion":4.5,"alwaysOutputData":true},{"id":"e5c83690-1696-43aa-a0db-164ca128dd67","name":"Create List","type":"n8n-nodes-base.code","position":[-660,700],"parameters":{"jsCode":"// Get the text directly from the OpenAI response\nconst text = $input.first().json.choices[0].message.content;\n\n// Split the text on literal '\\\\n', trim, and filter empty lines\nconst lines = text.split('\\\\n').map(line => line.trim()).filter(line => line !== '');\n\n// Create an array of items for n8n\nconst items = lines.map(line => ({\n  json: {\n    response: { text: line }\n  }\n}));\n\n// Return the array of items\nreturn items;"},"typeVersion":2},{"id":"ed99df67-2068-4c8b-a6ba-e67d234f03c4","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[620,480],"parameters":{"color":3,"width":1360,"height":380,"content":"## 5. 📥Complete video with [Creatomate](https://creatomate.com/)\n### (total cost: $0.38 approx. with the Essential plan credits | Free trial credits available)\n1. First, the list of videos/captions is combined with the generated voice over into a single item containing all 3 elements.\n2. Those are then passed over to the Creatomate Template ID you specified, replacing the template captions/video/audio with your generated ones.\n3. When the video is finished rendering, it's then uploaded to Google Drive and the permissions set so it can be accessed with a link.\n4. Then we update the original Google Sheet template with the information from our generation, including tokens to calculate cost, then mark this idea as completed.\n5. Finally, we send a notification to via [webhook to the Discord server](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks) when the video is ready to be downloaded and used!\n\n"},"typeVersion":1},{"id":"e7064a56-c500-4f9f-a54a-c4352c263b56","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-1260,-160],"parameters":{"width":620,"height":420,"content":"# 🤖 AI-Powered Short-Form Video Generator with OpenAI, Flux, Kling, and ElevenLabs\n\n## 📃Before you get started, you'll need:\n- [n8n installation](https://n8n.partnerlinks.io/n8nTTVideoGenTemplate) (tested on version 1.81.4)\n- [OpenAI API Key](https://platform.openai.com/api-keys) (free trial credits available)\n- [PiAPI](https://piapi.ai/?via=n8n) (free trial credits available)\n- [Eleven Labs](https://try.elevenlabs.io/n8n) (free account)\n- [Creatomate API Key](https://creatomate.com/) (free trial credits available)\n- Google Sheets API enabled in [Google Cloud Console](https://console.cloud.google.com/apis/api/sheets.googleapis.com/overview)\n- Google Drive API enabled in [Google Cloud Console](https://console.cloud.google.com/apis/api/drive.googleapis.com/overview)\n- OAuth 2.0 Client ID and Client Secret from your [Google Cloud Console Credentials](https://console.cloud.google.com/apis/credentials)\n"},"typeVersion":1},{"id":"4ddb7249-9785-4f51-b35c-b9a0c6a66e3b","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-1420,340],"parameters":{"color":7,"width":920,"height":700,"content":"## 1. 🗨️Generate video captions from ideas in a Google Sheet\n\n1. Setup your API keys for [PiAPI](https://piapi.ai/?via=n8n), [Eleven Labs](https://try.elevenlabs.io/n8n), and [Creatomate](https://creatomate.com/).\n- Once logged in to your Creatomate account, create a new video template and click \"source code\" in the top right. [Paste this JSON code](https://pastebin.com/c7aMTeLK). This will be your example template for this workflow.\n- In your Creatomate template, click the \"Use Template\" button in the top right and then click \"API Integration\" and you'll see your template_id. Set this value as your Creatomate Template ID in the Set API Keys node\n\n2. The next node will load a Google Sheet, you can copy the [Google Sheet Template](https://docs.google.com/spreadsheets/d/1cjd8p_yx-M-3gWLEd5TargtoB35cW-3y66AOTNMQrrM/edit?usp=sharing), simply choose File > Make a copy. Then in the Google Sheets node, connect to your copied sheet template.\n\n3. Next, we generate 5 captions for our video idea with OpenAI. You can edit this node to see the prompt and change it to your needs.\n\n4. In the final two nodes, we use custom javascript code to turn the OpenAI response into a list. Then, it validates to make sure the list was formed correctly (incase of an OpenAI failure to follow instructions)\n"},"typeVersion":1},{"id":"57ee2f8f-5371-4dab-b661-c58b25c7dd55","name":"Wait1","type":"n8n-nodes-base.wait","position":[980,700],"webhookId":"206d0cdf-b71f-44a7-909f-97df885c471a","parameters":{"unit":"minutes","amount":3},"typeVersion":1.1},{"id":"33781e51-ef30-437b-8499-94e39bfb38fa","name":"Get Final Video","type":"n8n-nodes-base.httpRequest","position":[1100,700],"parameters":{"url":"=https://api.creatomate.com/v1/renders/{{ $('Render Final Video').item.json.id }}","options":{},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"=Bearer {{ $('Set API Keys').item.json['Creatomate API Key'] }}"},{"name":"Content-Type","value":"application/json"}]}},"executeOnce":true,"typeVersion":4.2},{"id":"b0d0fe6f-39c2-4da6-9fcf-b0151ed2c351","name":"Upload Final Video","type":"n8n-nodes-base.googleDrive","position":[1360,700],"parameters":{"name":"=POV-{{ $('Render Final Video').item.json.id }}.mp4","driveId":{"__rl":true,"mode":"list","value":"My Drive"},"options":{},"folderId":{"__rl":true,"mode":"list","value":"1w1EQ8xyth6w7AbX2wpDI3vInfYeRy8vH","cachedResultUrl":"https://drive.google.com/drive/folders/1w1EQ8xyth6w7AbX2wpDI3vInfYeRy8vH","cachedResultName":"Resume Studio"}},"credentials":{"googleDriveOAuth2Api":{"id":"ZvDuyVfbZJbDJXcS","name":"Google Drive account"}},"typeVersion":3},{"id":"3893d1de-7464-48ad-91a3-14b867c2a516","name":"Get Raw File","type":"n8n-nodes-base.httpRequest","position":[1220,700],"parameters":{"url":"={{ $json.url }}","options":{"response":{"response":{"responseFormat":"file"}}}},"typeVersion":4.2},{"id":"74de5f28-f081-4ec5-a47e-681eb845f701","name":"Set Permissions","type":"n8n-nodes-base.googleDrive","position":[1500,700],"parameters":{"fileId":{"__rl":true,"mode":"id","value":"={{ $json.id }}"},"options":{},"operation":"share","permissionsUi":{"permissionsValues":{"role":"writer","type":"anyone","allowFileDiscovery":true}}},"credentials":{"googleDriveOAuth2Api":{"id":"ZvDuyVfbZJbDJXcS","name":"Google Drive account"}},"typeVersion":3},{"id":"a2c07158-e949-4b5b-a92e-f4b021742831","name":"Update Google Sheet","type":"n8n-nodes-base.googleSheets","position":[1660,700],"parameters":{"columns":{"value":{"id":"={{ $('Load Google Sheet').first().json.id }}","width":"={{ $('Get Raw File').item.json.width }}","height":"={{ $('Get Raw File').item.json.height }}","model1":"={{ $('Generate Video Captions').item.json.model }}","model2":"={{ $('Pair Videos with Audio').item.json.model }}","model3":"={{ $('Generate Script').item.json.model }}","duration":"={{ $('Get Raw File').item.json.duration }}","fluxCost":"0.075","frameRate":"={{ $('Get Raw File').item.json.frame_rate }}","klingCost":"2.3","production":"done","publishing":"for publishing","final_output":"={{ $('Upload Final Video').item.json.webContentLink }}","prompt1 input tokens":"={{ $('Generate Video Captions').item.json.usage.prompt_tokens }}","prompt2 input tokens":"={{ $('Pair Videos with Audio').item.json.input_tokens }}","prompt3 input tokens":"={{ $('Generate Script').item.json.usage.prompt_tokens }}","prompt1 output tokens":"={{ $('Generate Video Captions').item.json.usage.completion_tokens }}","prompt2 output tokens":"={{ $('Pair Videos with Audio').item.json.output_tokens }}","prompt3 output tokens":"={{ $('Generate Script').item.json.usage.completion_tokens }}"},"schema":[{"id":"id","type":"string","display":true,"removed":false,"required":false,"displayName":"id","defaultMatch":true,"canBeUsedToMatch":true},{"id":"idea","type":"string","display":true,"removed":false,"required":false,"displayName":"idea","defaultMatch":false,"canBeUsedToMatch":true},{"id":"caption","type":"string","display":true,"removed":false,"required":false,"displayName":"caption","defaultMatch":false,"canBeUsedToMatch":true},{"id":"production","type":"string","display":true,"removed":false,"required":false,"displayName":"production","defaultMatch":false,"canBeUsedToMatch":true},{"id":"environment_prompt","type":"string","display":true,"removed":false,"required":false,"displayName":"environment_prompt","defaultMatch":false,"canBeUsedToMatch":true},{"id":"publishing","type":"string","display":true,"removed":false,"required":false,"displayName":"publishing","defaultMatch":false,"canBeUsedToMatch":true},{"id":"final_output","type":"string","display":true,"removed":false,"required":false,"displayName":"final_output","defaultMatch":false,"canBeUsedToMatch":true},{"id":"width","type":"string","display":true,"removed":false,"required":false,"displayName":"width","defaultMatch":false,"canBeUsedToMatch":true},{"id":"height","type":"string","display":true,"removed":false,"required":false,"displayName":"height","defaultMatch":false,"canBeUsedToMatch":true},{"id":"duration","type":"string","display":true,"removed":false,"required":false,"displayName":"duration","defaultMatch":false,"canBeUsedToMatch":true},{"id":"frameRate","type":"string","display":true,"removed":false,"required":false,"displayName":"frameRate","defaultMatch":false,"canBeUsedToMatch":true},{"id":"model1","type":"string","display":true,"removed":false,"required":false,"displayName":"model1","defaultMatch":false,"canBeUsedToMatch":true},{"id":"prompt1 input tokens","type":"string","display":true,"removed":false,"required":false,"displayName":"prompt1 input tokens","defaultMatch":false,"canBeUsedToMatch":true},{"id":"prompt1 output tokens","type":"string","display":true,"removed":false,"required":false,"displayName":"prompt1 output tokens","defaultMatch":false,"canBeUsedToMatch":true},{"id":"model1 cost","type":"string","display":true,"removed":false,"required":false,"displayName":"model1 cost","defaultMatch":false,"canBeUsedToMatch":true},{"id":"model2","type":"string","display":true,"removed":false,"required":false,"displayName":"model2","defaultMatch":false,"canBeUsedToMatch":true},{"id":"prompt2 input tokens","type":"string","display":true,"removed":false,"required":false,"displayName":"prompt2 input tokens","defaultMatch":false,"canBeUsedToMatch":true},{"id":"prompt2 output tokens","type":"string","display":true,"removed":false,"required":false,"displayName":"prompt2 output tokens","defaultMatch":false,"canBeUsedToMatch":true},{"id":"model2 cost","type":"string","display":true,"removed":false,"required":false,"displayName":"model2 cost","defaultMatch":false,"canBeUsedToMatch":true},{"id":"model3","type":"string","display":true,"removed":false,"required":false,"displayName":"model3","defaultMatch":false,"canBeUsedToMatch":true},{"id":"prompt3 input tokens","type":"string","display":true,"removed":false,"required":false,"displayName":"prompt3 input tokens","defaultMatch":false,"canBeUsedToMatch":true},{"id":"prompt3 output tokens","type":"string","display":true,"removed":false,"required":false,"displayName":"prompt3 output tokens","defaultMatch":false,"canBeUsedToMatch":true},{"id":"model3 cost","type":"string","display":true,"removed":false,"required":false,"displayName":"model3 cost","defaultMatch":false,"canBeUsedToMatch":true},{"id":"cmCost","type":"string","display":true,"removed":false,"required":false,"displayName":"cmCost","defaultMatch":false,"canBeUsedToMatch":true},{"id":"upgradeCmCost","type":"string","display":true,"removed":false,"required":false,"displayName":"upgradeCmCost","defaultMatch":false,"canBeUsedToMatch":true},{"id":"fluxCost","type":"string","display":true,"removed":false,"required":false,"displayName":"fluxCost","defaultMatch":false,"canBeUsedToMatch":true},{"id":"klingCost","type":"string","display":true,"removed":false,"required":false,"displayName":"klingCost","defaultMatch":false,"canBeUsedToMatch":true},{"id":"totalCost","type":"string","display":true,"removed":false,"required":false,"displayName":"totalCost","defaultMatch":false,"canBeUsedToMatch":true},{"id":"datePosted","type":"string","display":true,"removed":false,"required":false,"displayName":"datePosted","defaultMatch":false,"canBeUsedToMatch":true},{"id":"row_number","type":"string","display":true,"removed":true,"readOnly":true,"required":false,"displayName":"row_number","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":["id"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"update","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1cjd8p_yx-M-3gWLEd5TargtoB35cW-3y66AOTNMQrrM/edit#gid=0","cachedResultName":"Sheet1"},"documentId":{"__rl":true,"mode":"list","value":"1cjd8p_yx-M-3gWLEd5TargtoB35cW-3y66AOTNMQrrM","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1cjd8p_yx-M-3gWLEd5TargtoB35cW-3y66AOTNMQrrM/edit?usp=drivesdk","cachedResultName":"Sheet Template"}},"credentials":{"googleSheetsOAuth2Api":{"id":"CkBO4U0JY0QvkimY","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"62423325-f9da-4cdf-8864-c011fb4fa14f","name":"Set API Keys","type":"n8n-nodes-base.set","notes":"SET BEFORE STARTING","position":[-1320,780],"parameters":{"options":{},"assignments":{"assignments":[{"id":"35659353-d8e2-4677-876b-401b549605a0","name":"PiAPI Key","type":"string","value":""},{"id":"c4927dd6-c597-48fe-b7c1-bbffcf5ff02f","name":"ElevenLabs API Key","type":"string","value":""},{"id":"f5e90c05-dd24-4918-9005-4c87a4fb344d","name":"Creatomate API Key","type":"string","value":""},{"id":"d0ebba50-5a99-4090-adcb-d18aa0b21be2","name":"Creatomate Template ID","type":"string","value":""}]}},"notesInFlow":true,"typeVersion":3.4},{"id":"4252d793-5f16-4d5e-bb78-9b155aef5d3e","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[-1380,720],"parameters":{"color":3,"width":220,"height":220,"content":"## DO THIS FIRST\n"},"typeVersion":1},{"id":"845d5b4a-8a3f-4d0d-afce-39aa4e349a7b","name":"Validate list formatting","type":"n8n-nodes-base.if","position":[-660,840],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"2681c0e9-aa45-4f0f-8933-6e6de324c7aa","operator":{"type":"array","operation":"lengthGt","rightType":"number"},"leftValue":"={{$input.all()}}","rightValue":1}]}},"typeVersion":2.2}],"active":false,"pinData":{},"settings":{"timezone":"America/Los_Angeles","callerPolicy":"workflowsFromSameOwner","executionOrder":"v1"},"versionId":"3c7215ae-325c-49e5-865d-78eba07c625c","connections":{"Wait1":{"main":[[{"node":"Get Final Video","type":"main","index":0}]]},"Get Video":{"main":[[{"node":"Fail check","type":"main","index":0}]]},"Get image":{"main":[[{"node":"Check for failures","type":"main","index":0}]]},"Wait 3min":{"main":[[{"node":"Get image","type":"main","index":0}]]},"Wait 5min":{"main":[[{"node":"Generate Image","type":"main","index":0}]]},"Fail check":{"main":[[{"node":"Wait to retry","type":"main","index":0}],[{"node":"Match captions with videos","type":"main","index":1}]]},"Wait 10min":{"main":[[{"node":"Get Video","type":"main","index":0}]]},"Create List":{"main":[[{"node":"Validate list formatting","type":"main","index":0}]]},"Get Raw File":{"main":[[{"node":"Upload Final Video","type":"main","index":0}]]},"Once Per Day":{"main":[[{"node":"Set API Keys","type":"main","index":0}]]},"Set API Keys":{"main":[[{"node":"Load Google Sheet","type":"main","index":0}]]},"List Elements":{"main":[[{"node":"Pair Videos with Audio","type":"main","index":0}]]},"Wait to retry":{"main":[[{"node":"Image-to-Video","type":"main","index":0}]]},"Generate Image":{"main":[[{"node":"Wait 3min","type":"main","index":0}]]},"Generate voice":{"main":[[{"node":"Upload Voice Audio","type":"main","index":0}]]},"Image-to-Video":{"main":[[{"node":"Wait 10min","type":"main","index":0}]]},"List Elements1":{"main":[[{"node":"Pair Videos with Audio","type":"main","index":1}]]},"Generate Script":{"main":[[{"node":"Generate voice","type":"main","index":0}]]},"Get Final Video":{"main":[[{"node":"Get Raw File","type":"main","index":0}]]},"Set Permissions":{"main":[[{"node":"Update Google Sheet","type":"main","index":0}]]},"Load Google Sheet":{"main":[[{"node":"Generate Video Captions","type":"main","index":0}]]},"Check for failures":{"main":[[{"node":"Wait 5min","type":"main","index":0}],[{"node":"Image-to-Video","type":"main","index":0}]]},"Render Final Video":{"main":[[{"node":"Wait1","type":"main","index":0}]]},"Upload Final Video":{"main":[[{"node":"Set Permissions","type":"main","index":0}]]},"Upload Voice Audio":{"main":[[{"node":"Set Access Permissions","type":"main","index":0}]]},"Update Google Sheet":{"main":[[{"node":"Notify me on Discord","type":"main","index":0}]]},"Calculate Token Usage":{"main":[[{"node":"Generate Image","type":"main","index":0}]]},"Generate Image Prompts":{"main":[[{"node":"Calculate Token Usage","type":"main","index":0}]]},"Pair Videos with Audio":{"main":[[{"node":"Render Final Video","type":"main","index":0}]]},"Set Access Permissions":{"main":[[{"node":"List Elements1","type":"main","index":0}]]},"Generate Video Captions":{"main":[[{"node":"Create List","type":"main","index":0}]]},"Validate list formatting":{"main":[[{"node":"Generate Image Prompts","type":"main","index":0},{"node":"Match captions with videos","type":"main","index":0},{"node":"Generate Script","type":"main","index":0}],[{"node":"Generate Video Captions","type":"main","index":0}]]},"Match captions with videos":{"main":[[{"node":"List Elements","type":"main","index":0}]]}}}


name: ✨🩷Automated Social Media Content Publishing Factory + System Prompt Composition
author_name: Joseph LePage
author_username: joe
categories: []
created_at: 2025-03-11T16:46:06.931Z
updated_at: 2025-03-11T16:46:06.931Z
url: https://n8n.io/workflows/3135
scraped_at: 2025-07-06 21:16:30
description:
  Social Media Content Publishing Factory for Streamlined Content Creation Across Platforms

  Who is this for?
  This workflow is designed for content creators, social media managers, and marketing teams who need to efficiently create and publish content across multiple social media platforms. It's perfect for businesses looking to maintain a consistent presence across X (Twitter), Instagram, Facebook, LinkedIn, Threads, and YouTube Shorts without spending hours crafting platform-specific content manually.

  What problem is this workflow solving?
  Creating tailored content for different social media platforms is time-consuming and requires understanding each platform's unique requirements and audience expectations. This workflow solves the challenge of:
  Maintaining consistent messaging across platforms while respecting platform-specific formats
  Generating optimized content that follows best practices for each platform
  Creating accompanying visuals without graphic design skills
  Streamlining the approval process before publishing
  Reducing the time spent on repetitive content creation tasks

  What this workflow does
  This automated content factory takes your content idea and transforms it into platform-optimized posts for all major social media channels. The workflow:

  Accepts your content idea or topic through a chat interface
  Leverages AI to generate tailored content for each platform (X/Twitter, Instagram, Facebook, LinkedIn, Threads, YouTube Shorts)
  Creates appropriate images using AI image generation
  Sends content for approval via email before publishing
  Publishes approved content to selected platforms
  Maintains chat memory to improve future content generation

  Setup
  Connect your social media platform credentials (X/Twitter, Instagram, Facebook, LinkedIn)
  Set up your email account for the approval process
  Configure your OpenAI API key for AI content generation
  Update the image generation service credentials (Pollinations.ai is used by default)
  Customize the system prompts and schemas in the Google Docs nodes with your brand voice and content requirements

  How to customize this workflow to your needs
  Modify the system prompts in the Google Docs nodes to match your brand voice and content strategy
  Adjust the social media schemas to include specific fields relevant to your content
  Update the approval process to include additional stakeholders if needed
  Add or remove social media platforms based on your marketing strategy
  Customize the image generation prompts to better match your visual branding
  Integrate with your existing content calendar or CRM systems

  This workflow eliminates the need to manually craft different versions of the same content for each platform, saving hours of work while ensuring your social media presence remains consistent and optimized for maximum engagement.

nodes_used:
  ["n8n-nodes-base.httpRequest","n8n-nodes-base.telegram","n8n-nodes-base.googleDrive","n8n-nodes-base.facebookGraphApi","n8n-nodes-base.twitter","n8n-nodes-base.gmail","n8n-nodes-base.linkedIn","n8n-nodes-base.googleDocs","n8n-nodes-base.code","@n8n/n8n-nodes-langchain.agent","@n8n/n8n-nodes-langchain.lmChatOpenAi","@n8n/n8n-nodes-langchain.memoryBufferWindow","@n8n/n8n-nodes-langchain.toolSerpApi","@n8n/n8n-nodes-langchain.toolWorkflow"]

workflow_json:
  {"id":"0KZs18Ti2KXKoLIr","meta":{"instanceId":"31e69f7f4a77bf465b805824e303232f0227212ae922d12133a0f96ffeab4fef","templateCredsSetupCompleted":true},"name":"✨🩷Automated Social Media Content Publishing Factory + System Prompt Composition","tags":[],"nodes":[{"id":"74fb48a6-1acd-4693-9b8e-39b36c5649a9","name":"When chat message received","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[-520,-2080],"webhookId":"faddb40a-7048-4398-a0f9-d239a19c32ce","parameters":{"options":{}},"typeVersion":1.1},{"id":"09f4a998-2d69-4683-9251-2694a77efeba","name":"Sticky Note20","type":"n8n-nodes-base.stickyNote","position":[-600,-1720],"parameters":{"color":7,"height":240,"content":"## LLM"},"typeVersion":1},{"id":"03b93e0b-a917-41f6-b99e-5a27ad07cd3e","name":"Sticky Note21","type":"n8n-nodes-base.stickyNote","position":[-600,-1460],"parameters":{"color":7,"height":240,"content":"## Chat Memory"},"typeVersion":1},{"id":"b6c61fe5-a519-4bdb-8641-3149362fbb54","name":"Sticky Note22","type":"n8n-nodes-base.stickyNote","position":[-620,-2160],"parameters":{"color":4,"width":300,"height":280,"content":"## 👍Start Here"},"typeVersion":1},{"id":"2cf0448a-76de-4b2c-a200-953d47e29a52","name":"Sticky Note32","type":"n8n-nodes-base.stickyNote","position":[1980,-2000],"parameters":{"color":2,"width":340,"height":420,"content":"## Social Media Publishing Router"},"typeVersion":1},{"id":"dff757e6-8ef4-4479-a9f8-71cb814fb8ef","name":"Sticky Note33","type":"n8n-nodes-base.stickyNote","position":[-300,-1640],"parameters":{"color":6,"height":240,"content":"## 1️⃣ X - Twitter"},"typeVersion":1},{"id":"fda64627-952a-4be9-b4c5-799d8c7801ad","name":"X-Twiter","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[-220,-1540],"parameters":{"name":"create_x_twitter_posts_tool","fields":{"values":[{"name":"route","stringValue":"=xtwitter"},{"name":"user_prompt","stringValue":"={{ $('When chat message received').item.json.chatInput }}"}]},"workflowId":{"__rl":true,"mode":"id","value":"={{ $workflow.id }}"},"description":"Use this tool to create XTwitter posts","jsonSchemaExample":""},"typeVersion":1.2},{"id":"5023b0b3-468b-4cbb-829c-e06aaf822b99","name":"Sticky Note34","type":"n8n-nodes-base.stickyNote","position":[-40,-1640],"parameters":{"color":6,"height":240,"content":"## 2️⃣ Instagram"},"typeVersion":1},{"id":"781df8c5-0b06-42a4-bbe9-6948ae345599","name":"Instagram","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[40,-1540],"parameters":{"name":"create_instagram_posts_tool","fields":{"values":[{"name":"route","stringValue":"=instagram"},{"name":"user_prompt","stringValue":"={{ $('When chat message received').item.json.chatInput }}"}]},"workflowId":{"__rl":true,"mode":"id","value":"={{ $workflow.id }}"},"description":"Use this tool to create Instagram posts","jsonSchemaExample":""},"typeVersion":1.2},{"id":"8687d1ff-06ee-44c7-a26e-f08da72bbd15","name":"Window Buffer Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[-520,-1360],"parameters":{},"typeVersion":1.3},{"id":"30cbcc50-e19b-43ea-8f0a-5e2021dc5e48","name":"When Executed by Another Workflow","type":"n8n-nodes-base.executeWorkflowTrigger","position":[-700,-560],"parameters":{"workflowInputs":{"values":[{"name":"user_prompt"},{"name":"route"}]}},"typeVersion":1.1},{"id":"0b9b7f07-d603-4890-96b0-f815feb38185","name":"Sticky Note35","type":"n8n-nodes-base.stickyNote","position":[220,-1640],"parameters":{"color":6,"height":240,"content":"## 3️⃣ Facebook"},"typeVersion":1},{"id":"12b17b82-8f98-4d80-9b49-aa9860827e01","name":"Sticky Note36","type":"n8n-nodes-base.stickyNote","position":[480,-1640],"parameters":{"color":6,"height":240,"content":"## 4️⃣ LinkedIn"},"typeVersion":1},{"id":"71dc9ccf-3691-4c0d-b53b-f3ff10f382a9","name":"Facebook","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[300,-1540],"parameters":{"name":"create_facebook_posts_tool","fields":{"values":[{"name":"route","stringValue":"=facebook"},{"name":"user_prompt","stringValue":"={{ $('When chat message received').item.json.chatInput }}"}]},"workflowId":{"__rl":true,"mode":"id","value":"={{ $workflow.id }}"},"description":"Use this tool to create Facebook posts","jsonSchemaExample":""},"typeVersion":1.2},{"id":"f953cd87-88a8-451f-841e-78227949b64d","name":"LinkedIn","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[560,-1540],"parameters":{"name":"create_linkedin_posts_tool","fields":{"values":[{"name":"route","stringValue":"=linkedin"},{"name":"user_prompt","stringValue":"={{ $('When chat message received').item.json.chatInput }}"}]},"workflowId":{"__rl":true,"mode":"id","value":"={{ $workflow.id }}"},"description":"Use this tool to create LinkedIn posts","jsonSchemaExample":""},"typeVersion":1.2},{"id":"97b6829d-6c9d-410a-8fa0-d89d884fd76e","name":"Sticky Note37","type":"n8n-nodes-base.stickyNote","position":[-40,-1380],"parameters":{"color":6,"height":240,"content":"## 5️⃣Threads"},"typeVersion":1},{"id":"463259f7-71b4-492f-b05a-d1a958917d5c","name":"Sticky Note38","type":"n8n-nodes-base.stickyNote","position":[220,-1380],"parameters":{"color":6,"height":240,"content":"## 6️⃣YouTube Shorts"},"typeVersion":1},{"id":"0cd9003b-8eeb-4e4a-9f1f-5f6b611d5194","name":"Short","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[40,-1280],"parameters":{"name":"create_threads_posts_tool","fields":{"values":[{"name":"route","stringValue":"=threads"},{"name":"user_prompt","stringValue":"={{ $('When chat message received').item.json.chatInput }}"}]},"workflowId":{"__rl":true,"mode":"id","value":"={{ $workflow.id }}"},"description":"Use this tool to create Threads posts","jsonSchemaExample":""},"typeVersion":1.2},{"id":"54c2bf4b-8053-4e9d-beb4-570db66f9bd4","name":"YouTube Short","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[300,-1280],"parameters":{"name":"create_youtube_short_tool","fields":{"values":[{"name":"route","stringValue":"=youtube_short"},{"name":"user_prompt","stringValue":"={{ $('When chat message received').item.json.chatInput }}"},{"name":"llm","stringValue":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Value', ``, 'string') }}"}]},"workflowId":{"__rl":true,"mode":"id","value":"={{ $workflow.id }}"},"description":"Use this tool to create a YouTube short","jsonSchemaExample":""},"typeVersion":1.2},{"id":"a72c3242-3a8b-444f-9623-fbcb0b47a817","name":"Sticky Note18","type":"n8n-nodes-base.stickyNote","position":[-340,-1720],"parameters":{"color":7,"width":1100,"height":620,"content":"## Social Media Agent Tools"},"typeVersion":1},{"id":"586a33ae-3546-4b31-9235-9a8fcfd28598","name":"Sticky Note25","type":"n8n-nodes-base.stickyNote","position":[-500,-940],"parameters":{"color":6,"width":3520,"height":820,"content":"# 🏭Social Media Content Factory"},"typeVersion":1},{"id":"153da903-fcd3-4694-aaa4-bef2b300d158","name":"pollinations.ai1","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","maxTries":5,"position":[1440,-560],"parameters":{"url":"=https://image.pollinations.ai/prompt/{{ $json.output.common_schema.image_suggestion.replaceAll(' ','-').replaceAll(',','').replaceAll('.','').slice(0,100) }}","options":{}},"retryOnFail":true,"typeVersion":4.2},{"id":"6c114f0b-1395-4fe6-8de7-0b3d0d9fd6b2","name":"Sticky Note26","type":"n8n-nodes-base.stickyNote","position":[1340,-720],"parameters":{"color":7,"width":300,"height":340,"content":"## Create Post Image\nhttps://pollinations.ai/\nhttps://image.pollinations.ai/prompt/[your image description]\n\n"},"typeVersion":1},{"id":"e196ea9b-f5d0-4fa6-a3d9-bea2f98fd872","name":"Save Image to imgbb.com","type":"n8n-nodes-base.httpRequest","position":[1760,-680],"parameters":{"url":"https://api.imgbb.com/1/upload","method":"POST","options":{"redirect":{"redirect":{}}},"sendBody":true,"sendQuery":true,"contentType":"multipart-form-data","bodyParameters":{"parameters":[{"name":"image","parameterType":"formBinaryData","inputDataFieldName":"data"}]},"queryParameters":{"parameters":[{"name":"expiration","value":"0"},{"name":"key","value":"={{ $env.IMGBB_API_KEY}} "}]}},"typeVersion":4.2},{"id":"225e34be-26ee-40d7-88d6-e866420e083a","name":"Sticky Note41","type":"n8n-nodes-base.stickyNote","position":[1980,-2280],"parameters":{"width":340,"height":180,"content":"💡Notes\n\nUpdate all Social Media Platform Credentials as required.\n\nAdjust parameters and content for each platform to suit your needs."},"typeVersion":1},{"id":"2f48f19d-92c1-478a-b7fa-3fc3b1100993","name":"Sticky Note42","type":"n8n-nodes-base.stickyNote","position":[1240,-1760],"parameters":{"color":4,"width":400,"height":360,"content":"# 👍 Approve Content Before Proceeding"},"typeVersion":1},{"id":"ce4e9f3c-801a-478e-8ffc-008c5e7d4e49","name":"Gmail","type":"n8n-nodes-base.gmail","position":[2640,-780],"webhookId":"cfc2a53d-14a7-47e1-8385-c0b0792d9843","parameters":{"sendTo":"={{ $env.TELEGRAM_CHAT_ID }}","message":"={{ $json.output }}","options":{"appendAttribution":false},"subject":"=Social Media Content - {{ $('Social Content').item.json.output.title }}"},"credentials":{"gmailOAuth2":{"id":"1xpVDEQ1yx8gV022","name":"Gmail account"}},"typeVersion":2.1},{"id":"31ee0735-c863-476c-9c4a-41b50ae9c61a","name":"Social Media Schema","type":"n8n-nodes-base.googleDocs","position":[-320,-700],"parameters":{"operation":"get","documentURL":"=12345"},"credentials":{"googleDocsOAuth2Api":{"id":"YWEHuG28zOt532MQ","name":"Google Docs account"}},"typeVersion":2},{"id":"18cfde4e-2637-496c-acca-070bdb84c2ba","name":"Social Media System Prompt","type":"n8n-nodes-base.googleDocs","position":[-320,-420],"parameters":{"operation":"get","documentURL":"=12345"},"credentials":{"googleDocsOAuth2Api":{"id":"YWEHuG28zOt532MQ","name":"Google Docs account"}},"typeVersion":2},{"id":"383ce472-ccf8-47fb-aa36-5b8aacbcd64f","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-440,-840],"parameters":{"color":7,"width":1120,"height":640,"content":"## Prompt & Schema Composition from External Sources"},"typeVersion":1},{"id":"8d2a2a64-bbaa-4692-94ed-2f541d0d40ca","name":"gpt-40-mini","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[2320,-600],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"gpt-4o-mini"},"options":{"responseFormat":"text"}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.2},{"id":"6e5faa4d-25a1-4dbe-998e-3255ed181ac5","name":"Instagram Image","type":"n8n-nodes-base.httpRequest","onError":"continueRegularOutput","position":[2440,-1940],"parameters":{"url":"https://graph.facebook.com/v20.0/[your-unique-id]/media","method":"POST","options":{},"sendQuery":true,"authentication":"predefinedCredentialType","queryParameters":{"parameters":[{"name":"image_url","value":"={{ $json.output.social_image.medium.url }}"},{"name":"caption","value":"={{ $json.output.caption }}"}]},"nodeCredentialType":"facebookGraphApi"},"credentials":{"facebookGraphApi":{"id":"PzDfmiwB7GPtmSaP","name":"Facebook Graph account"}},"typeVersion":4.2},{"id":"958793c8-7a74-498f-ac75-256232469fbc","name":"X Post","type":"n8n-nodes-base.twitter","onError":"continueRegularOutput","position":[2640,-2180],"parameters":{"text":"={{ $json.data.social_content.schema.post }}","additionalFields":{}},"credentials":{"twitterOAuth2Api":{"id":"wRDruLTCqjQ7C5jq","name":"X account"}},"typeVersion":2,"alwaysOutputData":true},{"id":"1f04a4b5-e97d-4574-abdb-270265da77fa","name":"Instragram Post","type":"n8n-nodes-base.facebookGraphApi","onError":"continueRegularOutput","position":[2640,-2000],"parameters":{"edge":"media_publish","node":"[your-unique-id]","options":{"queryParameters":{"parameter":[{"name":"creation_id","value":"={{ $json.id }}"},{"name":"caption","value":"={{ $('Social Media Publishing Router').item.json.output.caption }}"}]}},"graphApiVersion":"v20.0","httpRequestMethod":"POST"},"credentials":{"facebookGraphApi":{"id":"PzDfmiwB7GPtmSaP","name":"Facebook Graph account"}},"typeVersion":1,"alwaysOutputData":true},{"id":"92a917ff-d20d-4bbc-be8f-00e17be83ea2","name":"Facebook Post","type":"n8n-nodes-base.facebookGraphApi","onError":"continueRegularOutput","position":[2640,-1820],"parameters":{"edge":"photos","node":"[your-unique-id]","options":{"queryParameters":{"parameter":[{"name":"message","value":"={{ $json.output.post }}\n\n{{ $json.output.call_to_action }}\n"}]}},"sendBinaryData":true,"graphApiVersion":"v20.0","httpRequestMethod":"POST","binaryPropertyName":"data"},"credentials":{"facebookGraphApi":{"id":"PzDfmiwB7GPtmSaP","name":"Facebook Graph account"}},"typeVersion":1,"alwaysOutputData":true},{"id":"6c80332d-1aaf-4f3a-91fd-58c25f20ee0c","name":"LinkedIn Post","type":"n8n-nodes-base.linkedIn","onError":"continueRegularOutput","position":[2640,-1640],"parameters":{"text":"={{ $json.data.social_content.schema.post }}\n{{ $json.data.social_content.schema.call_to_action }}\n{{ $json.data.social_content.common_schema.hashtags }}\n","postAs":"organization","organization":"12345678","additionalFields":{},"binaryPropertyName":"=data","shareMediaCategory":"IMAGE"},"credentials":{"linkedInOAuth2Api":{"id":"WMm6pzAEgNd4wJdO","name":"LinkedIn account"}},"typeVersion":1,"alwaysOutputData":true},{"id":"f9d80261-8543-4a12-969c-eecd58513ef2","name":"Gmail User for Approval","type":"n8n-nodes-base.gmail","position":[1380,-1600],"webhookId":"abfae12d-ddcf-4981-ad33-bb7a8cc115a2","parameters":{"sendTo":"={{ $env.TELEGRAM_CHAT_ID }}","message":"={{ $json.output }}","options":{"limitWaitTime":{"values":{"resumeUnit":"minutes","resumeAmount":45}}},"subject":"=🔥FOR APPROVAL🔥 {{$('Extract as JSON').item.json.data.social_content.root_schema.name  }}","operation":"sendAndWait","approvalOptions":{"values":{"approvalType":"double"}}},"credentials":{"gmailOAuth2":{"id":"1xpVDEQ1yx8gV022","name":"Gmail account"}},"typeVersion":2.1},{"id":"97c2dec9-9e1e-4a42-9538-8a37392114e6","name":"Get Social Post Image","type":"n8n-nodes-base.httpRequest","position":[1640,-1340],"parameters":{"url":"={{ $('Extract as JSON').item.json.data.social_image.medium.url }}","options":{}},"retryOnFail":true,"typeVersion":4.2},{"id":"b5b6b7b9-d275-4c1a-a3c5-195b13be1538","name":"gpt-40-mini1","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[860,-1420],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"gpt-4o-mini"},"options":{"responseFormat":"text"}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.2},{"id":"0b5b8237-9e34-44b7-82d9-372a12c67546","name":"gpt-4o-mini","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[780,-360],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"gpt-4o-mini"},"options":{"responseFormat":"json_object"}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.2},{"id":"df61bbeb-1432-434b-9993-18362dba097f","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-1840,-1220],"parameters":{"color":5,"width":760,"height":1540,"content":"<system>\nYou are a specialized content creation AI for social media platforms.\nYour primary function is generating platform-optimized social media content across various platforms including LinkedIn, Instagram, Facebook, Twitter (X), Threads, and YouTube Shorts. Each piece of content must:\nMatch the specific platform's audience expectations and algorithm preferences\nShowcase relevant expertise in your field\nDeliver actionable insights for your target audience\nDrive meaningful engagement through value-driven content\nOBJECTIVES:\nCreate platform-specific content following each platform's best practices\nImplement strategic hashtag usage combining general and trending tags\nDesign content that encourages user interaction and community building\nMaintain consistent brand voice while adapting to platform requirements\nIncorporate data-driven insights to maximize content performance\nOUTPUT REQUIREMENTS:\nDeliver content in valid JSON format according to the platform-specific schema\nInclude all required fields as specified in the schema\nOmit any explanatory text or code fencing in your response\nTailor content specifically to the platform indicated in the user's request\nFor each content request, adapt your output based on the platform guidelines.  Never provide URLS for video or image suggestions and only describe the suggestion.\n</system>\n\n\n<rules>\nOnly provide final response in valid JSON for the appropriate social platform\nNever include any preamble or further explanation\nAlways remove any ``` ```json\n</rules>\n\n\n<linkedin>\n**Style**: Professional and insightful.\n**Tone**: Business-oriented; focus on automation use cases, industry insights, and community impact.\n**Content Length**: 3-4 sentences; concise but detailed.\n**Hashtags**: #Innovation #Automation #WorkflowSolutions #DigitalTransformation #Leadership\n**Call to Action (CTA)**: Encourage comments or visits to workflows.diy's website for more insights.\n</linkedin>\n\n<instagram>\n**Style**: Visual storytelling with creative captions.\n**Tone**: Inspirational and engaging; use emojis for relatability.\n**Content Length**: 2-3 sentences paired with eye-catching visuals (e.g., infographics or workflow demos).\n**Visuals**: Showcase milestones (e.g., new workflow launches), tutorials, or product highlights.\n**CTA**: Use phrases like \"Swipe to learn more,\" \"Tag your team,\" or \"Check out the link below!\"\n**Link Placement**: Add the provided link before hashtags; if no link is provided, use \"Visit our website: https://example.com\"\n**Hashtags**: #AutomationLife #TechInnovation #WorkflowTips #Programming #Engineering\n</instagram>\n\n<facebook>\n**Style**: Friendly and community-focused.\n**Tone**: Relatable; highlight user success stories or company achievements in automation.\n**Content Length**: 2-3 sentences; conversational yet professional.\n**Hashtags**: #SmallBusinessAutomation #Entrepreneurship #Leadership #WorkflowInnovation\n**CTA**: Encourage likes, shares, comments (e.g., \"What's your favorite automation tip?\").\n</facebook>\n\n<xtwitter>\n**Style**: Concise and impactful.\n**Tone**: Crisp and engaging; spark curiosity in 150 characters or less.\n**Hashtags**: #WorkflowTrends #AIWorkflows #AutomationTips #NoCodeSolutions\n**CTA**: Drive quick engagement through retweets or replies (e.g., \"What's your go-to n8n workflow?\").\n</xtwitter>\n\n<threads>\n**Style**: Conversational and community-driven posts.\n**Tone**: Casual yet informative; encourage discussions around automation trends or innovations.\n**Content Length**: 1-2 short paragraphs with a question or thought-provoking statement at the end.\n**Hashtags**: Similar to Instagram but tailored for trending Threads topics related to automation.\n</threads>\n\n<youtube_short>\n**Style**: Short-form video content showcasing quick workflow tutorials or use cases.\n**Tone**: Authoritative yet approachable; establish workflows.diy as a leader in n8n automation solutions.\n**Content Length**:\n  Tutorials/Reviews (long-form): 5-10 minutes\n  Shorts/Highlights (short-form): Under 1 minute\n**CTA**: Encourage subscriptions, likes, comments (e.g., \"Subscribe for more workflow tips!\").\n</youtube_short>\n\n\n\n\n"},"typeVersion":1},{"id":"ddf3d7d3-0218-4ba0-b990-34a6220a53fa","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-1060,-1220],"parameters":{"color":3,"height":1540,"content":"<common>\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"hashtags\": {\n            \"type\": \"array\",\n            \"items\": {\n                \"type\": \"string\"\n            }\n        },\n        \"image_suggestion\": {\n            \"type\": \"string\"\n        }\n    }\n}\n</common>\n\n<root>\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"name\": {\n            \"type\": \"string\"\n        },\n        \"description\": {\n            \"type\": \"string\"\n        },\n        \"additional_notes\": {\n            \"type\": \"string\"\n        }\n    }\n}\n</root>\n\n<linkedin>\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"post\": {\n            \"type\": \"string\"\n        },\n        \"call_to_action\": {\n            \"type\": \"string\"\n        }\n    }\n}\n</linkedin>\n\n<instagram>\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"caption\": {\n            \"type\": \"string\"\n        },\n        \"emojis\": {\n            \"type\": \"array\",\n            \"items\": {\n                \"type\": \"string\"\n            }\n        },\n        \"call_to_action\": {\n            \"type\": \"string\"\n        }\n    }\n}\n</instagram>\n\n<facebook>\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"post\": {\n            \"type\": \"string\"\n        },\n        \"call_to_action\": {\n            \"type\": \"string\"\n        }\n    }\n}\n</facebook>\n\n<xtwitter>\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"video_suggestion\": {\n            \"type\": \"string\"\n        },\n        \"post\": {\n            \"type\": \"string\"\n        },\n        \"character_limit\": {\n            \"type\": \"integer\"\n        }\n    }\n}\n</xtwitter>\n\n<threads>\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"text_post\": {\n            \"type\": \"string\"\n        },\n        \"call_to_action\": {\n            \"type\": \"string\"\n        }\n    }\n}\n</threads>\n\n<youtube_short>\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"video_suggestion\": {\n            \"type\": \"string\"\n        },\n        \"title\": {\n            \"type\": \"string\"\n        },\n        \"description\": {\n            \"type\": \"string\"\n        },\n        \"call_to_action\": {\n            \"type\": \"string\"\n        }\n    }\n}\n</youtube_short>\n\n\n\n"},"typeVersion":1},{"id":"72b378bd-6035-45da-8c76-ddd897d107c7","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-400,-480],"parameters":{"color":5,"width":260,"height":240,"content":"### 👈System Prompt"},"typeVersion":1},{"id":"ba60e52d-722a-4f07-86b4-f4ea64cb2bab","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-400,-760],"parameters":{"color":3,"width":260,"height":240,"content":"### 👈Social Media Schema"},"typeVersion":1},{"id":"bc1ff038-26ad-44d6-94d1-2c1f72a9bf87","name":"Schema","type":"n8n-nodes-base.set","position":[-60,-700],"parameters":{"options":{},"assignments":{"assignments":[{"id":"9d6d41f2-7216-4659-af34-7215298494d9","name":"schema","type":"string","value":"={{ $json.content }}"},{"id":"7d8c85f5-3f4a-4d72-bef0-0957c6ce82a4","name":"platform","type":"string","value":"={{ $('When Executed by Another Workflow').item.json.route }}"}]}},"typeVersion":3.4},{"id":"777d231c-f69c-4b48-bec5-6674175703bc","name":"System Prompt","type":"n8n-nodes-base.set","position":[-60,-420],"parameters":{"options":{},"assignments":{"assignments":[{"id":"5f789b37-b021-4cd4-b359-fdfbb9b71c2b","name":"system_prompt_doc_id","type":"string","value":"={{ $json.documentId }}"},{"id":"daac5758-38ad-4afe-966b-a9b4b89691b2","name":"system_prompt","type":"string","value":"={{ $json.content }}"}]}},"typeVersion":3.4},{"id":"3813a552-cf99-49ca-9617-7eaac56f6819","name":"Parse Schema","type":"n8n-nodes-base.code","position":[140,-700],"parameters":{"jsCode":"// Get the input data from previous node\nconst inputData = $input.first().json;\nconst xmlString = inputData.schema;\n\nconsole.log(inputData)\n\n// Function to extract content between XML tags with better regex handling\nfunction extractFromXmlTags(xmlString, tagName) {\n  const regex = new RegExp(`<${tagName}>(.*?)<\\/${tagName}>`, 'gs');\n  const match = regex.exec(xmlString);\n  return match ? match[1].trim() : null;\n}\n\n// Get the platform from the input or use a default\nconst platform = inputData.platform;\n\n// Extract the content from the specified tag\nconst extractedContent = extractFromXmlTags(xmlString, platform);\nconst rootContent = extractFromXmlTags(xmlString, 'root');\nconst commonContent = extractFromXmlTags(xmlString, 'common');\n\njsonData = JSON.parse(extractedContent);\nrootSchema = JSON.parse(rootContent);\ncommonSchema = JSON.parse(commonContent);\n\n// Return the result\nreturn {\n  json: {\n    schema: jsonData,\n    root_schema: rootSchema,\n    common_schema: commonSchema\n  }\n};\n"},"typeVersion":2},{"id":"c55da4a1-91f8-4d17-ad73-730013a99231","name":"Parse System Prompt","type":"n8n-nodes-base.code","position":[140,-420],"parameters":{"jsCode":"// Get the input data from previous node\nconst inputData = $input.first().json;\nconst xmlString = inputData.system_prompt;\n\n// Function to extract all content between XML tags\nfunction extractAllXmlTags(xmlString) {\n  // Create a result object to store tag contents\n  const result = {};\n  \n  // Regular expression to find all XML tags and their content\n  // This regex matches opening tag, content, and closing tag\n  const tagRegex = /<([^>\\/]+)>([\\s\\S]*?)<\\/\\1>/g;\n  \n  // Find all matches\n  let match;\n  while ((match = tagRegex.exec(xmlString)) !== null) {\n    const tagName = match[1].trim();\n    const content = match[2].trim();\n    \n    // Store the content with the tag name as the key\n    result[tagName] = content;\n  }\n  \n  return result;\n}\n\n// Extract all XML tags and their content\nconst extractedTags = extractAllXmlTags(xmlString);\n\n// Return the result as a JSON object\nreturn {\n  json: {\n    system_config: extractedTags\n  }\n};\n"},"typeVersion":2},{"id":"1767c787-943b-43d6-86cb-3fb60eaf878e","name":"Compose Prompt & Schema","type":"n8n-nodes-base.set","position":[520,-560],"parameters":{"options":{},"assignments":{"assignments":[{"id":"9216ad1c-a281-4c94-835d-e20507ef0cb5","name":"route","type":"string","value":"={{ $json.route }}"},{"id":"e6ca5cdf-5139-4db7-b065-ee52028216c5","name":"user_prompt","type":"string","value":"={{ $json.user_prompt }}"},{"id":"2927cd6f-c351-49df-954b-9f87b0338c58","name":"system_config.system","type":"string","value":"={{ $json.system_config.system }}"},{"id":"829b1519-9ffa-44d7-8caa-455e15b30614","name":"system_config.rules","type":"string","value":"={{ $json.system_config.rules }}"},{"id":"b44472ba-6e98-448b-bad6-e02da8b32b0a","name":"={{ $json.route }}","type":"string","value":"={{ $json.system_config[$json.route.toLowerCase()] }}"},{"id":"a96e8c30-1d44-4e23-9ef4-95d7303ea41e","name":"root_schema","type":"object","value":"={{ $json.root_schema }}"},{"id":"6cb68192-10f3-496d-88ca-289ee0c19940","name":"common_schema","type":"object","value":"={{ $json.common_schema }}"},{"id":"8f9b85f0-abaa-46c2-ba98-897f6a677105","name":"schema","type":"object","value":"={{ $json.schema }}"}]}},"typeVersion":3.4},{"id":"b7d78f57-ee83-4e03-ada6-fd6e2048c272","name":"Social Media Content Creator","type":"@n8n/n8n-nodes-langchain.agent","position":[800,-560],"parameters":{"text":"=Social Media Platform: {{ $json.route }}\nUser Prompt: {{ $json.user_prompt }}\n","options":{"systemMessage":"={{ $json.system_config.system }}\n\n<tools>\nYou have been provided with an internet search tool.  Use this tool to find relavent information about the users request before responding.  Todays date is: {{ $now }}\n</tools>\n\n<rules>\n{{ $json.system_config.rules }}\n- Output must conform to provided JSON schema\n</rules>\n\nFollow this Output JSON Schema:\n{\n  root_schema: {{ $json.root_schema.toJsonString() }},\n  common_schema: {{ $json.common_schema.toJsonString()}},\n  schema: {{  $json.schema.toJsonString() }}\n}"},"promptType":"define"},"typeVersion":1.7},{"id":"35469698-0eb5-4238-85d1-c67ccbacf2cb","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-1880,-1400],"parameters":{"color":7,"width":1100,"height":1760,"content":"# External System Prompt and Schema"},"typeVersion":1},{"id":"12b55edd-ff51-423b-a153-96a8a2a09678","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[2380,-2280],"parameters":{"color":6,"width":700,"height":1240,"content":"# 📄 Publish to Social Media "},"typeVersion":1},{"id":"78cd8af0-c10c-4bf5-8420-63061e7687bc","name":"Merge Prompts and Schema","type":"n8n-nodes-base.merge","position":[340,-560],"parameters":{"mode":"combine","options":{},"combineBy":"combineByPosition","numberInputs":3},"typeVersion":3},{"id":"e7a62296-729b-45df-bd15-002ccaae2fa0","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[720,-680],"parameters":{"width":400,"height":480,"content":"## Social Media Content Creator"},"typeVersion":1},{"id":"f6cb5a95-4047-4e41-a635-a73681fe6d8b","name":"Social Content","type":"n8n-nodes-base.set","position":[1180,-560],"parameters":{"options":{},"assignments":{"assignments":[{"id":"8c318996-aa79-4970-b8d7-33ae1931c8c6","name":"output","type":"object","value":"={{ $json.output }}"}]}},"typeVersion":3.4},{"id":"148df311-24db-4243-bc62-1a51579720d7","name":"Save Image to Google Drive","type":"n8n-nodes-base.googleDrive","position":[1760,-480],"parameters":{"name":"={{ $json.output.root_schema.name.replaceAll(' ','-').replaceAll(',','').replaceAll('.','') }}","driveId":{"__rl":true,"mode":"id","value":"=My Drive"},"options":{},"folderId":{"__rl":true,"mode":"id","value":"=12345"}},"credentials":{"googleDriveOAuth2Api":{"id":"UhdXGYLTAJbsa0xX","name":"Google Drive account"}},"typeVersion":3},{"id":"f84ab889-d193-4d9a-8e8b-4f35805edaa4","name":"Merge","type":"n8n-nodes-base.merge","position":[1980,-560],"parameters":{"mode":"combine","options":{"includeUnpaired":true},"combineBy":"combineByPosition","numberInputs":3},"typeVersion":3},{"id":"ca43646b-ca79-4ff6-ac02-da4f668e7aeb","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[2200,-880],"parameters":{"color":7,"width":660,"height":420,"content":"## Send Social Media Image and Post Contents to Gmail\n(optional)"},"typeVersion":1},{"id":"cf7bda38-260f-42c0-b60a-6a93181712de","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[2120,-420],"parameters":{"color":7,"width":840,"height":260,"content":"## Prepare Social Media Post and Save to Google Drive"},"typeVersion":1},{"id":"13cafb9c-5f04-4193-8f0e-0384f68d5e45","name":"Save Social Post to Google Drive","type":"n8n-nodes-base.googleDrive","position":[2560,-340],"parameters":{"name":"={{ $json.response.google_drive_image.id }}","content":"={{ $json.response.toJsonString() }}","driveId":{"__rl":true,"mode":"list","value":"My Drive"},"options":{},"folderId":{"__rl":true,"mode":"id","value":"= 12345"},"operation":"createFromText"},"credentials":{"googleDriveOAuth2Api":{"id":"UhdXGYLTAJbsa0xX","name":"Google Drive account"}},"typeVersion":3},{"id":"2bdecf8d-e180-4795-92c2-6158adf71daf","name":"Google Drive Image Meta","type":"n8n-nodes-base.set","position":[2200,-340],"parameters":{"options":{},"assignments":{"assignments":[{"id":"769d86e6-3764-4023-8932-f25f7d4fe34a","name":"id","type":"string","value":"={{ $json.id }}"},{"id":"4ccae0cc-d246-477c-9e94-3be461134d01","name":"webContentLink","type":"string","value":"={{ $json.webContentLink }}"},{"id":"74e22694-c7e6-4598-8e87-8ea6ae00144e","name":"webViewLink","type":"string","value":"={{ $json.webViewLink }}"},{"id":"e8eedbbf-7d42-475b-a748-0afbe8b730da","name":"thumbnailLink","type":"string","value":"={{ $json.thumbnailLink }}"}]}},"typeVersion":3.4},{"id":"d6e4902a-af19-45a4-8253-432135e17998","name":"Social Post JSON","type":"n8n-nodes-base.set","position":[2380,-340],"parameters":{"options":{},"assignments":{"assignments":[{"id":"b705af39-d286-4461-956c-d963ea151734","name":"response","type":"object","value":"={ \n  \"route\": \"{{ $('When Executed by Another Workflow').item.json.route }}\",\n \"social_image\": {{ $('Merge').item.json.data.toJsonString()  }},\n  \"social_content\": {{ $('Social Content').item.json.output.toJsonString() }},\n  \"google_drive_image\": {{ $json.toJsonString() }}\n}"}]}},"typeVersion":3.4},{"id":"b35623e6-9ddc-4091-905f-7b485efc5d60","name":"Respond with Google Drive Id","type":"n8n-nodes-base.set","position":[2740,-340],"parameters":{"options":{},"assignments":{"assignments":[{"id":"ad353ca7-059a-4108-88b9-fb92720a34fe","name":"response","type":"string","value":"={{ $json.id }}"}]}},"typeVersion":3.4},{"id":"410c3924-1011-480d-874c-a395c243f4c6","name":"Telegram Success Message (Optional)","type":"n8n-nodes-base.telegram","position":[1760,-880],"webhookId":"93342863-02c0-42ee-98c3-a2ec72b3bf12","parameters":{"text":"Image created successfully","chatId":"={{ $env.TELEGRAM_CHAT_ID }}","additionalFields":{"appendAttribution":false}},"credentials":{"telegramApi":{"id":"pAIFhguJlkO3c7aQ","name":"Telegram account"}},"typeVersion":1.2},{"id":"eba8445d-55da-43e2-b2aa-4822168a70ea","name":"Telegram Error Message (Optional)","type":"n8n-nodes-base.telegram","position":[1760,-300],"webhookId":"93342863-02c0-42ee-98c3-a2ec72b3bf12","parameters":{"text":"Error creating image (Debugging)","chatId":"={{ $env.TELEGRAM_CHAT_ID }}","additionalFields":{"appendAttribution":false}},"credentials":{"telegramApi":{"id":"pAIFhguJlkO3c7aQ","name":"Telegram account"}},"typeVersion":1.2},{"id":"af2c4945-0dac-4398-b8ad-329066eefedd","name":"Social Media Publishing Router","type":"n8n-nodes-base.switch","position":[2080,-1900],"parameters":{"rules":{"values":[{"outputKey":"1️⃣X-Twitter","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.data.route }}","rightValue":"xtwitter"}]},"renameOutput":true},{"outputKey":" 2️⃣Instagram","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"86d44336-bab7-422f-9266-fcb513252d19","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.route }}","rightValue":"instagram"}]},"renameOutput":true},{"outputKey":" 3️⃣Facebook","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"29f37628-6381-46af-babb-74bf00b4a849","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.route }}","rightValue":"facebook"}]},"renameOutput":true},{"outputKey":"4️⃣Linkedin","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"fdb7c8aa-4108-43f6-8f6b-71cd8f383d2a","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.route }}","rightValue":"=linkedin"}]},"renameOutput":true},{"outputKey":"5️⃣Threads","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"956baedd-4a0b-4e41-b85c-ef2c84332bdc","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.route }}","rightValue":"threads"}]},"renameOutput":true},{"outputKey":"6️⃣YouTube Short","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"4d690442-197c-4ff9-b176-b55dfabaecc9","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.route }}","rightValue":"youtube_short"}]},"renameOutput":true}]},"options":{}},"typeVersion":3.2},{"id":"682ee752-8e7f-4ee5-b617-88d7c1f7d4e7","name":"Prepare Email Contents","type":"@n8n/n8n-nodes-langchain.agent","position":[880,-1600],"parameters":{"text":"=Use the HTML template and populate [fields] as required from this: {{ $json.data.social_content.toJsonString() }}\n-----\nOnly output HTML without code block tags, preamble or further explanation in the format provided.\n\n## HTML Template\n<table style=\"max-width:640px;min-width:320px;width:100%;border-collapse:collapse;font-family:Arial,sans-serif;margin:20px auto\">\n    <tbody>\n        <tr>\n            <td colspan=\"2\" style=\"background-color:#ffffff;padding:15px;text-align:left\">\n                <img src=\"{{ $json.data.google_drive_image.thumbnailLink }}\" alt=\"{{ $json.data.social_content.root_schema.name }}\" style=\"max-width:100%;height:auto;\">\n            </td>\n        </tr>\n        <tr>\n            <td colspan=\"2\" style=\"background-color:#efefef;padding:15px;font-size:20px;text-align:left;font-weight:bold\">\n                {{ $json.data.social_content.root_schema.name }}\n            </td>\n        </tr>\n        <tr>\n            <td style=\"background-color:#f9f9f9;padding:15px;width:30%;text-align:left\"><strong>[label_1]:</strong></td>\n            <td style=\"background-color:#f9f9f9;padding:15px;text-align:left\">[content_1]</td>\n        </tr>\n        <tr>\n            <td style=\"background-color:#f1f1f1;padding:15px;text-align:left\"><strong>[label_2]:</strong></td>\n            <td style=\"background-color:#f1f1f1;padding:15px;text-align:left\">[content_2]</td>\n        </tr>\n\n        [continue the pattern ...]\n\n        <tr>\n            <td colspan=\"2\" style=\"background-color:#efefef;padding:15px;text-align:left\">\n                <strong>[footer_label]:</strong> [footer_content]\n            </td>\n        </tr>\n    </tbody>\n</table>\n\n","options":{},"promptType":"define"},"typeVersion":1.7},{"id":"eeab0159-cb24-4653-ba14-461740c8753c","name":"Is Approved?","type":"n8n-nodes-base.if","position":[1380,-1340],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"313cec9b-aad5-4f9c-a209-afe83af53df0","operator":{"type":"boolean","operation":"true","singleValue":true},"leftValue":"={{ $json.data.approved }}","rightValue":""}]}},"typeVersion":2.2},{"id":"dbe7cd63-9ec0-46cd-9255-8c1dc738847d","name":"File Id","type":"n8n-nodes-base.set","position":[1200,-2080],"parameters":{"options":{},"assignments":{"assignments":[{"id":"efb1c03b-8465-443d-a442-b76b8cd86a73","name":"output","type":"object","value":"={{ $json.output }}"}]}},"typeVersion":3.4},{"id":"cdb01e90-c54c-4ae4-87e2-75a3baec2295","name":"Get Social Post from Google Drive","type":"n8n-nodes-base.googleDrive","position":[1380,-2080],"parameters":{"fileId":{"__rl":true,"mode":"id","value":"={{ $json.output.response }}"},"options":{},"operation":"download"},"credentials":{"googleDriveOAuth2Api":{"id":"UhdXGYLTAJbsa0xX","name":"Google Drive account"}},"typeVersion":3},{"id":"aea6ec59-fcf4-4b5a-9fbc-86d9eb834388","name":"Extract as JSON","type":"n8n-nodes-base.extractFromFile","position":[1560,-2080],"parameters":{"options":{},"operation":"fromJson"},"typeVersion":1},{"id":"70ccf82d-3871-40cd-8dc0-961e36acd070","name":"Merge Image and Post Contents","type":"n8n-nodes-base.merge","position":[1820,-1840],"parameters":{"mode":"combine","options":{},"combineBy":"combineByPosition"},"typeVersion":3},{"id":"077f7110-215f-4ccf-8546-41d21c1105ad","name":"Sticky Note10","type":"n8n-nodes-base.stickyNote","position":[2540,-1460],"parameters":{"width":320,"height":380,"content":""},"typeVersion":1},{"id":"650a4191-6ed6-4868-b433-f44a0ddf959b","name":"Implement Threads Here","type":"n8n-nodes-base.noOp","position":[2640,-1420],"parameters":{},"typeVersion":1},{"id":"59651d51-92ce-42e5-a9c7-4faa18526ef2","name":"Implement YouTube Shorts Here","type":"n8n-nodes-base.noOp","position":[2640,-1260],"parameters":{},"typeVersion":1},{"id":"7cb931d5-d890-4ea6-9fca-84b934dd911c","name":"X Response","type":"n8n-nodes-base.set","position":[2840,-2180],"parameters":{"options":{},"assignments":{"assignments":[{"id":"4015bb20-da3b-4781-ab8c-46f4d826138e","name":"output","type":"string","value":"={{ $('Social Media Publishing Router').item.json.data.route }}\n\n{{ $('Social Media Publishing Router').item.json.data.social_content.root_schema.name }}\n\n{{ $('Social Media Publishing Router').item.json.data.social_content.schema.post }}\n\n![{{ $('Social Media Publishing Router').item.json.data.social_content.root_schema.name }}]({{ $('Social Media Publishing Router').item.json.data.social_image.thumb.url }})"}]}},"typeVersion":3.4},{"id":"90c4faa3-3376-41d1-83e7-0c4c2bc03de5","name":"Instagram Response","type":"n8n-nodes-base.set","position":[2840,-2000],"parameters":{"options":{},"assignments":{"assignments":[{"id":"da8fe7e3-e74d-46b6-91eb-1bf4432b73b0","name":"output","type":"string","value":"={{ $('Social Media Publishing Router').item.json.data.route }}  \n{{ $('Social Media Publishing Router').item.json.data.social_content.root_schema.name }}\n{{ $('Social Media Publishing Router').item.json.data.social_content.schema.caption }}\n![{{ $('Social Media Publishing Router').item.json.data.social_content.root_schema.name }}]({{ $('Social Media Publishing Router').item.json.data.social_image.thumb.url }})"}]}},"typeVersion":3.4},{"id":"de57e2c7-acac-4268-a535-e90f00548956","name":"Facebook Response","type":"n8n-nodes-base.set","position":[2840,-1820],"parameters":{"options":{},"assignments":{"assignments":[{"id":"e349e314-2967-456f-856a-85727bdf94f3","name":"output","type":"string","value":"={{ $('Social Media Publishing Router').item.json.data.route }}\n\n{{ $('Social Media Publishing Router').item.json.data.social_content.root_schema.name }}\n\n{{ $('Social Media Publishing Router').item.json.data.social_content.schema.post }}\n\n![{{ $('Social Media Publishing Router').item.json.data.social_content.root_schema.name }}]({{ $('Social Media Publishing Router').item.json.data.social_image.thumb.url }})"}]}},"typeVersion":3.4},{"id":"030e8933-0eae-4e6c-956d-dce0e702b163","name":"LinkedIn Response","type":"n8n-nodes-base.set","position":[2840,-1640],"parameters":{"options":{},"assignments":{"assignments":[{"id":"88404fde-a41b-4da5-bbdb-0e41b879a52c","name":"output","type":"string","value":"={{ $('Social Media Publishing Router').item.json.data.route }}\n\n{{ $('Social Media Publishing Router').item.json.data.social_content.root_schema.name }}\n\n{{ $('Social Media Publishing Router').item.json.data.social_content.schema.post }}\n\n![{{ $('Social Media Publishing Router').item.json.data.social_content.root_schema.name }}]({{ $('Social Media Publishing Router').item.json.data.social_image.thumb.url }})\n"}]}},"typeVersion":3.4},{"id":"d48b6b3a-9410-4012-85bf-f70b4e91eccb","name":"Sticky Note11","type":"n8n-nodes-base.stickyNote","position":[-1060,-1300],"parameters":{"color":3,"height":80,"content":"## Social Media Schema"},"typeVersion":1},{"id":"e3ef0a13-42ca-4021-aeb5-2230f4ac7eac","name":"Sticky Note12","type":"n8n-nodes-base.stickyNote","position":[-1840,-1300],"parameters":{"color":5,"width":760,"height":80,"content":"## System Prompt"},"typeVersion":1},{"id":"11457221-fa5e-41f4-93a5-bb3eea3f02a9","name":"Sticky Note13","type":"n8n-nodes-base.stickyNote","position":[-120,-2200],"parameters":{"width":620,"height":320,"content":"# Social Media Router Agent"},"typeVersion":1},{"id":"f40e9cde-1810-4471-9751-6da724a06f6c","name":"🤖Social Media Router Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[60,-2080],"parameters":{"text":"=You are a helpful assistant that uses the provided tools.  Respond with a valid JSON object.\n\nUser prompt:  {{ $json.chatInput }}","options":{"systemMessage":"## RULES\n- You do not answer the users questions directly and your sole purpose is to call the appropriate tool to and provide the verbatim response.\n\n## TOOLS\n- create_x_twitter_posts_tool: Use this tool to create X-Twitter posts\n- create_instagram_posts_tool: Use this tool to create Instagram posts\n- create_facebook_posts_tool: Use this tool to create Facebook posts\n- create_linkedin_posts_tool: Use this tool to create LinkedIn posts\n- create_threads_posts_tool: Use this tool to create Threads posts\n- create_youtube_short_tool: Use this tool to create a YouTube short\n\n\n"},"promptType":"define"},"typeVersion":1.7},{"id":"e6715ea6-f70d-427b-bf3d-499ed8040140","name":"Sticky Note14","type":"n8n-nodes-base.stickyNote","position":[800,-1720],"parameters":{"width":400,"height":440,"content":"## Prepare Email Approval Contents as HTML"},"typeVersion":1},{"id":"cbb2a190-8aad-4e09-9d5c-a43dbcb32184","name":"SerpAPI","type":"@n8n/n8n-nodes-langchain.toolSerpApi","position":[980,-360],"parameters":{"options":{}},"credentials":{"serpApi":{"id":"DfdkTTaZtPp0iHYv","name":"SerpAPI account"}},"typeVersion":1},{"id":"58da1f9e-caa4-4ea2-8b02-3e734758af80","name":"Sticky Note15","type":"n8n-nodes-base.stickyNote","position":[-500,-120],"parameters":{"color":7,"width":3520,"height":680,"content":"# 💫Features & Benefits"},"typeVersion":1},{"id":"e65c6e37-0523-4e7d-b634-d3499aef5516","name":"Sticky Note16","type":"n8n-nodes-base.stickyNote","position":[-440,-40],"parameters":{"color":7,"width":680,"height":280,"content":"## 1️⃣System Prompt Composition from External Source\nCentralized prompt management: Store and update system prompts in Google Docs for easy team collaboration\n\n- Consistent brand voice: Ensure all generated content maintains consistent tone and style across platforms\n\n- Flexible customization: Quickly modify prompts without changing workflow code\n\n- Version control: Track changes to prompts over time with Google Docs revision history\n\n- Role-specific access: Control who can edit core prompts while allowing broader viewing access\n"},"typeVersion":1},{"id":"b7ccbaa4-3c33-4f32-a72d-fb693b9c63d6","name":"Sticky Note17","type":"n8n-nodes-base.stickyNote","position":[-440,260],"parameters":{"color":7,"width":680,"height":260,"content":"## 2️⃣Output Schema Composition from External Source\n- Structured content generation: Enforce consistent JSON output formats for each platform\n\n- Platform-specific optimization: Tailor content structure to each social network's requirements\n\n- Reduced errors: Validate content against schemas before publishing\n\n- Easy updates: Modify schemas as platform requirements change without workflow modifications\n\n- Standardized metadata: Ensure all required fields are included for each platform"},"typeVersion":1},{"id":"b36e874a-a893-439d-bd29-524ea567b695","name":"Sticky Note19","type":"n8n-nodes-base.stickyNote","position":[720,-40],"parameters":{"color":7,"width":400,"height":520,"content":"## 4️⃣ Dynamic Social Media Content Creator Agent with Web Search Tool to Match Social Post and Platform Schema\n\n- Real-time research: Incorporate current events and trending topics into content\n\n- Fact-checking: Verify information before publishing to maintain credibility\n\n- Competitive analysis: Reference industry trends and competitor content\n\n- Contextual relevance: Create content that responds to current market conditions\n\n- Enhanced engagement: Generate content that aligns with trending conversations"},"typeVersion":1},{"id":"d57e47d1-e95e-45b6-95cf-a8952320da35","name":"Sticky Note23","type":"n8n-nodes-base.stickyNote","position":[1160,-40],"parameters":{"color":7,"width":340,"height":520,"content":"## 5️⃣ Dynamic Image Creation to Match Social Post & Platform Schema\n\n- Visual consistency: Generate platform-optimized images that match content themes\n\n- Automated alt text: Create accessibility-compliant image descriptions\n\n- Multi-format output: Generate images in various dimensions for different platforms\n\n- Brand compliance: Ensure all visuals align with brand guidelines\n\n- Reduced design bottlenecks: Eliminate waiting for custom graphics for each post"},"typeVersion":1},{"id":"4323fd33-f2ff-434a-bd44-0ecb59fc4962","name":"Sticky Note24","type":"n8n-nodes-base.stickyNote","position":[1520,-40],"parameters":{"color":7,"width":300,"height":520,"content":"## 6️⃣ Image Archiving to Multiple Cloud Services for Future Use\n\n- Redundant storage: Prevent content loss with multi-location backups\n\n-Searchable repository: Build a library of past content for reference and reuse\n\n- Asset tracking: Maintain records of which images were used for which campaigns\n\n- Compliance documentation: Keep records of published content for regulatory purposes\n\n- Resource optimization: Reuse successful visual assets for future campaigns"},"typeVersion":1},{"id":"e0dc7e2a-275f-4389-973a-e0d92af6de6c","name":"Sticky Note27","type":"n8n-nodes-base.stickyNote","position":[1840,-40],"parameters":{"color":7,"width":260,"height":520,"content":"## 7️⃣ Telegram Messaging for Workflow Status \n\n- Real-time notifications: Get immediate alerts about workflow execution\n\n- Error tracking: Quickly identify and address failures in the content pipeline\n\n- Team coordination: Keep stakeholders informed of content progress\n\n- Audit trail: Maintain records of when content was created and published\n\n- Remote monitoring: Track workflow execution from mobile devices"},"typeVersion":1},{"id":"0d9940df-faad-4adc-a79f-4b89f2f2d16e","name":"Sticky Note28","type":"n8n-nodes-base.stickyNote","position":[2120,-40],"parameters":{"color":7,"width":840,"height":280,"content":"## 8️⃣ Optional Workflow Reporting to Gmail in with Structured HTML Content\n- Executive summaries: Provide management with clean, formatted reports\n\n- Content approval: Enable stakeholders to review content before publishing\n\n- Performance tracking: Document content metrics in standardized formats\n\n- Schedule adherence: Monitor if content is being published according to plan\n\n- Resource allocation: Track time and effort spent on different content types"},"typeVersion":1},{"id":"febb3aa7-d0ed-422a-b115-33863889a152","name":"Sticky Note29","type":"n8n-nodes-base.stickyNote","position":[2120,260],"parameters":{"color":7,"width":840,"height":260,"content":"## 9️⃣ Social Post Archiving to Google Drive for Future Use\n- Content library: Build a searchable repository of all published content\n\n- Performance correlation: Connect content with its performance metrics\n\n- Compliance records: Maintain documentation of published materials\n\n- Content repurposing: Easily find and adapt past successful content\n\n- Campaign documentation: Group related content for campaign analysis"},"typeVersion":1},{"id":"697fab77-d1bb-41d8-8683-193230471721","name":"Sticky Note30","type":"n8n-nodes-base.stickyNote","position":[260,-40],"parameters":{"width":420,"height":960,"content":"## 3️⃣Dynamic System Prompt and Platform Schema Composition based on User Prompt using External Sources\n- Centralized prompt management: Store all system prompts in a single external source for easier maintenance and updates\n\n- Platform-specific optimization: Automatically tailor content to each platform's unique requirements and audience expectations\n\n- Consistent brand voice: Ensure all generated content maintains your brand's tone and messaging guidelines across platforms\n\n- Reduced technical debt: Modify prompts and schemas without changing workflow code or redeploying applications\n\n- Collaborative improvement: Enable marketing teams to refine prompts without developer intervention\n\n- Version control: Track changes to prompts and schemas over time with document revision history\n\n- A/B testing capability: Easily test different prompt variations to optimize content performance\n\n- Scalable content strategy: Add support for new platforms by simply creating new prompt and schema documents\n\n- Dynamic adaptation: Respond to platform algorithm changes by quickly updating external prompt documents\n\n- Knowledge preservation: Maintain institutional knowledge about effective platform-specific content strategies\n\n- Reduced onboarding time: New team members can understand content requirements by reviewing documented prompts\n\n- Compliance management: Ensure all generated content follows legal and brand guidelines by centralizing rules"},"typeVersion":1},{"id":"11ba3bef-7036-416b-a63d-a82cf7cbe30f","name":"Prepare Social Media Email Contents","type":"@n8n/n8n-nodes-langchain.agent","position":[2300,-780],"parameters":{"text":"=Use the HTML template and populate [fields] as required from this: {{ $('pollinations.ai1').item.json.output.toJsonString() }}\n-----\nOnly output HTML without code block tags, preamble or further explanation in the format provided.\n\n## HTML Template\n<table style=\"max-width:640px;min-width:320px;width:100%;border-collapse:collapse;font-family:Arial,sans-serif;margin:20px auto\">\n    <tbody>\n        <tr>\n            <td colspan=\"2\" style=\"background-color:#ffffff;padding:15px;text-align:left\">\n                <img src=\"{{ $json.thumbnailLink }}\" alt=\"{{ $json.output.root_schema.name }}\" style=\"max-width:100%;height:auto;\">\n            </td>\n        </tr>\n        <tr>\n            <td colspan=\"2\" style=\"background-color:#efefef;padding:15px;font-size:20px;text-align:left;font-weight:bold\">\n                {{ $json.output.root_schema.name  }}\n            </td>\n        </tr>\n        <tr>\n            <td style=\"background-color:#f9f9f9;padding:15px;width:30%;text-align:left\"><strong>Platform:</strong></td>\n            <td style=\"background-color:#f9f9f9;padding:15px;text-align:left\">{{ $('Compose Prompt & Schema').item.json.route }}</td>\n        </tr>\n        <tr>\n            <td style=\"background-color:#f9f9f9;padding:15px;width:30%;text-align:left\"><strong>[label_1]:</strong></td>\n            <td style=\"background-color:#f9f9f9;padding:15px;text-align:left\">[content_1]</td>\n        </tr>\n        <tr>\n            <td style=\"background-color:#f1f1f1;padding:15px;text-align:left\"><strong>[label_2]:</strong></td>\n            <td style=\"background-color:#f1f1f1;padding:15px;text-align:left\">[content_2]</td>\n        </tr>\n\n        [continue the pattern ...]\n\n        <tr>\n            <td colspan=\"2\" style=\"background-color:#efefef;padding:15px;text-align:left\">\n                <strong>[footer_label]:</strong> [footer_content]\n            </td>\n        </tr>\n    </tbody>\n</table>\n\n","options":{},"promptType":"define"},"typeVersion":1.7},{"id":"1dc19a25-ff27-4582-a574-279831f7bc28","name":"Sticky Note43","type":"n8n-nodes-base.stickyNote","position":[-760,-340],"parameters":{"height":500,"content":"💡Notes\n\n- Create Google Doc for the Social Media Schema and copy the provided schema.\n\n- Update the Google Doc ID in the Social Media Schema node.\n\n- Create Google Doc for the Social Media System Prompt and copy the provided System Prompt.\n\n- Update the Google Doc ID in the Social Media System Prompt node.\n\n\n\nAdjust system prompt and platform specific prompts to suit your needs."},"typeVersion":1},{"id":"6b1d2ad9-9ad8-4a33-ab7d-430f96dc317c","name":"Sticky Note44","type":"n8n-nodes-base.stickyNote","position":[1340,-360],"parameters":{"width":300,"content":"💡Notes\n\nReplace pollinations.ai with any online image generation service that produces an image file you can download."},"typeVersion":1},{"id":"e7c2d9ba-6b9a-404f-a84d-8e90e4c5f4bb","name":"Sticky Note45","type":"n8n-nodes-base.stickyNote","position":[720,-840],"parameters":{"width":400,"height":140,"content":"💡Notes\n\nReplace Chat model with other LLMs and test out the results.  Add more tools or try other web search tools to suit your use case."},"typeVersion":1},{"id":"00204106-dd0f-46d5-89c8-60fd92f1388e","name":"gpt-4o","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-520,-1620],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o","cachedResultName":"gpt-4o"},"options":{"responseFormat":"json_object"}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.2}],"active":false,"pinData":{"Social Media Schema":[{"json":{"content":"<common>\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"hashtags\": {\n            \"type\": \"array\",\n            \"items\": {\n                \"type\": \"string\"\n            }\n        },\n        \"image_suggestion\": {\n            \"type\": \"string\"\n        }\n    }\n}\n</common>\n\n<root>\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"name\": {\n            \"type\": \"string\"\n        },\n        \"description\": {\n            \"type\": \"string\"\n        },\n        \"additional_notes\": {\n            \"type\": \"string\"\n        }\n    }\n}\n</root>\n\n<linkedin>\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"post\": {\n            \"type\": \"string\"\n        },\n        \"call_to_action\": {\n            \"type\": \"string\"\n        }\n    }\n}\n</linkedin>\n\n<instagram>\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"caption\": {\n            \"type\": \"string\"\n        },\n        \"emojis\": {\n            \"type\": \"array\",\n            \"items\": {\n                \"type\": \"string\"\n            }\n        },\n        \"call_to_action\": {\n            \"type\": \"string\"\n        }\n    }\n}\n</instagram>\n\n<facebook>\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"post\": {\n            \"type\": \"string\"\n        },\n        \"call_to_action\": {\n            \"type\": \"string\"\n        }\n    }\n}\n</facebook>\n\n<xtwitter>\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"video_suggestion\": {\n            \"type\": \"string\"\n        },\n        \"post\": {\n            \"type\": \"string\"\n        },\n        \"character_limit\": {\n            \"type\": \"integer\"\n        }\n    }\n}\n</xtwitter>\n\n<threads>\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"text_post\": {\n            \"type\": \"string\"\n        },\n        \"call_to_action\": {\n            \"type\": \"string\"\n        }\n    }\n}\n</threads>\n\n<youtube_short>\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"video_suggestion\": {\n            \"type\": \"string\"\n        },\n        \"title\": {\n            \"type\": \"string\"\n        },\n        \"description\": {\n            \"type\": \"string\"\n        },\n        \"call_to_action\": {\n            \"type\": \"string\"\n        }\n    }\n}\n</youtube_short>\n\n\n\n","documentId":"[your-doc-id-here]"}}],"Social Media System Prompt":[{"json":{"content":"<system>\nYou are a specialized content creation AI for social media platforms.\nYour primary function is generating platform-optimized social media content across various platforms including LinkedIn, Instagram, Facebook, Twitter (X), Threads, and YouTube Shorts. Each piece of content must:\nMatch the specific platform's audience expectations and algorithm preferences\nShowcase relevant expertise in your field\nDeliver actionable insights for your target audience\nDrive meaningful engagement through value-driven content\nOBJECTIVES:\nCreate platform-specific content following each platform's best practices\nImplement strategic hashtag usage combining general and trending tags\nDesign content that encourages user interaction and community building\nMaintain consistent brand voice while adapting to platform requirements\nIncorporate data-driven insights to maximize content performance\nOUTPUT REQUIREMENTS:\nDeliver content in valid JSON format according to the platform-specific schema\nInclude all required fields as specified in the schema\nOmit any explanatory text or code fencing in your response\nTailor content specifically to the platform indicated in the user's request\nFor each content request, adapt your output based on the platform guidelines and ensure it aligns with your organization's mission and values.  Never provide URLS for video or image suggestions and only describe the suggestion.\n</system>\n\n\n<rules>\n- Only provide final response in valid JSON for the appropriate social platform\n- Never include any preamble or further explanation\n- Always remove any ``` ```json\n</rules>\n\n\n<linkedin>\n**Style**: Professional and insightful.\n**Tone**: Business-oriented; focus on automation use cases, industry insights, and community impact.\n**Content Length**: 3-4 sentences; concise but detailed.\n**Hashtags**: #Innovation #Automation #WorkflowSolutions #DigitalTransformation #Leadership\n**Call to Action (CTA)**: Encourage comments or visits to workflows.diy's website for more insights.\n</linkedin>\n\n<instagram>\n**Style**: Visual storytelling with creative captions.\n**Tone**: Inspirational and engaging; use emojis for relatability.\n**Content Length**: 2-3 sentences paired with eye-catching visuals (e.g., infographics or workflow demos).\n**Visuals**: Showcase milestones (e.g., new workflow launches), tutorials, or product highlights.\n**CTA**: Use phrases like \"Swipe to learn more,\" \"Tag your team,\" or \"Check out the link below!\"\n**Link Placement**: Add the provided link before hashtags; if no link is provided, use \"Visit our website: https://workflows.diy.\"\n**Hashtags**: #AutomationLife #TechInnovation #WorkflowTips #Programming #Engineering\n</instagram>\n\n<facebook>\n**Style**: Friendly and community-focused.\n**Tone**: Relatable; highlight user success stories or company achievements in automation.\n**Content Length**: 2-3 sentences; conversational yet professional.\n**Hashtags**: #SmallBusinessAutomation #Entrepreneurship #Leadership #WorkflowInnovation\n**CTA**: Encourage likes, shares, comments (e.g., \"What's your favorite automation tip?\").\n</facebook>\n\n<xtwitter>\n**Style**: Concise and impactful.\n**Tone**: Crisp and engaging; spark curiosity in 150 characters or less.\n**Hashtags**: #WorkflowTrends #AIWorkflows #AutomationTips #NoCodeSolutions\n**CTA**: Drive quick engagement through retweets or replies (e.g., \"What's your go-to n8n workflow?\").\n</xtwitter>\n\n<threads>\n**Style**: Conversational and community-driven posts.\n**Tone**: Casual yet informative; encourage discussions around automation trends or innovations.\n**Content Length**: 1-2 short paragraphs with a question or thought-provoking statement at the end.\n**Hashtags**: Similar to Instagram but tailored for trending Threads topics related to automation.\n</threads>\n\n<youtube_short>\n**Style**: Short-form video content showcasing quick workflow tutorials or use cases.\n**Tone**: Authoritative yet approachable; establish workflows.diy as a leader in n8n automation solutions.\n**Content Length**:\n  - Tutorials/Reviews (long-form): 5-10 minutes\n  - Shorts/Highlights (short-form): Under 1 minute\n**CTA**: Encourage subscriptions, likes, comments (e.g., \"Subscribe for more workflow tips!\").\n</youtube_short>\n\n\n\n","documentId":"[your-doc-id-here]"}}],"When Executed by Another Workflow":[{"json":{"route":"instagram","user_prompt":"i need an instagram post about using n8n to transform business automation with reference to a related historical fact and example"}}]},"settings":{"executionOrder":"v1"},"versionId":"110ac387-48e7-4ed2-98d6-0e3ddbb34063","connections":{"Gmail":{"main":[[]]},"Merge":{"main":[[{"node":"Prepare Social Media Email Contents","type":"main","index":0},{"node":"Google Drive Image Meta","type":"main","index":0}]]},"Short":{"ai_tool":[[{"node":"🤖Social Media Router Agent","type":"ai_tool","index":0}]]},"Schema":{"main":[[{"node":"Parse Schema","type":"main","index":0}]]},"X Post":{"main":[[{"node":"X Response","type":"main","index":0}]]},"gpt-4o":{"ai_languageModel":[[{"node":"🤖Social Media Router Agent","type":"ai_languageModel","index":0}]]},"File Id":{"main":[[{"node":"Get Social Post from Google Drive","type":"main","index":0}]]},"SerpAPI":{"ai_tool":[[{"node":"Social Media Content Creator","type":"ai_tool","index":0}]]},"Facebook":{"ai_tool":[[{"node":"🤖Social Media Router Agent","type":"ai_tool","index":0}]]},"LinkedIn":{"ai_tool":[[{"node":"🤖Social Media Router Agent","type":"ai_tool","index":0}]]},"X-Twiter":{"ai_tool":[[{"node":"🤖Social Media Router Agent","type":"ai_tool","index":0}]]},"Instagram":{"ai_tool":[[{"node":"🤖Social Media Router Agent","type":"ai_tool","index":0}]]},"gpt-40-mini":{"ai_languageModel":[[{"node":"Prepare Social Media Email Contents","type":"ai_languageModel","index":0}]]},"gpt-4o-mini":{"ai_languageModel":[[{"node":"Social Media Content Creator","type":"ai_languageModel","index":0}]]},"Is Approved?":{"main":[[{"node":"Get Social Post Image","type":"main","index":0}]]},"Parse Schema":{"main":[[{"node":"Merge Prompts and Schema","type":"main","index":0}]]},"gpt-40-mini1":{"ai_languageModel":[[{"node":"Prepare Email Contents","type":"ai_languageModel","index":0}]]},"Facebook Post":{"main":[[{"node":"Facebook Response","type":"main","index":0}]]},"LinkedIn Post":{"main":[[{"node":"LinkedIn Response","type":"main","index":0}]]},"System Prompt":{"main":[[{"node":"Parse System Prompt","type":"main","index":0}]]},"YouTube Short":{"ai_tool":[[{"node":"🤖Social Media Router Agent","type":"ai_tool","index":0}]]},"Social Content":{"main":[[{"node":"pollinations.ai1","type":"main","index":0}]]},"Extract as JSON":{"main":[[{"node":"Merge Image and Post Contents","type":"main","index":0},{"node":"Prepare Email Contents","type":"main","index":0}]]},"Instagram Image":{"main":[[{"node":"Instragram Post","type":"main","index":0}]]},"Instragram Post":{"main":[[{"node":"Instagram Response","type":"main","index":0}]]},"Social Post JSON":{"main":[[{"node":"Save Social Post to Google Drive","type":"main","index":0}]]},"pollinations.ai1":{"main":[[{"node":"Telegram Success Message (Optional)","type":"main","index":0},{"node":"Save Image to imgbb.com","type":"main","index":0},{"node":"Save Image to Google Drive","type":"main","index":0},{"node":"Merge","type":"main","index":1}],[{"node":"Telegram Error Message (Optional)","type":"main","index":0}]]},"Parse System Prompt":{"main":[[{"node":"Merge Prompts and Schema","type":"main","index":2}]]},"Social Media Schema":{"main":[[{"node":"Schema","type":"main","index":0}]]},"Window Buffer Memory":{"ai_memory":[[{"node":"🤖Social Media Router Agent","type":"ai_memory","index":0}]]},"Get Social Post Image":{"main":[[{"node":"Merge Image and Post Contents","type":"main","index":1}]]},"Prepare Email Contents":{"main":[[{"node":"Gmail User for Approval","type":"main","index":0}]]},"Compose Prompt & Schema":{"main":[[{"node":"Social Media Content Creator","type":"main","index":0}]]},"Gmail User for Approval":{"main":[[{"node":"Is Approved?","type":"main","index":0}]]},"Google Drive Image Meta":{"main":[[{"node":"Social Post JSON","type":"main","index":0}]]},"Save Image to imgbb.com":{"main":[[{"node":"Merge","type":"main","index":0}]]},"Merge Prompts and Schema":{"main":[[{"node":"Compose Prompt & Schema","type":"main","index":0}]]},"Save Image to Google Drive":{"main":[[{"node":"Merge","type":"main","index":2}]]},"Social Media System Prompt":{"main":[[{"node":"System Prompt","type":"main","index":0}]]},"When chat message received":{"main":[[{"node":"🤖Social Media Router Agent","type":"main","index":0}]]},"Social Media Content Creator":{"main":[[{"node":"Social Content","type":"main","index":0}]]},"Merge Image and Post Contents":{"main":[[{"node":"Social Media Publishing Router","type":"main","index":0}]]},"🤖Social Media Router Agent":{"main":[[{"node":"File Id","type":"main","index":0}]]},"Social Media Publishing Router":{"main":[[{"node":"X Post","type":"main","index":0}],[{"node":"Instagram Image","type":"main","index":0}],[{"node":"Facebook Post","type":"main","index":0}],[{"node":"LinkedIn Post","type":"main","index":0}],[{"node":"Implement Threads Here","type":"main","index":0}],[{"node":"Implement YouTube Shorts Here","type":"main","index":0}]]},"Save Social Post to Google Drive":{"main":[[{"node":"Respond with Google Drive Id","type":"main","index":0}]]},"Get Social Post from Google Drive":{"main":[[{"node":"Extract as JSON","type":"main","index":0}]]},"When Executed by Another Workflow":{"main":[[{"node":"Social Media System Prompt","type":"main","index":0},{"node":"Social Media Schema","type":"main","index":0},{"node":"Merge Prompts and Schema","type":"main","index":1}]]},"Prepare Social Media Email Contents":{"main":[[{"node":"Gmail","type":"main","index":0}]]}}}


name: AI Email Analyzer: Process PDFs, Images & Save to Google Drive + Telegram
author_name: Davide
author_username: n3witalia
categories: []
created_at: 2025-03-14T16:27:15.934Z
updated_at: 2025-03-14T16:27:15.934Z
url: https://n8n.io/workflows/3169
scraped_at: 2025-07-06 21:16:30
description:
  This workflow automates the process of analyzing emails and their attachments (PDFs and images) using AI models (DeepSeek, Gemini, and OpenRouter). It extracts and summarizes the content of emails and attachments, saves the summaries to Google Sheets, and sends a final consolidated summary via Telegram. 

  This is a powerful tool for automating email analysis and summarization, saving time and ensuring that important information is easily accessible and actionable.

  Below is a breakdown of the workflow:

  1. How It Works
  The workflow is designed to process incoming emails, analyze their content and attachments, and generate summaries. Here's how it works:

  Email Trigger:
     The workflow starts with the Email Trigger (IMAP) node, which monitors an email inbox for new emails.
     If an email contains attachments, the workflow processes them.

  Check for Attachments:
     The Contain Attachments? node checks if the email has attachments.
     If attachments are present, the workflow proceeds to process them.

  Process Attachments:
     The Get PDF and Images Attachments node extracts PDF and image attachments from the email.
     The Switch node separates PDFs and images for further processing:
       PDFs: The Extract from PDF node extracts text from PDFs, and the PDF Analyzer node summarizes the content.
       Images: The Analyze Image node uses AI to describe the content of images.

  Summarize Email Content:
     The Convert Text node converts the email's HTML content to plain text.
     The Email Summarization Chain node uses AI to generate a summary of the email's text content.

  Save Summaries:
     The Save Summary PDF, Save Summary Image, and Save Summary Text nodes save the summaries of PDFs, images, and email text, respectively, to Google Sheets.

  Consolidate Summaries:
     The All Summaries node aggregates the summaries of the email text, PDFs, and images.
     The Create Final Summary node uses AI to generate a unified summary of all the content.

  Send Final Summary:
     The Send Final Summary node sends the consolidated summary via Telegram to a specified chat ID.

  2. Set Up Steps
  To set up and use this workflow in n8n, follow these steps:

  IMAP Configuration:
     Set up IMAP credentials in n8n for the Email Trigger (IMAP) node.
     Ensure the email account is accessible via IMAP.

  AI Model Configuration:
     Configure the DeepSeek, Gemini, and OpenRouter credentials in n8n for the Email Summarization Chain, PDF Analyzer, and Create Final Summary nodes.
     Ensure the AI models are set up to generate summaries.

  Google Sheets Integration:
     Set up Google Sheets credentials in n8n for the Save Summary PDF, Save Summary Image, and Save Summary Text nodes.
     Specify the Google Sheet and worksheet where the summaries will be saved.

  Telegram Integration:
     Set up Telegram credentials in n8n for the Send Final Summary node.
     Insert your Chat ID in the Telegram node to receive the final summary.

  Test the Workflow:
     Send an email with attachments (PDFs and images) to the monitored email account.
     The workflow will:
       Extract and summarize the email content and attachments.
       Save the summaries to Google Sheets.
       Send a consolidated summary via Telegram.

  Optional Customization:
       replace IMAP trigger with Gmail or Outlook trigger 
       Modify the workflow to include additional features, such as:
       Adding more AI models for different types of analysis.
       Sending notifications via other channels (e.g., Slack, email).
       Integrating with other storage services (e.g., Dropbox, AWS S3).

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

nodes_used:
  ["n8n-nodes-base.googleSheets","n8n-nodes-base.telegram","n8n-nodes-base.googleDrive","n8n-nodes-base.code","@n8n/n8n-nodes-langchain.chainSummarization","@n8n/n8n-nodes-langchain.chainLlm","@n8n/n8n-nodes-langchain.lmChatOpenAi","@n8n/n8n-nodes-langchain.outputParserStructured","@n8n/n8n-nodes-langchain.openAi","@n8n/n8n-nodes-langchain.lmChatOpenRouter"]

workflow_json:
  {"id":"MCzA5RzvO83kNJi7","meta":{"instanceId":"a4bfc93e975ca233ac45ed7c9227d84cf5a2329310525917adaf3312e10d5462","templateCredsSetupCompleted":true},"name":"AI Email Analyzer: Process PDFs, Images","tags":[],"nodes":[{"id":"0526c603-2c35-4f65-88ee-e143f7aa3ca4","name":"Email Trigger (IMAP)","type":"n8n-nodes-base.emailReadImap","position":[-80,500],"parameters":{"options":{},"downloadAttachments":true},"credentials":{"imap":{"id":"k31W9oGddl9pMDy4","name":"IMAP info@n3witalia.com"}},"typeVersion":2},{"id":"9b0b83d1-7d7c-4858-aedc-4816e2f02276","name":"DeepSeek R1","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[1320,980],"parameters":{"model":{"__rl":true,"mode":"list","value":"deepseek/deepseek-r1:free","cachedResultName":"deepseek/deepseek-r1:free"},"options":{}},"credentials":{"openAiApi":{"id":"XJTqRiKFJpFs5MuX","name":"OpenRouter account"}},"typeVersion":1.2},{"id":"2e8ad64a-d767-441e-9e12-7a75f5ed4c1c","name":"Email Summarization Chain","type":"@n8n/n8n-nodes-langchain.chainSummarization","position":[1360,800],"parameters":{"options":{"binaryDataKey":"={{ $json.data }}","summarizationMethodAndPrompts":{"values":{"prompt":"=Write a concise summary of the following in max 100 words :\n\n\"{{ $json.data }}\"\n\nDo not enter the total number of words used.","combineMapPrompt":"=## Email Summarization System Prompt\n\nYou are a specialized AI assistant focused exclusively on creating precise, concise summaries of emails. Your task is to analyze the complete email text provided as input and produce a clear, comprehensive summary that captures all essential information in a cohesive narrative format.\n\n### Your responsibilities:\n\n1. Extract and summarize the main topic and purpose of the email\n2. Identify key points, requests, deadlines, or action items mentioned\n3. Preserve critical details like dates, times, locations, and names\n4. Maintain the original tone and urgency level of the message\n5. Organize information in order of importance\n6. Remove unnecessary pleasantries, redundancies, and filler content\n\n### Summary format:\n\n- Begin with a one-sentence overview of the email's main purpose\n- Present all key information in a cohesive paragraph format (no bullet points)\n- Follow a logical flow from most to least important information\n- Include any critical deadlines, requests, or action items within the narrative\n- Keep the summary to 3-5 sentences total\n- Use clear, straightforward language with appropriate transitions between ideas\n- Preserve the original intent and meaning without introducing new information\n\n### What to exclude:\n\n- Greetings and sign-offs\n- Redundant information\n- Minor details that don't affect the main message\n- Your own opinions or interpretations\n- Information not explicitly stated in the email\n\nThe email text to summarize is:\n{{$json.data}}"}}},"operationMode":"nodeInputBinary"},"typeVersion":2},{"id":"97f2b5f8-b2ba-4bd5-a951-c97e64e6f833","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-140,-280],"parameters":{"color":3,"width":580,"height":400,"content":"# AI Email Analyzer: Process PDFs, Images \n\nThis is a powerful tool for automating email analysis and summarization, saving time and ensuring that important information is easily accessible and actionable.\n\nAll summaries are saved on a Google Sheet and identified by a numeric ID referring to the single email.\n\n## Preliminary step:\n- Clone this [Google Drive Sheet](https://docs.google.com/spreadsheets/d/1rBa0RI6XFfMerylVCV0dlKhJT_f4UAd8S6jyYX4aRRo/edit?usp=sharing)\n- Insert  your Chat_ID in Telegram node\n- Choose the AI model you prefer\n"},"typeVersion":1},{"id":"d2012cbc-0e79-4579-ac3d-e5e84ad56dc1","name":"Switch","type":"n8n-nodes-base.switch","position":[960,120],"parameters":{"rules":{"values":[{"outputKey":"pdf","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"loose"},"combinator":"and","conditions":[{"id":"31b7fb0b-3149-479e-852a-52c1ec8935ca","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $binary.data.fileExtension }}","rightValue":"pdf"}]},"renameOutput":true},{"outputKey":"image","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"loose"},"combinator":"and","conditions":[{"id":"9fe6411d-cf35-4fdd-a9ad-8c96f0a5cf66","operator":{"type":"string","operation":"regex"},"leftValue":"={{ $binary.data.fileExtension }}","rightValue":"=/^(jpg|png)$/i"}]},"renameOutput":true}]},"options":{},"looseTypeValidation":true},"typeVersion":3.2},{"id":"8a9d55b8-9ba5-4a6f-ae13-9c529875a2a4","name":"Structured Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[2040,-320],"parameters":{"schemaType":"manual","inputSchema":"{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"content\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t}\n}"},"typeVersion":1.2},{"id":"658696f5-08e0-4d51-89bc-2a1c31576700","name":"Split Out","type":"n8n-nodes-base.splitOut","position":[2540,-420],"parameters":{"options":{},"fieldToSplitOut":"=output"},"typeVersion":1},{"id":"d2ba57c3-9e0e-4a7d-957d-216763e357c3","name":"Aggregate","type":"n8n-nodes-base.aggregate","position":[3660,220],"parameters":{"options":{},"fieldsToAggregate":{"fieldToAggregate":[{"fieldToAggregate":"data.output"}]}},"typeVersion":1},{"id":"10e6d3c6-10f6-4fea-be37-b5ee50e0b529","name":"OpenRouter Chat Model1","type":"@n8n/n8n-nodes-langchain.lmChatOpenRouter","position":[3920,400],"parameters":{"model":"google/gemini-2.0-flash-exp:free","options":{}},"credentials":{"openRouterApi":{"id":"pb06rfB4xmxzVe3Q","name":"OpenRouter"}},"typeVersion":1},{"id":"dcdcb7f2-669d-4e1b-a3f2-49a5b6c760b1","name":"Contain attachments?","type":"n8n-nodes-base.if","position":[260,500],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"5cf96104-c887-44fe-b528-30171943dd15","operator":{"type":"boolean","operation":"true","singleValue":true},"leftValue":"={{ $binary.isNotEmpty() }}","rightValue":""}]}},"typeVersion":2.2},{"id":"6280db8e-42e4-4f88-bbe7-4e65eff3a34f","name":"Get PDF and images attachments","type":"n8n-nodes-base.code","position":[600,300],"parameters":{"jsCode":"let results = [];\n\nfor (const item of $input.all()) {\n  for (key of Object.keys(item.binary)) {\n        results.push({\n            json: {},\n            binary: {\n                data: item.binary[key],\n            }\n        });\n    }\n}\n\nreturn results;"},"typeVersion":2},{"id":"53a7333d-fb49-46d4-9e3b-d186a5e416ca","name":"Extract from PDF","type":"n8n-nodes-base.extractFromFile","position":[1460,-540],"parameters":{"options":{},"operation":"pdf"},"typeVersion":1},{"id":"9d5c3b14-a3b0-4d2b-88d5-5a2c21a6907f","name":"PDF Analyzer","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[1780,-540],"parameters":{"text":"=## PDF Summarization System Prompt\n\nYou are a specialized AI assistant tasked with creating concise, accurate summaries of documents. Your goal is to extract and distill the most important information from the content provided as input and present it in a clear, precise plain text summary.\n\n### Your responsibilities:\n\n1. Identify the main topic and purpose of the document\n2. Extract key points, arguments, findings, or conclusions\n3. Preserve essential data points, statistics, dates, and figures\n4. Recognize and highlight critical information and takeaways\n5. Maintain the original document's logical structure in your summary\n6. Prioritize information based on its significance to the document's purpose\n\n### Summary format:\n\n- Provide your summary in plain text only (no formatting)\n- Begin with a concise overview of the document's main topic and purpose\n- Present important points in a logical, sequential narrative\n- Use clear, direct language that accurately represents the original content\n- Maintain appropriate context for all extracted information\n- Keep the summary concise while including all crucial information\n- Use proper transitions between topics to maintain readability\n\n### What to exclude:\n\n- Minor details that don't contribute to the main points\n- Repetitive information\n- Extensive examples unless they're critical to understanding\n- Citations, references, and bibliographic details unless specifically important\n- Decorative or non-essential images (describe important visualized data if relevant)\n- Your own interpretations or opinions not supported by the document\n\n{{ $json.text }}","promptType":"define","hasOutputParser":true},"typeVersion":1.5},{"id":"ba6f6d2f-9a13-4bb4-80fb-72f5c4124473","name":"Save summary PDF","type":"n8n-nodes-base.googleSheets","position":[2580,-800],"parameters":{"columns":{"value":{"ID":"={{ $('Email Trigger (IMAP)').item.json.metadata[\"x-message-id\"] }}","DATE":"={{ $now.format('dd/LL/yyyy') }}","TYPE":"pdf","EMAIL":"={{ $('Email Trigger (IMAP)').item.json.from }}","SUBJECT":"={{ $('Email Trigger (IMAP)').item.json.subject }}","SUMMARY":"={{ $json.output.content }}"},"schema":[{"id":"DATE","type":"string","display":true,"required":false,"displayName":"DATE","defaultMatch":false,"canBeUsedToMatch":true},{"id":"EMAIL","type":"string","display":true,"required":false,"displayName":"EMAIL","defaultMatch":false,"canBeUsedToMatch":true},{"id":"ID","type":"string","display":true,"required":false,"displayName":"ID","defaultMatch":false,"canBeUsedToMatch":true},{"id":"SUBJECT","type":"string","display":true,"required":false,"displayName":"SUBJECT","defaultMatch":false,"canBeUsedToMatch":true},{"id":"TYPE","type":"string","display":true,"required":false,"displayName":"TYPE","defaultMatch":false,"canBeUsedToMatch":true},{"id":"SUMMARY","type":"string","display":true,"required":false,"displayName":"SUMMARY","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/1rBa0RI6XFfMerylVCV0dlKhJT_f4UAd8S6jyYX4aRRo/edit#gid=0","cachedResultName":"Foglio1"},"documentId":{"__rl":true,"mode":"list","value":"1rBa0RI6XFfMerylVCV0dlKhJT_f4UAd8S6jyYX4aRRo","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1rBa0RI6XFfMerylVCV0dlKhJT_f4UAd8S6jyYX4aRRo/edit?usp=drivesdk","cachedResultName":"Analyze Email + Attachments"}},"credentials":{"googleSheetsOAuth2Api":{"id":"JYR6a64Qecd6t8Hb","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"4c7ff16e-8649-4364-9aa6-c06670f4c36a","name":"All summaries","type":"n8n-nodes-base.merge","position":[3080,220],"parameters":{"numberInputs":3},"typeVersion":3},{"id":"46af5694-6b28-45e7-8b1b-d77482b326e7","name":"Map image summaries","type":"n8n-nodes-base.set","position":[2020,280],"parameters":{"options":{},"assignments":{"assignments":[{"id":"11592bed-7555-4e61-a692-d71b1a733fd4","name":"content","type":"string","value":"={{ $json.content }}"}]}},"typeVersion":3.4},{"id":"dc5858b7-c30b-413b-a1d0-143a068f2c87","name":"Upload attachments","type":"n8n-nodes-base.googleDrive","position":[1440,480],"parameters":{"name":"={{$now.format('yyyyLLddhhiiss')}}-{{ $binary.data.fileName }}","driveId":{"__rl":true,"mode":"list","value":"My Drive"},"options":{},"folderId":{"__rl":true,"mode":"list","value":"1CV5PgqBQIVFEacmbApdCApjNEtoNPzXQ","cachedResultUrl":"https://drive.google.com/drive/folders/1CV5PgqBQIVFEacmbApdCApjNEtoNPzXQ","cachedResultName":"Analyze attachments"}},"credentials":{"googleDriveOAuth2Api":{"id":"HEy5EuZkgPZVEa9w","name":"Google Drive account (n3w.it)"}},"typeVersion":3},{"id":"9537f678-163c-40de-93f3-9934f4ae2ad0","name":"Email summary","type":"n8n-nodes-base.set","position":[2000,800],"parameters":{"options":{},"assignments":{"assignments":[{"id":"ef348518-a9fb-4ea9-bd70-9dcf3bff092a","name":"content","type":"string","value":"={{ $json.response.text }}"}]}},"typeVersion":3.4},{"id":"ba0c45d9-7d5a-413e-9034-3e22a79ead77","name":"Send final summary","type":"n8n-nodes-base.telegram","position":[4340,220],"webhookId":"9c8e4675-762e-47dd-8cef-b94a5261ffd4","parameters":{"text":"={{ $json.text }}","chatId":"CHAT_ID","additionalFields":{}},"credentials":{"telegramApi":{"id":"0hSq9VwaiJifiscT","name":"Telegram account"}},"typeVersion":1.2},{"id":"7a97052b-37c5-4754-ac1a-0f1a20569df7","name":"Create final summary","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[3940,220],"parameters":{"text":"=The inputs to synthesize are:\n'''\n{{ $json.output }}\n'''","messages":{"messageValues":[{"message":"## Comprehensive Email Analysis System Prompt\n\nYou are a specialized AI assistant tasked with creating a unified, concise summary of an email and all its attachments. Your input includes a summary of the email text, summaries of any images, and summaries of any PDF attachments. Your goal is to synthesize all this information into a single coherent summary that captures the essential message and purpose.\n\n### Your responsibilities:\n\n1. Identify the overarching theme or purpose connecting the email and its attachments\n2. Recognize relationships between the email content and the attached materials\n3. Extract and consolidate the most critical information from all sources\n4. Maintain proper context when combining information from different sources\n5. Prioritize information based on relevance to the email's main purpose\n6. Create a unified narrative that flows logically between email content and attachments\n\n### Input structure:\n- Email summary: A summary of the main email text\n- Image descriptions: Summaries of any images attached to the email\n- PDF summaries: Condensed versions of any PDF documents attached\n\n### Output format:\n\n- Provide your summary in plain text only\n- Begin with a one-sentence statement of the email's overall purpose and theme\n- Present a unified narrative that integrates information from the email and all attachments\n- Organize information by importance and relevance, not by source\n- Keep the final summary concise (5-7 sentences maximum) while including all essential information\n- Use clear transitions to maintain coherence when moving between different information sources\n- Preserve the original intent and tone of the communication\n\n### What to include:\n\n- The main topic and purpose of the communication\n- Key points from both the email and attachments\n- Critical requests, deadlines, or action items\n- Essential details like dates, figures, or specific references\n- Contextual information that clarifies the purpose of attachments\n\n### What to exclude:\n\n- Redundant information repeated across multiple sources\n- Minor details that don't contribute to understanding the main message\n- Excessive descriptions of attachments beyond their relevance to the email's purpose\n- Your own interpretations beyond what's supported by the input materials"}]},"promptType":"define"},"typeVersion":1.5},{"id":"99b4c22c-a29b-4b72-bc4a-bed5c1320386","name":"Save summary image","type":"n8n-nodes-base.googleSheets","position":[2020,20],"parameters":{"columns":{"value":{"ID":"={{ $('Email Trigger (IMAP)').item.json.metadata[\"x-message-id\"] }}","DATE":"={{ $now.format('dd/LL/yyyy') }}","TYPE":"image","EMAIL":"={{ $('Email Trigger (IMAP)').item.json.from }}","SUBJECT":"={{ $('Email Trigger (IMAP)').item.json.subject }}","SUMMARY":"={{ $json.content }}"},"schema":[{"id":"DATE","type":"string","display":true,"required":false,"displayName":"DATE","defaultMatch":false,"canBeUsedToMatch":true},{"id":"EMAIL","type":"string","display":true,"required":false,"displayName":"EMAIL","defaultMatch":false,"canBeUsedToMatch":true},{"id":"ID","type":"string","display":true,"required":false,"displayName":"ID","defaultMatch":false,"canBeUsedToMatch":true},{"id":"SUBJECT","type":"string","display":true,"required":false,"displayName":"SUBJECT","defaultMatch":false,"canBeUsedToMatch":true},{"id":"TYPE","type":"string","display":true,"required":false,"displayName":"TYPE","defaultMatch":false,"canBeUsedToMatch":true},{"id":"SUMMARY","type":"string","display":true,"required":false,"displayName":"SUMMARY","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/1rBa0RI6XFfMerylVCV0dlKhJT_f4UAd8S6jyYX4aRRo/edit#gid=0","cachedResultName":"Foglio1"},"documentId":{"__rl":true,"mode":"list","value":"1rBa0RI6XFfMerylVCV0dlKhJT_f4UAd8S6jyYX4aRRo","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1rBa0RI6XFfMerylVCV0dlKhJT_f4UAd8S6jyYX4aRRo/edit?usp=drivesdk","cachedResultName":"Analyze Email + Attachments"}},"credentials":{"googleSheetsOAuth2Api":{"id":"JYR6a64Qecd6t8Hb","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"2b32c086-c436-436e-93c3-da88e6f08247","name":"Save summary text","type":"n8n-nodes-base.googleSheets","position":[2020,1040],"parameters":{"columns":{"value":{"ID":"={{ $('Email Trigger (IMAP)').item.json.metadata[\"x-message-id\"] }}","DATE":"={{ $now.format('dd/LL/yyyy') }}","TYPE":"email","EMAIL":"={{ $('Email Trigger (IMAP)').item.json.from }}","SUBJECT":"={{ $('Email Trigger (IMAP)').item.json.subject }}","SUMMARY":"={{ $json.response.text }}"},"schema":[{"id":"DATE","type":"string","display":true,"required":false,"displayName":"DATE","defaultMatch":false,"canBeUsedToMatch":true},{"id":"EMAIL","type":"string","display":true,"required":false,"displayName":"EMAIL","defaultMatch":false,"canBeUsedToMatch":true},{"id":"ID","type":"string","display":true,"required":false,"displayName":"ID","defaultMatch":false,"canBeUsedToMatch":true},{"id":"SUBJECT","type":"string","display":true,"required":false,"displayName":"SUBJECT","defaultMatch":false,"canBeUsedToMatch":true},{"id":"TYPE","type":"string","display":true,"required":false,"displayName":"TYPE","defaultMatch":false,"canBeUsedToMatch":true},{"id":"SUMMARY","type":"string","display":true,"required":false,"displayName":"SUMMARY","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/1rBa0RI6XFfMerylVCV0dlKhJT_f4UAd8S6jyYX4aRRo/edit#gid=0","cachedResultName":"Foglio1"},"documentId":{"__rl":true,"mode":"list","value":"1rBa0RI6XFfMerylVCV0dlKhJT_f4UAd8S6jyYX4aRRo","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1rBa0RI6XFfMerylVCV0dlKhJT_f4UAd8S6jyYX4aRRo/edit?usp=drivesdk","cachedResultName":"Analyze Email + Attachments"}},"credentials":{"googleSheetsOAuth2Api":{"id":"JYR6a64Qecd6t8Hb","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"135bf3c3-e45f-4363-857b-2345e0bc7964","name":"Convert text","type":"n8n-nodes-base.markdown","position":[860,940],"parameters":{"html":"={{ $json.textHtml }}","options":{}},"typeVersion":1},{"id":"0c2cf33a-d7bb-438d-a9c9-06a77f91b56e","name":"Gemini 2.0 Flash","type":"@n8n/n8n-nodes-langchain.lmChatOpenRouter","position":[1700,-320],"parameters":{"model":"google/gemini-2.0-flash-exp:free","options":{}},"credentials":{"openRouterApi":{"id":"pb06rfB4xmxzVe3Q","name":"OpenRouter"}},"typeVersion":1},{"id":"50d5fd05-db5f-451c-92ce-e0f42d8322f9","name":"Parsing","type":"n8n-nodes-base.code","position":[3360,220],"parameters":{"jsCode":"const inputData = $input.all();\n\nconst outputData = inputData.map(item => {\n  \n  const outputValue = item.json.output || item.json.content;\n\n  return {\n    data: {\n      output: outputValue \n    }\n  };\n});\n\nreturn outputData;"},"typeVersion":2},{"id":"801659a1-cc9d-4014-9403-d6d0952e856a","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[520,220],"parameters":{"width":260,"height":240,"content":"Get all attachments present in the email (in this WF only PDFs and images are considered)"},"typeVersion":1},{"id":"15dc13b9-b35c-43d3-8af9-a8793382a2b6","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[1740,-600],"parameters":{"width":340,"height":200,"content":"Analyze the content of PDF files and make a summary for each one"},"typeVersion":1},{"id":"6c68ce17-13f1-4aba-9f43-e4003e5cd723","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[1380,120],"parameters":{"height":200,"content":"Analyze the content of the image and describe it accurately"},"typeVersion":1},{"id":"ff746258-dc11-43aa-afe9-06c9dfb3708b","name":"Analyze image","type":"@n8n/n8n-nodes-langchain.openAi","position":[1440,180],"parameters":{"text":"## Image Analysis System Prompt\n\nYou are a specialized AI assistant focused on analyzing images. Your task is to carefully examine the image provided as input and produce a detailed, accurate description in plain text format.\n\n### Your responsibilities:\n\n1. Observe and describe the main subject(s) or focal point(s) of the image\n2. Identify notable objects, people, animals, or other elements present\n3. Describe the setting, background, and environment if applicable\n4. Note any text visible in the image, transcribing it accurately\n5. Recognize any actions, activities, or events taking place\n6. Identify relevant contextual information (time of day, weather, season, etc.)\n7. Describe colors, lighting, composition, and other visual elements when relevant\n\n### Response format:\n\n- Provide your analysis in plain text only (no HTML, markdown, or other formatting)\n- Begin with a concise overview of what the image depicts\n- Follow with a detailed description covering all significant elements\n- Organize information logically, typically moving from main subjects to background details\n- Use clear, descriptive language that accurately represents what is actually visible\n- Keep descriptions objective and factual\n\n### What to exclude:\n\n- Speculation about elements not clearly visible in the image\n- Subjective judgments or interpretations beyond what is objectively present\n- Personal opinions about the quality or purpose of the image\n- Complex technical analysis unless specifically relevant\n- Any formatting beyond plain text\n\nThe image to analyze is the one provided in the input.","modelId":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"GPT-4O-MINI"},"options":{},"resource":"image","inputType":"base64","operation":"analyze"},"credentials":{"openAiApi":{"id":"CDX6QM4gLYanh0P4","name":"OpenAi account"}},"typeVersion":1.8},{"id":"ce353f02-72ff-49bf-9297-5a2b3229fa49","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[1340,740],"parameters":{"width":320,"height":180,"content":"Analyze the content of the email and summarize it"},"typeVersion":1},{"id":"01ee4c00-5993-47ce-af04-320cd3319593","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[3060,100],"parameters":{"width":720,"height":80,"content":"All the summaries of the email components (text, PDF, images) are aggregated and a final summary is generated"},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"30310971-f23c-4761-823c-36ddad8bc8dd","connections":{"Switch":{"main":[[{"node":"Upload attachments","type":"main","index":0},{"node":"Extract from PDF","type":"main","index":0}],[{"node":"Upload attachments","type":"main","index":0},{"node":"Analyze image","type":"main","index":0}]]},"Parsing":{"main":[[{"node":"Aggregate","type":"main","index":0}]]},"Aggregate":{"main":[[{"node":"Create final summary","type":"main","index":0}]]},"Split Out":{"main":[[{"node":"All summaries","type":"main","index":0}]]},"DeepSeek R1":{"ai_languageModel":[[{"node":"Email Summarization Chain","type":"ai_languageModel","index":0}]]},"Convert text":{"main":[[{"node":"Email Summarization Chain","type":"main","index":0}]]},"PDF Analyzer":{"main":[[{"node":"Save summary PDF","type":"main","index":0},{"node":"Split Out","type":"main","index":0}]]},"All summaries":{"main":[[{"node":"Parsing","type":"main","index":0}]]},"Analyze image":{"main":[[{"node":"Save summary image","type":"main","index":0},{"node":"Map image summaries","type":"main","index":0}]]},"Email summary":{"main":[[{"node":"All summaries","type":"main","index":2}]]},"Extract from PDF":{"main":[[{"node":"PDF Analyzer","type":"main","index":0}]]},"Gemini 2.0 Flash":{"ai_languageModel":[[{"node":"PDF Analyzer","type":"ai_languageModel","index":0}]]},"Save summary PDF":{"main":[[]]},"Save summary text":{"main":[[]]},"Save summary image":{"main":[[]]},"Upload attachments":{"main":[[]]},"Map image summaries":{"main":[[{"node":"All summaries","type":"main","index":1}]]},"Contain attachments?":{"main":[[{"node":"Get PDF and images attachments","type":"main","index":0},{"node":"Convert text","type":"main","index":0}],[{"node":"Convert text","type":"main","index":0}]]},"Create final summary":{"main":[[{"node":"Send final summary","type":"main","index":0}]]},"Email Trigger (IMAP)":{"main":[[{"node":"Contain attachments?","type":"main","index":0}]]},"OpenRouter Chat Model1":{"ai_languageModel":[[{"node":"Create final summary","type":"ai_languageModel","index":0}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"PDF Analyzer","type":"ai_outputParser","index":0}]]},"Email Summarization Chain":{"main":[[{"node":"Save summary text","type":"main","index":0},{"node":"Email summary","type":"main","index":0}]]},"Get PDF and images attachments":{"main":[[{"node":"Switch","type":"main","index":0}]]}}}


name: Turn YouTube Videos into Summaries, Transcripts, and Visual Insights
author_name: Colleen Brady
author_username: colleen
nodes_used: ["n8n-nodes-base.httpRequest","n8n-nodes-base.code"]
categories: []
created_at: 2025-03-17T02:41:29.515Z
updated_at: 2025-03-17T02:41:29.515Z
url: https://n8n.io/workflows/3188
scraped_at: 2025-07-06 21:16:30
description:
  Who is this for?  

  This workflow is built for anyone who works with YouTube content, whether you're:  

  A learner looking to understand a video’s key points  
  A content creator repurposing video material  
  A YouTube manager looking to update titles, descriptions
  A social media strategist searching for the most shareable clips  


  Don't just ask questions about what's said. Find out what's going on in a video too.

  Video Overview: https://www.youtube.com/watch?v=Ovg_KfKxnC8

  What problem does this solve?  

  YouTube videos hold valuable insights, but watching and processing them manually takes time. This workflow automates:  

  Quick content extraction**: Summarize key ideas without watching full videos   
  Visual analysis**: Understand what’s happening beyond spoken words  
  Clip discovery**: Identify the best moments for social sharing  

  How the workflow works  

  This n8n-powered automation:  

  Uses Google’s Gemini 1.5 Flash AI for intelligent video analysis  
  Provides multiple content analysis templates tailored to different needs  

  What makes this workflow powerful?  

  The easiest place to start is by requesting a summary or transcript. From there, you can refine the prompts to match your specific use case and the type of video content you’re working with.  

  But what's even more amazing? You can ask questions about what’s happening in the video — and get detailed insights about the people, objects, and scenes. It's jaw-dropping.  

  This workflow is versatile — the actions adapt based on the values set. That means you can use a single workflow to:  

  Extract transcripts  
  Generate an extended YouTube description  
  Write a summary blog post  

  You can also modify the trigger based on how you want to run the workflow — use a webhook, connect it to an event in Airtable, or leave it as-is for on-demand use. The output can then be sent anywhere: Notion, Airtable, CMS platforms, or even just stored for reference.  

  How to set it up  

  Connect your Google API key  
  Paste a YouTube video URL  
  Select an analysis method  
  Run the workflow and get structured results  

  Analysis Templates  

  Basic & Timestamped Transcripts**: Extract spoken content  
  Summaries**: Get concise takeaways  
  Visual Scene Analysis**: Detect objects, settings, and people  
  Clip Finder**: Locate shareable moments  
  Actionable Insights**: Extract practical information  

  Customization Options  

  Modify templates to fit your needs  
  Connect with external platforms  
  Adjust formatting preferences  

  Advanced Configuration  

  This workflow is designed for use with gemini-1.5-flash. In the future, you can update the flow to work with different models or even modify the HTTP request node to define which API endpoint should be used. 

  It's also been designed so you can use this flow on it's own or add to a new / existing worflow. 

  This workflow helps you get the most out of YouTube content — quickly and efficiently.

workflow_json:
  {"id":"wZBgoWrBZveMmzYi","meta":{"instanceId":"147b9b53621dbd6fca5f762b57fc3fabf293d676d0c08463ec52c91332ab391f","templateCredsSetupCompleted":true},"name":"Turn YouTube Videos into Summaries, Transcripts, and Visual Insights","tags":[],"nodes":[{"id":"61c56de7-0d8e-44fe-baf3-3e33ddd35b21","name":"When clicking ‘Test workflow’","type":"n8n-nodes-base.manualTrigger","position":[-1340,120],"parameters":{},"typeVersion":1},{"id":"4e43030c-16cd-4b77-8c58-c3b703646a16","name":"Set: Define Initial Variables","type":"n8n-nodes-base.set","position":[-840,120],"parameters":{"options":{},"assignments":{"assignments":[{"id":"72590fa0-cf12-4249-80fc-7aaec9992390","name":"automationID","type":"string","value":"optional-enter-reference-tracking-identifier"},{"id":"24e9b1c3-2955-4e0b-9b4b-a6b9d046fb72","name":"apiKey","type":"string","value":"enter-your-api-key-here"},{"id":"b6600a42-1b8d-486a-a51d-0868bc45452e","name":"youtubeURL","type":"string","value":"https://www.youtube.com/watch?v=Ovg_KfKxnC8"},{"id":"ce9a9a40-5ae4-4106-ae61-0daba2ec185f","name":"promptType","type":"string","value":"transcript"}]}},"typeVersion":3.4},{"id":"add611c6-c053-464c-b12b-f0f20b4c3c4f","name":"Switch: What kind of question do we want to ask?","type":"n8n-nodes-base.switch","onError":"continueRegularOutput","position":[-200,60],"parameters":{"rules":{"values":[{"outputKey":"Transcript","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"4ba139e4-2fd7-473f-869d-f27a1a2f3823","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.promptType.toLowerCase() }}","rightValue":"transcript"}]},"renameOutput":true},{"outputKey":"Transcript with Timestamps","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"486f3c1c-7203-4bc5-a796-87939d4360c5","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.promptType.toLowerCase() }}","rightValue":"timestamps"}]},"renameOutput":true},{"outputKey":"Summary","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"814597ad-12ff-450d-a4bc-cd2eb2836d8f","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.promptType.toLowerCase() }}","rightValue":"summary"}]},"renameOutput":true},{"outputKey":"Scene Description","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"759debf2-3dfb-4bdd-b41f-7ef0a709e25e","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.promptType.toLowerCase() }}","rightValue":"scene"}]},"renameOutput":true},{"outputKey":"Clips","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"5c66a390-2566-461d-b9bc-b0e7ebdc4af8","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.promptType.toLowerCase() }}","rightValue":"clips"}]},"renameOutput":true}]},"options":{"fallbackOutput":"extra"}},"typeVersion":3.2,"alwaysOutputData":false},{"id":"96b6a6c7-3b4f-412d-b200-526971782346","name":"Set: Scene Prompt","type":"n8n-nodes-base.set","position":[480,220],"parameters":{"options":{},"assignments":{"assignments":[{"id":"8be68e95-53df-492f-a88a-14c06f51f531","name":"prompt","type":"string","value":"=Please provide a detailed description of the scene in the video, including:\n\nSetting: Where the scene takes place (e.g., indoors, outdoors, specific location). Be specific - is it a forest, a city street, a living room?\n\nObjects: Prominent objects visible in the scene (e.g., furniture, vehicles, natural elements). Include details like color, size, and material if discernible.\n\nPeople: Description of any people present, including their appearance (clothing, hair, etc.), approximate age, and any actions they are performing.\n\nLighting: The overall lighting of the scene (e.g., bright, dim, natural, artificial). Note any specific light sources (lamps, sunlight).\n\nColors: Dominant colors and color palettes used in the scene.\n\nCamera Angle/Movement: Describe the camera perspective (e.g., close-up, wide shot, aerial view) and any camera movement (panning, zooming, static).\n\nStart output directly with the response -- do not include any introductory text or explanations."},{"id":"bfa3b421-643d-4a52-93e9-0830f794140b","name":"model","type":"string","value":"gemini-1.5-flash"}]},"includeOtherFields":true},"typeVersion":3.4},{"id":"7506b5fa-be12-4d34-8583-027bc782db0d","name":"Set: Summarize Prompt","type":"n8n-nodes-base.set","position":[480,20],"parameters":{"options":{},"assignments":{"assignments":[{"id":"8be68e95-53df-492f-a88a-14c06f51f531","name":"prompt","type":"string","value":"=Provide a concise summary of the main points in nested bullets, using quotes only when absolutely essential for clarity. Start output directly with the response."},{"id":"ccc44699-0918-4837-89a6-c763b157fc8c","name":"model","type":"string","value":"gemini-1.5-flash"}]},"includeOtherFields":true},"typeVersion":3.4},{"id":"2aaf482d-af31-4cd8-9014-7b77efbf3021","name":"Set: Transcript Prompt","type":"n8n-nodes-base.set","position":[480,-380],"parameters":{"options":{},"assignments":{"assignments":[{"id":"8be68e95-53df-492f-a88a-14c06f51f531","name":"prompt","type":"string","value":"=Transcribe the video. Return only the spoken dialogue, verbatim. Omit any additional text or descriptions."},{"id":"b445c2da-934f-4a78-a57b-f383d8950f8a","name":"model","type":"string","value":"gemini-1.5-flash"}]},"includeOtherFields":true},"typeVersion":3.4},{"id":"75a6ac10-00c2-45ab-88b7-dfec3cd58bf2","name":"Set: Fallback","type":"n8n-nodes-base.set","position":[480,620],"parameters":{"options":{},"assignments":{"assignments":[{"id":"8be68e95-53df-492f-a88a-14c06f51f531","name":"prompt","type":"string","value":"=Summarize this YouTube video with a focus on actionable insights. Use nested bullets and include relevant quotes. Specifically, highlight any recommended tools, strategies, or resources mentioned."},{"id":"da626eb8-a097-4a65-834d-4d1709aed260","name":"model","type":"string","value":"gemini-1.5-flash"}]},"includeOtherFields":true},"typeVersion":3.4},{"id":"29ef7f9f-34c9-46f5-96f9-17b42feea381","name":"Set: Transcript with Timestamps Prompt","type":"n8n-nodes-base.set","position":[480,-180],"parameters":{"options":{},"assignments":{"assignments":[{"id":"8be68e95-53df-492f-a88a-14c06f51f531","name":"prompt","type":"string","value":"=Generate a timestamped transcript of the video. Each line must follow this format precisely:  [hh:mm:ss] Dialogue. Return only the timestamp and spoken content; omit any other text or formatting.  "},{"id":"98ca7af8-0fbd-4ba8-8fc8-f914e5bbe48a","name":"model","type":"string","value":"gemini-1.5-flash"}]},"includeOtherFields":true},"typeVersion":3.4},{"id":"e10524ed-09dd-4c0f-86b0-9161fa347821","name":"Set: Scene Clips","type":"n8n-nodes-base.set","position":[480,420],"parameters":{"options":{},"assignments":{"assignments":[{"id":"8be68e95-53df-492f-a88a-14c06f51f531","name":"prompt","type":"string","value":"=Extract shareable clips for social media. Each clip must include:\n\n* **Timestamp:** [hh:mm:ss]-[hh:mm:ss]\n* **Transcript:** Verbatim dialogue/text within the clip.\n* **Rationale:**  A concise explanation (under 20 words) of the clip's social media appeal (e.g., \"humorous,\" \"controversial,\" \"inspiring,\" \"informative\").  Focus on virality, engagement potential (shares, likes, comments).\n\nStart output directly with the response -- do not include any introductory text or explanations."},{"id":"0493ffa7-4fef-4e48-b9d7-7f0891660325","name":"model","type":"string","value":"gemini-1.5-flash"}]},"includeOtherFields":true},"typeVersion":3.4},{"id":"be66d323-9035-4123-8086-dde14e528dc8","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[-2340,-600],"parameters":{"width":780,"height":820,"content":"# How to Use This Workflow\n\nVideo Overview: [https://www.youtube.com/watch?v=Ovg_KfKxnC8](https://www.youtube.com/watch?v=Ovg_KfKxnC8)\n\nUse this workflow to analyze YouTube videos effortlessly. Start by requesting a summary or transcript—then refine the prompts to fit your needs and the type of content you're working with.\n\nEven more impressive? You can ask specific questions about what’s happening in a video—identifying people, scenes, and visual details. The ability to extract this level of insight is game-changing.\n\nThis workflow is highly adaptable—actions adjust based on the values you set. With a single flow, you can generate transcripts, create detailed YouTube descriptions, and draft summary blog posts.\n\nTriggers are flexible, too. Run it manually, connect it to a webhook, or automate it through Airtable or another system. The output can go anywhere -- Notion, Google Docs, CMS platforms -- or simply stay in n8n for on-the-fly analysis.\n\nThis workflow was created using n8n 1.82.3.\n\n## Requirements\n* [Google API key](https://console.developers.google.com/) (or obtain via [AI Studio](https://aistudio.google.com/apikey))\n\n## Testing\n* This workflow was tested on an assortment of public YouTube videos from shorts up to about an hour in length.\n\n## Future-proofing\n* This workflow was created for use with gemini-1.5-flash. In the future, the set nodes for prompts could be updated to use different models and possibly add in what API endpoint should be used in the http node.\n\n## Documentation\n* [Explore vision capabilities with the Gemini API](https://ai.google.dev/gemini-api/docs/vision?lang=python)\n* [Pricing](https://ai.google.dev/gemini-api/docs/pricing)"},"typeVersion":1},{"id":"a8f5541c-d267-4998-bb31-32f2684b0874","name":"Set Fields: Define Outcome","type":"n8n-nodes-base.set","position":[2800,120],"parameters":{"include":"except","options":{},"assignments":{"assignments":[{"id":"300bfbe7-8d13-41ba-8828-17bba1d0eabe","name":"answerAIGenerated","type":"string","value":"={{ $json.candidates?.[0]?.content?.parts?.[0]?.text ? $json.candidates[0].content.parts[0].text : ($json.error ? $json.error : \"No content or error found\") }}"},{"id":"a54eeb5d-e4de-4fd9-a15c-be51cc414c46","name":"promptTokenCount","type":"string","value":"={{ $json.usageMetadata?.promptTokenCount ? $json.usageMetadata.promptTokenCount : ($json.error ? $json.error : \"No content or error found\") }}"},{"id":"dd590788-069e-48d9-adb2-6a5d10f8af2f","name":"candidatesTokenCount","type":"string","value":"={{ $json.usageMetadata?.candidatesTokenCount ? $json.usageMetadata.candidatesTokenCount : ($json.error ? $json.error : \"No content or error found\") }}"},{"id":"23766495-25df-4d3d-bc62-9e79a860ee19","name":"totalTokenCount","type":"string","value":"={{ $json.usageMetadata?.totalTokenCount ? $json.usageMetadata.totalTokenCount : ($json.error ? $json.error : \"No content or error found\") }}"},{"id":"cfad5ba2-a2c5-48ff-b64b-9131a51fd23c","name":"modelVersionUsed","type":"string","value":"={{ $json.modelVersion ? $json.modelVersion : ($json.error ? $json.error : \"No content or error found\") }}"}]},"excludeFields":"candidates, usageMetadata","includeOtherFields":true},"typeVersion":3.4},{"id":"062b5d41-27bb-4e67-8ffa-6e3e392fb437","name":"HTTP Request to Google","type":"n8n-nodes-base.httpRequest","onError":"continueRegularOutput","position":[1740,120],"parameters":{"url":"=https://generativelanguage.googleapis.com/v1beta/models/{{ $json.model }}:generateContent?key={{ $json.apiKey }}","method":"POST","options":{},"jsonBody":"={\n  \"contents\": [{\n    \"parts\": [\n      { \"text\": {{ JSON.stringify($json.prompt) }} },\n      { \"file_data\": { \"file_uri\": \"{{ $json.youtubeURL }}\" } }\n    ]\n  }]\n}","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"Content-Type","value":"application/json"}]}},"typeVersion":4.2,"alwaysOutputData":true},{"id":"0a204e60-674a-453d-81e1-9eb59a3214e2","name":"Set: Merged Values","type":"n8n-nodes-base.set","position":[1380,120],"parameters":{"options":{},"includeOtherFields":true},"typeVersion":3.4},{"id":"48ed5162-61e1-4077-a13a-b2cf135fc11e","name":"If: Was an error detected?","type":"n8n-nodes-base.if","disabled":true,"position":[2560,780],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"148e9a72-f826-468c-86a3-471873717ed4","operator":{"type":"string","operation":"exists","singleValue":true},"leftValue":"={{ $json.error }}","rightValue":""}]}},"typeVersion":2.2},{"id":"f9c0ef37-da99-4100-bd04-b5f2ac93a694","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-2340,280],"parameters":{"width":780,"height":3580,"content":"## Prompt Inspiration Ideas\n\nUse these prompts as inspiration for your workflow. A quick way to iterate on ideas is to try them in [https://aistudio.google.com/](https://aistudio.google.com/).\n\n### 📝 Essential Video Summarizer (Quick Content Digestion)\nProvide a concise summary of the main points of this YouTube video in nested bullets, using quotes only when absolutely essential for clarity.\n\nStart output directly with the response -- do not include any introductory text or explanations.\n\n### 🚀 Complete YouTube SEO Package Generator (Content Marketing)\n\nGenerate a complete YouTube package (Title, Description, Keywords, and Timestamps) based on the following transcript:\n\n**Instructions:**\n\n* **Title:** Craft a concise and engaging title (under 60 characters) that accurately reflects the video's content and will attract viewers.  \n* **Description:** Write a detailed description (around 150-200 words) summarizing the key topics covered in the video.  This description should:\n    * Clearly outline the value proposition for the viewer (what they will learn or gain).\n    * Include relevant keywords to improve searchability.\n    * Feature a strong call to action (e.g., subscribe, visit a website, follow on social media).\n    * Optionally include a brief, intriguing hook at the beginning to grab the viewer's attention.\n* **Keywords:** Generate a list of relevant keywords and tags (around 10-15) that accurately describe the video's content and will help viewers find it in search results.  Consider:\n    * Specific topics discussed\n    * Related terms and concepts\n    * Industry jargon (if applicable)\n    * Names of people or products mentioned\n* **Timestamps:**  Generate timestamps for key topics or sections within the video. These should be formatted clearly for easy navigation.  For example:\n    * 0:00 Introduction\n    * 1:15 Topic 1\n    * 3:45 Topic 2 ...etc.  \n\n**Important Considerations:**\n\n* **Target Audience:** Assume the target audience is [Describe your target audience – e.g., beginners learning Python, experienced marketers, people interested in gardening].\n* **Overall Tone:** The tone of the entire package should be [Specify the desired tone – e.g., informative and educational, enthusiastic and engaging, humorous and lighthearted].\n* **Video's Purpose:** The primary goal of the video is to [State the video's objective – e.g., teach a skill, provide information, entertain, persuade].\n\n\n**Optional:**\n* If the video promotes a product, service, or other content, include relevant links in the description.\n* If there are any specific phrases or branding elements that should be included, specify them here.\n\nStart output directly with the response -- do not include any introductory text or explanations.\n\n### 🗺️ Structured Video Content Map (Educational Organization)\n\nSummarize the key points of this YouTube video with no introductory text. Follow this structured format:\n\nMain Topics\n* Organize content using Level 2 headers (##) based on key themes.\n\nUnder each header:\n* List only the most essential concepts using concise bullet points.\n* Ensure technical accuracy while maintaining clarity.\n\nOrganize sections in this order when applicable:\n* Overview & Context\n* Core Concepts & Features\n* How It Works\n* Benefits & Drawbacks\n\nFormatting Rules:\n* Use Markdown for structured readability.\n* Keep bullet points simple (avoid nesting).\n* No summaries, conclusions, or extra explanations -- just structured content.\n\n### 🎯 Goal-Oriented Learning Digest (Personal Development)\n\nI'm trying to learn about [Specific Goal, e.g., \"how to improve my public speaking skills,\" \"the latest trends in web development\"]. Summarize the relevant information using nested bullets and quotes, focusing on how it helps me achieve this goal.\n\nStart output directly with the response -- do not include any introductory text or explanations.\n\n### ⚙️ Actionable Insights Framework (Implementation Planning)\n\nExtract actionable insights with a focus on practical applications and recommendations.\n\nStart output directly with the response—do not include any introductory text or explanations.\n\nFormat the summary using markdown and follow this structure:\n\nProblem Statement\n* Summarize the core issue or topic addressed.\n\nKey Solutions & Recommendations\n* Use separate ## headers for each major solution or recommendation.\n\nImplementation Steps:\n* Under each solution, list key steps using bullet points.\n\nExpected Outcomes & Benefits:\n* Describe the potential impact and advantages of each solution.\n\nResources & Tools\n* List any relevant tools, frameworks, or resources mentioned.\n\n### 💡 Concept Extractor with Supporting Quotes (Deep Content Analysis)\n\nExtract the core concepts presented using nested bullets. Include supporting quotes for each concept. Focus on [Specific Topic/Area, e.g., \"the impact of AI on marketing,\" \"the principles of effective communication,\" etc.].\n\nStart output directly with the response -- do not include any introductory text or explanations.\n\n\n### 👥 Audience-Targeted Video Analysis (Professional Development)\n\nAnalyze this video for a target audience of [Specify Target Audience, e.g., \"software engineers,\" \"marketing professionals,\" \"general readers\"].\n\nFormat the summary using markdown and structure it as follows:\n\nMain Topics\nOrganize key points under Level 2 headers (##), focusing on essential insights.\nSuggested sections (adjust as needed):\nOverview (context & background)\nKey Concepts & Features\nHow It Works (technical or practical explanation)\nBenefits & Challenges\nKey Instructions:\n\nTailor content to the [Target Audience] and their expected level of expertise.\nUse bullet points for clarity and conciseness.\nBold key terms to emphasize important ideas.\nEnsure technical accuracy, simplifying complex ideas only when needed.\nUse tables when making comparisons.\nLength Guidance:\n\nSummarize in approximately [Specify Desired Length, e.g., \"200 words,\" \"500 words,\" \"one page\"].\n\nStart output directly with the response -- do not include any introductory text or explanations.\n\n### 🧠 Knowledge Extension Analyzer (Advanced Learning & Analysis)\n\nAssuming I already understand [briefly state relevant background knowledge], provide specific insights that build upon this knowledge. Use nested bullets and relevant quotes.\n\nStart output directly with the response -- do not include any introductory text or explanations.\n\n### 🔍 Argument Analysis Blueprint (Critical Thinking)\n\nAnalyze the argument presented in this video. Outline the main claims and supporting evidence using nested bullets. Include direct quotes to illustrate key points. Identify any potential counterarguments or weaknesses in the reasoning.\n\nStart output directly with the response -- do not include any introductory text or explanations.\n\n### ⚖️ YouTube Argument Analyzer (Debate & Rhetoric)\n\nAnalyze the argument presented in this YouTube video. Outline the main claims and supporting evidence using nested bullets. Include direct quotes to illustrate key points. Identify any potential counterarguments or weaknesses in the reasoning.\n\nStart output directly with the response -- do not include any introductory text or explanations.\n\n### 🎭 Rhetorical Technique Evaluator (Communication Analysis)\n\nAnalyze the speaker's [e.g., presentation style, persuasive techniques, use of rhetoric]. Use nested bullets and include specific quotes to illustrate your observations. Focus on how these techniques contribute to (or detract from) the video's overall message.\n\nStart output directly with the response -- do not include any introductory text or explanations.\n\n"},"typeVersion":1},{"id":"d15f5fa4-731d-4d63-a065-e81a5248e8d8","name":"Code: Merge data from prior nodes with HTTP Output","type":"n8n-nodes-base.code","position":[2340,120],"parameters":{"mode":"runOnceForEachItem","jsCode":"return {\n  json: {\n    ...$json, // Keep data from http request\n    ...$('Set: Merged Values').item.json, // Keep data from before http request\n  }\n};\n\n\n\n"},"typeVersion":2},{"id":"eb3b45bc-c59e-45f7-a352-97f62ae079f2","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-1080,-80],"parameters":{"width":560,"height":520,"content":"## ✏️ Set Values For Use in Flow\n1. automationID: Use this to reference the automation. Useful for troubleshooting when you have lots of flows running.\n2. apiKey: API key from Google\n3. youtubeURL: Public URL for video to be processed\n4. promptType: Used by switch node and determines which prompt is sent as part of API call."},"typeVersion":1},{"id":"440539da-e658-404f-8f85-9e28e9acffc9","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[-460,-80],"parameters":{"width":560,"height":520,"content":"## ℹ️ Determine which prompt will be passed in API call based on promptType value\n"},"typeVersion":1},{"id":"ba3f3e35-d691-449e-9f62-d2246223ff5e","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[280,-580],"parameters":{"width":560,"height":1520,"content":"## ✏️ Set Values For Prompts & Model\n1. prompt: What do you want to know about a video\n2. model: Which model to use (gemini-1.5-flash)"},"typeVersion":1},{"id":"b33de065-16d5-4b29-8117-91cfd9d9034a","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[1300,-60],"parameters":{"width":260,"height":520,"content":"## ℹ️ Making it easier to reference values in the http node\n"},"typeVersion":1},{"id":"eb6788d8-4b99-42e5-b0c1-0430a8d786e6","name":"Sticky Note10","type":"n8n-nodes-base.stickyNote","position":[2420,580],"parameters":{"width":560,"height":520,"content":"## ℹ️ If you want to add special processing when errors occur (Optional)\n\n"},"typeVersion":1},{"id":"432ef0bf-8c85-4f72-a771-42b3b2173094","name":"Sticky Note11","type":"n8n-nodes-base.stickyNote","position":[1680,-60],"parameters":{"width":260,"height":520,"content":"## ℹ️ Makes call to Google endpoint using values set in earlier nodes\n\n"},"typeVersion":1},{"id":"57f29827-7f1f-4b73-b700-51af8bd1e582","name":"Sticky Note13","type":"n8n-nodes-base.stickyNote","position":[2240,-60],"parameters":{"width":300,"height":520,"content":"## ℹ️ Merges data from returned by Google with values set in prior nodes so that earlier data isn't lost"},"typeVersion":1},{"id":"c42daf8b-2d9e-4258-91be-97b830c4eff4","name":"Sticky Note14","type":"n8n-nodes-base.stickyNote","position":[2700,-60],"parameters":{"width":300,"height":520,"content":"## ℹ️ Gives returned data meaningful names; Simplifies amount of data available to follow-on nodes"},"typeVersion":1},{"id":"fb246216-645d-4c01-adc7-9b2be2920bcd","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-1460,280],"parameters":{"width":360,"content":"#### 💡 Trigger Ideas\nYou can change the trigger to meet your use case. If you need to run it once in awhile, can leave in current format. Try one of n8n's YouTube nodes, a form, a webhook, etc. for running more frequently as part of an automation."},"typeVersion":1},{"id":"ba228de2-c2de-475c-95c3-20ef712edcc9","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[3120,100],"parameters":{"width":360,"height":240,"content":"#### 💡 Next Step Ideas\nUse a webhook to send data to another destination or use one of n8n's other nodes to send to Airtable, Notion, etc."},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"5d83e29e-caf0-4c3a-be04-9da966904a5a","connections":{"Set: Fallback":{"main":[[{"node":"Set: Merged Values","type":"main","index":0}]]},"Set: Scene Clips":{"main":[[{"node":"Set: Merged Values","type":"main","index":0}]]},"Set: Scene Prompt":{"main":[[{"node":"Set: Merged Values","type":"main","index":0}]]},"Set: Merged Values":{"main":[[{"node":"HTTP Request to Google","type":"main","index":0}]]},"Set: Summarize Prompt":{"main":[[{"node":"Set: Merged Values","type":"main","index":0}]]},"HTTP Request to Google":{"main":[[{"node":"Code: Merge data from prior nodes with HTTP Output","type":"main","index":0},{"node":"If: Was an error detected?","type":"main","index":0}]]},"Set: Transcript Prompt":{"main":[[{"node":"Set: Merged Values","type":"main","index":0}]]},"Set: Define Initial Variables":{"main":[[{"node":"Switch: What kind of question do we want to ask?","type":"main","index":0}]]},"When clicking ‘Test workflow’":{"main":[[{"node":"Set: Define Initial Variables","type":"main","index":0}]]},"Set: Transcript with Timestamps Prompt":{"main":[[{"node":"Set: Merged Values","type":"main","index":0}]]},"Switch: What kind of question do we want to ask?":{"main":[[{"node":"Set: Transcript Prompt","type":"main","index":0}],[{"node":"Set: Transcript with Timestamps Prompt","type":"main","index":0}],[{"node":"Set: Summarize Prompt","type":"main","index":0}],[{"node":"Set: Scene Prompt","type":"main","index":0}],[{"node":"Set: Scene Clips","type":"main","index":0}],[{"node":"Set: Fallback","type":"main","index":0}]]},"Code: Merge data from prior nodes with HTTP Output":{"main":[[{"node":"Set Fields: Define Outcome","type":"main","index":0}]]}}}


name: 💥🛠️Build a Web Search Chatbot with GPT-4o and MCP Brave Search
author_name: Joseph LePage
author_username: joe
categories: []
created_at: 2025-03-17T04:10:26.833Z
updated_at: 2025-03-17T04:10:26.833Z
url: https://n8n.io/workflows/3189
scraped_at: 2025-07-06 21:16:30
description:
  MCP AI Chatbot using Brave Search

  Disclaimer:  This workflow only works with local installations of n8n because it uses a community MCP node

  Who is this for?
  This workflow is ideal for developers, automation enthusiasts, and businesses looking to integrate AI-powered chat capabilities into their workflows. It's particularly useful for those leveraging Brave Search and MCP tools to enhance user interactions and streamline data retrieval.

  What problem is this workflow solving?
  This workflow addresses the challenge of creating an intelligent chatbot that can process user queries, execute searches using Brave Search, and provide responses enriched by AI. It simplifies the integration of multiple tools into a cohesive system, saving time and effort for users who need a robust conversational AI solution.

  What this workflow does
  Listens for incoming chat messages using the Chat Trigger node.
  Processes user input with an AI Agent powered by GPT-4o.
  Retrieves relevant tools using the MCP Get Brave Tools node.
  Executes specific search queries via the MCP Execute Brave Search node.
  Maintains short-term memory of conversations with the Simple Memory node.

  Setup
  Prerequisites:
     Access to an n8n instance (self-hosted).
     API credentials for OpenAI and MCP Client Tools.
     Brave Search API key.

  Steps:
     Import the workflow JSON into your n8n instance.
     Configure the API credentials for OpenAI and MCP Client Tools in their respective nodes.
     Set up your Brave Search API key in the MCP nodes. https://brave.com/search/api/

  Testing:
     Use the built-in chat interface to send test messages.
     Verify that the chatbot processes queries and returns results as expected.

  How to customize this workflow to your needs
  Modify the AI Agent's prompt settings to tailor responses to your specific use case.
  Adjust the memory buffer in the Simple Memory node to retain more or less conversational context.
  Replace or add additional tools in the MCP nodes to expand functionality.

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

workflow_json:
  {"id":"6MRJ2tfl8c2f3AuE","meta":{"instanceId":"31e69f7f4a77bf465b805824e303232f0227212ae922d12133a0f96ffeab4fef"},"name":"💥🛠️Build a Web Search Chatbot with GPT-4o and MCP Brave Search","tags":[],"nodes":[{"id":"b6e5eaa8-ddb3-4c13-8069-ce360bf4a945","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[240,-180],"parameters":{"options":{}},"typeVersion":1.8},{"id":"dde0154e-f7c2-4778-abcc-f79406db5e6b","name":"When chat message received","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[-260,-180],"webhookId":"68e54e15-548a-44df-ad06-7fb9e4e912a9","parameters":{"options":{}},"typeVersion":1.1},{"id":"877ce640-4d08-4ba7-b1d3-bcfc79600d2c","name":"MCP Get Brave Tools","type":"n8n-nodes-mcp.mcpClientTool","position":[200,280],"parameters":{},"credentials":{"mcpClientApi":{"id":"t2IDYWq0EcqBWvMA","name":"MCP Client (STDIO) account 2"}},"typeVersion":1},{"id":"fb3ce3c2-a809-43e5-92d0-82db0d78a971","name":"MCP Execute Brave Search","type":"n8n-nodes-mcp.mcpClientTool","position":[460,280],"parameters":{"toolName":"={{ $fromAI('tool', 'Set this with the specific tool name') }}","operation":"executeTool","toolParameters":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Tool_Parameters', ``, 'json') }}"},"credentials":{"mcpClientApi":{"id":"t2IDYWq0EcqBWvMA","name":"MCP Client (STDIO) account 2"}},"typeVersion":1},{"id":"357bde6a-66d0-48dc-972d-d0b35e3868ed","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[-120,280],"parameters":{},"typeVersion":1.3},{"id":"3eba14c5-e4ed-4c4f-8f1d-2b5671b462cc","name":"gpt-4o","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-380,280],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o","cachedResultName":"gpt-4o"},"options":{}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.2},{"id":"781e5d92-6e9d-4874-93fc-5ea17d11f67f","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[120,160],"parameters":{"color":4,"height":280,"content":"## 1️⃣ MCP Get Brave Tools"},"typeVersion":1},{"id":"78a52697-352f-47ed-a7d2-3a65c9641fd7","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[380,160],"parameters":{"color":4,"height":280,"content":"## 2️⃣ MCP Execute Brave Search"},"typeVersion":1},{"id":"876003d5-7d90-4865-af36-3c0e504b02e7","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-200,160],"parameters":{"color":3,"height":280,"content":"## Short Term Chat Memory"},"typeVersion":1},{"id":"9f64f499-73d7-414f-a3d3-02c0417368a6","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-460,160],"parameters":{"color":5,"height":280,"content":"## Cloud LLM"},"typeVersion":1},{"id":"fc423452-832c-4377-9bde-04ab6d5c89aa","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[-500,-400],"parameters":{"color":7,"width":1200,"height":920,"content":"# 💥🛠️Your First Simple MCP AI Chatbot using Brave Search\nhttps://github.com/nerding-io/n8n-nodes-mcp\nhttps://brave.com/search/api/"},"typeVersion":1},{"id":"5c6c7307-3283-4698-9104-c80df8a62888","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[80,40],"parameters":{"width":580,"height":440,"content":"## 🛠️ MCP Toolbox\nhttps://github.com/nerding-io/n8n-nodes-mcp\nhttps://brave.com/search/api/"},"typeVersion":1},{"id":"9d1bb515-f8fa-4d48-bbf5-c083f5efd89d","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[-360,-240],"parameters":{"color":4,"width":300,"height":240,"content":"## 👍Try Me!"},"typeVersion":1},{"id":"b093a455-aee7-4822-b079-7d9cbac783c2","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-1060,-400],"parameters":{"width":520,"height":1040,"content":"### **Who is this for?**\nThis workflow is ideal for developers, automation enthusiasts, and businesses looking to integrate AI-powered chat capabilities into their workflows. It's particularly useful for those leveraging Brave Search and MCP tools to enhance user interactions and streamline data retrieval.\n\n### **What problem is this workflow solving?**\nThis workflow addresses the challenge of creating an intelligent chatbot that can process user queries, execute searches using Brave Search, and provide responses enriched by AI. It simplifies the integration of multiple tools into a cohesive system, saving time and effort for users who need a robust conversational AI solution.\n\n### **What this workflow does**\n- Listens for incoming chat messages using the **Chat Trigger** node.\n- Processes user input with an **AI Agent** powered by GPT-4o.\n- Retrieves relevant tools using the **MCP Get Brave Tools** node.\n- Executes specific search queries via the **MCP Execute Brave Search** node.\n- Maintains short-term memory of conversations with the **Simple Memory** node.\n\n### **Setup**\n1. **Prerequisites**:\n   - Access to an n8n instance (self-hosted).\n   - API credentials for OpenAI and MCP Client Tools.\n   - Brave Search API key.\n\n2. **Steps**:\n   - Import the workflow JSON into your n8n instance.\n   - Configure the API credentials for OpenAI and MCP Client Tools in their respective nodes.\n   - Set up your Brave Search API key in the MCP nodes. https://brave.com/search/api/\n\n3. **Testing**:\n   - Use the built-in chat interface to send test messages.\n   - Verify that the chatbot processes queries and returns results as expected.\n\n### **How to customize this workflow to your needs**\n- Modify the AI Agent's prompt settings to tailor responses to your specific use case.\n- Adjust the memory buffer in the Simple Memory node to retain more or less conversational context.\n- Replace or add additional tools in the MCP nodes to expand functionality.\n"},"typeVersion":1},{"id":"8fb4f215-da26-43ad-b187-9b52ed6485ba","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[80,-280],"parameters":{"width":580,"height":280,"content":"## 🤖 AI Agent with Tools"},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"a555f325-abd3-44bd-ac48-8b0f6910824e","connections":{"gpt-4o":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"MCP Get Brave Tools":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"MCP Execute Brave Search":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"When chat message received":{"main":[[{"node":"AI Agent","type":"main","index":0}]]}}}


name: Analyze Any Website with OpenAI And Get On-Page SEO Audit
author_name: Not Another Marketer
author_username: notanothermarketer
categories: []
created_at: 2025-03-19T21:20:11.472Z
updated_at: 2025-03-19T21:20:11.472Z
url: https://n8n.io/workflows/3224
scraped_at: 2025-07-06 21:16:30
description:
  Instantly Find & Fix What’s Holding Your Page Back

  You’ve put in the work. Your content is strong. Your design is polished.

  But…

  ❌ Your page isn’t ranking where it should.
  ❌ Your competitors are outranking you—even with weaker content.
  ❌ You have no idea what’s wrong—or how to fix it.

  The truth? SEO isn’t just about keywords.

  Your technical setup, content structure, and on-page elements must work together seamlessly.
  And if anything is off? Google won’t rank your page.

  Who Is This For?
  SaaS Founders & Startups – Get higher rankings & organic traffic that converts.
  Marketing Teams & Agencies – Audit & optimize pages in seconds.
  E-commerce & Content Sites – Improve rankings for product pages, blogs, and landing pages.

  How It Works
  Paste your URL
  Get an instant audit + recommendations list
  Implement changes & watch your rankings jump

  The workflow scrapes the url you input, gets the htlm source code of the landing page, and sends it to OpenAI AI Agent.

  The Agent makes a deep analysis, audit the Technical + Content SEO of the page, and provides 10 Recommendations to improve your SEO.

  Setup Guide
  You will need OpenAI Credentials with an API Key to run the workflow.

  The workflow is using the OpenAI-o1 model to deliver the best results. It costs between $0.20/0.30 per run.

  You can adjust the prompt to your wish in the AI Agent parameters.

  Once the audit has been completed, it will send an email (don't forget to add your email address here)

  Below is an example of what you can expect

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

workflow_json:
  {"id":"iLpBIRuhpWToO22N","meta":{"instanceId":"e8ec316b54e91908f34cbfdc330e5d1d5e97aa0ea8f7277c00d8a8a3892c9983","templateCredsSetupCompleted":true},"name":"🤖 On-Page SEO Audit","tags":[{"id":"TF9zcHoRnyCYBNVV","name":"SEO","createdAt":"2025-03-14T12:08:26.948Z","updatedAt":"2025-03-14T12:08:26.948Z"}],"nodes":[{"id":"f4a971be-a961-4ad6-b38d-830c5fca5407","name":"Landing Page Url","type":"n8n-nodes-base.formTrigger","position":[-180,0],"webhookId":"afe067a5-4878-4c9d-b746-691f77190f54","parameters":{"options":{},"formTitle":"Conversion Rate Optimizer","formFields":{"values":[{"fieldLabel":"Landing Page Url","placeholder":"https://yuzuu.co","requiredField":true}]},"formDescription":"Your Landing Page is Leaking Sales—Fix It Now"},"typeVersion":2.2},{"id":"e280139f-94b8-49dc-91e7-c6ffa0c04716","name":"Scrape Website","type":"n8n-nodes-base.httpRequest","position":[20,0],"parameters":{"url":"={{ $json['Landing Page Url'] }}","options":{}},"typeVersion":4.2},{"id":"de9ff0da-4ef9-4878-af0d-5733e010402c","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[320,20],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"MtyWeuRTqwi3Yx9H","name":"OpenAi account"}},"typeVersion":1.2},{"id":"25969781-4b1c-42ad-969c-efbb605be9e5","name":"OpenAI Chat Model1","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[360,400],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"MtyWeuRTqwi3Yx9H","name":"OpenAi account"}},"typeVersion":1.2},{"id":"0f135a2d-156c-43ee-b254-581c7d543a8c","name":"Content Audit","type":"@n8n/n8n-nodes-langchain.agent","position":[380,200],"parameters":{"text":"=You are the best SEO Manager in the country—a world-class expert in optimizing websites to rank on Google.\n\nIn this task, you will analyze the content of the webpage and perform a detailed and structured SEO Content Audit.\n\nAudit Structure\nYou will divide your audit in 2 parts:\n- The first part is the Analysis\n- The second is the Recommendations\n\nIn the Analysis, you will include:\n- Content Quality Assessment – Evaluate the content's overall quality, accuracy, and relevance to the target audience.\n- Keyword Research and Analysis – Identify primary and secondary keywords, keyword density, and keyword placement strategies.\n- Readability Analysis – Assess the content's readability score using metrics such as Flesch-Kincaid Grade Level, Flesch Reading Ease, and Gunning-Fog Index.\n\nIn the Recommendations, you will present your recommendations and actionable suggestions in clear, organized bullet points. Recommendations must improve the rankings in Google but also the user engagement. \n\nEnsure the output is properly formatted, clean, and highly readable. Do not include any introductory or explanatory text—only the audit findings.\n\nHere is the content of my landing page: {{ $json.data }}","options":{},"promptType":"define"},"typeVersion":1.7},{"id":"b693e35c-c0d4-4202-8c5e-2a5646a16cc4","name":"Technical Audit","type":"@n8n/n8n-nodes-langchain.agent","position":[380,-200],"parameters":{"text":"=You are the best SEO Manager in the country—a world-class expert in optimizing websites to rank on Google.\nIn this task, you will analyze the HTML code of a webpage and perform a detailed and structured On-Page Technical SEO Audit.\n\nAudit Structure\nYou will review all technical SEO aspects of the page. Once completed, you will present your findings and recommendations in clear, organized bullet points, categorized into three sections:\n- Critical Issues – Must be fixed immediately.\n- Quick Wins – Easy fixes with a big impact.\n- Opportunities for Improvement – Require more effort but offer potential benefits.\n\nEnsure the output is properly formatted, clean, and highly readable. Do not include any introductory or explanatory text—only the audit findings.\n\nHere is the content of my landing page: {{ $json.data }}","options":{},"promptType":"define"},"typeVersion":1.7},{"id":"3d172f93-7d94-4a43-9403-5cec799bbe47","name":"Merge","type":"n8n-nodes-base.merge","position":[880,0],"parameters":{},"typeVersion":3,"alwaysOutputData":true},{"id":"2081bf62-0e47-497e-8a3e-d30d330f6a9d","name":"Aggregate","type":"n8n-nodes-base.aggregate","position":[1080,0],"parameters":{"options":{},"fieldsToAggregate":{"fieldToAggregate":[{"fieldToAggregate":"output"}]}},"typeVersion":1},{"id":"e1cfc16e-e0dc-4298-9b94-ffb7f23b45aa","name":"Markdown","type":"n8n-nodes-base.markdown","position":[1280,0],"parameters":{"mode":"markdownToHtml","options":{},"markdown":"=# On-Page Technical Audit\n{{ $json.output[0] }}\n\n# On-Page SEO Content Audit\n{{ $json.output[1] }}"},"typeVersion":1},{"id":"7dc41215-e276-439c-be11-92278b1c3a60","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[1360,-160],"parameters":{"color":3,"width":360,"height":100,"content":"## Send Email \nConnect your credentials & Easily send emails from a Gmail address. "},"typeVersion":1},{"id":"28aea6bd-beef-4116-97c2-e8b88e96d5ac","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[320,-380],"parameters":{"color":3,"width":420,"height":140,"content":"## Open AI Setup\n- Add your credentials\n- Select o1 model for (way) better results. \n- One run = one page audit = around $0.3 with o1"},"typeVersion":1},{"id":"3242a0c3-4439-4ad1-8185-47185046080d","name":"Gmail","type":"n8n-nodes-base.gmail","position":[1480,0],"webhookId":"2979e4dc-1689-447e-8cd4-eb907b4eedf4","parameters":{"sendTo":"hello@youremail.com","message":"={{ $json.data }}","options":{},"subject":"=On-Page SEO Audit -  {{ $('Landing Page Url').item.json['Landing Page Url'] }}"},"credentials":{"gmailOAuth2":{"id":"9EELWJ0jA3PIbx13","name":"Gmail account"}},"typeVersion":2.1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"bc4ac79c-71a0-4dae-805d-55b682b0c199","connections":{"Merge":{"main":[[{"node":"Aggregate","type":"main","index":0}]]},"Markdown":{"main":[[{"node":"Gmail","type":"main","index":0}]]},"Aggregate":{"main":[[{"node":"Markdown","type":"main","index":0}]]},"Content Audit":{"main":[[{"node":"Merge","type":"main","index":1}]]},"Scrape Website":{"main":[[{"node":"Content Audit","type":"main","index":0},{"node":"Technical Audit","type":"main","index":0}]]},"Technical Audit":{"main":[[{"node":"Merge","type":"main","index":0}]]},"Landing Page Url":{"main":[[{"node":"Scrape Website","type":"main","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"Technical Audit","type":"ai_languageModel","index":0}]]},"OpenAI Chat Model1":{"ai_languageModel":[[{"node":"Content Audit","type":"ai_languageModel","index":0}]]}}}


name: Create Notes and Comments on Any Odoo Model Record
author_name: Carlos Contreras
author_username: carlosecv
nodes_used: ["n8n-nodes-base.odoo"]
categories: []
created_at: 2025-03-21T17:49:37.686Z
updated_at: 2025-03-21T17:49:37.686Z
url: https://n8n.io/workflows/3282
scraped_at: 2025-07-06 21:16:30
description:
  Introduction
  This workflow is designed to create and attach notes or comments to any record in your Odoo instance. It acts as a sub-workflow that can be triggered by a main workflow to log messages or comments in a centralized manner. By leveraging the powerful Odoo API, this template ensures that updates to records are handled efficiently, providing an organized way to document important information related to your business processes.

  Setup Instructions
  Import the Workflow:

  Import the provided JSON file into your n8n instance.

  Odoo Credentials:

  Ensure you have valid Odoo API credentials (e.g., "Roodsys Odoo Automation Account") configured in n8n.

  Node Configuration:

  Verify that the "Odoo" node (consider renaming it to "Odoo Record Manager" for clarity) is set up with your server details and authentication parameters.

  Check that the workflow trigger ("When Executed by Another Workflow") is configured to receive input parameters from the parent workflow.

  Execution Trigger:

  This workflow is designed to be initiated by another workflow. Make sure the main workflow supplies the required inputs.

  Workflow Details
  Trigger Node:
  The workflow begins with the "When Executed by Another Workflow" node, which accepts three inputs:

  rec_id: A numeric identifier for the Odoo record.

  message: The text of the comment or note.

  model: The specific Odoo model (e.g., rs.deployment.action.log) where the note should be attached.

  Odoo Node:
  The second node in the workflow calls the Odoo API to create a new log message. It maps the inputs as follows:

  message_type is set to "comment".

  model is assigned the provided model name.

  res_id is assigned the record ID (rec_id).

  body is assigned the message content.

  Additional Information:
  A sticky note node is included to provide a brief overview of the workflow’s purpose directly within the interface.

  Input Parameters
  Record ID (rec_id):
  The unique identifier of the record in Odoo where the note will be added.

  Message (message):
  The content of the comment or note that is to be logged.

  Model (model):
  The Odoo model name indicating the context in which the note should be created (e.g., rs.deployment.action.log).

  Usage Examples
  Internal Logging:
  Use the workflow to attach internal comments or logs to specific records, such as customer profiles, orders, or deployment logs.

  Audit Trails:
  Create a comprehensive audit trail by documenting changes or important events in Odoo records.

  Integration with Other Workflows:
  Link this workflow with other automation processes in n8n (like email notifications, data synchronization, or reporting) to create a seamless integration across your systems.

  Pre-conditions
  The Odoo instance must be accessible and correctly configured.

  API permissions and user roles should be validated to ensure that the workflow has the necessary access rights.

  The workflow expects inputs from an external trigger or parent workflow.

  Customization & Integration
  This template offers several customization options to tailor it to your needs:

  Field Customization: Modify or add new fields to match your logging or commenting requirements.

  Node Renaming: Rename nodes for better clarity and consistency within your workflow ecosystem.

  Integration Possibilities: Easily integrate this workflow with other processes in n8n, such as triggering notifications or synchronizing data across different systems.



  This sub-workflow receives data from a main workflow (for example, a record ID, a message, and the Odoo model) and creates a new note (or comment) in the corresponding Odoo record. Essentially, it acts as a centralized point for logging comments or notes in a specific Odoo model, ensuring that the information remains organized and easy to track.

  Your model must inherit from

   _inherit = ['portal.mixin', 'mail.thread.main.attachment']

workflow_json:
  {"id":"g9L52eIw9UtmEKlk","meta":{"instanceId":"1ed2ca0b20b27416028c1a74b1ee5a18d8b9a12cf5d27f153d2ae6fe9f4453d9","templateCredsSetupCompleted":true},"name":"Send Log Message to Odoo","tags":[],"nodes":[{"id":"aec2c855-0861-4757-a43e-2729d63973ea","name":"When Executed by Another Workflow","type":"n8n-nodes-base.executeWorkflowTrigger","position":[0,0],"parameters":{"workflowInputs":{"values":[{"name":"rec_id","type":"number"},{"name":"message"},{"name":"model"}]}},"typeVersion":1.1},{"id":"30a07404-6aa2-4ea4-9edc-e558d551f611","name":"Odoo","type":"n8n-nodes-base.odoo","position":[220,0],"parameters":{"resource":"custom","customResource":"={{ 'mail.message' }}","fieldsToCreateOrUpdate":{"fields":[{"fieldName":"message_type","fieldValue":"comment"},{"fieldName":"model","fieldValue":"={{ $json.model }}"},{"fieldName":"res_id","fieldValue":"={{ $json.rec_id }}"},{"fieldName":"body","fieldValue":"={{ $json.message }}"}]}},"credentials":{"odooApi":{"id":"EdPd58r6gWSjk4dR","name":"Roodsys Odoo Automation Account"}},"typeVersion":1},{"id":"b5c95ef2-66a7-4706-9ffb-9359133c889e","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-580,-60],"parameters":{"color":6,"width":400,"height":260,"content":"## Creates a Note in an Odoo Record\nThis sub-workflow receives data from a main workflow (for example, a record ID, a message, and the Odoo model) and creates a new note (or comment) in the corresponding Odoo record. Essentially, it acts as a centralized point for logging comments or notes in a specific Odoo model, ensuring that the information remains organized and easy to track."},"typeVersion":1}],"active":false,"pinData":{"When Executed by Another Workflow":[{"json":{"model":"rs.deployment.action.log","rec_id":35,"message":"Test Message"}}]},"settings":{"timezone":"America/Mexico_City","callerPolicy":"workflowsFromSameOwner","executionOrder":"v1","executionTimeout":-1},"versionId":"0e263156-7239-4470-b8ad-2e46f832b74a","connections":{"When Executed by Another Workflow":{"main":[[{"node":"Odoo","type":"main","index":0}]]}}}


name: 🔍🛠️Generate SEO-Optimized WordPress Content with AI Powered Perplexity Research
author_name: Joseph LePage
author_username: joe
categories: []
created_at: 2025-03-23T02:02:14.835Z
updated_at: 2025-03-23T02:02:14.835Z
url: https://n8n.io/workflows/3291
scraped_at: 2025-07-06 21:16:30
description:
  Generate SEO-Optimized WordPress Content with Perplexity Research

  Who is This For?
  This workflow is ideal for content creators, marketers, and businesses looking to streamline the creation of SEO-optimized blog posts for WordPress. It is particularly suited for professionals in the AI consulting and workflow automation industries.

  What Problem Does This Workflow Solve?
  Creating high-quality, SEO-friendly blog posts can be time-consuming and challenging, especially when trying to balance research, formatting, and publishing. This workflow automates the process by integrating research capabilities, AI-driven content creation, and seamless WordPress publishing. It reduces manual effort while ensuring professional-grade output.

  What This Workflow Does
  Research: Gathers detailed insights from Perplexity AI based on user-provided queries.
  Content Generation: Uses OpenAI models to create structured blog posts, including titles, slugs, meta descriptions, and HTML content optimized for WordPress.
  Image Handling: Automatically fetches and uploads featured images to WordPress posts.
  Publishing: Drafts the blog post directly in WordPress with all necessary formatting and metadata.
  Notification: Sends a success message via Telegram upon completion.

  Setup Guide
  Prerequisites:
     A WordPress account with API access.
     OpenAI API credentials.
     Perplexity AI API credentials.
     Telegram bot credentials for notifications.

  Steps:
     Import the workflow into your n8n instance.
     Configure API credentials for WordPress, OpenAI, Perplexity AI, and Telegram.
     Customize the form trigger to define your research query.
     Test the workflow using sample queries to ensure smooth execution.

  How to Customize This Workflow to Your Needs
  Modify the research query prompt in the "Form Trigger" node to suit your industry or niche.
  Adjust content generation guidelines in the "Copywriter AI Agent" node for specific formatting preferences.
  Replace the image URL in the "Set Image URL" node with your own source or dynamic image selection logic.

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

workflow_json:
  {"id":"5lMPjSDuoMvCJnko","meta":{"instanceId":"31e69f7f4a77bf465b805824e303232f0227212ae922d12133a0f96ffeab4fef","templateCredsSetupCompleted":true},"name":"🔍🛠️Generate SEO-Optimized WordPress Content with Perplexity Research","tags":[],"nodes":[{"id":"17ab0b24-b1eb-4e4e-a249-9889c9876fe4","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-1440,460],"parameters":{"color":3,"width":420,"height":440,"content":"## Write SEO Optimized Blog Post\n\n\n"},"typeVersion":1},{"id":"0931aacf-5c47-4bb0-86b6-158c2c7470b1","name":"Wordpress","type":"n8n-nodes-base.wordpress","position":[-1220,1120],"parameters":{"title":"={{ $('Combine Blog Details').item.json.data[2].output.title }}","additionalFields":{"slug":"={{ $('Combine Blog Details').item.json.data[2].output.slug }}","status":"draft","sticky":false,"content":"={{ $json.content }}","authorId":2,"postTemplate":{"values":{}},"commentStatus":"closed"}},"credentials":{"wordpressApi":{"id":"50Ph69y0TPKvO9tn","name":"Wordpress"}},"typeVersion":1},{"id":"81329ff1-b26a-499c-bd82-fd334503ab4f","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[-980,220],"parameters":{"color":7,"width":440,"height":280,"content":"## Create HTML\n\n\n"},"typeVersion":1},{"id":"03de9f23-e5ec-483b-a3dd-97617bd5165d","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[-1320,1020],"parameters":{"color":4,"width":300,"height":280,"content":"## Post on Wordpress\n\n\n"},"typeVersion":1},{"id":"6bf602e0-ad29-47e6-93d7-79fd2a4228c2","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-900,820],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.2},{"id":"8a3739ac-9492-400c-b5b8-eeb305647752","name":"Structured Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[-680,820],"parameters":{"jsonSchemaExample":"{\n\"slug\": \"rpo-benefits-recruitment\",\n\"title\": \"7 Key Advantages of RPO for Modern Recruitment\",\n\"meta\": \"Explore how Recruitment Process Outsourcing (RPO) enhances hiring efficiency, reduces costs, and expands talent pools for businesses seeking top candidates.\"\n}"},"typeVersion":1.2},{"id":"af02ee94-4c26-4be5-bd21-09e020bff876","name":"Create Title, Slug, Meta","type":"@n8n/n8n-nodes-langchain.agent","position":[-880,640],"parameters":{"text":"=**Create a slug, blog post title, and meta description for the following blog post:**\n\n{{ $json.output }}\n\n**Slug Guidelines:**\n- Keep it concise (4-5 words maximum).\n- Include the primary keyword related to recruitment or HR.\n- Use hyphens to separate words.\n- Avoid unnecessary words, articles, or prepositions.\n- Ensure it reflects the main topic of the blog post.\n- Make it readable and relevant for both users and search engines.\n\n**Title Guidelines:**\n- Avoid AI words like \"Transform\" or \"Revolutionize\" and similar overused terms.\n- Avoid using a colon (:) in the title.\n- Never structure it as a primary/secondary title separated by a colon.\n- Include the primary keyword related to recruitment or HR (e.g., 'AI in recruitment' or 'talent acquisition trends').\n- Clearly inform users what they can expect from reading the blog post.\n- Be concise and engaging, ideally 50-60 characters long.\n- Incorporate power words that appeal to HR professionals and recruiters.\n\n**Meta Description Guidelines:**\n- Avoid AI words like \"Transform\" or \"Revolutionize\" and similar overused terms.\n- Be concise: Limit to 150-160 characters to ensure full visibility in search results.\n- Include keywords: Naturally incorporate primary recruitment-related keywords to enhance relevance and visibility.\n- Provide value: Clearly convey the benefits or insights readers will gain from the article.\n- Be engaging: Use action-oriented language or a thought-provoking question to encourage clicks.\n- Align with content: Accurately reflect the blog post's content to meet user expectations and reduce bounce rates.\n- Highlight expertise: Subtly emphasize SocialFind's authority in the recruitment field.\n\nYour output must be a single valid JSON object with these 3 fields:\n-slug: The slug\n-title: The blog post title\n-meta: The meta description  \n\nEach should be presented without any additional text, explanation, quotation marks, or formatting.\n","options":{},"promptType":"define","hasOutputParser":true},"typeVersion":1.8},{"id":"115c4043-6fda-42a4-ac3c-c7979b2f327e","name":"Create HTML","type":"@n8n/n8n-nodes-langchain.openAi","position":[-880,300],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"GPT-4O-MINI"},"options":{},"messages":{"values":[{"content":"=Only output the HTML content without preamble or further explanation. Generate WordPress-compatible HTML for a blog post based on the provided content.\n\n### CONTENT PROCESSING:\n- Process all content from {{ $json.output }}\n- Preserve all original facts, information, and URLs\n- Format according to the specifications below\n\n### REQUIRED STRUCTURE (IN THIS ORDER):\n1. Title (H2)\n2. Estimated reading time\n3. Key takeaways (3-5 bullet points)\n4. Table of contents (linked to all headings)\n5. Main content (with proper heading hierarchy)\n6. FAQ section\n\n### STYLING REQUIREMENTS:\n- Style Override: Include a style section with !important declarations\n- Links: All hyperlinks, TOC items, and FAQ questions must be #00c2ff (blue)\n- Headings: All headings need a bottom border in #00c2ff with padding\n- Spacing: Add <br><br> between each major section\n\n### ENGAGEMENT FORMATTING:\n- Use bold, italics, bullet points, quotes, and highlighting for emphasis\n- Create proper paragraph structure with appropriate line breaks\n- NO emojis allowed\n- Use whitespace strategically for readability\n\n### HYPERLINK HANDLING (CRITICAL):\n- When URLs appear next to keyphrases (e.g., \"AI tools (https://example.com)\")\n- Convert to: <a href=\"https://example.com\" style=\"color: #00c2ff !important;\">AI tools</a>\n- The KEYPHRASE must be linked, never the URL itself\n\n### WORDPRESS COMPATIBILITY:\n- Use WordPress block classes (wp-block-heading, wp-block-paragraph, etc.)\n- Add heading IDs starting with \"h-\" for better TOC linking\n- Ensure all styles use !important to override theme styles\n\nDO NOT include any explanations, code tags, or comments. Output ONLY the raw HTML.\n"}]}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.8},{"id":"4756c8f2-406e-4a56-adb0-0c4708dabe6a","name":"Merge","type":"n8n-nodes-base.merge","position":[-420,560],"parameters":{"numberInputs":3},"typeVersion":3},{"id":"1205aecf-08a1-499d-ac9e-822dd66b295f","name":"Upload Image to Wordpress","type":"n8n-nodes-base.httpRequest","position":[-520,1120],"parameters":{"url":"https://commonclone.com/wp-json/wp/v2/media","method":"POST","options":{},"sendBody":true,"contentType":"binaryData","sendHeaders":true,"authentication":"predefinedCredentialType","headerParameters":{"parameters":[{"name":"Content-Disposition","value":"=attachment; filename=\"cover-image-{{ $('Wordpress').item.json.id }}.jpeg\""}]},"inputDataFieldName":"data","nodeCredentialType":"wordpressApi"},"credentials":{"wordpressApi":{"id":"50Ph69y0TPKvO9tn","name":"Wordpress CommonClone.com RazorCX"}},"typeVersion":4.2},{"id":"b4437d9e-8b90-4d15-a96d-46645618a56d","name":"Set Image on Wordpress Post","type":"n8n-nodes-base.httpRequest","position":[-320,1120],"parameters":{"url":"=https://commonclone.com/wp-json/wp/v2/posts/{{ $('Wordpress').item.json.id }}","method":"POST","options":{},"sendQuery":true,"authentication":"predefinedCredentialType","queryParameters":{"parameters":[{"name":"featured_media","value":"={{ $json.id }}"}]},"nodeCredentialType":"wordpressApi"},"credentials":{"wordpressApi":{"id":"50Ph69y0TPKvO9tn","name":"Wordpress CommonClone.com RazorCX"}},"typeVersion":4.2},{"id":"bf05eaf3-2522-488e-893d-1ed9b2ed88b2","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-1940,460],"parameters":{"color":4,"width":460,"height":300,"content":"## Perplexity Research\n\n\n"},"typeVersion":1},{"id":"22e8c044-ed98-495a-957e-c5e3fecc2b7d","name":"On form submission","type":"n8n-nodes-base.formTrigger","position":[-2120,560],"webhookId":"a29cbcd3-9d11-4f7c-9aad-14681c356c53","parameters":{"options":{},"formTitle":"Blog Factory","formFields":{"values":[{"fieldType":"textarea","fieldLabel":"Research Query","placeholder":"=What are the most common challenges facing Canadian employers regarding recruitment and why would they want to hire a recruiting firm to solve these problems.","requiredField":true}]},"formDescription":"Create SEO optimized blog posts"},"typeVersion":2.2},{"id":"6e6d4952-793f-4dc5-8d29-219d420149a9","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-1940,800],"parameters":{"width":460,"height":500,"content":"## Sample Generic Search Terms\nAdd your own or try these for your specific geo location.\n\n1. **Severe skills shortages in healthcare, construction, and education sectors.**  \n2. **Aging workforce widens employment gaps in key industries.**  \n3. **Tight labor market with 110 vacancies per 100 unemployed people.**  \n4. **High demand for specialized skills due to economic changes.**  \n5. **Housing shortages deter international candidates from relocating to the Netherlands.**  \n6. **Strict employment regulations complicate hiring processes for non-EU workers.**  \n7. **Intense competition for talent due to low unemployment rates.**  \n8. **Mismatch between available talent and job-specific skill requirements.**  \n9. **Candidates expect high benefits packages, increasing recruitment costs significantly.**  \n10. **Difficulty navigating compliance and labor laws for international hiring processes.**"},"typeVersion":1},{"id":"bb94017e-dc2a-43e3-ae5c-1f3227b1f0ef","name":"Perplexity Research","type":"n8n-nodes-base.httpRequest","position":[-1860,560],"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 professional news researcher who is capable of finding detailed summaries about a news topic from highly reputable sources.\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \" Research the following topic and return everything you can find about: '{{ $json['Research Query'] }}'.\"\n    }\n  ]\n}\n","sendBody":true,"specifyBody":"json","authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"05RfNG280MisTyPP","name":"Perplexity"}},"typeVersion":4.2},{"id":"66086876-4b49-45fe-aecc-f7f062a59dba","name":"Cleanup Links","type":"n8n-nodes-base.set","position":[-1660,560],"parameters":{"options":{},"assignments":{"assignments":[{"id":"23b8e8c4-9191-415a-9661-1b60d413528a","name":"research","type":"string","value":"={{ $json.choices[0].message.content.replaceAll(\"[1]\", \" - source: \" +$json.citations[0]).replaceAll(\"[2]\",\" - source:\" +$json.citations[1]).replaceAll(\"[3]\",\" - source: \" +$json.citations[2]).replaceAll(\"[4]\",\" - source: \"+$json.citations[3]).replaceAll(\"[5]\",\" - source: \"+$json.citations[4]).replaceAll(\"[6]\",\" - source: \"+$json.citations[5]).replaceAll(\"[7]\",\" - source: \"+$json.citations[6]).replaceAll(\"[8]\",\" - source: \"+$json.citations[7]).replaceAll(\"[9]\",\" - source: \"+$json.citations[8]).replaceAll(\"[10]\",\" - source: \"+$json.citations[9]) }}"}]}},"typeVersion":3.4},{"id":"f81c9505-111f-473a-94b6-c79364410810","name":"Copywriter AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[-1360,560],"parameters":{"text":"=You are part of a marketing team that creates high-quality blog posts for the AI consulting and workflow automation industry based in Canada. Your goal is to produce engaging, SEO-optimized content that positions the company as an authority in the AI consulting industry and attracts inbound leads.\n\nEvery 2 days, your team posts a blog on the most trending topics in AI consulting and n8n workflows. As the copywriter, you are provided with the following information:\n\n- Query: The main topic for this week's blog post, representing the most trending news in the recruitment space.\n\n- Other keywords: A list of high-search-volume keywords related to AI consulting and n8n workflows. Incorporate these naturally into the blog post where relevant, without forcing them or changing the post's meaning.\n\n- Research findings: Detailed information from reputable sources related to the blog topic. Your post must be based on this research.\n\nGiven this information, write a comprehensive blog post that:\n\n- Includes the query in the blog title, H2 header, and early in the introduction.\n- Incorporates all details from the research findings, including source URLs for potential hyperlinks.\n- Is detailed and informative, showcasing the companies expertise in AI consulting and n8n workflows to automate business processes.\n- Uses a professional yet engaging tone, highlighting the exciting developments and challenges in the recruitment industry.\n- Flows naturally and logically, making it easy for readers to follow.\n- Is between 1500 to 2000 words long.\n- Is written at a level accessible to HR professionals and business leaders.\n\nAdditional requirements:\n- Include practical takeaways or actionable advice for recruiters and HR professionals.\n- Highlight how the topic relates to the companies services or expertise.\n- Include a call-to-action (CTA) that encourages readers to explore the comapnies services or contact for more information.\n\nCreate the entire blog post draft in your first output. Don't stop or cut it short.\n\nYour output must be the blog post and nothing else.\n\nHere are the details of this blog post project:\n\nQuery:\n{{ $('On form submission').item.json['Research Query'] }}\n\nDetailed Research:\n{{ $('Cleanup Links').item.json.research }}\n\n\n","options":{},"promptType":"define"},"typeVersion":1.8},{"id":"1ee6bb8f-6441-4ed9-83e0-d0839b2d0e01","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[-980,540],"parameters":{"color":7,"width":440,"height":440,"content":"## Create Title, Slug & Meta\n\n\n"},"typeVersion":1},{"id":"cc53a2af-ef22-446b-a9ee-b6f4ee649865","name":"Cleanup HTML ","type":"n8n-nodes-base.set","position":[-220,820],"parameters":{"options":{},"assignments":{"assignments":[{"id":"0afb2988-1481-4b04-b16d-fb33c50a16d0","name":"content","type":"string","value":"={{ $json.data[0].message.content.replaceAll('```html', '').replaceAll('```','') }}"}]}},"typeVersion":3.4},{"id":"b31c8afe-e402-49c4-ba49-ee418cecc44e","name":"GET Image","type":"n8n-nodes-base.httpRequest","position":[-720,1120],"parameters":{"url":"={{ $json['image-url'] }}","options":{}},"typeVersion":4.2},{"id":"1089466a-1307-4f22-a242-d324c9165379","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-980,1020],"parameters":{"width":820,"height":280,"content":"## Set Image for Wordpress Post"},"typeVersion":1},{"id":"288e212b-5aa5-452e-87d6-ae06c6ad062a","name":"Set Image URL","type":"n8n-nodes-base.set","position":[-920,1120],"parameters":{"options":{},"assignments":{"assignments":[{"id":"1f0541df-05ab-4e3d-a5d8-3904579fc8a9","name":"image-url","type":"string","value":"=https://smartcdn.gprod.postmedia.digital/healthing/wp-content/uploads/2024/07/GettyImages-1455799246.jpg?quality=90&strip=all&w=704&h=395"}]}},"typeVersion":3.4},{"id":"38bf38e5-888e-4d63-a48e-e6affab28158","name":"Send Success Message to Telegram","type":"n8n-nodes-base.telegram","position":[-80,1120],"webhookId":"91f7d710-450a-4b66-8e46-82f53492351e","parameters":{"text":"=Success! Your blog post was created at {{ $now }}","chatId":"={{ $env.TELEGRAM_CHAT_ID }}","additionalFields":{"appendAttribution":false}},"credentials":{"telegramApi":{"id":"pAIFhguJlkO3c7aQ","name":"Telegram account"}},"typeVersion":1.2},{"id":"30f0fa84-9918-4bf6-86e4-ef8f1dcf079c","name":"gpt-4o-mini","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-1360,760],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.2},{"id":"d2d83cc5-1502-4b04-ac12-0bb351a90e58","name":"Combine Blog Details","type":"n8n-nodes-base.aggregate","position":[-220,560],"parameters":{"options":{},"aggregate":"aggregateAllItemData"},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"4209c818-8b02-453e-9254-c70bde66f743","connections":{"Merge":{"main":[[{"node":"Combine Blog Details","type":"main","index":0}]]},"GET Image":{"main":[[{"node":"Upload Image to Wordpress","type":"main","index":0}]]},"Wordpress":{"main":[[{"node":"Set Image URL","type":"main","index":0}]]},"Create HTML":{"main":[[{"node":"Merge","type":"main","index":0}]]},"gpt-4o-mini":{"ai_languageModel":[[{"node":"Copywriter AI Agent","type":"ai_languageModel","index":0}]]},"Cleanup HTML ":{"main":[[{"node":"Wordpress","type":"main","index":0}]]},"Cleanup Links":{"main":[[{"node":"Copywriter AI Agent","type":"main","index":0}]]},"Set Image URL":{"main":[[{"node":"GET Image","type":"main","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"Create Title, Slug, Meta","type":"ai_languageModel","index":0}]]},"On form submission":{"main":[[{"node":"Perplexity Research","type":"main","index":0}]]},"Copywriter AI Agent":{"main":[[{"node":"Create HTML","type":"main","index":0},{"node":"Create Title, Slug, Meta","type":"main","index":0},{"node":"Merge","type":"main","index":1}]]},"Perplexity Research":{"main":[[{"node":"Cleanup Links","type":"main","index":0}]]},"Combine Blog Details":{"main":[[{"node":"Cleanup HTML ","type":"main","index":0}]]},"Create Title, Slug, Meta":{"main":[[{"node":"Merge","type":"main","index":2}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"Create Title, Slug, Meta","type":"ai_outputParser","index":0}]]},"Upload Image to Wordpress":{"main":[[{"node":"Set Image on Wordpress Post","type":"main","index":0}]]},"Set Image on Wordpress Post":{"main":[[{"node":"Send Success Message to Telegram","type":"main","index":0}]]}}}


