# templates

name: Upload to Instagram, Tiktok & Youtube from Google Drive
author_name: Juan Carlos Cavero Gracia
author_username: carlosgracia
categories: []
created_at: 2025-02-12T20:39:02.442Z
updated_at: 2025-02-12T20:39:02.442Z
url: https://n8n.io/workflows/2894
scraped_at: 2025-06-19 22:50:19
description:
  Description
  This automation template is designed for content creators, digital marketers, and social media managers looking to simplify their video posting workflow. It automates the process of generating engaging video descriptions and uploading content to both Instagram and TikTok, making your social media management more efficient and error-free.

  Who Is This For?
  Content Creators & Influencers:** Streamline your video uploads and focus more on creating content.
  Digital Marketers:** Ensure consistent posting across multiple platforms with minimal manual intervention.
  Social Media Managers:** Automate repetitive tasks and maintain a steady online presence.

  What Problem Does This Workflow Solve?
  Manually creating descriptions and uploading videos to different platforms can be time-consuming and error-prone. This workflow addresses these challenges by:
  Automating Video Uploads:** Monitors a designated Google Drive folder for new videos.
  Generating Descriptions:** Uses OpenAI to transcribe video audio and generate engaging, customized social media descriptions.
  Ensuring Multi-Platform Consistency:** Simultaneously posts your video with the generated description to Instagram and TikTok.
  Error Notifications:** Optional Telegram integration sends alerts in case of issues, ensuring smooth operations.

  How It Works
  Video Upload: Place your video in the designated Google Drive folder.
  Description Generation: The automation triggers OpenAI to transcribe your video’s audio and generate a captivating description.
  Content Distribution: Automatically uploads the video and description to both Instagram and TikTok.
  Error Handling: Sends Telegram notifications if any issues arise during the process.

  Setup
  Generate an API token at upload-post.com and configure it in both the Upload to TikTok and Upload to Instagram nodes.
  Google Cloud Project: Create a project in Google Cloud Platform, enable the Google Drive API, and generate the necessary OAuth credentials to connect to your Google Drive account.
  Set up your Google Drive folder in the Google Drive Trigger node.
  Customize the OpenAI prompt in the Generate Social Description node to match your brand’s tone.
  (Optional) Configure Telegram credentials for error notifications.

  Requirements
  Accounts:** upload-post.com, Google Drive, and (optionally) Telegram.
  API Keys & Credentials:** Upload-post.com API token, OpenAI API key, and (optional) Telegram bot token.
  Google Cloud:** A project with the Google Drive API enabled and valid OAuth credentials.

  Use this template to enhance your productivity, maintain consistency across your social media channels, and engage your audience with high-quality video content.

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

workflow_json:
  {"id":"9nBQ1BfwxLhuzTcK","meta":{"instanceId":"3378b0d68c3b7ebfc71b79896d94e1a044dec38e99a1160aed4e9c323910fbe2"},"name":"google drive to instagram, tiktok and youtube","tags":[],"nodes":[{"id":"b6c1d2f5-a8de-42dc-a164-3b1e80b2f19d","name":"Google Drive Trigger","type":"n8n-nodes-base.googleDriveTrigger","position":[220,320],"parameters":{"event":"fileCreated","options":{},"pollTimes":{"item":[{"mode":"everyMinute"}]},"triggerOn":"specificFolder","folderToWatch":{"__rl":true,"mode":"list","value":"18m0i341QLQuyWuHv_FBdz8-r-QDtofYm","cachedResultUrl":"https://drive.google.com/drive/folders/18m0i341QLQuyWuHv_FBdz8-r-QDtofYm","cachedResultName":"Influencersde"}},"credentials":{"googleDriveOAuth2Api":{"id":"2TbhWtnbRfSloGxX","name":"Google Drive account"}},"typeVersion":1},{"id":"1dda484a-f6f5-4677-85a3-09b2a47e69c4","name":"Google Drive","type":"n8n-nodes-base.googleDrive","position":[400,320],"parameters":{"fileId":{"__rl":true,"mode":"","value":"={{ $json.id || $json.data[0].id }}"},"options":{},"operation":"download","authentication":"oAuth2"},"credentials":{"googleDriveOAuth2Api":{"id":"2TbhWtnbRfSloGxX","name":"Google Drive account"}},"retryOnFail":true,"typeVersion":1,"waitBetweenTries":5000},{"id":"f9388923-b20e-40f0-ba10-fd00b463b1a7","name":"Error Trigger","type":"n8n-nodes-base.errorTrigger","position":[620,660],"parameters":{},"typeVersion":1},{"id":"eda45ad6-d976-4665-9b6d-dae4c3212191","name":"Telegram","type":"n8n-nodes-base.telegram","position":[960,640],"webhookId":"f6729386-9905-45f1-800f-4fe01a06ac9c","parameters":{"text":"=🔔 ERROR SUBIENDO VIDEOS","additionalFields":{"appendAttribution":false}},"retryOnFail":true,"typeVersion":1.2,"waitBetweenTries":5000},{"id":"7b1d6015-49b8-423c-be64-e905ff791574","name":"If","type":"n8n-nodes-base.if","position":[760,660],"parameters":{"options":{},"conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"9fadb3fd-2547-42bd-8f40-f410a97dcf57","operator":{"type":"string","operation":"notContains"},"leftValue":"={{ $json.trigger.error.message }}","rightValue":"The DNS server returned an error, perhaps the server is offline"}]}},"typeVersion":2.1},{"id":"6e9882aa-b11f-4c1a-8600-eedda9d92046","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-220,0],"parameters":{"width":860,"height":260,"content":"## Description\nThis automation allows you to upload a video to a configured Google Drive folder, and it will automatically create descriptions and upload it to Instagram and TikTok.\n\n## How to Use\n1. Generate an API token at upload-post.com and add to Upload to Tiktok and Upload to Instagram nodes\n2. Configure your Google Drive folder\n3. Customize the OpenAI prompt for your specific use case\n4. Optional: Configure Telegram for error notifications\n\n## Requirements\n- upload-post.com account\n- Google Drive account\n- OpenAI API key\n"},"typeVersion":1},{"id":"b3eed1dc-8273-4593-ab07-8860fffa0907","name":"Get Audio from Video","type":"@n8n/n8n-nodes-langchain.openAi","notes":"Extract the audio from video for generate the description","position":[860,320],"parameters":{"options":{},"resource":"audio","operation":"transcribe"},"credentials":{"openAiApi":{"id":"XJdxgMSXFgwReSsh","name":"n8n key"}},"notesInFlow":true,"retryOnFail":true,"typeVersion":1,"waitBetweenTries":5000},{"id":"b057fea0-087e-4c7f-b5ac-6d16ca658437","name":"Read video from Google Drive","type":"n8n-nodes-base.writeBinaryFile","position":[580,320],"parameters":{"options":{},"fileName":"={{ $json.originalFilename.replaceAll(\" \", \"_\") }}"},"typeVersion":1},{"id":"f9296b8f-b631-4df4-b8b5-aa7139dd65cd","name":"Generate Description for Videos  in Tiktok and Instagram","type":"@n8n/n8n-nodes-langchain.openAi","notes":"Request to OpenAi for generate description with the audio extracted from the video","position":[1060,320],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o","cachedResultName":"GPT-4O"},"options":{},"messages":{"values":[{"role":"system","content":"You are an expert assistant in creating engaging social media video titles."},{"content":"=I'm going to upload a video to social media. Here are some examples of descriptions that have worked well on Instagram:\n\nFollow and save for later. Discover InfluencersDe, the AI tool that automates TikTok creation and publishing to drive traffic to your website. Perfect for entrepreneurs and brands.\n#digitalmarketing #ugc #tiktok #ai #influencersde #contentcreation\n\nDiscover the video marketing revolution with InfluencersDe!\n.\n.\n.\n#socialmedia #videomarketing #ai #tiktok #influencersde #growthhacking\n\nDon't miss InfluencersDe, the tool that transforms your marketing strategy with just one click!\n.\n.\n.\n#ugc #ai #tiktok #digitalmarketing #influencersde #branding\n\nCan you create another title for the Instagram post based on this recognized audio from the video?\n\nAudio: {{ $('Get Audio from Video').item.json.text }}\n\nIMPORTANT: Reply only with the description, don't add anything else."}]}},"credentials":{"openAiApi":{"id":"XJdxgMSXFgwReSsh","name":"n8n key"}},"notesInFlow":true,"retryOnFail":true,"typeVersion":1.4,"waitBetweenTries":5000},{"id":"e80758fd-5532-48b0-b663-085629137fc0","name":"Read Video from Google Drive","type":"n8n-nodes-base.readBinaryFile","position":[1620,100],"parameters":{"filePath":"={{ $('Read video from Google Drive').item.json.originalFilename.replaceAll(\" \", \"_\") }}","dataPropertyName":"datavideo"},"typeVersion":1},{"id":"8f13c601-4282-4a44-8e8a-dc88e4165ee4","name":"Read Video from Google Drive2","type":"n8n-nodes-base.readBinaryFile","position":[1620,400],"parameters":{"filePath":"={{ $('Read video from Google Drive').item.json.originalFilename.replaceAll(\" \", \"_\") }}","dataPropertyName":"datavideo"},"typeVersion":1},{"id":"1b46976e-be37-49bd-b77b-e48d8e619954","name":"Upload Video and Description to Tiktok","type":"n8n-nodes-base.httpRequest","notes":"Generate in upload-post.com the token and add to the credentials in the header-> Authorization: Apikey (token here)","position":[1880,100],"parameters":{"url":"https://api.upload-post.com/api/upload","method":"POST","options":{},"sendBody":true,"contentType":"multipart-form-data","authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"title","value":"={{ $('Generate Description for Videos  in Tiktok and Instagram').item.json.message.content.replaceAll(\"\\\"\", \"\") }}"},{"name":"platform[]","value":"tiktok"},{"name":"video","parameterType":"formBinaryData","inputDataFieldName":"datavideo"},{"name":"user","value":"Add user generated in upload-post"}]},"genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"WNjAx7UqrEZ1JDrR","name":"VituManco"}},"notesInFlow":true,"typeVersion":4.2},{"id":"0404a57f-2c1a-4ccd-90df-893dd01acaa0","name":"Upload Video and Description to Instagram","type":"n8n-nodes-base.httpRequest","notes":"Generate in upload-post.com the token and add to the credentials in the header-> Authorization: Apikey (token here)","position":[1880,400],"parameters":{"url":"https://api.upload-post.com/api/upload","method":"POST","options":{},"sendBody":true,"contentType":"multipart-form-data","authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"title","value":"={{ $('Generate Description for Videos  in Tiktok and Instagram').item.json.message.content.replaceAll(\"\\\"\", \"\") }}"},{"name":"platform[]","value":"instagram"},{"name":"video","parameterType":"formBinaryData","inputDataFieldName":"datavideo"},{"name":"user","value":"Add user generated in upload-post"}]},"genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"47dO31ED0WIaJkR6","name":"Header Auth account"}},"notesInFlow":true,"typeVersion":4.2},{"id":"358da7b7-2d0a-475b-a10d-ffc499b5e99d","name":"Read Video from Google Drive3","type":"n8n-nodes-base.readBinaryFile","position":[1620,660],"parameters":{"filePath":"={{ $('Read video from Google Drive').item.json.originalFilename.replaceAll(\" \", \"_\") }}","dataPropertyName":"datavideo"},"typeVersion":1},{"id":"0e46ee9b-e466-4a5d-8916-3836eed4fc2d","name":"Upload Video and Description to Youtube","type":"n8n-nodes-base.httpRequest","notes":"Generate in upload-post.com the token and add to the credentials in the header-> Authorization: Apikey (token here)","position":[1880,660],"parameters":{"url":"https://api.upload-post.com/api/upload","method":"POST","options":{},"sendBody":true,"contentType":"multipart-form-data","authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"title","value":"={{ $('Generate Description for Videos  in Tiktok and Instagram').item.json.message.content.replaceAll(\"\\\"\", \"\").substring(0, 70) }}\n"},{"name":"platform[]","value":"youtube"},{"name":"video","parameterType":"formBinaryData","inputDataFieldName":"datavideo"},{"name":"user","value":"test2"}]},"genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"47dO31ED0WIaJkR6","name":"Header Auth account"}},"notesInFlow":true,"typeVersion":4.2}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"13975e04-a6c4-42d0-887c-e6c4ff219f42","connections":{"If":{"main":[[{"node":"Telegram","type":"main","index":0}]]},"Google Drive":{"main":[[{"node":"Read video from Google Drive","type":"main","index":0}]]},"Error Trigger":{"main":[[{"node":"If","type":"main","index":0}]]},"Get Audio from Video":{"main":[[{"node":"Generate Description for Videos  in Tiktok and Instagram","type":"main","index":0}]]},"Google Drive Trigger":{"main":[[{"node":"Google Drive","type":"main","index":0}]]},"Read Video from Google Drive":{"main":[[{"node":"Upload Video and Description to Tiktok","type":"main","index":0}]]},"Read video from Google Drive":{"main":[[{"node":"Get Audio from Video","type":"main","index":0}]]},"Read Video from Google Drive2":{"main":[[{"node":"Upload Video and Description to Instagram","type":"main","index":0}]]},"Read Video from Google Drive3":{"main":[[{"node":"Upload Video and Description to Youtube","type":"main","index":0}]]},"Generate Description for Videos  in Tiktok and Instagram":{"main":[[{"node":"Read Video from Google Drive","type":"main","index":0},{"node":"Read Video from Google Drive2","type":"main","index":0},{"node":"Read Video from Google Drive3","type":"main","index":0}]]}}}


name: N8N for Beginners: Looping over Items
author_name: Dominik Baranowski
author_username: dom
nodes_used: ["n8n-nodes-base.code"]
categories: []
created_at: 2025-02-13T00:40:12.140Z
updated_at: 2025-02-13T00:40:12.140Z
url: https://n8n.io/workflows/2896
scraped_at: 2025-06-19 22:49:25
description:
  N8N for Beginners: Looping Over Items

  Description

  This workflow is designed for n8n beginners to understand how n8n handles looping (iteration) over multiple items. It highlights two key behaviors:

  Built-In Looping:** By default, most n8n nodes iterate over each item in an input array.
  Explicit Looping:* The *Loop Over Items* node allows controlled iteration, enabling *custom batch processing** and multi-step workflows.

  This workflow demonstrates the difference between processing an unsplit array of strings (single item) vs. a split array (multiple items).

  Setup

  1. Input Data

  To begin, paste the following JSON into the Manual Trigger node:

  {
    "urls": [
      "https://www.reddit.com",
      "https://www.n8n.io/",
      "https://n8n.io/",
      "https://supabase.com/",
      "https://duckduckgo.com/"
    ]
  }

  📌 Steps to Paste Data:
  Double-click** the "Manual Trigger" node.
  Click "Edit Output" (top-right corner).
  Paste the JSON and Save.
  The node turns purple, indicating that test data is pinned.

  1. Click "Test Workflow" button at the bottom of the canvas

  Explanation of the n8n Nodes in the Workflow

  | Node Name | Purpose | Documentation Link |
  |-----------|---------|--------------------|
  | Manual Trigger | Starts the workflow manually and sends test data | Docs |
  | Split Out | Converts an array of strings into separate JSON objects | Docs |
  | Loop Over Items (Loop Over Items 1) | Demonstrates how an unsplit array is treated as one item | Docs |
  | Loop Over Items (Loop Over Items 2) | Iterates over each item separately | Docs |
  | Wait | Introduces a delay per iteration (set to 1 second) | Docs |
  | Code | Adds a constant parameter (param1) to each item | Docs |
  | NoOp (Result Nodes) | Displays output for inspection | Docs |

  Execution Details

  1. How the Workflow Runs

  Manual Trigger starts execution** with the pasted JSON data.
  The workflow follows two paths:
    Unsplit Array Path → Loop Over Items 1  
       Processes the entire array as a single item.
       Result1 & Result5: Show that the array was not split.
    
    Split Array Path → Split Out → Loop Over Items 2
       Splits the array into separate objects.
       Result2, Result3, Result4: Show that each item is processed individually.
       A Wait node (1 sec delay) demonstrates controlled execution.
       Code nodes modify the JSON, adding a parameter (param1).

  2. What You Will See

  | Node | Expected Output |
  |------|---------------|
  | Result1 & Result5 | The entire array is processed as one item. |
  | Result2, Result3, Result4 | The array is split and processed as individual items. |
  | Wait Node | Adds a 1-second delay per item in Loop Over Items 2. |

  Use Cases

  This workflow is useful for:

  ✅ API Data Processing: Loop through API responses containing arrays.  
  ✅ Web Scraping: Process multiple URLs individually.  
  ✅ Task Automation: Execute a sequence of actions per item.  
  ✅ Workflow Optimization: Control execution order, delays, and dependencies.

  Notes

  Sticky notes are included in the workflow for easy reference.
  The Wait node is optional—remove it for faster execution.
  This template is structured for beginners but serves as a building block for more advanced automations.

workflow_json:
  {"id":"CDVBZRDH5gNUzIml","meta":{"instanceId":"ab60b809a7fa5daa22fa7edffc14e989a6e59d4063ec838ad62f2655caafd963","templateCredsSetupCompleted":true},"name":"N8N for Beginners: Looping over Items","tags":[],"nodes":[{"id":"500304a1-5164-4907-b0a7-e514e455e3dc","name":"Result1","type":"n8n-nodes-base.noOp","notes":"Look Here to see resulting output","position":[880,-280],"parameters":{},"notesInFlow":true,"typeVersion":1},{"id":"32808ad1-1a35-497f-b1d3-c935a924c541","name":"Result2","type":"n8n-nodes-base.noOp","notes":"Look here to see resulting output","position":[880,40],"parameters":{},"notesInFlow":true,"typeVersion":1},{"id":"f3c9fa5d-a4c7-4cf0-beb5-774d8483974f","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[800,-340],"parameters":{"color":3,"width":320,"height":240,"content":"\n### Result1 shows that the array of strings is seen as one item by Loop1"},"typeVersion":1},{"id":"0bb96765-60ce-4618-9b39-7cd203a3cb48","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[800,-60],"parameters":{"color":3,"width":320,"height":260,"content":"### Result2 shows that the Loop2 sees 5 items after the array of strings is split into separate objects"},"typeVersion":1},{"id":"b71fcc86-b0cd-4241-b0d6-21abe4c6b68d","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-1680,-1100],"parameters":{"width":1200,"height":2480,"content":"# N8N for Beginners: Looping Over Items\n\n## Description\n\nThis workflow is designed for **n8n beginners** to understand how n8n handles **looping (iteration)** over multiple items. It highlights two key behaviors:\n\n- **Built-In Looping:** By default, most n8n nodes iterate over each item in an input array.\n- **Explicit Looping:** The **Loop Over Items** node allows controlled iteration, enabling **custom batch processing** and multi-step workflows.\n\nThis workflow demonstrates the difference between processing an **unsplit array of strings (single item)** vs. **a split array (multiple items)**.\n\n---\n\n## Setup\n\n### 1. Input Data\n\nTo begin, **paste the following JSON** into the **Manual Trigger** node:\n\n```json\n{\n  \"urls\": [\n    \"https://www.reddit.com\",\n    \"https://www.n8n.io/\",\n    \"https://n8n.io/\",\n    \"https://supabase.com/\",\n    \"https://duckduckgo.com/\"\n  ]\n}\n```\n\nðŸ“Œ **Steps to Paste Data:**\n- **Double-click** the \"Manual Trigger\" node.\n- Click **\"Edit Output\"** (top-right corner).\n- Paste the JSON and **Save**.\n- The node **turns purple**, indicating that test data is pinned. \n\n---\n\n## Explanation of the n8n Nodes in the Workflow\n\n### Manual Trigger  \nThis node starts the workflow manually and sends test data.  \n**Documentation:** [Manual Trigger Node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.manualtrigger/)\n\n### Split Out (Split Array of Strings into Array of Objects)  \nExtracts the `urls` array and splits it so that each URL becomes a separate JSON object.  \n**Documentation:** [Split Out Node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.splitout/)\n\n### Loop Over Items (Loop Over Items 1)  \nDemonstrates how an **unsplit** array is treated as one item, processing it as a single unit.  \n**Documentation:** [Loop Over Items Node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.splitinbatches/)\n\n### Loop Over Items (Loop Over Items 2)  \nProcesses the **split array** one item at a time. This demonstrates individual iteration and controlled looping.  \n**Documentation:** [Loop Over Items Node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.splitinbatches/)\n\n### Wait Node  \nIntroduces a **1-second delay** per iteration to demonstrate sequential execution. This can be removed for faster performance.  \n**Documentation:** [Wait Node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.wait/)\n\n### Code Nodes (Add param1 to outputX)  \nEach Code node adds a constant field (`param1`) to the data, ensuring that every item gets enriched with the same parameter.  \n**Documentation:** [Code Node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.code/)\n\n### NoOp Nodes (Result1, Result2, Result3, Result4, Result5)\nThese nodes display the output at different stages of the workflow for inspection.\n**Documentation:** [NoOp Node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.noop/)\n\n\n\n---\n\n## Execution Details\n\n### 1. How the Workflow Runs\n\n- **Manual Trigger starts execution** with the pasted JSON data.\n- The workflow follows **two paths**:\n\n#### Unsplit Array Path â†’ Loop Over Items 1  \n- The original JSON is processed **as a single item**.  \n- **Result1 & Result5:** Show that the array was **not split** before processing.\n\n#### Split Array Path â†’ Split Out â†’ Loop Over Items 2  \n- The **Split Out** node converts the `urls` array into separate objects.\n- The **Loop Over Items 2** node processes each URL **one by one**.\n- A **Wait node** (1-second delay) demonstrates **controlled execution**.\n- **Code nodes** modify the JSON, adding the field (`param1`).\n- **Result2, Result3, Result4:** Display the final processed output.\n\n### 2. What You Will See\n\n- **Result1 & Result5:** The entire array is processed **as one item** before splitting.\n- **Result2, Result3, Result4:** Each URL is processed **individually** after being split.\n- **Wait Node:** Adds a **1-second delay per item** in **Loop Over Items 2**.\n\n---\n\n## Notes\n\n- Sticky notes are included in the workflow **for easy reference**.\n- The **Wait node** is **optional**â€”remove it for faster execution.\n- This template is structured for **beginners** but serves as a **building block** for more advanced automations.\n\n---\n\n"},"typeVersion":1},{"id":"53e7d23a-2a4f-4ada-aeb5-de128acf8625","name":"Split Array of Strings into Array of Objects","type":"n8n-nodes-base.splitOut","position":[-20,380],"parameters":{"options":{"destinationFieldName":"url"},"fieldToSplitOut":"urls"},"typeVersion":1},{"id":"4910fec6-d600-43be-97b2-5050039db416","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[800,700],"parameters":{"color":3,"width":320,"height":260,"content":"### Result4 shows that we can turn off the looping feature by setting the looping behavior to \"Run Once For All Items\""},"typeVersion":1},{"id":"f0e68b30-5341-4672-8d8e-7a24d894eb03","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[800,420],"parameters":{"color":3,"width":320,"height":240,"content":"### Result3 shows that looping over items is built in to n8n nodes"},"typeVersion":1},{"id":"70a987b9-6a4a-49c3-a87c-0dd9cc1879ed","name":"Result3","type":"n8n-nodes-base.noOp","notes":"Look here to see resulting output","position":[900,500],"parameters":{},"notesInFlow":true,"typeVersion":1},{"id":"9de5fac9-e987-4fb1-8f7f-b59af2985e5c","name":"Result4","type":"n8n-nodes-base.noOp","notes":"Look here to see resulting output","position":[900,780],"parameters":{},"notesInFlow":true,"typeVersion":1},{"id":"d5fee847-7758-44ac-a270-6334dd81bb97","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[800,-640],"parameters":{"color":3,"width":320,"height":260,"content":"### Result5 shows that the array of strings is seen as one item by Code5. So the behavior is the same as Loop1"},"typeVersion":1},{"id":"9a134620-4067-4c7a-8b0f-30e19c93a66c","name":"Result5","type":"n8n-nodes-base.noOp","notes":"Look here to see resulting output","position":[880,-540],"parameters":{},"notesInFlow":true,"typeVersion":1},{"id":"c273cd55-708d-4f86-81f2-3bbe991f59f8","name":"Paste JSON into this node","type":"n8n-nodes-base.manualTrigger","position":[-400,-540],"parameters":{},"typeVersion":1},{"id":"8f64b987-05c5-43a9-89c0-201499df0aa6","name":"Add param1 to output5","type":"n8n-nodes-base.code","position":[320,-540],"parameters":{"jsCode":"\n  $json.param1 =  'add_me_to_all_items_and_name_me_param1';\n\n\nreturn $json"},"typeVersion":2,"alwaysOutputData":true},{"id":"4920b4e4-b511-4059-b38a-623d14b6df25","name":"Add param1 to output1","type":"n8n-nodes-base.code","position":[500,-180],"parameters":{"mode":"runOnceForEachItem","jsCode":"\n  $json.param1 = \"add_me_to_all_items_and_name_me_param1\"\n\nreturn $json"},"typeVersion":2,"alwaysOutputData":true},{"id":"28ce5239-6437-4b7a-9395-3beb162fded6","name":"Loop over Items 2","type":"n8n-nodes-base.splitInBatches","position":[320,60],"parameters":{"options":{}},"typeVersion":3},{"id":"628edc5e-1b7f-4f50-9c29-8990bd4a5cc0","name":"Loop over Items 1","type":"n8n-nodes-base.splitInBatches","position":[320,-260],"parameters":{"options":{"reset":false}},"typeVersion":3},{"id":"ffccda97-066d-4c13-b4eb-a13ff849b90a","name":"Add param1 to output2","type":"n8n-nodes-base.code","position":[680,220],"parameters":{"mode":"runOnceForEachItem","jsCode":"\n  $json.param1 =   \"add_me_to_all_items_and_name_me_param1\"\n\n\nreturn $json"},"typeVersion":2,"alwaysOutputData":true},{"id":"6fb44840-6365-46db-9c50-eecd420f274f","name":"Add param1 to output3","type":"n8n-nodes-base.code","position":[320,500],"parameters":{"mode":"runOnceForEachItem","jsCode":"\n  $json.param1 =   \"add_me_to_all_items_and_name_me_param1\"\n\n\nreturn $json"},"typeVersion":2,"alwaysOutputData":true},{"id":"51b8d766-25ed-407f-a956-693b93bda95f","name":"Add param1 to output4","type":"n8n-nodes-base.code","position":[320,780],"parameters":{"jsCode":"\n  $json.param1 =   \"add_me_to_all_items_and_name_me_param1\"\n\n\nreturn $json"},"typeVersion":2,"alwaysOutputData":true},{"id":"f8edde34-cf47-42e2-bbd3-552df2509451","name":"Wait one second(just for show)","type":"n8n-nodes-base.wait","position":[480,180],"webhookId":"61aef80b-4e9d-43ae-a083-cd87b4fdec11","parameters":{"amount":1},"typeVersion":1.1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"e1eff37a-1ffd-4691-9560-eada5baab88d","connections":{"Result1":{"main":[[]]},"Result2":{"main":[[]]},"Loop over Items 1":{"main":[[{"node":"Result1","type":"main","index":0}],[{"node":"Add param1 to output1","type":"main","index":0}]]},"Loop over Items 2":{"main":[[{"node":"Result2","type":"main","index":0}],[{"node":"Wait one second(just for show)","type":"main","index":0}]]},"Add param1 to output1":{"main":[[{"node":"Loop over Items 1","type":"main","index":0}]]},"Add param1 to output2":{"main":[[{"node":"Loop over Items 2","type":"main","index":0}]]},"Add param1 to output3":{"main":[[{"node":"Result3","type":"main","index":0}]]},"Add param1 to output4":{"main":[[{"node":"Result4","type":"main","index":0}]]},"Add param1 to output5":{"main":[[{"node":"Result5","type":"main","index":0}]]},"Paste JSON into this node":{"main":[[{"node":"Split Array of Strings into Array of Objects","type":"main","index":0},{"node":"Add param1 to output5","type":"main","index":0},{"node":"Loop over Items 1","type":"main","index":0}]]},"Wait one second(just for show)":{"main":[[{"node":"Add param1 to output2","type":"main","index":0}]]},"Split Array of Strings into Array of Objects":{"main":[[{"node":"Loop over Items 2","type":"main","index":0},{"node":"Add param1 to output4","type":"main","index":0},{"node":"Add param1 to output3","type":"main","index":0}]]}}}


name: AI-Powered Social Media Content Generator & Publisher
author_name: Amjid Ali
author_username: amjid
categories: []
created_at: 2025-02-20T12:47:09.520Z
updated_at: 2025-02-20T12:47:09.520Z
url: https://n8n.io/workflows/2950
scraped_at: 2025-06-19 22:48:58
description:
  AI-Powered Social Media Content Generator & Publisher 🚀  

  This AI-driven n8n workflow automates social media content creation and publishing across LinkedIn, Instagram, Facebook, and Twitter (X). It generates engaging, platform-optimized posts using Google Gemini AI, based on user inputs such as a post title, keywords, and an uploaded image. The workflow ensures seamless content generation and publishing, making it a perfect tool for marketers, business owners, influencers, and content creators.  

  🌟 Features & Benefits  

  ✅ AI-Generated Social Media Posts – Uses Google Gemini AI to create high-quality, optimized content.  
  ✅ Multi-Platform Support – Automatically generates posts for LinkedIn, Instagram, Facebook, and Twitter (X).  
  ✅ Hashtag & SEO Optimization – Includes trending hashtags to enhance visibility and engagement.  
  ✅ Image Upload & Processing – Allows image uploads for Instagram and Facebook using imgbb and Facebook Graph API.  
  ✅ Automated Publishing – Posts are automatically published on all selected platforms.  
  ✅ Custom Call-to-Action – Each platform's post is optimized with CTAs for better engagement.  
  ✅ User-Friendly Form Submission – Easy-to-use form where users can enter post titles, keywords, links, and images.  
  ✅ Performance Tracking – Provides confirmation and tracking links for published posts.  

  📌 How It Works  

  1️⃣ User Submission Form  
     Fill out the form with Post Title, Keywords, and an Optional Link.  
     Upload an image for Instagram & Facebook posts.  

  2️⃣ AI Content Generation  
     Google Gemini AI generates optimized content for each platform.  
     The AI ensures professional, engaging, and audience-specific content.  

  3️⃣ Content Review  
     Users review and approve the AI-generated content before publishing.  

  4️⃣ Automated Publishing  
     Posts are automatically published on LinkedIn, Facebook, Instagram, and Twitter (X).  
     Uses Facebook Graph API, LinkedIn API, Twitter API, and Instagram API.  

  5️⃣ Post Confirmation & Tracking  
     Get links to track published posts on each platform.  

  🛠️ Prerequisites  

  Before using this workflow, ensure you have:  

  ✅ n8n Instance (Cloud or Self-Hosted)  
  ✅ Social Media API Credentials (Facebook, Instagram, LinkedIn, Twitter API)  
  ✅ Google Gemini AI API Key  
  ✅ imgbb API Key (for image hosting)  

  Get N8n
  My Affiliate Link
  Buy My Book:  
  Mastering n8n on Amazon

  Full Courses & Tutorials:  
  http://lms.syncbricks.com

  📺 YouTube Video Tutorial 🎥  

  Watch the step-by-step tutorial on how to set up and use this n8n workflow template:  

  🔗 YouTube Tutorial - AI-Powered Social Media Posting in n8n  

  🎯 Use Cases  

  📌 Marketing Agencies – Automate client content scheduling.  
  📌 Businesses & Brands – Maintain a consistent brand presence on social media.  
  📌 Content Creators & Influencers – Generate high-quality posts quickly.  
  📌 E-commerce & Startups – Promote products and services effortlessly.  
  📌 Corporate & Enterprise Teams – Streamline internal and external communications.  

  Important
  Start with n8n  

  Learn n8n with Amjid   
  Get n8n Book 

  👨‍💻 Creator Information  

  👤 Developed by: Amjid Ali  
  🌐 Website: SyncBricks  
  📧 Email: info@syncbricks.com  
  💼 LinkedIn: Amjid Ali  
  📺 YouTube: SyncBricks  

  💡 Support & Contributions  

  If you find this workflow helpful, consider supporting my work:  

  👉 Donate via PayPal  

  For full courses on * AI Automation*, visit:  

  📚 SyncBricks LMS  

  📚 AI and Auotmation Course 

  👉  Get Started with N8N  

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

workflow_json:
  {"id":"LzDLmNc63zyqQBXz","meta":{"instanceId":"942ff96108ceedc60ba777eabc4e8ea2ae87415579996cd64d20cc647c4d3523"},"name":"Social Media Tutorial","tags":[],"nodes":[{"id":"8034d082-f50e-4f6b-8a79-ce7f86012d72","name":"On form submission","type":"n8n-nodes-base.formTrigger","position":[920,20],"webhookId":"syncbricks-social-posting-ai-agent","parameters":{},"typeVersion":2.2},{"id":"e38a74d5-a733-4f5c-a97b-2c761b46919b","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[1180,520],"parameters":{},"typeVersion":1.7},{"id":"ca0a8aef-0251-45ed-bc9b-05ee977febf9","name":"Google Gemini Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[980,780],"parameters":{},"typeVersion":1},{"id":"31e88059-94ca-4d4e-a673-e0f8cd1ac96e","name":"Structured Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[1300,780],"parameters":{},"typeVersion":1.2},{"id":"ffda1c79-faa4-4cc8-8655-6f7fc14b7e2d","name":"Split Form Input","type":"n8n-nodes-base.set","position":[1320,40],"parameters":{},"typeVersion":3.2},{"id":"37e443e1-6925-44a1-a07e-9eb1120e55a9","name":"Upload Image","type":"n8n-nodes-base.form","position":[320,1160],"webhookId":"0dc811ef-b2e0-4213-a0c9-e9b5fb9fcbf1","parameters":{},"typeVersion":1},{"id":"265068ce-22fc-4c41-9ed2-93eadc0ce25f","name":"Split Data","type":"n8n-nodes-base.set","position":[1560,40],"parameters":{},"typeVersion":3.2},{"id":"b8470879-413e-4901-bf39-23a19beaee5f","name":"Data for AI","type":"n8n-nodes-base.set","position":[1880,40],"parameters":{},"typeVersion":3.4},{"id":"eef02dcb-7c7f-4d6c-a1fd-039c8b30f10d","name":"Aggregate","type":"n8n-nodes-base.aggregate","position":[1680,760],"parameters":{},"typeVersion":1},{"id":"097e7724-4dc0-4cc9-b12c-2dbdae4e024f","name":"Form","type":"n8n-nodes-base.form","position":[1820,1960],"webhookId":"e84b9492-038c-4701-a367-c68237ddebf6","parameters":{},"typeVersion":1},{"id":"7b1d64fc-02ad-4b8f-ad1e-be8894abd932","name":"Nest Top Meta","type":"n8n-nodes-base.set","position":[940,1160],"parameters":{},"typeVersion":3.3},{"id":"11ddcfe8-1978-4f5a-8c29-67e72920431a","name":"Rename Image Binary Top Image","type":"n8n-nodes-base.code","position":[-40,1960],"parameters":{},"typeVersion":2},{"id":"19892590-5ddf-47ac-b544-7a72a68bd45e","name":"Publish to Facebook","type":"n8n-nodes-base.facebookGraphApi","position":[440,2080],"parameters":{},"typeVersion":1},{"id":"b3b0068b-c75a-427c-bb2d-77b21bc6ff16","name":"Publish to LinkedIn","type":"n8n-nodes-base.linkedIn","position":[420,1840],"parameters":{},"typeVersion":1},{"id":"ed5fe0c2-a07a-45f1-90cb-65f21d416a1a","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[860,-80],"parameters":{"content":""},"typeVersion":1},{"id":"c4a2e59d-165a-49cc-8074-9868ee4e0d6c","name":"X","type":"n8n-nodes-base.twitter","position":[440,1600],"parameters":{},"typeVersion":2},{"id":"66ba98a9-24c0-4128-9ad9-792a0d400aae","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[860,340],"parameters":{"content":""},"typeVersion":1},{"id":"02fafdc7-0272-4f34-9b66-dfbe8e16e70d","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-240,960],"parameters":{"content":""},"typeVersion":1},{"id":"21d945c3-446c-4bb9-8696-a70034801485","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-240,1480],"parameters":{"content":""},"typeVersion":1},{"id":"c9efdc38-94c6-494e-a932-45b75312bb54","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[1620,1480],"parameters":{"content":""},"typeVersion":1},{"id":"93632f4f-9182-4b76-bbe0-e6d5dd230452","name":"Edit Fields","type":"n8n-nodes-base.set","position":[800,1600],"parameters":{},"typeVersion":3.4},{"id":"89f22cf8-9499-4b7f-872d-97099c5d1e50","name":"Image for Instagram","type":"n8n-nodes-base.httpRequest","position":[740,2280],"parameters":{},"typeVersion":4.2},{"id":"c415eeb9-f916-4c08-afb1-baed3f3280cc","name":"Publish to Instagram","type":"n8n-nodes-base.facebookGraphApi","position":[1060,2280],"parameters":{},"typeVersion":1},{"id":"1c8f6ba6-c28b-45a8-ba0d-3f2f21ccbfa0","name":"Merge1","type":"n8n-nodes-base.merge","position":[1380,1940],"parameters":{},"typeVersion":3},{"id":"d9cfdcd1-18db-4d0d-9b6a-66897600e496","name":"Upload Image to imgbb.com","type":"n8n-nodes-base.httpRequest","position":[440,2280],"parameters":{},"typeVersion":4.2},{"id":"f7e5b1b1-aeaa-4851-be04-53e8255fa343","name":"Sticky Note11","type":"n8n-nodes-base.stickyNote","position":[-240,-80],"parameters":{"content":""},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"4a55bf93-ae0c-4aa9-84a8-cd4d02375e51","connections":{"X":{"main":[[{"node":"Edit Fields","type":"main","index":0}]]},"Merge1":{"main":[[{"node":"Form","type":"main","index":0}]]},"AI Agent":{"main":[[{"node":"Aggregate","type":"main","index":0}]]},"Aggregate":{"main":[[{"node":"Upload Image","type":"main","index":0}]]},"Split Data":{"main":[[{"node":"Data for AI","type":"main","index":0}]]},"Data for AI":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Edit Fields":{"main":[[{"node":"Merge1","type":"main","index":0}]]},"Upload Image":{"main":[[{"node":"Nest Top Meta","type":"main","index":0}]]},"Nest Top Meta":{"main":[[{"node":"Rename Image Binary Top Image","type":"main","index":0}]]},"Split Form Input":{"main":[[{"node":"Split Data","type":"main","index":0}]]},"On form submission":{"main":[[{"node":"Split Form Input","type":"main","index":0}]]},"Image for Instagram":{"main":[[{"node":"Publish to Instagram","type":"main","index":0}]]},"Publish to Facebook":{"main":[[{"node":"Merge1","type":"main","index":2}]]},"Publish to LinkedIn":{"main":[[{"node":"Merge1","type":"main","index":1}]]},"Publish to Instagram":{"main":[[{"node":"Merge1","type":"main","index":3}]]},"Google Gemini Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"AI Agent","type":"ai_outputParser","index":0}]]},"Upload Image to imgbb.com":{"main":[[{"node":"Image for Instagram","type":"main","index":0}]]},"Rename Image Binary Top Image":{"main":[[{"node":"X","type":"main","index":0},{"node":"Publish to LinkedIn","type":"main","index":0},{"node":"Publish to Facebook","type":"main","index":0},{"node":"Upload Image to imgbb.com","type":"main","index":0}]]}}}


name: 🤖 AI Powered RAG Chatbot for Your Docs + Google Drive + Gemini + Qdrant
author_name: Joseph LePage
author_username: joe
categories: []
created_at: 2025-02-23T01:59:29.690Z
updated_at: 2025-02-23T01:59:29.690Z
url: https://n8n.io/workflows/2982
scraped_at: 2025-06-19 22:49:10
description:
  🤖 AI-Powered RAG Chatbot with Google Drive Integration

  This workflow creates a powerful RAG (Retrieval-Augmented Generation) chatbot that can process, store, and interact with documents from Google Drive using Qdrant vector storage and Google's Gemini AI.

  How It Works

  Document Processing & Storage 📚
  Retrieves documents from a specified Google Drive folder
  Processes and splits documents into manageable chunks
  Extracts metadata using AI for enhanced search capabilities
  Stores document vectors in Qdrant for efficient retrieval

  Intelligent Chat Interface 💬
  Provides a conversational interface powered by Google Gemini
  Uses RAG to retrieve relevant context from stored documents
  Maintains chat history in Google Docs for reference
  Delivers accurate, context-aware responses

  Vector Store Management 🗄️
  Features secure delete operations with human verification
  Includes Telegram notifications for important operations
  Maintains data integrity with proper version control
  Supports batch processing of documents

  Setup Steps

  Configure API Credentials:
     Set up Google Drive & Docs access
     Configure Gemini AI API
     Set up Qdrant vector store connection
     Add Telegram bot for notifications
     Add OpenAI Api Key to the 'Delete Qdrant Points by File ID' node

  Configure Document Sources:
     Set Google Drive folder ID
     Define Qdrant collection name
     Set up document processing parameters

  Test and Deploy:
     Verify document processing
     Test chat functionality
     Confirm vector store operations
     Check notification system


  This workflow is ideal for organizations needing to create intelligent chatbots that can access and understand large document repositories while maintaining context and providing accurate responses through RAG technology.

nodes_used:
  ["n8n-nodes-base.telegram","n8n-nodes-base.googleDrive","n8n-nodes-base.googleDocs","@n8n/n8n-nodes-langchain.agent","@n8n/n8n-nodes-langchain.code","@n8n/n8n-nodes-langchain.embeddingsOpenAi","@n8n/n8n-nodes-langchain.lmChatOpenAi","@n8n/n8n-nodes-langchain.memoryBufferWindow","@n8n/n8n-nodes-langchain.textSplitterTokenSplitter","@n8n/n8n-nodes-langchain.documentDefaultDataLoader","@n8n/n8n-nodes-langchain.vectorStoreQdrant","@n8n/n8n-nodes-langchain.lmChatGoogleGemini","@n8n/n8n-nodes-langchain.informationExtractor"]

workflow_json:
  {"id":"8tusZTTtcyaiznEG","meta":{"instanceId":"31e69f7f4a77bf465b805824e303232f0227212ae922d12133a0f96ffeab4fef","templateCredsSetupCompleted":true},"name":"🤖 AI Powered RAG Chatbot for Your Docs + Google Drive + Gemini + Qdrant","tags":[],"nodes":[{"id":"7ad5796b-d1a0-4cc1-bed6-105ff499beeb","name":"Data Loader","type":"@n8n/n8n-nodes-langchain.documentDefaultDataLoader","position":[620,720],"parameters":{"options":{"metadata":{"metadataValues":[{"name":"file_id","value":"={{ $json.id }}"},{"name":"pubkey","value":"={{ $json.name }}"},{"name":"=overarching_theme","value":"={{ $('Extract Meta Data').item.json.output.overarching_theme }}"},{"name":"recurring_topics","value":"={{ $('Extract Meta Data').item.json.output.recurring_topics }}"},{"name":"pain_points","value":"={{ $('Extract Meta Data').item.json.output.pain_points }}"},{"name":"analytical_insights","value":"={{ $('Extract Meta Data').item.json.output.analytical_insights }}"},{"name":"conclusion","value":"={{ $('Extract Meta Data').item.json.output.conclusion }}"},{"name":"keywords","value":"={{ $('Extract Meta Data').item.json.output.keywords }}"}]}},"dataType":"binary","binaryMode":"specificField"},"typeVersion":1},{"id":"84986ee2-4d79-49e8-8778-b8a955cf2174","name":"Token Splitter","type":"@n8n/n8n-nodes-langchain.textSplitterTokenSplitter","position":[720,860],"parameters":{"chunkSize":3000},"typeVersion":1},{"id":"82aa7016-f3af-4de8-a410-b1c802041213","name":"Qdrant Vector Store","type":"@n8n/n8n-nodes-langchain.vectorStoreQdrant","onError":"continueRegularOutput","position":[540,520],"parameters":{"mode":"insert","options":{},"qdrantCollection":{"__rl":true,"mode":"id","value":"=nostr-damus-user-profiles"}},"credentials":{"qdrantApi":{"id":"DJQ4hVAVdWZytjr2","name":"QdrantApi account"}},"executeOnce":false,"retryOnFail":true,"typeVersion":1},{"id":"07f4d14a-1864-406b-946b-09c776e3038b","name":"Loop Over Items","type":"n8n-nodes-base.splitInBatches","onError":"continueRegularOutput","position":[180,-140],"parameters":{"options":{}},"typeVersion":3},{"id":"b0f9b066-62de-41bc-afce-dcb4d20d100c","name":"Wait","type":"n8n-nodes-base.wait","position":[1020,840],"webhookId":"237d7f8a-aead-479a-b813-f407d1f37fa5","parameters":{},"typeVersion":1.1},{"id":"2a883003-f5ec-409e-97e4-809360ca11ed","name":"When clicking ‘Test workflow’","type":"n8n-nodes-base.manualTrigger","position":[-1160,-280],"parameters":{},"typeVersion":1},{"id":"cfbb6b77-142f-4689-b051-436f40ababe6","name":"Google Gemini Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[1120,-20],"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":"c9c50387-64a3-473f-9ea7-509a301836a3","name":"Merge","type":"n8n-nodes-base.merge","position":[820,200],"parameters":{"mode":"combine","options":{},"combineBy":"combineAll"},"typeVersion":3},{"id":"ea143b9f-9bd8-4f3f-8979-5a0fd2691e9d","name":"Extract Meta Data","type":"@n8n/n8n-nodes-langchain.informationExtractor","position":[1020,-180],"parameters":{"text":"={{ $json.data }}","options":{"systemPromptTemplate":"You are an expert extraction algorithm.\nOnly extract relevant information from the text.\nIf you do not know the value of an attribute asked to extract, you may omit the attribute's value."},"attributes":{"attributes":[{"name":"overarching_theme","description":"Summarize the main theme(s) discussed in the \"Overarching Theme\" section."},{"name":"recurring_topics","description":"List the recurring topics mentioned in the \"Common Threads\" section as an array of strings."},{"name":"pain_points","description":"Summarize the user's frustrations or challenges mentioned in the \"Pain Points\" section as an array of strings."},{"name":"analytical_insights","description":"Extract a list of key analytical observations from the \"Analytical Insights\" section, including shifts in tone or behavior."},{"name":"conclusion","description":"Summarize the conclusions drawn about the user’s threads and their overall focus."},{"name":"keywords","description":"Generate a list of 10 keywords that capture the essence of the document (e.g., \"askNostr,\" \"decentralization,\" \"spam filtering\")."}]}},"typeVersion":1},{"id":"2ddd778f-6676-4a4b-b592-536401831bc8","name":"Get File Contents","type":"n8n-nodes-base.extractFromFile","position":[820,-180],"parameters":{"options":{},"operation":"text"},"typeVersion":1},{"id":"cdbb8bbc-967c-4f01-b844-4d31328153df","name":"Download File From Google Drive","type":"n8n-nodes-base.googleDrive","position":[500,-180],"parameters":{"fileId":{"__rl":true,"mode":"id","value":"={{ $json.id }}"},"options":{},"operation":"download"},"credentials":{"googleDriveOAuth2Api":{"id":"UhdXGYLTAJbsa0xX","name":"Google Drive account"}},"typeVersion":3},{"id":"399e196c-76ec-4077-aacc-f669173b0229","name":"Find File Ids in Google Drive Folder","type":"n8n-nodes-base.googleDrive","position":[-620,-160],"parameters":{"filter":{"driveId":{"mode":"list","value":"My Drive"},"folderId":{"__rl":true,"mode":"id","value":"={{ $json.folder_id }}"}},"options":{},"resource":"fileFolder","returnAll":true},"credentials":{"googleDriveOAuth2Api":{"id":"UhdXGYLTAJbsa0xX","name":"Google Drive account"}},"typeVersion":3},{"id":"3bc4f005-c6c8-4f73-816a-1573d6dfb62f","name":"text-embeddings-3-large","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[480,720],"parameters":{"model":"text-embedding-3-large","options":{}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1},{"id":"5d42b34a-7156-4163-a2c4-a9cb3c984c96","name":"Google Folder ID","type":"n8n-nodes-base.set","position":[-820,-160],"parameters":{"options":{},"assignments":{"assignments":[{"id":"e6f6188f-c895-4c8c-b39a-0ef55b490fd6","name":"folder_id","type":"string","value":"[Your-Google-Folder-ID]"}]}},"typeVersion":3.4},{"id":"7be310c2-d30f-42a2-8f57-33c7b184e429","name":"gpt-4o-mini1","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-400,940],"parameters":{"options":{}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1},{"id":"18aacfd9-3f6e-4fba-9f68-d8cc95bc667b","name":"Delete Qdrant Points by File ID","type":"@n8n/n8n-nodes-langchain.code","position":[-500,800],"parameters":{"code":{"execute":{"code":"const { QdrantVectorStore } = require(\"@langchain/qdrant\");\nconst { OpenAIEmbeddings } = require(\"@langchain/openai\");\n\n// Qdrant connection details\nconst url = \"http://localhost:6333/\";\nconst apiKey = \"\";\n\n// OpenAI API configuration\nconst openAIApiKey = \"[Your-OpenAI-API-Key]\";\n\n// Get input data\nconst items = this.getInputData()[0];\n// console.log(items)\n\nconst collectionName =  items.json.qdrant_collection_name;\n// console.log(collectionName)\n\nasync function deleteDocumentsFromQdrant() {\n  try {\n    // Initialize OpenAI embeddings\n    const embeddings = new OpenAIEmbeddings({\n      model: \"text-embedding-3-large\",\n      openAIApiKey: openAIApiKey\n    });\n\n    // Connect to existing Qdrant collection\n    const vectorStore = await QdrantVectorStore.fromExistingCollection(embeddings, {\n      url: url,\n      apiKey: apiKey,\n      collectionName: collectionName,\n    });\n\n    const fileIds = items.json.appended_id.map(item => item);\n\n    console.log(fileIds)\n\n    // Delete points by fileId\n    const deletionResults = await Promise.all(fileIds.map(async (file_id) => {\n      const filter = {\n        must: [\n          {\n            key: \"metadata.file_id\",\n            match: { value: file_id }\n          }\n        ]\n      };\n\n      try {\n        // Access the underlying Qdrant client to perform the deletion\n        await vectorStore.client.delete(collectionName, { filter });\n        return { file_id, status: \"deleted\" };\n      } catch (error) {\n        console.error(`Error deleting documents for fileId ${file_id}:`, error);\n        return { file_id, status: \"error\", message: error.message };\n      }\n    }));\n\n    return deletionResults;\n  } catch (error) {\n    console.error(\"An error occurred during the deletion process:\", error);\n    return error.message;\n  }\n}\n\n// Execute the deletion process\ntry {\n  const result = await deleteDocumentsFromQdrant();\n  console.log(\"Deletion process completed:\", result);\n  return [];\n} catch (error) {\n  console.error(\"Failed to execute deletion process:\", error);\n  return [{ json: { error } }];\n}\n\n"}},"inputs":{"input":[{"type":"main","required":true,"maxConnections":1},{"type":"ai_languageModel","required":true,"maxConnections":1}]},"outputs":{"output":[{"type":"main"}]}},"typeVersion":1},{"id":"329cec97-aac1-4714-97ce-add5915b1078","name":"Qdrant Collection Name","type":"n8n-nodes-base.set","position":[-700,100],"parameters":{"options":{},"assignments":{"assignments":[{"id":"11fa71e9-6cbc-4183-9439-e3379b2b970e","name":"qdrant_collection_name","type":"string","value":"nostr-damus-user-profiles"}]}},"typeVersion":3.4},{"id":"82e98da8-530d-4a3c-97e6-5e91ad644a46","name":"File Id List","type":"n8n-nodes-base.summarize","position":[-700,280],"parameters":{"options":{},"fieldsToSummarize":{"values":[{"field":"id","aggregation":"append"}]}},"typeVersion":1.1},{"id":"f3def614-2709-4847-831d-d6a80c86ec1c","name":"Merge1","type":"n8n-nodes-base.merge","position":[-340,340],"parameters":{"mode":"combine","options":{},"combineBy":"combineByPosition"},"typeVersion":3},{"id":"cfe399fb-8560-4ac4-98f7-4f539ae6a52c","name":"Merge2","type":"n8n-nodes-base.merge","position":[-80,-140],"parameters":{},"typeVersion":3},{"id":"1059da47-2abd-4884-b9c2-6b7d1623e31d","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-1280,560],"parameters":{"color":3,"width":1180,"height":760,"content":"## Prepare Qdrant Vector Store"},"typeVersion":1},{"id":"2616e08f-070e-45b5-906f-40e832519aa2","name":"Confirm Qdrant Delete Points","type":"n8n-nodes-base.telegram","position":[-1060,760],"webhookId":"29aac1ac-9345-4e44-babf-ebcfae701d88","parameters":{"chatId":"={{ $env.TELEGRAM_CHAT_ID }}","message":"=WARNING - {{ $json.appended_id.length }} Records in the Qdrant vector store collection \"{{ $json.qdrant_collection_name }}\" will be deleted.  Are you sure you want to continue?  This action cannot be undone!","options":{"limitWaitTime":{"values":{"resumeUnit":"minutes","resumeAmount":15}}},"operation":"sendAndWait","approvalOptions":{"values":{"approvalType":"double"}}},"credentials":{"telegramApi":{"id":"pAIFhguJlkO3c7aQ","name":"Telegram account"}},"typeVersion":1.2},{"id":"9d167192-e87b-41be-87f2-d7ddf866bb8d","name":"If","type":"n8n-nodes-base.if","position":[-1060,1000],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"20f530d6-fd55-420d-b8a9-70e5303f688e","operator":{"type":"boolean","operation":"true","singleValue":true},"leftValue":"={{ $json.data.approved }}","rightValue":""}]}},"typeVersion":2.2},{"id":"1178f8cf-ece0-4b11-942d-18dd025da366","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[320,420],"parameters":{"color":7,"width":920,"height":640,"content":"## Perform Qdrant Vector Store Operations"},"typeVersion":1},{"id":"cbf17a08-2f4c-4605-8418-5bf93ade7cf4","name":"Send Declined Message","type":"n8n-nodes-base.telegram","position":[-740,1120],"webhookId":"382a3b43-b83f-47b1-a276-67c6b98a441a","parameters":{"text":"Qdrant vector store upsert declined","chatId":"={{ $env.TELEGRAM_CHAT_ID }}","additionalFields":{"appendAttribution":false}},"credentials":{"telegramApi":{"id":"pAIFhguJlkO3c7aQ","name":"Telegram account"}},"typeVersion":1.2},{"id":"890f478a-e000-418d-8582-4fef946e44d8","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-900,-380],"parameters":{"width":480,"height":840,"content":"## 🌟Workflow Config\n\n- Google Drive Folder Id\n- Qdrant Collection Name\n- List of Google Drive File Id's"},"typeVersion":1},{"id":"d2bc2fed-c134-4e54-bd9d-69996be966a3","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[740,-280],"parameters":{"color":6,"width":640,"height":420,"content":"## Extract Metadata for Qdrant Hybrid Search"},"typeVersion":1},{"id":"61f3c21e-bc2a-47bc-8ab1-678b1f425ee3","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[400,-280],"parameters":{"color":2,"width":300,"height":320,"content":"## Google Drive"},"typeVersion":1},{"id":"61e608e4-ac6a-4131-9ca8-c46a5134bff9","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[80,-360],"parameters":{"color":5,"width":1360,"height":1480,"content":"## ✨ Save Documents to Qdrant Vector Store"},"typeVersion":1},{"id":"410681cb-e757-42c0-89de-902edbe998e3","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[-580,680],"parameters":{"color":5,"width":420,"height":400,"content":"## Delete From Qdrant Vector Store\nThis operation can not be undone!!!"},"typeVersion":1},{"id":"238469ce-3710-4681-b1b2-200c1b699d5e","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[-1200,640],"parameters":{"color":4,"width":380,"height":520,"content":"## Human In The Loop\nUser must verify deletion of points from Qdrant vector store"},"typeVersion":1},{"id":"0b2f6ff4-dd02-4f0e-b2eb-60b1ce736cf5","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[-1280,-380],"parameters":{"color":4,"width":340,"height":460,"content":"## 👍Start Here!"},"typeVersion":1},{"id":"abde545b-1a23-4b3e-8046-335b9d0fa445","name":"Webhook","type":"n8n-nodes-base.webhook","disabled":true,"position":[-1160,-100],"webhookId":"3a30557f-9264-4bc8-a253-a9356677c791","parameters":{"path":"upsert","options":{}},"typeVersion":2},{"id":"897d29af-719d-4fe7-93a9-44c693cc6547","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[-600,-1200],"parameters":{"text":"={{ $json.chatInput }}","options":{"systemMessage":"=You are an intelligent assistant specialized in answering user questions using Nostr user profiles. Your primary goal is to provide precise, contextually relevant, and concise answers based on the tools and resources available.\n\n### TOOL\nUse the \"nostr_damus_user_profiles\" tool to:\n- perform semantic similarity searches and retrieve information from Nostr user profiles relevant to the user's query.\n- access detailed information about Nostr and/or Damus users when additional context or specifics are required.\n\n### Key Instructions\n1. **Response Guidelines**:\n   - Clearly explain how the retrieved information addresses the user's query, if applicable.\n   - If no relevant information is found, respond with: \"I cannot find the answer in the available resources.\"\n\n2. **Focus and Relevance**:\n   - Ensure all responses are directly aligned with the user's question.\n   - Avoid including extraneous details or relying solely on internal knowledge.\n"},"promptType":"define"},"typeVersion":1.7},{"id":"316b0d8d-bbc7-4c40-b6d0-d0c762554fca","name":"Window Buffer Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[-580,-1000],"parameters":{"contextWindowLength":40},"typeVersion":1.3},{"id":"f1e342a8-d50e-48a8-9d7a-850f8be93cff","name":"When chat message received","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[-1160,-1200],"webhookId":"5f1c0c82-0ff9-40c7-9e2e-b1a96ffe24cd","parameters":{"options":{}},"typeVersion":1.1},{"id":"12902fa9-5bcb-4e8b-ac13-7f4cb6e7e1d0","name":"Google Gemini Chat Model1","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[-760,-1000],"parameters":{"options":{"maxOutputTokens":8192},"modelName":"models/gemini-2.0-flash-exp"},"credentials":{"googlePalmApi":{"id":"L9UNQHflYlyF9Ngd","name":"Google Gemini(PaLM) Api account"}},"typeVersion":1},{"id":"1c5818d4-6251-4d14-8b4f-d1f3ddfbed38","name":"text-embeddings-3-large1","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[-320,-840],"parameters":{"model":"text-embedding-3-large","options":{}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1},{"id":"80056067-5d2b-4ac7-8e69-e75bd66a1ad4","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[-900,-1300],"parameters":{"color":5,"width":860,"height":680,"content":"## 🤖Retrieve Content from Qdrant Vector Store"},"typeVersion":1},{"id":"b45b18e4-7773-4eec-837b-f43fc0eeb90c","name":"Sticky Note10","type":"n8n-nodes-base.stickyNote","position":[-1280,-1300],"parameters":{"color":4,"width":340,"height":320,"content":"## 🗣️ Chat with Your Documents"},"typeVersion":1},{"id":"8fe891dd-dee6-4abb-bc09-d90e6d7bf3cb","name":"Sticky Note11","type":"n8n-nodes-base.stickyNote","position":[-1360,-480],"parameters":{"color":7,"width":2880,"height":1880,"content":"# Step 1 - Save Documents to Qdrant Vector Store"},"typeVersion":1},{"id":"4a9bf716-3fc3-4ccc-b831-19a1afdb4588","name":"Sticky Note12","type":"n8n-nodes-base.stickyNote","position":[-1360,-1420],"parameters":{"color":7,"width":1780,"height":880,"content":"# Step 2 - Chat with Your Documents from Qdrant Vector Store"},"typeVersion":1},{"id":"fccedfde-c5aa-4237-9d1c-feb9ebabf4f3","name":"Google Drive","type":"n8n-nodes-base.googleDrive","disabled":true,"position":[120,-780],"parameters":{"name":"=Nostr Chatbot - Avatar - {{ $now }}","content":"={{ $json.output }}","driveId":{"__rl":true,"mode":"list","value":"My Drive"},"options":{},"folderId":{"__rl":true,"mode":"list","value":"root","cachedResultName":"/ (Root folder)"},"operation":"createFromText"},"credentials":{"googleDriveOAuth2Api":{"id":"UhdXGYLTAJbsa0xX","name":"Google Drive account"}},"typeVersion":3},{"id":"6d6813f6-4f2e-499a-9e5c-fe15624a91ef","name":"Respond to User","type":"n8n-nodes-base.set","position":[120,-960],"parameters":{"options":{},"assignments":{"assignments":[{"id":"cd8f88e1-19c0-4b9e-914d-e2e7ba21d9fa","name":"output","type":"string","value":"={{ $json.output }}"}]}},"typeVersion":3.4},{"id":"1c73bae9-2bdd-4383-a6f8-3cf43d3c15be","name":"Sticky Note13","type":"n8n-nodes-base.stickyNote","position":[0,-1300],"parameters":{"color":4,"width":340,"height":300,"content":"## Save Chat History"},"typeVersion":1},{"id":"db3dcc69-d1d0-48a1-b949-37f2de802b4a","name":"Update Chat History","type":"n8n-nodes-base.googleDocs","position":[120,-1200],"parameters":{"actionsUi":{"actionFields":[{"text":"=\n-------------------------------\n\n{{ $now }}\n\n{{ $('When chat message received').item.json.chatInput  }}\n\n{{ $json.output }}","action":"insert"}]},"operation":"update","documentURL":"1ej_qLolUFp1h4eZkrb99T3DWQ3JOwXVEMS3VUjWyVf0"},"credentials":{"googleDocsOAuth2Api":{"id":"YWEHuG28zOt532MQ","name":"Google Docs account"}},"typeVersion":2},{"id":"2dd28eed-b71b-44fb-bb78-8cb50b0d0c93","name":"Qdrant Vector Store Tool","type":"@n8n/n8n-nodes-langchain.vectorStoreQdrant","position":[-420,-1000],"parameters":{"mode":"retrieve-as-tool","topK":20,"options":{},"toolName":"nostr_damus_user_profiles","toolDescription":"Retrieve information about Nostr or Damus users","qdrantCollection":{"__rl":true,"mode":"list","value":"nostr-damus-user-profiles","cachedResultName":"nostr-damus-user-profiles"}},"credentials":{"qdrantApi":{"id":"DJQ4hVAVdWZytjr2","name":"QdrantApi account"}},"typeVersion":1},{"id":"3b130cf8-ab8e-4001-a3d0-a129194aee98","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","disabled":true,"position":[-760,-820],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1.2},{"id":"ccc64645-ad14-4b6b-a507-0b5fb0ac945f","name":"Send Completed Message","type":"n8n-nodes-base.telegram","position":[500,200],"webhookId":"382a3b43-b83f-47b1-a276-67c6b98a441a","parameters":{"text":"Qdrant vector store upsert completed","chatId":"={{ $env.TELEGRAM_CHAT_ID }}","additionalFields":{"appendAttribution":false}},"credentials":{"telegramApi":{"id":"pAIFhguJlkO3c7aQ","name":"Telegram account"}},"typeVersion":1.2},{"id":"885fef53-2246-45b1-a122-ab5b82374585","name":"Sticky Note14","type":"n8n-nodes-base.stickyNote","position":[-2120,-480],"parameters":{"width":700,"height":1240,"content":"# 🤖 AI-Powered RAG Chatbot with Google Drive Integration\n\nThis workflow creates a powerful RAG (Retrieval-Augmented Generation) chatbot that can process, store, and interact with documents from Google Drive using Qdrant vector storage and Google's Gemini AI.\n\n## How It Works\n\n### Document Processing & Storage 📚\n- Retrieves documents from a specified Google Drive folder\n- Processes and splits documents into manageable chunks\n- Extracts metadata using AI for enhanced search capabilities\n- Stores document vectors in Qdrant for efficient retrieval\n\n### Intelligent Chat Interface 💬\n- Provides a conversational interface powered by Google Gemini\n- Uses RAG to retrieve relevant context from stored documents\n- Maintains chat history in Google Docs for reference\n- Delivers accurate, context-aware responses\n\n### Vector Store Management 🗄️\n- Features secure delete operations with human verification\n- Includes Telegram notifications for important operations\n- Maintains data integrity with proper version control\n- Supports batch processing of documents\n\n## Setup Steps\n\n1. Configure API Credentials:\n   - Set up Google Drive & Docs access\n   - Configure Gemini AI API\n   - Set up Qdrant vector store connection\n   - Add Telegram bot for notifications\n\n2. Configure Document Sources:\n   - Set Google Drive folder ID\n   - Define Qdrant collection name\n   - Set up document processing parameters\n\n3. Test and Deploy:\n   - Verify document processing\n   - Test chat functionality\n   - Confirm vector store operations\n   - Check notification system\n\n\nThis workflow is ideal for organizations needing to create intelligent chatbots that can access and understand large document repositories while maintaining context and providing accurate responses through RAG technology.\n"},"typeVersion":1}],"active":false,"pinData":{},"settings":{"timezone":"America/Vancouver","callerPolicy":"workflowsFromSameOwner","executionOrder":"v1"},"versionId":"0c0d90e5-02f9-4169-b477-fd90c52ce44e","connections":{"If":{"main":[[{"node":"Delete Qdrant Points by File ID","type":"main","index":0}],[{"node":"Send Declined Message","type":"main","index":0}]]},"Wait":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Merge":{"main":[[{"node":"Qdrant Vector Store","type":"main","index":0}]]},"Merge1":{"main":[[{"node":"Confirm Qdrant Delete Points","type":"main","index":0}]]},"Merge2":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Webhook":{"main":[[{"node":"Google Folder ID","type":"main","index":0}]]},"AI Agent":{"main":[[{"node":"Update Chat History","type":"main","index":0},{"node":"Respond to User","type":"main","index":0}]]},"Data Loader":{"ai_document":[[{"node":"Qdrant Vector Store","type":"ai_document","index":0}]]},"File Id List":{"main":[[{"node":"Merge1","type":"main","index":1}]]},"gpt-4o-mini1":{"ai_languageModel":[[{"node":"Delete Qdrant Points by File ID","type":"ai_languageModel","index":0}]]},"Token Splitter":{"ai_textSplitter":[[{"node":"Data Loader","type":"ai_textSplitter","index":0}]]},"Loop Over Items":{"main":[[{"node":"Send Completed Message","type":"main","index":0}],[{"node":"Download File From Google Drive","type":"main","index":0}]]},"Respond to User":{"main":[[]]},"Google Folder ID":{"main":[[{"node":"Find File Ids in Google Drive Folder","type":"main","index":0}]]},"Extract Meta Data":{"main":[[{"node":"Merge","type":"main","index":0}]]},"Get File Contents":{"main":[[{"node":"Extract Meta Data","type":"main","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[]]},"Qdrant Vector Store":{"main":[[{"node":"Wait","type":"main","index":0}]]},"Update Chat History":{"main":[[]]},"Window Buffer Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Qdrant Collection Name":{"main":[[{"node":"Merge1","type":"main","index":0}]]},"text-embeddings-3-large":{"ai_embedding":[[{"node":"Qdrant Vector Store","type":"ai_embedding","index":0}]]},"Google Gemini Chat Model":{"ai_languageModel":[[{"node":"Extract Meta Data","type":"ai_languageModel","index":0}]]},"Qdrant Vector Store Tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]],"ai_vectorStore":[[]]},"text-embeddings-3-large1":{"ai_embedding":[[{"node":"Qdrant Vector Store Tool","type":"ai_embedding","index":0}]]},"Google Gemini Chat Model1":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"When chat message received":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Confirm Qdrant Delete Points":{"main":[[{"node":"If","type":"main","index":0}]]},"Delete Qdrant Points by File ID":{"main":[[{"node":"Merge2","type":"main","index":1}]]},"Download File From Google Drive":{"main":[[{"node":"Get File Contents","type":"main","index":0},{"node":"Merge","type":"main","index":1}]]},"When clicking ‘Test workflow’":{"main":[[{"node":"Google Folder ID","type":"main","index":0}]]},"Find File Ids in Google Drive Folder":{"main":[[{"node":"File Id List","type":"main","index":0},{"node":"Qdrant Collection Name","type":"main","index":0},{"node":"Merge2","type":"main","index":0}]]}}}


name: All-in-One Telegram/Baserow AI Assistant 🤖🧠 Voice/Photo/Save Notes/Long Term Mem
author_name: Rod
author_username: xxbean-sproutxx
categories: []
created_at: 2025-02-23T09:02:25.572Z
updated_at: 2025-02-23T09:02:25.572Z
url: https://n8n.io/workflows/2986
scraped_at: 2025-06-19 22:50:19
description:
  Telegram Personal Assistant with Long-Term Memory & Note-Taking

  This n8n workflow transforms your Telegram bot into a powerful personal assistant that handles voice, photo, and text messages. The assistant uses AI to interpret messages, save important details as long-term memories or notes in a Baserow database, and recall information for future interactions.

  🌟 How It Works

  Message Reception & Routing  
     Telegram Integration: The workflow is triggered by incoming messages on your Telegram bot.  
     Dynamic Routing: A switch node inspects the message to determine whether it's voice, text, or photo (with captions) and routes it for the appropriate processing.

  Content Processing  
     Voice Messages: Audio files are retrieved and sent to an AI transcription node to convert spoken words into text.  
     Text Messages: Text is directly captured and prepared for analysis.  
     Photos: If an image is received, the bot fetches the file (and caption, if provided) and uses an AI-powered image analysis node to extract relevant details.

  AI-Powered Agent & Memory Management  
     The core AI agent (powered by GPT-4o-mini) processes the incoming message along with any previous conversation history stored in PostgreSQL memory buffers.  
     Long-Term Memory: When a message contains personal or noteworthy information, the assistant uses a dedicated tool to save this data as a long-term memory in Baserow.  
     Note-Taking: For specific instructions or reminders, the assistant saves concise notes in a separate Baserow table.  
     The AI agent follows defined rules to decide which details are saved as memories and which are saved as notes.

  Response Generation  
     After processing the message and updating memory/notes as needed, the AI agent crafts a contextual and personalized response.  
     The response is sent back to the user via Telegram, ensuring smooth and natural conversation flow.

  🚀 Key Features

  Multimodal Input:**  
    Seamlessly handles voice, photo (with captions), and text messages.

  Long-Term Memory & Note-Taking:**  
    Uses a Baserow database to store personal details and notes, enhancing conversational context over time.

  AI-Driven Contextual Responses:**  
    Leverages an AI agent to generate personalized, context-aware replies based on current input and past interactions.

  User Security & Validation:**  
    Incorporates validation steps to verify the user's Telegram ID before processing, ensuring secure and personalized interactions.

  Easy Baserow Setup:**  
    Comes with a clear setup guide and sample configurations to quickly integrate Baserow for managing memories and notes.

  🔧 Setup Guide

  Telegram Bot Setup:  
     Create your bot via BotFather and obtain the Bot Token.  
     Configure the Telegram webhook in n8n with your bot's token and URL.

  Baserow Database Configuration:  
     Memory Table:  
       Create a workspace titled "Memories and Notes".  
       Set up a table (e.g., "Memory Table") with at least two fields:  
         Memory (long text)  
         Date Added (US date format with time)  
     Notes Table:  
       Duplicate the Memory Table and rename it to "Notes Table".  
       Change the first field's name from "Memory" to "Notes".

  n8n Workflow Import & Configuration:  
     Import the workflow JSON into your n8n instance.  
     Update credentials for Telegram, Baserow, OpenAI, and PostgreSQL (for memory buffering) as needed.
     Adjust node settings if you need to customize AI agent prompts or memory management rules.

  Testing & Deployment:  
     Test your bot by sending various message types (text, voice, photo) to confirm that the workflow processes them correctly, updates Baserow, and returns the appropriate response.  
     Monitor logs to ensure that memory and note entries are correctly stored and retrieved.

  ✨ Example Interactions

  Voice Message Processing:**  
    User sends a voice note requesting a reminder.  
    Bot Response: "Thanks for your message! I've noted your reminder and saved it for future reference."

  Photo with Caption:**  
    User sends a photo with the caption "Save this recipe for dinner ideas."  
    Bot Response: "Got it! I've saved this recipe along with the caption for you."

  Text Message for Memory Saving:**  
    User: "I love hiking on weekends."  
    Bot Response: "Noted! I’ll remember your interest in hiking."

  Retrieving Information:**  
    User asks: "What notes do I have?"  
    Bot Response: "Here are your latest notes: [list of saved notes]."

  🛠️ Resources & Next Steps

  Telegram Bot Configuration:** Telegram BotFather Guide  
  n8n Documentation:** n8n Docs  
  Community Forums:** Join discussions and share your customizations!

  This workflow not only streamlines message processing but also empowers users with a personal AI assistant that remembers details over time. Customize the rules and responses further to fit your unique requirements and enjoy a more engaging, intelligent conversation experience on Telegram!

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

workflow_json:
  {"id":"Dctc6QKyRXK17oEq","meta":{"instanceId":"ca87034fd2d5cf9c52373260a6e37ca15a4a059ecc2971ac41c079ce4aa21138","templateCredsSetupCompleted":true},"name":"All-in-One Telegram/Baserow AI Assistant 🤖🧠 Voice/Photo/Save Notes/Long Term Mem","tags":[],"nodes":[{"id":"bbcaac28-f07c-421b-91c6-e3b2d024a71f","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[-900,80],"parameters":{"color":4,"width":340,"height":380,"content":"## Retrieve Long Term Memories\nBaserow"},"typeVersion":1},{"id":"399c0a44-72b5-4e71-b578-3e4eb8087b3c","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[-180,420],"parameters":{"width":280,"height":380,"content":"## Save To Current Chat Memory"},"typeVersion":1},{"id":"d0438c1d-42e4-47d0-b23b-78f9cee5a28c","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[140,420],"parameters":{"color":4,"width":280,"height":380,"content":"## Save Long Term Memories\nBaserow"},"typeVersion":1},{"id":"d8cbf733-2a69-45d5-9767-43e8c67a43ee","name":"gpt-4o-mini","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-400,580],"parameters":{"options":{}},"credentials":{"openAiApi":{"id":"lpt7A1AOIMshaaE7","name":"OpenAi account"}},"typeVersion":1.1},{"id":"3cd6b923-b369-45e6-a3c1-5fff74a3074c","name":"Chat Response","type":"n8n-nodes-base.set","position":[220,160],"parameters":{"options":{},"assignments":{"assignments":[{"id":"d6f68b1c-a6a6-44d4-8686-dc4dcdde4767","name":"output","type":"string","value":"={{ $json.output }}"}]}},"typeVersion":3.4},{"id":"912bf06d-ae8f-4513-a0c9-83c1edb1c159","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-500,420],"parameters":{"color":3,"width":280,"height":380,"content":"## LLM"},"typeVersion":1},{"id":"d5cf2019-d9bb-4fb6-b95c-e9e9f9ac5808","name":"Telegram Response","type":"n8n-nodes-base.telegram","position":[560,180],"webhookId":"2ae9d05c-68e8-440a-9f13-08e5ef92bf6c","parameters":{"text":"={{ $json.output }}","chatId":"={{ $('Listen for Telegram Events').item.json.body.message.chat.id }}","additionalFields":{"parse_mode":"HTML","appendAttribution":false}},"credentials":{"telegramApi":{"id":"EDuT6lIMLHRxdqqN","name":"Telegram account"}},"typeVersion":1.2},{"id":"0858e353-8d83-437c-90bc-f57b31e92d1c","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[440,60],"parameters":{"width":360,"height":300,"content":"## Telegram \n(Optional)"},"typeVersion":1},{"id":"c315e630-2ed3-4141-a715-ab08849336be","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-540,80],"parameters":{"color":5,"width":1320,"height":780,"content":"## AI AGENT with Long Term Memory & Note Storage"},"typeVersion":1},{"id":"2d09319d-f3be-43b8-a134-929992d4f469","name":"AI Tools Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[-140,180],"parameters":{"text":"={{\n  (() => {\n    try {\n      return $('Edit Fields').item.json.text;\n    } catch (e) {\n      return undefined;\n    }\n  })() ||\n  (() => {\n    try {\n      return $('Edit Fields1').item.json.text;\n    } catch (e) {\n      return undefined;\n    }\n  })() ||\n  (() => {\n    try {\n      return $('Transcribe Recording').item.json.text;\n    } catch (e) {\n      return undefined;\n    }\n  })() ||\n  'default value' // optional default if all are undefined\n}}\n","options":{"systemMessage":"=## ROLE  \nYou are a friendly, attentive, and helpful AI assistant. Your primary goal is to assist the user while maintaining a personalized and engaging interaction. When possible, address the user by their first name to create a warmer, more personal experience.\n\n---\n\n## KEY TOOLS: MEMORY & NOTE MANAGEMENT\n\nThese are the core features of this workflow. **You do not need permission to save notes and memories; it’s your decision based on the conversation.**\n\n### Memory Management  \n- **When to Use:**  \n  Evaluate each incoming message for noteworthy or personal information (e.g., preferences, habits, goals, important events, etc.).  \n- **Action:**  \n  If the message contains such details, autonomously use the **Save Memory** Baserow tool to store a clear, concise summary.  \n- **Response:**  \n  Always provide a meaningful reply that naturally acknowledges the input without revealing that a memory was saved.\n\n### Note Management  \n- **When to Use:**  \n  If the user shares specific instructions, reminders, or standalone pieces of information meant to be retained, use the **Save Note** Baserow tool.  \n- **Action:**  \n  Save these as concise notes without asking for permission.  \n- **Response:**  \n  Your reply should integrate the note context naturally, ensuring that the note’s purpose is honored without overemphasizing the saving action.\n\n---\n\n## GENERAL RULES\n\n1. **Context Awareness:**  \n   - Use stored memories and notes to craft contextually relevant and personalized responses.  \n   - Always consider the date and time when a memory or note was collected to ensure your responses are up-to-date.\n\n2. **User-Centric Responses:**  \n   - Tailor your responses based on the user's preferences and past interactions.  \n   - If the user’s first name is provided in the user info section, address them by name when it feels natural and appropriate.  \n   - Be proactive in recalling relevant details from memory or notes without overwhelming the conversation.\n\n3. **Privacy and Sensitivity:**  \n   - Handle all user data with care. Do not share or expose stored information unless it directly enhances the interaction.  \n   - Never store passwords or usernames.\n\n4. **Fallback Responses:**  \n   - If no specific task or question arises (e.g., when only saving information), respond in a way that keeps the conversation flowing naturally:  \n     - “Thanks for sharing that, [First Name]! Is there anything else I can help you with today?”  \n   - DO NOT tell jokes as a fallback response.\n\n5. **Additional Tools:**  \n   - The remaining tools (Contacts, Calendar, Web Search, Qdrant Vector Retrieval) are available as extra features. They can be used when relevant but are secondary to the core Memory and Note management functionalities.\n\n---\n\n## USER INFO\n\n- **First Name**: {{ $('Listen for Telegram Events').item.json.body.message.from.first_name }}\n- **Age**: (if provided)  \n- **Location**: (if provided)  \n- **Job/Profession**: (if provided)\n\nUtilize this information to personalize your responses. For example, if the user's first name is available, begin responses with “Hi [First Name], …”\n\n---\n\n## REMAINING TOOLS\n\n### <More Tools>\n- <if you add more tools, add them here and add descriptions>\n\n---\n\n## MEMORIES  \n\n### Recent Noteworthy Memories  \nHere are the most recent memories collected from the user, including their date and time of collection:  \n\n**{{  \n  $json.data.map(item => item.Memory).join('\\n')  \n}}**\n\n**Guidelines:**  \n- Prioritize recent memories while considering older ones if still relevant.  \n- Cross-reference memories for consistency (e.g., if conflicting details are present, clarify as needed).\n\n---\n\n## NOTES  \n\n### Recent Notes Collected from User:  \nHere are the most recent notes collected from the user:  \n\n**{{  \n  $json.data.map(item => item.Notes).join('\\n')  \n}}**\n\n**Guidelines:**  \n- Use notes for specific instructions or reminders.  \n- Keep note content distinct from general memory content.\n\n---\n\n## ADDITIONAL INSTRUCTIONS  \n\n- Think critically before responding to ensure your answers are thoughtful and accurate.  \n- Strive to build trust with the user by being consistent, reliable, and personable.  \n- Avoid robotic or overly formal language; aim for a conversational tone that is both friendly and helpful.\n\n## CURRENT DATE\n\n - {{ $now.setZone('America/Chicago').toISO() }} (Set Timezone Accordingly) \n"},"promptType":"define"},"typeVersion":1.7,"alwaysOutputData":false},{"id":"4a5a636a-e526-4b0f-bf11-8cd623e46c68","name":"Sticky Note10","type":"n8n-nodes-base.stickyNote","position":[460,420],"parameters":{"color":4,"width":280,"height":380,"content":"## Save Notes\nBaserow"},"typeVersion":1},{"id":"46cb38d9-4932-481e-96f2-14b3224de0a9","name":"Sticky Note11","type":"n8n-nodes-base.stickyNote","position":[-900,480],"parameters":{"color":4,"width":340,"height":380,"content":"## Retrieve Notes\nBaserow"},"typeVersion":1},{"id":"c643683f-eee6-49c2-9f1a-05ba9a0742a6","name":"Aggregate","type":"n8n-nodes-base.aggregate","position":[-320,180],"parameters":{"options":{},"aggregate":"aggregateAllItemData"},"typeVersion":1},{"id":"cdd999a7-d14f-4e20-88ea-4170c8cd521c","name":"Merge","type":"n8n-nodes-base.merge","position":[-480,180],"parameters":{},"typeVersion":3},{"id":"a60582a7-63ca-497e-aec0-2be8077ebc53","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-2160,180],"parameters":{"color":7,"width":420,"height":260,"content":"## Validate Telegram User\n"},"typeVersion":1},{"id":"3b3b2573-5a2e-4c0f-8005-376ed55b068b","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-2220,780],"parameters":{"color":6,"width":1289,"height":432,"content":"# Process Image"},"typeVersion":1},{"id":"3d27c492-758b-45d2-bc79-a51cc69ac2ef","name":"Get Audio File","type":"n8n-nodes-base.telegram","position":[-1380,180],"webhookId":"4f5c2290-ff1a-4ce0-8319-e84807b1b1fc","parameters":{"fileId":"={{ $json.body.message.voice.file_id }}","resource":"file"},"credentials":{"telegramApi":{"id":"EDuT6lIMLHRxdqqN","name":"Telegram account"}},"typeVersion":1.2},{"id":"9bef0848-30a5-4e98-b0e8-640e061c475d","name":"Analyze Image","type":"@n8n/n8n-nodes-langchain.openAi","position":[-1460,1000],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"GPT-4O-MINI"},"options":{},"resource":"image","inputType":"base64","operation":"analyze"},"credentials":{"openAiApi":{"id":"lpt7A1AOIMshaaE7","name":"OpenAi account"}},"typeVersion":1.6},{"id":"b493ea36-c9f6-470d-97a9-8df43c10af18","name":"Transcribe Recording","type":"@n8n/n8n-nodes-langchain.openAi","position":[-1100,180],"parameters":{"options":{},"resource":"audio","operation":"transcribe","binaryPropertyName":"=data"},"credentials":{"openAiApi":{"id":"lpt7A1AOIMshaaE7","name":"OpenAi account"}},"typeVersion":1.6},{"id":"05aff1e5-daf0-47d3-8df3-a548ca4ca2cd","name":"Edit Fields","type":"n8n-nodes-base.set","position":[-1240,540],"parameters":{"options":{},"assignments":{"assignments":[{"id":"b37b48ba-8fef-4e6c-bbca-73e6c2e1e0a8","name":"text","type":"string","value":"={{ $json.body.message.text }}"}]}},"typeVersion":3.4},{"id":"ea70790d-716b-4f5d-b3d0-99259481ef22","name":"Convert to Image File","type":"n8n-nodes-base.convertToFile","position":[-1640,1000],"parameters":{"options":{"fileName":"={{ $json.result.file_path }}"},"operation":"toBinary","sourceProperty":"data"},"typeVersion":1.1},{"id":"3e5913bf-0270-4e32-8647-80138abefde5","name":"Extract from File to Base64","type":"n8n-nodes-base.extractFromFile","position":[-1820,1000],"parameters":{"options":{},"operation":"binaryToPropery"},"typeVersion":1},{"id":"7d13ffbe-9496-4037-a7f2-d7b5774698ca","name":"Sticky Note12","type":"n8n-nodes-base.stickyNote","position":[-1440,80],"parameters":{"color":6,"width":513,"height":309,"content":"# Process Audio"},"typeVersion":1},{"id":"73570d5a-87a6-4d1f-95f3-2b8ed087a28a","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[-1440,420],"parameters":{"color":6,"width":513,"height":329,"content":"# Process Text"},"typeVersion":1},{"id":"f8851e90-d710-4bc6-9705-af4828d65a48","name":"Message Router","type":"n8n-nodes-base.switch","position":[-1880,480],"parameters":{"rules":{"values":[{"outputKey":"audio","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"operator":{"type":"object","operation":"exists","singleValue":true},"leftValue":"={{ $json.body.message.voice }}","rightValue":""}]},"renameOutput":true},{"outputKey":"text","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"342f0883-d959-44a2-b80d-379e39c76218","operator":{"type":"string","operation":"exists","singleValue":true},"leftValue":"={{ $json.body.message.text }}","rightValue":""}]},"renameOutput":true},{"outputKey":"image","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"ded3a600-f861-413a-8892-3fc5ea935ecb","operator":{"type":"array","operation":"exists","singleValue":true},"leftValue":"={{ $json.body.message.photo }}","rightValue":""}]},"renameOutput":true}]},"options":{"fallbackOutput":"extra"}},"typeVersion":3.2},{"id":"88127339-2cc5-4364-9f27-6dea9df505ff","name":"Image Schema1","type":"n8n-nodes-base.set","position":[-2160,880],"parameters":{"options":{},"assignments":{"assignments":[{"id":"17989eb0-feca-4631-b5c8-34b1d4a6c72b","name":"image_file_id","type":"string","value":"={{ $json.body.message.photo.last().file_id }}"},{"id":"9317d7ae-dffd-4b1f-9a9c-b3cc4f1e0dd3","name":"caption","type":"string","value":"={{ $json.body.message.caption }}"}]}},"typeVersion":3.4},{"id":"b0922d42-9864-4d9a-a5c9-b674892935ff","name":"caption","type":"n8n-nodes-base.splitOut","position":[-1460,860],"parameters":{"options":{},"fieldToSplitOut":"caption"},"typeVersion":1},{"id":"74256b12-6f3b-44ba-a98b-bd233f90c360","name":"Merge1","type":"n8n-nodes-base.merge","position":[-1260,860],"parameters":{"mode":"combine","options":{},"combineBy":"combineByPosition"},"typeVersion":3},{"id":"9f77577b-167c-4628-b2d1-37e17d9ddb10","name":"Get Image","type":"n8n-nodes-base.telegram","position":[-2000,1000],"webhookId":"2d9b0a49-b46f-4794-9f4b-f406a213e74a","parameters":{"fileId":"={{ $json.image_file_id }}","resource":"file"},"credentials":{"telegramApi":{"id":"EDuT6lIMLHRxdqqN","name":"Telegram account"}},"typeVersion":1.2},{"id":"ffdf119a-cfa1-408a-aaca-458691f8d56b","name":"Edit Fields1","type":"n8n-nodes-base.set","position":[-1100,860],"parameters":{"options":{},"assignments":{"assignments":[{"id":"b37b48ba-8fef-4e6c-bbca-73e6c2e1e0a8","name":"text","type":"string","value":"={{ $json.caption }}\n\n{{ $json.content }}"}]}},"typeVersion":3.4},{"id":"2b750b39-c72a-46ae-8e3f-0060181d2a51","name":"Sticky Note13","type":"n8n-nodes-base.stickyNote","position":[-2220,80],"parameters":{"color":4,"width":753,"height":669,"content":"# Secure User"},"typeVersion":1},{"id":"18fcbf54-301e-449b-bb67-7f63753ac4c5","name":"Sticky Note14","type":"n8n-nodes-base.stickyNote","position":[-1720,60],"parameters":{"color":3,"width":273,"height":269,"content":"# Error\n"},"typeVersion":1},{"id":"8d7824b1-92d0-4907-8468-1d04e7d40d6c","name":"Postgres Chat Memory","type":"@n8n/n8n-nodes-langchain.memoryPostgresChat","position":[-20,540],"parameters":{"sessionKey":"={{ $('Listen for Telegram Events').item.json.body.message.from.id }}","sessionIdType":"customKey","contextWindowLength":50},"credentials":{"postgres":{"id":"aVzWyCraiN3kiV5K","name":"Postgres account"}},"typeVersion":1.3},{"id":"f21c0dfa-d16a-461d-9ff3-8b9932e8abb6","name":"Save Note Tool","type":"n8n-nodes-base.baserowTool","position":[560,600],"parameters":{"tableId":640,"fieldsUi":{"fieldValues":[{"fieldId":6025,"fieldValue":"={{ $fromAI('notes', `note to be created`, 'string') }}"},{"fieldId":6027,"fieldValue":"={{ $fromAI('date-added', 'date created', 'string') }}"}]},"operation":"create","databaseId":122,"descriptionType":"manual","toolDescription":"Save Notes"},"credentials":{"baserowApi":{"id":"1YeHyTi4fmB007co","name":"Baserow account"}},"typeVersion":1},{"id":"242ff3e7-3421-4bc4-a877-0164cee7cd69","name":"Save Memory","type":"n8n-nodes-base.baserowTool","position":[240,600],"parameters":{"tableId":639,"fieldsUi":{"fieldValues":[{"fieldId":6022,"fieldValue":"={{ $fromAI('memory', 'memory to be created', 'string') }}"},{"fieldId":6024,"fieldValue":"={{ $fromAI('date-added', 'date created', 'string') }}"}]},"operation":"create","databaseId":122,"descriptionType":"manual","toolDescription":"Save Long Term Memories"},"credentials":{"baserowApi":{"id":"1YeHyTi4fmB007co","name":"Baserow account"}},"typeVersion":1},{"id":"f681f671-7759-46ba-b674-5b8b0e385d09","name":"Listen for Telegram Events","type":"n8n-nodes-base.webhook","position":[-2380,240],"webhookId":"097f36f3-1574-44f9-815f-58387e3b20bf","parameters":{"path":"gram","options":{"binaryPropertyName":"data"},"httpMethod":"POST"},"typeVersion":2},{"id":"959a8a01-0fb9-4bc9-9997-cc49b3a81216","name":"Validation","type":"n8n-nodes-base.set","position":[-2100,240],"parameters":{"options":{},"assignments":{"assignments":[{"id":"0cea6da1-652a-4c1e-94c3-30608ced90f8","name":"first_name","type":"string","value":"[Your First Name on Telegram]"},{"id":"b90280c6-3e36-49ca-9e7e-e15c42d256cc","name":"last_name","type":"string","value":"[Your Last Name on Telegram]"},{"id":"f6d86283-16ca-447e-8427-7d3d190babc0","name":"id","type":"number","value":1122334455}]},"includeOtherFields":true},"typeVersion":3.4},{"id":"7903c22c-26f2-4e89-9e27-ee945e225b0e","name":"Check User & Chat ID","type":"n8n-nodes-base.if","position":[-1920,240],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"5fe3c0d8-bd61-4943-b152-9e6315134520","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $('Listen for Telegram Events').item.json.body.message.chat.first_name }}","rightValue":"={{ $json.first_name }}"},{"id":"98a0ea91-0567-459c-bbce-06abc14a49ce","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $('Listen for Telegram Events').item.json.body.message.chat.last_name }}","rightValue":"={{ $json.last_name }}"},{"id":"18a96c1f-f2a0-4a2a-b789-606763df4423","operator":{"type":"number","operation":"equals"},"leftValue":"={{ $('Listen for Telegram Events').item.json.body.message.chat.id }}","rightValue":"={{ $json.id }}"}]},"looseTypeValidation":"="},"typeVersion":2.2},{"id":"262c2621-5499-4481-ad94-97650b0f9714","name":"Sticky Note15","type":"n8n-nodes-base.stickyNote","position":[-2460,160],"parameters":{"color":6,"width":273,"height":269,"content":"# Start Here"},"typeVersion":1},{"id":"1cc31571-7d01-4cac-81a0-8cb6691ef1ed","name":"Error message","type":"n8n-nodes-base.telegram","position":[-1640,160],"webhookId":"b3b41cd7-40d9-47dc-817a-291733213c8b","parameters":{"text":"=Unable to process your message.","chatId":"={{ $json.body.message.chat.id }}","additionalFields":{"appendAttribution":false}},"credentials":{"telegramApi":{"id":"EDuT6lIMLHRxdqqN","name":"Telegram account"}},"typeVersion":1.2},{"id":"72b0fd9e-a82c-455b-a1d7-face4a9d55b4","name":"Baserow Retrieve Memories","type":"n8n-nodes-base.baserow","position":[-780,220],"parameters":{"tableId":639,"returnAll":true,"databaseId":122,"additionalOptions":{}},"credentials":{"baserowApi":{"id":"1YeHyTi4fmB007co","name":"Baserow account"}},"typeVersion":1},{"id":"40618bf6-657a-4b8a-818b-90b5e7aecbd5","name":"Baserow Retrieve Notes","type":"n8n-nodes-base.baserow","position":[-780,620],"parameters":{"tableId":640,"returnAll":true,"databaseId":122,"additionalOptions":{}},"credentials":{"baserowApi":{"id":"1YeHyTi4fmB007co","name":"Baserow account"}},"typeVersion":1},{"id":"87bfdbe7-bf2f-40d8-8fb5-c0c0015d8a10","name":"Window Memory (Easy Mode)","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[-140,640],"parameters":{"sessionKey":"={{ $('Listen for Telegram Events').item.json.body.message.from.id }}","sessionIdType":"customKey","contextWindowLength":50},"typeVersion":1.3},{"id":"02f650e9-3d8d-4622-9cd9-16154d4d27c5","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[300,820],"parameters":{"width":280,"height":520,"content":"## Baserow Set-up:\n- Create a new Workspace called \"Memories and Notes\"\n- Create a table within the new workspace called \"Memory Table\"\n- Within the \"Memory Table\" table, create two fields\n- First field is called \"Memory\" (select \"long text\" as the field type)\n- Second field is called \"Date Added\" (select 'US' date format, and check include time\n\n## Notes Setup:\n- For the notes table we can simply \"Duplicate\" the \"Memory Table\" table that we just created\n- Rename the table to \"Notes Table\" \n- Rename the first from \"Memory\" to \"Notes\"\n- **Make sure time and date are on and set correctly in \"Date Added\" field.**"},"typeVersion":1},{"id":"26efbccd-7605-4308-85d2-c91cdd4897ad","name":"Sticky Note16","type":"n8n-nodes-base.stickyNote","position":[580,840],"parameters":{"color":6,"width":720,"height":1180,"content":"## Baserow Memory Table Setup:\n![Baserow example 1](https://i.imgur.com/hXADtza.png)\n## Name first field \"Memory\" and set to \"Long Text\":\n![Baserow example 2](https://i.imgur.com/AJG0jO6.png)\n## Name second field \"Date Added\" and set to 'US' date format\n![Baserow example 2](https://i.imgur.com/z8AJWfB.png)\n"},"typeVersion":1},{"id":"d30c8a6a-4668-49f9-8555-0f827d8157c0","name":"Sticky Note17","type":"n8n-nodes-base.stickyNote","position":[1300,860],"parameters":{"color":5,"width":540,"height":1120,"content":"## Tool node Setup Example:\n![Baserow example 2](https://i.imgur.com/DQ6jolu.png)"},"typeVersion":1},{"id":"54dce9dd-f06c-4e61-9a96-b691fe76dfa3","name":"Sticky Note18","type":"n8n-nodes-base.stickyNote","position":[-2120,400],"parameters":{"width":150,"height":80,"content":"## *Setup validation"},"typeVersion":1},{"id":"9166bd3d-2f21-4f19-b787-ccf9be5b5acc","name":"Sticky Note19","type":"n8n-nodes-base.stickyNote","position":[-120,140],"parameters":{"width":200,"height":120,"content":"## *Setup Prompt\n"},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"755d754f-9577-41b2-ae5c-1f0918389fc6","connections":{"Merge":{"main":[[{"node":"Aggregate","type":"main","index":0}]]},"Merge1":{"main":[[{"node":"Edit Fields1","type":"main","index":0}]]},"caption":{"main":[[{"node":"Merge1","type":"main","index":0}]]},"Aggregate":{"main":[[{"node":"AI Tools Agent","type":"main","index":0}]]},"Get Image":{"main":[[{"node":"Extract from File to Base64","type":"main","index":0}]]},"Validation":{"main":[[{"node":"Check User & Chat ID","type":"main","index":0}]]},"Edit Fields":{"main":[[{"node":"Baserow Retrieve Memories","type":"main","index":0},{"node":"Baserow Retrieve Notes","type":"main","index":0}]]},"Save Memory":{"ai_tool":[[{"node":"AI Tools Agent","type":"ai_tool","index":0}]]},"gpt-4o-mini":{"ai_languageModel":[[{"node":"AI Tools Agent","type":"ai_languageModel","index":0}]]},"Edit Fields1":{"main":[[{"node":"Baserow Retrieve Memories","type":"main","index":0},{"node":"Baserow Retrieve Notes","type":"main","index":0}]]},"Analyze Image":{"main":[[{"node":"Merge1","type":"main","index":1}]]},"Image Schema1":{"main":[[{"node":"Get Image","type":"main","index":0},{"node":"caption","type":"main","index":0}]]},"AI Tools Agent":{"main":[[{"node":"Telegram Response","type":"main","index":0},{"node":"Chat Response","type":"main","index":0}]]},"Get Audio File":{"main":[[{"node":"Transcribe Recording","type":"main","index":0}]]},"Message Router":{"main":[[{"node":"Get Audio File","type":"main","index":0}],[{"node":"Edit Fields","type":"main","index":0}],[{"node":"Image Schema1","type":"main","index":0}],[{"node":"Error message","type":"main","index":0}]]},"Save Note Tool":{"ai_tool":[[{"node":"AI Tools Agent","type":"ai_tool","index":0}]]},"Check User & Chat ID":{"main":[[{"node":"Message Router","type":"main","index":0}],[{"node":"Error message","type":"main","index":0}]]},"Postgres Chat Memory":{"ai_memory":[[{"node":"AI Tools Agent","type":"ai_memory","index":0}]]},"Transcribe Recording":{"main":[[{"node":"Baserow Retrieve Memories","type":"main","index":0},{"node":"Baserow Retrieve Notes","type":"main","index":0}]]},"Convert to Image File":{"main":[[{"node":"Analyze Image","type":"main","index":0}]]},"Baserow Retrieve Notes":{"main":[[{"node":"Merge","type":"main","index":1}]]},"Baserow Retrieve Memories":{"main":[[{"node":"Merge","type":"main","index":0}]]},"Listen for Telegram Events":{"main":[[{"node":"Validation","type":"main","index":0}]]},"Extract from File to Base64":{"main":[[{"node":"Convert to Image File","type":"main","index":0}]]}}}


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-06-19 22:50:09
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-06-19 22:50:00
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-06-19 22:49:56
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-06-19 22:48:52
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: Telegram Bot with Menu-Driven Commands
author_name: Daniel Jimenez
author_username: ldaniel-jmz
nodes_used: ["n8n-nodes-base.telegram","n8n-nodes-base.code"]
categories: []
created_at: 2025-03-01T18:53:19.378Z
updated_at: 2025-03-01T18:53:19.378Z
url: https://n8n.io/workflows/3055
scraped_at: 2025-06-19 22:50:40
description:
  This template provides a structured way to build Telegram bots that respond to specific commands and handle user input. It allows users to interact with your bot by selecting options from a Telegram bot menu, without needing to type out full instructions or rely on conversational AI. This approach offers precise control and predictable behavior for command-driven interactions.

  Key Features:

  🤖 Structured Command Handling: Unlike approaches that rely on conversational AI (like the "AI Agent" node), this template provides a deterministic way to handle specific commands triggered by users selecting options from a Telegram bot menu. Users do not need to write out full instructions.
  ➕ Command-Based Interaction (Extensible): Ready to process three commands (/command1, /command2, /command3), and easily extensible to support additional commands.
  🚦 Clear Command Routing: Employs Switch nodes to efficiently route execution based on both the initial command and the current conversation state.
  💬 Content Requesting: Prompts the user to provide content after a command is received. This is handled by dedicated Telegram nodes.
  🛠️ Easy Customization: Includes placeholder (No Operation, do nothing) nodes where you can easily insert your own custom processing logic for each command.

  Why This Template is Unique:

  n8n currently lacks a native, built-in mechanism for handling individual Telegram commands in a structured, non-conversational way. Many users resort to "AI Agent" nodes, which are designed for open-ended conversations. This template fills that gap by providing a framework for:

  ✅ Predefined Commands: Users interact with your bot through a menu of predefined commands, eliminating the need for complex natural language processing.
  🧠 Deterministic Behavior: The workflow's response is predictable and directly tied to the selected command, unlike AI-driven approaches where responses can be less consistent.
  🖱️ Simplified Interaction: Users simply click a button in the Telegram menu, making the interaction intuitive and user-friendly.

  How to Use:

  Initialization (One-Time): Execute the "Temp to Initiate Static Data" node once to create the necessary telegramStates object in the workflow's static data. This is crucial for state management.
  Customize Processing Logic: Replace the NoOp nodes (Command1 processing, Command2 processing, Command3 processing) with your own nodes to handle the content received for each command. It is highly recommended to add input validation within your processing logic.
  Telegram Credentials: Configure the Telegram Trigger and Telegram nodes with your bot's API token.

  Example Use Case:

  This template is ideal for creating bots that require a command followed by specific input, such as:

  📊 Data Collection: A command to initiate a form, followed by a request for the data.
  🛠️ Service Requests: A command to request a service, followed by a request for details.
  📚 Interactive Tutorials: A command to start a tutorial, followed by a request of completion.

workflow_json:
  {"id":"eEmBseW5YPdHz35S","meta":{"instanceId":"6c95892900403ee6d5a67d4e34c6cfd2346cc00474b9c722851858297e8e52b2","templateCredsSetupCompleted":true},"name":"AA - Telegram bot 3 commands (for template)","tags":[],"nodes":[{"id":"b45285b7-5d2e-4f87-b796-b4db51416dcb","name":"Telegram Trigger","type":"n8n-nodes-base.telegramTrigger","position":[-460,200],"webhookId":"30a3f361-4607-40f0-bc7e-d1fb385430d2","parameters":{},"typeVersion":1},{"id":"bcdab8f6-7844-45b9-a4b1-6c7b4e7db34e","name":"Switch (Command Routing)","type":"n8n-nodes-base.switch","position":[-40,160],"parameters":{},"typeVersion":3.2},{"id":"f355edc9-07f7-409f-9f03-6d2895b49a53","name":"Temp to Initiate Static Data","type":"n8n-nodes-base.code","notes":"You only need to run the initialization step once per workflow, regardless of the number of Telegram chat IDs. The initialization creates the telegramStates object within the global static data of the workflow. Once that object exists, the workflow will use it to store the state for any chat ID.","position":[-460,-300],"parameters":{},"notesInFlow":false,"typeVersion":2},{"id":"c99b639e-d184-481d-9871-7dd4416836d2","name":"Check State","type":"n8n-nodes-base.switch","position":[-20,880],"parameters":{},"typeVersion":3.2},{"id":"a9d01dd0-0927-4c58-9866-1230af22e965","name":"Clear State","type":"n8n-nodes-base.code","position":[920,760],"parameters":{},"typeVersion":2},{"id":"6389f680-fa93-4e8f-95ff-0e21f11af087","name":"Set waitingForContent1","type":"n8n-nodes-base.code","position":[240,-340],"parameters":{},"typeVersion":2},{"id":"549abb7a-c688-4cc1-91e1-cb34d13b9700","name":"Set waitingForContent2","type":"n8n-nodes-base.code","position":[240,-120],"parameters":{},"typeVersion":2},{"id":"d2f98541-2150-4472-8ae8-f698257a8258","name":"Prepare IF Value","type":"n8n-nodes-base.code","position":[-180,900],"parameters":{},"typeVersion":2},{"id":"ae7a40ca-55eb-478d-8bde-c23cfdf3d85e","name":"Command Check","type":"n8n-nodes-base.if","position":[-240,200],"parameters":{},"typeVersion":1},{"id":"aa197f22-5a55-4883-a852-bed4f0919baa","name":"Set waitingForContent3","type":"n8n-nodes-base.code","position":[240,100],"parameters":{},"typeVersion":2},{"id":"7c5803ba-f704-4664-983e-6534742d9c4a","name":"Send Typing action","type":"n8n-nodes-base.telegram","position":[-240,-60],"webhookId":"425443f1-117e-4aaa-84d5-74ce2a1a1b64","parameters":{},"typeVersion":1.2},{"id":"7c32f9b4-b9ae-48e3-aede-c8c304167c43","name":"Command1 content request","type":"n8n-nodes-base.telegram","position":[500,-340],"webhookId":"e6222973-c851-4ee3-88e7-114eb59193e6","parameters":{},"typeVersion":1},{"id":"b09fdfed-e95c-4e0e-ae34-cbecf552585c","name":"Command2 content request","type":"n8n-nodes-base.telegram","position":[500,-120],"webhookId":"4b6373cf-99db-4fd9-8665-bc8dbba64c32","parameters":{},"typeVersion":1},{"id":"d402d0e1-2afb-4c10-95af-4db1058e6036","name":"Command3 content request","type":"n8n-nodes-base.telegram","position":[500,100],"webhookId":"8e2fb397-4b82-4a5d-a358-32ed6c18ac22","parameters":{},"typeVersion":1},{"id":"ffac12bc-ec49-474d-ac4b-6a401433cad3","name":"No Command check","type":"n8n-nodes-base.telegram","position":[240,1280],"webhookId":"2814cc4c-0392-43f4-bbb4-fd096e61ac13","parameters":{},"typeVersion":1},{"id":"81dd8b62-e5fb-487e-86dd-f69a72dd261c","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[160,400],"parameters":{"content":""},"typeVersion":1},{"id":"3ec1c4cc-c9e0-4c4e-b56c-e733bc853270","name":"Command1 result","type":"n8n-nodes-base.telegram","position":[520,500],"webhookId":"05e84345-6d19-42cf-bc8c-afdfd87339f1","parameters":{},"typeVersion":1},{"id":"1b9114f0-e7ee-43fa-ba9d-536429f926e2","name":"Command2 result","type":"n8n-nodes-base.telegram","position":[520,760],"webhookId":"55ee4a03-2d14-4caa-94f8-b11db34ddabd","parameters":{},"typeVersion":1},{"id":"f5c30793-59fc-4070-91cb-5ca20aeb2431","name":"Command3 result","type":"n8n-nodes-base.telegram","position":[520,1020],"webhookId":"55ee4a03-2d14-4caa-94f8-b11db34ddabd","parameters":{},"typeVersion":1},{"id":"c8bab9d3-f159-44a1-868b-d194e4c05c7e","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-560,-580],"parameters":{"content":""},"typeVersion":1},{"id":"2e3ee128-2c7c-4662-bf2e-6ba518743feb","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[160,-440],"parameters":{"content":""},"typeVersion":1},{"id":"bef8cc55-9f19-47d2-826b-41512c90964e","name":"Command1 processing","type":"n8n-nodes-base.noOp","position":[240,500],"parameters":{},"typeVersion":1},{"id":"9b766ceb-dfd1-47b5-a9f8-148fbd79d1d2","name":"Command2 processing","type":"n8n-nodes-base.noOp","position":[240,760],"parameters":{},"typeVersion":1},{"id":"40902676-eb28-46a7-bad4-c11075979c5d","name":"Command3 processing","type":"n8n-nodes-base.noOp","position":[240,1020],"parameters":{},"typeVersion":1},{"id":"42462e2d-8536-4509-a2aa-851f40ae6c1e","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[160,1480],"parameters":{"content":""},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"aa1ed21d-c431-4866-ac73-9f21d69a28cf","connections":{"Check State":{"main":[[{"node":"Command1 processing","type":"main","index":0}],[{"node":"Command2 processing","type":"main","index":0}],[{"node":"Command3 processing","type":"main","index":0}],[{"node":"No Command check","type":"main","index":0}]]},"Command Check":{"main":[[{"node":"Switch (Command Routing)","type":"main","index":0}],[{"node":"Prepare IF Value","type":"main","index":0}]]},"Command1 result":{"main":[[{"node":"Clear State","type":"main","index":0}]]},"Command2 result":{"main":[[{"node":"Clear State","type":"main","index":0}]]},"Command3 result":{"main":[[{"node":"Clear State","type":"main","index":0}]]},"Prepare IF Value":{"main":[[{"node":"Check State","type":"main","index":0}]]},"Telegram Trigger":{"main":[[{"node":"Command Check","type":"main","index":0},{"node":"Send Typing action","type":"main","index":0}]]},"Command1 processing":{"main":[[{"node":"Command1 result","type":"main","index":0}]]},"Command2 processing":{"main":[[{"node":"Command2 result","type":"main","index":0}]]},"Command3 processing":{"main":[[{"node":"Command3 result","type":"main","index":0}]]},"Set waitingForContent1":{"main":[[{"node":"Command1 content request","type":"main","index":0}]]},"Set waitingForContent2":{"main":[[{"node":"Command2 content request","type":"main","index":0}]]},"Set waitingForContent3":{"main":[[{"node":"Command3 content request","type":"main","index":0}]]},"Command2 content request":{"main":[[]]},"Switch (Command Routing)":{"main":[[{"node":"Set waitingForContent1","type":"main","index":0}],[{"node":"Set waitingForContent2","type":"main","index":0}],[{"node":"Set waitingForContent3","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-06-19 22:48:44
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: 🦜✨Use OpenAI to Transcribe Audio + Summarize with AI + Save to Google Drive
author_name: Joseph LePage
author_username: joe
categories: []
created_at: 2025-03-03T23:06:23.260Z
updated_at: 2025-03-03T23:06:23.260Z
url: https://n8n.io/workflows/3076
scraped_at: 2025-06-19 22:50:39
description:
  Automate Audio Transcription, AI Summarization, and Google Drive Storage

  Who is this for?  
  Content Teams, Researchers, and Administrators who need to automatically process voice memos, meeting recordings, or interview audio into structured, searchable documents.

  What problem does this solve?  
  Eliminates manual transcription work by automatically converting audio files into organized text documents with AI analysis, while maintaining human oversight through approval workflows.

  What this workflow does  
  Smart Audio Processing:  
     Triggers when new .m4a files appear in Google Drive  
     Uses OpenAI's Whisper for accurate transcription  
     Implements dual-format reporting (JSON + Markdown)  

  Human Oversight (optional):  
     Requires email approval before processing  
     45-minute response window with escalation options  

  AI-Powered Analysis:  
     Generates structured JSON reports with:  
       Key points & action items  
       Sentiment analysis  
       Technical terminology glossary  
     Creates Markdown versions for easy reading  

  Document Management:  
     Stores raw transcripts + reports in Google Drive  
     Automatic file naming with timestamps  
     Sends completion alerts via Email/Telegram  

  Workflow visualization showing audio file processing path

  Setup  
  Credentials Needed:  
     Google Drive API access  
     OpenAI API key (GPT-4o-mini)  
     Gmail & Telegram integrations  

  Configuration:  
     Set your Google Drive folder ID in 3 nodes  
     Update email addresses in Gmail nodes  
     Customize approval timeout in "Gmail User for Approval"  

  Customization Points:  
     File extension filters (.m4a)  
     AI report templates and prompts  
     Notification channels (Email/Telegram)  

  How to customize  
  Approval Process**: Add SMS/Teams notifications via additional nodes  
  File Types**: Modify filter node for .mp3/.wav support  
  Analysis Depth**: Adjust GPT-4 prompts in "Summarize to JSON" nodes  
  Storage**: Connect to Notion/Airtable instead of Google Drive  

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

workflow_json:
  {"id":"CNOMivCLJRGfZnUM","meta":{"instanceId":"31e69f7f4a77bf465b805824e303232f0227212ae922d12133a0f96ffeab4fef","templateCredsSetupCompleted":true},"name":"🦜✨Use OpenAI to Transcribe Audio + Summarize with AI + Save to Google Drive","tags":[],"nodes":[{"id":"3918995a-a587-40c1-828c-97e75b988a9f","name":"Gmail User for Approval","type":"n8n-nodes-base.gmail","disabled":true,"position":[360,-20],"webhookId":"c46cf421-ddb6-45a8-b83b-80b381666f0e","parameters":{"sendTo":"={{ $env.EMAIL_ADDRESS_JOE }} ","message":"=A new was just created in the Audio Recordings folder on Google Drive.  Would you like to continue the workflow and Transcribe the audio file and generate reports.","options":{"limitWaitTime":{"values":{"resumeUnit":"minutes","resumeAmount":45}}},"subject":"=💡New Audio File Created - Approve Transcription Service","operation":"sendAndWait","approvalOptions":{"values":{"approvalType":"double"}}},"credentials":{"gmailOAuth2":{"id":"1xpVDEQ1yx8gV022","name":"Gmail account"}},"typeVersion":2.1},{"id":"44aa6e99-9b4a-4af4-93e3-4b1a50fc7628","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-320,680],"parameters":{"color":3,"width":260,"height":280,"content":"## 3️⃣ Transcribe Audio"},"typeVersion":1},{"id":"cbf765b5-b888-4e22-b4a2-1d430b557109","name":"Set Config","type":"n8n-nodes-base.set","position":[0,780],"parameters":{"options":{},"assignments":{"assignments":[{"id":"2f5cef95-a26b-46ff-ab9a-501187ce4211","name":"text","type":"string","value":"={{ $json.text }}"},{"id":"ac623698-1263-4b83-8c59-159863d950b9","name":"datetime","type":"string","value":"={{ $now }}"}]}},"typeVersion":3.4},{"id":"bd9cd4aa-6afc-4875-a487-df4f0d3a4a29","name":"Transcribe with OpenAI","type":"@n8n/n8n-nodes-langchain.openAi","position":[-240,780],"parameters":{"options":{},"resource":"audio","operation":"transcribe"},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1},{"id":"4d91f6f7-a89e-44d9-9433-4d9a1df368a2","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[180,580],"parameters":{"color":5,"width":1560,"height":280,"content":"## 4️⃣ Process Transcript and Generate Structured JSON Report"},"typeVersion":1},{"id":"64421d13-0aff-46f8-bf3e-5fac89ec9c46","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[180,900],"parameters":{"color":6,"width":1560,"height":280,"content":"## 5️⃣ Process Transcript and Generate Structured JSON -> Markdown Report"},"typeVersion":1},{"id":"769ca5a4-2a54-4ed8-85af-4359b97755bc","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[1000,1220],"parameters":{"color":2,"width":460,"height":280,"content":"## 6️⃣ Save Raw Transcript to Google Drive"},"typeVersion":1},{"id":"aa612f37-f7cd-4cf7-919c-87564f03eef1","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-100,240],"parameters":{"color":4,"width":300,"height":300,"content":"## 1️⃣ Start Transcription Service"},"typeVersion":1},{"id":"1e520267-6275-4d07-bba8-9ebaf0afbc68","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-100,-140],"parameters":{"width":700,"height":340,"content":"## Wait for Google Drive Trigger and Send for User Approval to Proceed (Human in the Loop)\n(optional)"},"typeVersion":1},{"id":"1f07fa9c-ecfc-4534-a0b2-569eca1a3092","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[680,240],"parameters":{"color":2,"width":880,"height":300,"content":"## 2️⃣ Search and Download Audio File from Google Drive\n💡Note:  Adjust Filter and Limit settings for your needs"},"typeVersion":1},{"id":"b769d523-6b1f-45f2-98b1-4d0f8eb2d7f4","name":"Filter by .m4a extension","type":"n8n-nodes-base.filter","position":[980,340],"parameters":{"options":{"ignoreCase":true},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":false,"typeValidation":"loose"},"combinator":"and","conditions":[{"id":"420e1a9c-2145-4845-b4b0-31a82855a78c","operator":{"type":"string","operation":"endsWith"},"leftValue":"={{ $json.name }}","rightValue":".m4a"}]},"looseTypeValidation":true},"typeVersion":2.2},{"id":"5a67182e-4f13-4b6f-a3e2-863e18af31b0","name":"Limit to last file","type":"n8n-nodes-base.limit","position":[1180,340],"parameters":{"keep":"lastItems"},"typeVersion":1},{"id":"f42b4efc-6e04-49a1-8bd8-252ebd3dbf42","name":"Download audio file","type":"n8n-nodes-base.googleDrive","position":[1380,340],"parameters":{"fileId":{"__rl":true,"mode":"id","value":"={{ $json.id }}"},"options":{},"operation":"download"},"credentials":{"googleDriveOAuth2Api":{"id":"UhdXGYLTAJbsa0xX","name":"Google Drive account"}},"typeVersion":3},{"id":"4313e19f-ca7a-4982-b3b4-1680c674e696","name":"Search Google Drive","type":"n8n-nodes-base.googleDrive","position":[780,340],"parameters":{"filter":{"folderId":{"__rl":true,"mode":"list","value":"1Wqd4zEEb847gFYKoDBbNnXsWEc-kCAm2","cachedResultUrl":"https://drive.google.com/drive/folders/1Wqd4zEEb847gFYKoDBbNnXsWEc-kCAm2","cachedResultName":"Audio Recordings"},"whatToSearch":"files"},"options":{},"resource":"fileFolder"},"credentials":{"googleDriveOAuth2Api":{"id":"UhdXGYLTAJbsa0xX","name":"Google Drive account"}},"typeVersion":3},{"id":"e25655b0-9d30-40d4-9051-bffe38fb41e0","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[2020,700],"parameters":{"width":660,"height":480,"content":"## 7️⃣ Send Transcription Report Links to User"},"typeVersion":1},{"id":"38ff9906-41af-430a-9de9-0500577826a5","name":"Send Telegram Message","type":"n8n-nodes-base.telegram","position":[2460,980],"webhookId":"bb40ede7-03cf-493d-b051-196b96725925","parameters":{"text":"=Audio Transcribed and Reports Generated\n{{ $json.id_json.webViewLink }}\n{{ $json.id_markdown.webViewLink }}","chatId":"={{ $env.TELEGRAM_CHAT_ID }}","additionalFields":{"parse_mode":"HTML","appendAttribution":false}},"credentials":{"telegramApi":{"id":"pAIFhguJlkO3c7aQ","name":"Telegram account"}},"typeVersion":1.2},{"id":"5b6aedaa-897f-4b76-84d8-3ca18d06cc5c","name":"Send Gmail Message","type":"n8n-nodes-base.gmail","position":[2460,800],"webhookId":"0a81b95a-cd82-465d-8450-cf38518a4cbb","parameters":{"sendTo":"={{ $env.EMAIL_ADDRESS_JOE }} ","message":"={{ $json.message.content }}","options":{"appendAttribution":false},"subject":"Audio Transcribed and Reports Generated"},"credentials":{"gmailOAuth2":{"id":"1xpVDEQ1yx8gV022","name":"Gmail account"}},"typeVersion":2.1},{"id":"4500efdb-7a70-40da-97b6-e4668af21a19","name":"Email Content Formatter","type":"@n8n/n8n-nodes-langchain.openAi","position":[2100,800],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"GPT-4O-MINI"},"options":{},"messages":{"values":[{"content":"=Prapare this HTML template using the following: \n{{ $json.id_json.toJsonString() }}\n{{ $json.id_markdown.toJsonString() }}\n\nEnsure that the 'webViewLink' is always provided.\n\nRespond only with HTML and avoid any preamble or further explanation.  Remove all ``` or ```html from final response.\n\n<style type=\"text/css\">\n    /* Reset styles */\n    body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }\n    .wrapper { max-width: 600px; margin: 0 auto; }\n    .content { padding: 30px; line-height: 1.6; color: #333333; }\n    .divider { border-top: 1px solid #eeeeee; margin: 25px 0; }\n    .button { display: inline-block; padding: 12px 24px; background-color: #2563eb; color: white; text-decoration: none; border-radius: 6px; }\n</style>\n</head>\n<body>\n    <div class=\"wrapper\">\n        <div class=\"content\">\n            <h2 style=\"color: #1f2937; margin-bottom: 20px;\">Your Documents</h2>\n            \n            <div style=\"margin-bottom: 30px;\">\n                <h3 style=\"color: #374151; margin-bottom: 12px;\">[name]</h3>\n                <a href=\"[webViewLink]\" class=\"button\" style=\"color: white;\">View Document</a>\n            </div>\n\n            <div class=\"divider\"></div>\n\n            [continue the pattern ...]\n\n        </div>\n    </div>\n</body>"},{"role":"system"}]}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1},{"id":"287fcc26-69be-43d8-a855-c57658e92ac4","name":"Summarize to Structured JSON","type":"@n8n/n8n-nodes-langchain.openAi","position":[240,660],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"GPT-4O-MINI"},"options":{},"messages":{"values":[{"content":"=\"Today is \" {{ $now }}  \"Transcript: \" {{  $json.text }}"},{"role":"system","content":"## ROLE\nYou are an expert at summarizing long transcripts.\n\n## TASK\nSummarize the provided transcript into a structured JSON format.\n\n## RULES\nReturn only valid JSON in this example format:\n\"transcript_report\": {\n\"title\": \"Notion Buttons\",\n\"summary\": \"A collection of buttons for Notion\",\n\"main_points\": [\"item 1\", \"item 2\", \"item 3\"],\n\"action_items\": [\"item 1\", \"item 2\", \"item 3\"],\n\"follow_up\": [\"item 1\", \"item 2\", \"item 3\"],\n\"stories\": [\"item 1\", \"item 2\", \"item 3\"],\n\"references\": [\"item 1\", \"item 2\", \"item 3\"],\n\"arguments\": [\"item 1\", \"item 2\", \"item 3\"],\n\"related_topics\": [\"item 1\", \"item 2\", \"item 3\"],\n\"sentiment\": \"positive\"\n}"}]},"jsonOutput":true},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1},{"id":"7b5b751f-a7fa-4983-a0e4-1a79e5c4286c","name":"Summarize to JSON","type":"@n8n/n8n-nodes-langchain.openAi","position":[240,980],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"GPT-4O-MINI"},"options":{},"messages":{"values":[{"content":"=Transcript: {{  $json.text }}"},{"role":"system","content":"=## ROLE: Expert Transcript Analyst\n**Current Date:** {{ $now }}\n**Specialization:** Technical documentation, executive reporting, and information architecture\n\n\n## TASK: Create Structured Transcript Summary\nTransform verbose transcripts into well-organized technical documents using this 3-step process:\n1. Extract key information\n2. Identify natural thematic groupings\n3. Structure for optimal scannability\n\n\n## FORMAT REQUIREMENTS\n[Document Title] - {{ $now }}\n\nExecutive Summary (3-5 sentences)\n- Core purpose of discussion\n- Key decision points\n- Actionable outcomes\n\nDetailed Analysis\n[Topic 1: Clear Section Name]\n- Key statements\n- Supporting data points\n- Action items\n\n[Topic 2: Specific Category]\n-Decision rationale\n-Contradictions/agreements\n-Follow-up requirements\n\n(...continue pattern...)\n\nAdditional Observations\n- Unresolved questions\n- Technical terminology glossary\n- Participant sentiment trends\n\n\n## RULES\n1. **Content Fidelity**\n   - Never add external knowledge\n   - Preserve quantitative data exactly\n   - Maintain speaker intent through paraphrasing\n\n2. **Structural Requirements**\n   - Use H2/H3 headers only\n   - Apply consistent tense (prefer present)\n   - Include timestamps for critical points [00:00]\n\n3. **Style Guidelines**\n   - Technical > conversational tone\n   - Active voice required\n   - Bullet points for lists\n   - **Bold** key decisions\n\n4. **Validation**\n   - Self-check for topic overlap\n   - Verify chronological accuracy\n   - Confirm all action items are highlighted"}]},"jsonOutput":true},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1},{"id":"e92d8de3-8287-4ecd-9ca6-6f8d18b8942e","name":"Convert JSON to Markdown","type":"@n8n/n8n-nodes-langchain.openAi","position":[620,980],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"GPT-4O-MINI"},"options":{},"messages":{"values":[{"content":"=Today is: {{ $now }}\nTranscript: {{ $json.message.content.toJsonString() }}"},{"role":"system","content":"Convert this transcript summary to a markdown document.  Only respond with text and remove all ``` or ```markdown."}]}},"credentials":{"openAiApi":{"id":"jEMSvKmtYfzAkhe6","name":"OpenAi account"}},"typeVersion":1},{"id":"419e050f-3a9b-4fc0-99f2-2e478f080e06","name":"Get Filename for JSON","type":"n8n-nodes-base.set","position":[980,660],"parameters":{"options":{},"assignments":{"assignments":[{"id":"a0c31c80-87c9-41e5-ae07-8639bf52870c","name":"filename","type":"string","value":"={{ $('Download audio file').item.json.id }}-{{ $('Download audio file').item.json.name }}-{{ $('Set Config').item.json.datetime }}.json"}]}},"typeVersion":3.4},{"id":"1307431e-80ea-404c-925f-d3ad5bdaa27c","name":"Get Filename for Markdown","type":"n8n-nodes-base.set","position":[980,980],"parameters":{"options":{},"assignments":{"assignments":[{"id":"a0c31c80-87c9-41e5-ae07-8639bf52870c","name":"filename","type":"string","value":"={{ $('Download audio file').item.json.id }} - {{ $('Download audio file').item.json.name }}- {{ $('Set Config').item.json.datetime }}.md"}]}},"typeVersion":3.4},{"id":"c87a9dcb-3edb-47ba-a059-6e7a6c63c287","name":"Save JSON file to Google Drive","type":"n8n-nodes-base.googleDrive","position":[1180,660],"parameters":{"name":"={{ $json.filename }}","content":"={{ $('Summarize to Structured JSON').item.json.message.content.toJsonString() }}","driveId":{"__rl":true,"mode":"list","value":"My Drive"},"options":{},"folderId":{"__rl":true,"mode":"list","value":"1Wqd4zEEb847gFYKoDBbNnXsWEc-kCAm2","cachedResultUrl":"https://drive.google.com/drive/folders/1Wqd4zEEb847gFYKoDBbNnXsWEc-kCAm2","cachedResultName":"Audio Recordings"},"operation":"createFromText"},"credentials":{"googleDriveOAuth2Api":{"id":"UhdXGYLTAJbsa0xX","name":"Google Drive account"}},"typeVersion":3},{"id":"2f0c30b5-1c99-4c06-9c1b-8a18033e6921","name":"Save Markdown file to Google Drive","type":"n8n-nodes-base.googleDrive","position":[1180,980],"parameters":{"name":"={{ $json.filename }}","content":"={{ $('Convert JSON to Markdown').item.json.message.content }}","driveId":{"__rl":true,"mode":"list","value":"My Drive"},"options":{},"folderId":{"__rl":true,"mode":"list","value":"1Wqd4zEEb847gFYKoDBbNnXsWEc-kCAm2","cachedResultUrl":"https://drive.google.com/drive/folders/1Wqd4zEEb847gFYKoDBbNnXsWEc-kCAm2","cachedResultName":"Audio Recordings"},"operation":"createFromText"},"credentials":{"googleDriveOAuth2Api":{"id":"UhdXGYLTAJbsa0xX","name":"Google Drive account"}},"typeVersion":3},{"id":"abc070ee-c276-410b-a3cf-a8504bf992a1","name":"Get JSON File Meta","type":"n8n-nodes-base.googleDrive","position":[1380,660],"parameters":{"filter":{"whatToSearch":"files"},"options":{"fields":["id","webViewLink","name"]},"resource":"fileFolder","queryString":"={{ $('Get Filename for JSON').item.json.filename }}"},"credentials":{"googleDriveOAuth2Api":{"id":"UhdXGYLTAJbsa0xX","name":"Google Drive account"}},"typeVersion":3},{"id":"0961424a-f3a3-4469-962b-6b2a7affd66d","name":"Get Markdown File Meta","type":"n8n-nodes-base.googleDrive","position":[1380,980],"parameters":{"filter":{"whatToSearch":"files"},"options":{"fields":["id","webViewLink","name"]},"resource":"fileFolder","queryString":"={{ $('Get Filename for Markdown').item.json.filename }}"},"credentials":{"googleDriveOAuth2Api":{"id":"UhdXGYLTAJbsa0xX","name":"Google Drive account"}},"typeVersion":3},{"id":"bddd4298-7570-48df-a16b-5352909f6530","name":"Prepare Response JSON","type":"n8n-nodes-base.set","position":[1580,660],"parameters":{"options":{},"assignments":{"assignments":[{"id":"c89d0613-9b1e-4906-a4d2-ecc5fe585f5b","name":"id_json","type":"object","value":"={{ $json }}"}]}},"typeVersion":3.4},{"id":"d3a77222-96ac-4d2e-a98c-b185524bebe0","name":"Prepare Response Markdown","type":"n8n-nodes-base.set","position":[1580,980],"parameters":{"options":{},"assignments":{"assignments":[{"id":"9e23ce26-bdf5-46c8-9099-02179cd29fc5","name":"id_markdown","type":"object","value":"={{ $json }}"}]}},"typeVersion":3.4},{"id":"41e6a279-426e-4fcd-ad6d-182fbc111d28","name":"Merge All Paths","type":"n8n-nodes-base.merge","position":[1840,980],"parameters":{"mode":"combine","options":{},"combineBy":"combineByPosition","numberInputs":3},"typeVersion":3},{"id":"e2bb4ed5-f9cd-4807-950c-8f9a4bef1a24","name":"Save Raw Transcript to Google Drive","type":"n8n-nodes-base.googleDrive","position":[1180,1300],"parameters":{"name":"={{ $('Download audio file').item.json.id }} - {{ $('Download audio file').item.json.name }}- {{ $('Set Config').item.json.datetime }}.txt","content":"={{  $('Transcribe with OpenAI').item.json.text }}","driveId":{"__rl":true,"mode":"list","value":"My Drive"},"options":{},"folderId":{"__rl":true,"mode":"list","value":"1Wqd4zEEb847gFYKoDBbNnXsWEc-kCAm2","cachedResultUrl":"https://drive.google.com/drive/folders/1Wqd4zEEb847gFYKoDBbNnXsWEc-kCAm2","cachedResultName":"Audio Recordings"},"operation":"createFromText"},"credentials":{"googleDriveOAuth2Api":{"id":"UhdXGYLTAJbsa0xX","name":"Google Drive account"}},"typeVersion":3},{"id":"fb2cced9-8c42-43de-b4a3-5dd66ddd24b3","name":"Start Workflow","type":"n8n-nodes-base.manualTrigger","position":[0,340],"parameters":{},"typeVersion":1},{"id":"c2ef200f-4e45-42ba-a5f2-f7eb47df8f2f","name":"On File Created Trigger","type":"n8n-nodes-base.googleDriveTrigger","disabled":true,"position":[0,-20],"parameters":{"event":"fileCreated","options":{"fileType":"application/vnd.google-apps.audio"},"pollTimes":{"item":[{"mode":"everyMinute"}]},"triggerOn":"specificFolder","folderToWatch":{"__rl":true,"mode":"list","value":"1Wqd4zEEb847gFYKoDBbNnXsWEc-kCAm2","cachedResultUrl":"https://drive.google.com/drive/folders/1Wqd4zEEb847gFYKoDBbNnXsWEc-kCAm2","cachedResultName":"Audio Recordings"}},"credentials":{"googleDriveOAuth2Api":{"id":"UhdXGYLTAJbsa0xX","name":"Google Drive account"}},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"a477e29e-d516-439c-ac41-16281dcca559","connections":{"Set Config":{"main":[[{"node":"Summarize to JSON","type":"main","index":0},{"node":"Summarize to Structured JSON","type":"main","index":0},{"node":"Save Raw Transcript to Google Drive","type":"main","index":0}]]},"Start Workflow":{"main":[[{"node":"Search Google Drive","type":"main","index":0}]]},"Merge All Paths":{"main":[[{"node":"Send Telegram Message","type":"main","index":0},{"node":"Email Content Formatter","type":"main","index":0}]]},"Summarize to JSON":{"main":[[{"node":"Convert JSON to Markdown","type":"main","index":0}]]},"Get JSON File Meta":{"main":[[{"node":"Prepare Response JSON","type":"main","index":0}]]},"Limit to last file":{"main":[[{"node":"Download audio file","type":"main","index":0}]]},"Download audio file":{"main":[[{"node":"Transcribe with OpenAI","type":"main","index":0}]]},"Search Google Drive":{"main":[[{"node":"Filter by .m4a extension","type":"main","index":0}]]},"Get Filename for JSON":{"main":[[{"node":"Save JSON file to Google Drive","type":"main","index":0}]]},"Prepare Response JSON":{"main":[[{"node":"Merge All Paths","type":"main","index":0}]]},"Get Markdown File Meta":{"main":[[{"node":"Prepare Response Markdown","type":"main","index":0}]]},"Transcribe with OpenAI":{"main":[[{"node":"Set Config","type":"main","index":0}]]},"Email Content Formatter":{"main":[[{"node":"Send Gmail Message","type":"main","index":0}]]},"Gmail User for Approval":{"main":[[{"node":"Search Google Drive","type":"main","index":0}]]},"On File Created Trigger":{"main":[[{"node":"Gmail User for Approval","type":"main","index":0}]]},"Convert JSON to Markdown":{"main":[[{"node":"Get Filename for Markdown","type":"main","index":0}]]},"Filter by .m4a extension":{"main":[[{"node":"Limit to last file","type":"main","index":0}]]},"Get Filename for Markdown":{"main":[[{"node":"Save Markdown file to Google Drive","type":"main","index":0}]]},"Prepare Response Markdown":{"main":[[{"node":"Merge All Paths","type":"main","index":1}]]},"Summarize to Structured JSON":{"main":[[{"node":"Get Filename for JSON","type":"main","index":0}]]},"Save JSON file to Google Drive":{"main":[[{"node":"Get JSON File Meta","type":"main","index":0}]]},"Save Markdown file to Google Drive":{"main":[[{"node":"Get Markdown File Meta","type":"main","index":0}]]},"Save Raw Transcript to Google Drive":{"main":[[{"node":"Merge All Paths","type":"main","index":2}]]}}}


name: 5 Ways to Process Images & PDFs with Gemini AI in n8n
author_name: Julian Kaiser
author_username: jksr
categories: []
created_at: 2025-03-04T17:59:47.368Z
updated_at: 2025-03-04T17:59:47.368Z
url: https://n8n.io/workflows/3078
scraped_at: 2025-06-19 22:50:25
description:
  How it works

  Many users have asked in the support forum about different methods to analyze images and PDF documents with Google Gemini AI in n8n. This workflow answers that question by demonstrating five different approaches:

  Single image with auto binary passthrough - The simplest approach using AI Agent's automatic binary handling
  Multiple images with predefined prompts - For customized analysis with different instructions per image
  Native n8n item-by-item processing - For handling multiple items using n8n's standard workflow paradigm
  PDF analysis via direct API - For document analysis and text extraction
  Image analysis via direct API - For direct control over API parameters
  Each method has advantages depending on your specific use case, data volume, and customization needs.

  Set up steps

  Setup time: ~5-10 minutes

  You'll need:

  A Google Gemini API key
  n8n with HTTP Request and AI Agent nodes
  Important: For the HTTP Request nodes making direct API calls to Gemini (Methods 3, 4, and 5), you'll need to set up Query Authentication with your Gemini API key. Add a parameter named "key" with your API key value in the Query Auth section of these nodes.

  I'll updated this if I find better ways. Also let me know if you know other ways. Eager to learn :) 

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

workflow_json:
  {"meta":{"instanceId":"d4d7965840e96e50a3e02959a8487c692901dfa8d5cc294134442c67ce1622d3","templateCredsSetupCompleted":true},"nodes":[{"id":"eec7d9b8-d1e3-4a43-9e0d-f6d750e736b5","name":"When clicking ‘Test workflow’","type":"n8n-nodes-base.manualTrigger","position":[-640,-400],"parameters":{},"typeVersion":1},{"id":"5276a2cf-3d42-409a-800d-9080aa5e1a09","name":"Google Gemini Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[1820,-60],"parameters":{"options":{},"modelName":"models/gemini-2.0-flash"},"credentials":{"googlePalmApi":{"id":"BB5B0v4OaFQeEt3C","name":"Google Gemini(PaLM) Api account"}},"typeVersion":1},{"id":"1b89dca9-1137-4e0f-b3ff-1b354152c128","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[1880,-260],"parameters":{"text":"={{ $('Loop Over Items').all() }}","options":{"passthroughBinaryImages":true},"promptType":"define"},"typeVersion":1.7},{"id":"00348203-882f-48da-8127-e57cf30c5b20","name":"Get image from unsplash2","type":"n8n-nodes-base.httpRequest","position":[1160,-280],"parameters":{"url":"={{ $json.url }}","options":{}},"typeVersion":4.2},{"id":"1b07777f-954b-4471-ab4b-070c902c0bc1","name":"Split Out","type":"n8n-nodes-base.splitOut","position":[500,-280],"parameters":{"options":{},"fieldToSplitOut":"urls"},"typeVersion":1},{"id":"3646a695-d63b-4e25-93b4-a208592e6eac","name":"Get image from unsplash3","type":"n8n-nodes-base.httpRequest","position":[720,0],"parameters":{"url":"={{ $json.urls }}","options":{}},"typeVersion":4.2},{"id":"34ef745b-23c6-422d-9367-de79eeb54e77","name":"Transform to base","type":"n8n-nodes-base.extractFromFile","position":[940,0],"parameters":{"options":{},"operation":"binaryToPropery"},"typeVersion":1},{"id":"762507d2-2093-4ac8-a4d4-2972c53fa839","name":"Call Gemini API1","type":"n8n-nodes-base.httpRequest","position":[1160,0],"parameters":{"url":"=https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent","method":"POST","options":{},"jsonBody":"={\n  \"contents\": [{\n    \"parts\":[\n      {\"text\": \"Whats on this image?\"},\n      {\n        \"inline_data\": {\n          \"mime_type\": \"image/jpeg\",\n          \"data\": \"{{ $json.data }}\"\n        }\n      }\n    ]\n  }]\n}\n","sendBody":true,"specifyBody":"json","authentication":"genericCredentialType","genericAuthType":"httpQueryAuth"},"credentials":{"httpQueryAuth":{"id":"Eh1GI1UjOtJk4CDZ","name":"Query Gemini Auth account"}},"typeVersion":4.2},{"id":"0dfa7ae9-1eda-49ca-8067-c467346c27cb","name":"Loop Over Items","type":"n8n-nodes-base.splitInBatches","position":[1560,-280],"parameters":{"options":{}},"typeVersion":3},{"id":"c5562d6b-0b56-4f15-bbd0-441359f89d86","name":"AI Agent2","type":"@n8n/n8n-nodes-langchain.agent","position":[1560,-700],"parameters":{"text":"whats on the image","options":{"passthroughBinaryImages":true},"promptType":"define"},"typeVersion":1.7},{"id":"277c44ec-109b-4dfa-bc04-defec26e6581","name":"Google Gemini Chat Model1","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[1500,-540],"parameters":{"options":{},"modelName":"models/gemini-2.0-flash"},"credentials":{"googlePalmApi":{"id":"BB5B0v4OaFQeEt3C","name":"Google Gemini(PaLM) Api account"}},"typeVersion":1},{"id":"c303ab4e-155f-4c36-bf07-4825d0d1fd93","name":"Get image from unsplash4","type":"n8n-nodes-base.httpRequest","position":[1160,-700],"parameters":{"url":"=https://plus.unsplash.com/premium_photo-1740023685108-a12c27170d51?q=80&w=2340&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D","options":{}},"typeVersion":4.2},{"id":"b786ac03-75d0-4830-849f-ee9ed8e108fa","name":"Get PDF file","type":"n8n-nodes-base.httpRequest","position":[260,360],"parameters":{"url":"https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf","options":{}},"typeVersion":4.2},{"id":"bb7ba59e-050a-4259-8238-dc25f458e3c4","name":"Get image from unsplash","type":"n8n-nodes-base.httpRequest","position":[260,660],"parameters":{"url":"=https://plus.unsplash.com/premium_photo-1740023685108-a12c27170d51?q=80&w=2340&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D","options":{}},"typeVersion":4.2},{"id":"65a4cb42-632b-4fbd-8e28-10e36e9f1e00","name":"Call Gemini API with PDF","type":"n8n-nodes-base.httpRequest","position":[720,360],"parameters":{"url":"=https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent","method":"POST","options":{},"jsonBody":"={\n  \"contents\": [{\n    \"parts\":[\n      {\"text\": \"Whats on this pdf?\"},\n      {\n        \"inline_data\": {\n          \"mime_type\": \"application/pdf\",\n          \"data\": \"{{ $json.data }}\"\n        }\n      }\n    ]\n  }]\n}\n","sendBody":true,"specifyBody":"json","authentication":"genericCredentialType","genericAuthType":"httpQueryAuth"},"credentials":{"httpQueryAuth":{"id":"Eh1GI1UjOtJk4CDZ","name":"Query Gemini Auth account"}},"typeVersion":4.2},{"id":"75a13a82-c051-449a-bf52-837256c18f22","name":"Call Gemini API with Image","type":"n8n-nodes-base.httpRequest","position":[720,660],"parameters":{"url":"=https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent","method":"POST","options":{},"jsonBody":"={\n  \"contents\": [{\n    \"parts\":[\n      {\"text\": \"Whats on this image?\"},\n      {\n        \"inline_data\": {\n          \"mime_type\": \"image/jpeg\",\n          \"data\": \"{{ $json.data }}\"\n        }\n      }\n    ]\n  }]\n}\n","sendBody":true,"specifyBody":"json","authentication":"genericCredentialType","genericAuthType":"httpQueryAuth"},"credentials":{"httpQueryAuth":{"id":"Eh1GI1UjOtJk4CDZ","name":"Query Gemini Auth account"}},"typeVersion":4.2},{"id":"55964e8d-ce0a-4157-b536-41862da946ab","name":"Transform to base64 (image)","type":"n8n-nodes-base.extractFromFile","position":[500,660],"parameters":{"options":{},"operation":"binaryToPropery"},"typeVersion":1},{"id":"57fc92ee-2a74-4d49-ae7a-6c499a1f380e","name":"Transform to base64 (pdf)","type":"n8n-nodes-base.extractFromFile","position":[500,360],"parameters":{"options":{},"operation":"binaryToPropery"},"typeVersion":1},{"id":"dc0a5515-1a51-4a11-9b39-ac8b30bcb0ba","name":"Define Multiple Image URLs","type":"n8n-nodes-base.set","position":[260,0],"parameters":{"options":{},"assignments":{"assignments":[{"id":"95f15b6e-f66a-450a-be19-75d4c339f943","name":"urls","type":"array","value":"=[\n  \"https://plus.unsplash.com/premium_photo-1740023685108-a12c27170d51?q=80&w=2340&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\",\n  \"https://images.unsplash.com/photo-1739609579483-00b49437cc45?q=80&w=2342&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\"\n]\n"}]}},"typeVersion":3.4},{"id":"4f9037a3-adc5-4ada-b977-6ecdf6f58705","name":"Split Out to multiple items","type":"n8n-nodes-base.splitOut","position":[500,0],"parameters":{"options":{},"fieldToSplitOut":"urls"},"typeVersion":1},{"id":"0e0bbf58-4c83-4769-9616-c120296ce5e0","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-760,-780],"parameters":{"color":5,"width":440,"height":340,"content":"## When clicking \"Test workflow\"\n\nThis trigger demonstrates five different approaches to analyze media with AI:\n1. Top branch: Single image with automatic binary passthrough\n2. Second branch: Multiple images with custom prompts\n3. Third branch: Standard n8n item processing with direct API\n4. Fourth branch: PDF analysis via direct API\n5. Fifth branch: Image analysis via direct API\n\nEach approach has advantages depending on your use case.\n\n"},"typeVersion":1},{"id":"2a6236b2-c5a3-4feb-883a-b3654ce78278","name":"Define URLs And Prompts","type":"n8n-nodes-base.set","position":[260,-280],"parameters":{"options":{},"assignments":{"assignments":[{"id":"95f15b6e-f66a-450a-be19-75d4c339f943","name":"urls","type":"array","value":"={{ \n[\n  {\n    url: \"https://plus.unsplash.com/premium_photo-1740023685108-a12c27170d51?q=80&w=2340&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\",\n    prompt: \"what is special about this image?\",\n    process: true\n  },\n  {\n    url: \"https://images.unsplash.com/photo-1739609579483-00b49437cc45?q=80&w=2342&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\",\n    prompt: \"what is the main color?\",\n    process: true\n  },\n  {\n    url: \"https://plus.unsplash.com/premium_photo-1740023685108-a12c27170d51?q=80&w=2340&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\",\n    prompt: \"test\", \n    process: false\n  }\n]\n}}"}]}},"typeVersion":3.4},{"id":"91dd2eec-3179-4c14-857e-bb65499723be","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[1920,-700],"parameters":{"color":4,"width":440,"height":300,"content":"## METHOD 1: Single image with automatic binary passthrough\n\nThis branch demonstrates the easiest way to analyze a single image with AI:\n1. Fetch an image from Unsplash\n2. Send directly to the AI Agent with \"Automatically Passthrough Binary Images\" enabled\n3. Get AI analysis without any data transformation\n\nBEST FOR: Quick implementation with minimal configuration for single image analysis.\n\n"},"typeVersion":1},{"id":"2b48f2d0-8c55-40da-acf5-0d9267691817","name":"Filter (optional)","type":"n8n-nodes-base.filter","position":[720,-280],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"51b55272-94af-4761-a42e-5c91f3b8e39e","operator":{"type":"boolean","operation":"true","singleValue":true},"leftValue":"={{ $json.process }}","rightValue":""}]}},"typeVersion":2.2},{"id":"f9f98d03-99c6-4424-b7cc-fd2ef836173b","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[2220,-260],"parameters":{"color":3,"width":460,"height":360,"content":"## METHOD 2: Multiple images with custom prompts\n\nThis branch shows how to analyze different images with custom instructions:\n1. Prepare data structure with image URLs and their corresponding prompts\n2. Split into individual items and filter if needed\n3. Fetch each image from Unsplash\n4. Process sequentially through the Loop node\n5. Analyze each with its specific prompt using the AI Agent\n\nBEST FOR: When you need different analysis goals for each image (e.g., one for object detection, another for scene description).\n"},"typeVersion":1},{"id":"057ecbfa-3079-451f-9376-eefcdf4ab96a","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[1360,0],"parameters":{"color":7,"width":360,"height":380,"content":"## METHOD 3: Standard n8n item processing with direct API\n\nThis branch demonstrates n8n's standard approach to handling multiple items:\n1. Define multiple image URLs in a single node\n2. Split into individual items for processing\n3. Fetch each image individually\n4. Transform each to base64 format\n5. Make direct API calls to Gemini for each item\n\nBEST FOR: Processing multiple images using n8n's standard item-by-item approach with direct API control.\n\n"},"typeVersion":1},{"id":"3dfbde27-7141-4558-a958-00b2891274ec","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[920,360],"parameters":{"width":340,"height":280,"content":"## METHOD 4: PDF analysis via direct API\n\nThis branch shows how to analyze PDF documents:\n1. Fetch a PDF file\n2. Transform to base64 format\n3. Send directly to Gemini API for analysis\n\nBEST FOR: Document analysis, text extraction, summarization of PDFs.\n"},"typeVersion":1},{"id":"f50dae19-77e4-4450-a516-7f0e676d161a","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[920,660],"parameters":{"width":340,"height":300,"content":"## METHOD 5: Image analysis via direct API\n\nThis branch demonstrates direct API control for image analysis:\n1. Fetch an image\n2. Transform to base64 format\n3. Make a customized API call to Gemini\n\nBEST FOR: Advanced users who need precise control over API parameters and response handling.\n"},"typeVersion":1}],"pinData":{},"connections":{"AI Agent":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Split Out":{"main":[[{"node":"Filter (optional)","type":"main","index":0}]]},"Get PDF file":{"main":[[{"node":"Transform to base64 (pdf)","type":"main","index":0}]]},"Loop Over Items":{"main":[[],[{"node":"AI Agent","type":"main","index":0}]]},"Call Gemini API1":{"main":[[]]},"Filter (optional)":{"main":[[{"node":"Get image from unsplash2","type":"main","index":0}]]},"Transform to base":{"main":[[{"node":"Call Gemini API1","type":"main","index":0}]]},"Define URLs And Prompts":{"main":[[{"node":"Split Out","type":"main","index":0}]]},"Get image from unsplash":{"main":[[{"node":"Transform to base64 (image)","type":"main","index":0}]]},"Get image from unsplash2":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Get image from unsplash3":{"main":[[{"node":"Transform to base","type":"main","index":0}]]},"Get image from unsplash4":{"main":[[{"node":"AI Agent2","type":"main","index":0}]]},"Google Gemini Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Google Gemini Chat Model1":{"ai_languageModel":[[{"node":"AI Agent2","type":"ai_languageModel","index":0}]]},"Transform to base64 (pdf)":{"main":[[{"node":"Call Gemini API with PDF","type":"main","index":0}]]},"Define Multiple Image URLs":{"main":[[{"node":"Split Out to multiple items","type":"main","index":0}]]},"Split Out to multiple items":{"main":[[{"node":"Get image from unsplash3","type":"main","index":0}]]},"Transform to base64 (image)":{"main":[[{"node":"Call Gemini API with Image","type":"main","index":0}]]},"When clicking ‘Test workflow’":{"main":[[{"node":"Define URLs And Prompts","type":"main","index":0},{"node":"Define Multiple Image URLs","type":"main","index":0},{"node":"Get PDF file","type":"main","index":0},{"node":"Get image from unsplash","type":"main","index":0},{"node":"Get image from unsplash4","type":"main","index":0}]]}}}


name: Social Media Content Generator And Publisher | X, Linkedin
author_name: ömer
author_username: gocmen
categories: []
created_at: 2025-03-04T20:39:58.733Z
updated_at: 2025-03-04T20:39:58.733Z
url: https://n8n.io/workflows/3082
scraped_at: 2025-06-19 22:50:39
description:
  Generate and Publish AI Content to LinkedIn and X (Twitter) with n8n

  Overview
  This n8n workflow automates the generation and publishing of AI-powered social media content across LinkedIn and X (formerly Twitter). By leveraging AI, this workflow helps social media managers, marketers, and content creators streamline their posting process.

  Who is this for?
  Social media managers
  Content creators
  Digital marketers
  Businesses looking to automate content generation

  Features
  AI-powered content creation** tailored for LinkedIn and X (Twitter)
  Automated publishing** to both platforms
  Structured output parsing** to ensure consistency
  OAuth2 authentication** for secure posting
  Merge and confirmation steps** to track successful postings

  Setup Instructions
  Prerequisites
  Before using this workflow, ensure you have:
  An n8n instance set up
  API credentials for:
    Google Gemini AI (for content generation)
    X Developer Account with OAuth2 authentication
    LinkedIn Developer Account with OAuth2 authentication
  A form submission service integrated with n8n

  Workflow Breakdown

  1. Trigger: Form Submission
  A user submits a form containing the post title.
  The form is secured with Basic Authentication.
  The submitted title is passed to the AI Agent.

  2. AI Content Generation
  The Google Gemini Chat Model processes the title and generates:
    LinkedIn post content
    Twitter (X) post content
    Hashtags
    Call-to-action (LinkedIn)
    Character limit check (Twitter)

  3. Parsing AI Output
  A structured output parser converts the AI-generated content into a JSON format.
  Ensures correct formatting for LinkedIn and Twitter (X).

  4. Publishing to Social Media
  X (Twitter) Posting
  Extracts the Twitter post from the AI output.
  Publishes it via an OAuth2-authenticated X (Twitter) account.

  LinkedIn Posting
  Extracts the LinkedIn post from the AI output.
  Publishes it via an OAuth2-authenticated LinkedIn account.

  5. Merging Post Results
  Merges the response data from both LinkedIn and Twitter after publishing.

  6. Confirmation Step
  Displays a final confirmation form once the posts are successfully published.

  Benefits
  Save time** by automating content creation and publishing.
  Ensure consistency** across platforms with structured AI-generated posts.
  Secure authentication** using OAuth2 for LinkedIn and Twitter.
  Increase engagement** with AI-optimized hashtags and CTAs.

  This workflow enables seamless social media automation, helping professionals post engaging AI-powered content effortlessly. 🚀

nodes_used:
  ["n8n-nodes-base.twitter","n8n-nodes-base.linkedIn","@n8n/n8n-nodes-langchain.agent","@n8n/n8n-nodes-langchain.outputParserStructured","@n8n/n8n-nodes-langchain.lmChatGoogleGemini"]

workflow_json:
  {"id":"wyzRJoRGTlwmZ0JJ","meta":{"instanceId":"38c7fb933498a5028d938adeb8c37dbb3117d7ec2d546d718be8f13730816a0d","templateCredsSetupCompleted":true},"name":"Social Media Content Generator And Publisher | X, Linkedin","tags":[],"nodes":[{"id":"7095690e-4f33-4ad0-8276-f5f91768bc42","name":"Google Gemini Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[200,220],"parameters":{"options":{},"modelName":"models/gemini-2.0-flash"},"credentials":{"googlePalmApi":{"id":"Td5xMGwy3MYAYRjH","name":"Google Gemini(PaLM) Api account"}},"typeVersion":1},{"id":"2858290a-82be-4f2f-9f20-a1147d1feb32","name":"Receive Post Title","type":"n8n-nodes-base.formTrigger","position":[0,0],"webhookId":"4d921ee9-7668-4133-8750-4e35f9fc2353","parameters":{"options":{},"formTitle":"post","formFields":{"values":[{"fieldLabel":"post title"}]},"authentication":"basicAuth","formDescription":"post"},"credentials":{"httpBasicAuth":{"id":"YoS57iMdTC3pnXR6","name":"Unnamed credential 2"}},"typeVersion":2.2},{"id":"b1540464-46ca-42d3-9e53-c3b7bd006d55","name":"Generate AI Content","type":"@n8n/n8n-nodes-langchain.agent","position":[200,0],"parameters":{"text":"=\nwrite min 50 word about this topic '{{ $json[\"post title\"] }}'\nfor Linkedin and X platform separately","options":{},"promptType":"define","hasOutputParser":true},"typeVersion":1.7},{"id":"ac86de4e-49a2-4efc-9067-bbb0008a218c","name":"Format AI Output","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[360,260],"parameters":{"schemaType":"manual","inputSchema":"{\n  \"type\": \"object\",\n  \"properties\": {\n    \"event_name\": {\n      \"type\": \"string\"\n    },\n    \"event_description\": {\n      \"type\": \"string\"\n    },\n    \"platform_posts\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"LinkedIn\": {\n          \"type\": \"object\",\n          \"properties\": {\n            \"post\": {\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        \"Twitter\": {\n          \"type\": \"object\",\n          \"properties\": {\n            \"post\": {\n              \"type\": \"string\"\n            },\n            \"hashtags\": {\n              \"type\": \"array\",\n              \"items\": {\n                \"type\": \"string\"\n              }\n            },\n            \"character_limit\": {\n              \"type\": \"integer\"\n            }\n          }\n        }\n      }\n    },\n    \"additional_notes\": {\n      \"type\": \"string\"\n    }\n  }\n}"},"typeVersion":1.2},{"id":"5a4cbb6f-4efc-4fd1-85ea-9022d6415811","name":"Post to X","type":"n8n-nodes-base.twitter","position":[580,-100],"parameters":{"text":"={{ $json.output.platform_posts.Twitter.post }}","additionalFields":{}},"credentials":{"twitterOAuth2Api":{"id":"tFoAD5zVouFXHqHV","name":"X account 4"}},"typeVersion":2},{"id":"6be0a393-1ef8-4e2e-b58e-e7dd90bf5295","name":"Post to LinkedIn","type":"n8n-nodes-base.linkedIn","position":[580,120],"parameters":{"text":"={{ $json.output.platform_posts.LinkedIn.post }}","person":"-HtNhNKSsE","additionalFields":{}},"credentials":{"linkedInOAuth2Api":{"id":"wssjQBMipjgQPG10","name":"LinkedIn account 3"}},"typeVersion":1},{"id":"10336b6e-b093-473c-b8d1-90d6b7b043b3","name":"Append Linkedin And X Publishing Responses","type":"n8n-nodes-base.merge","position":[860,20],"parameters":{"mode":"combine","options":{},"combineBy":"combineAll"},"typeVersion":3},{"id":"a236d6ba-0ded-4d42-99a3-0b53069faec5","name":"Show Confirmation","type":"n8n-nodes-base.form","position":[1080,20],"webhookId":"9c0b2419-aff6-40dd-95f7-5dfd0a88d46c","parameters":{"options":{},"operation":"completion","completionTitle":"Your post has been successfully shared","completionMessage":"=🔗 View your posts:\n\nX (Twitter): \n[https://x.com/x/status/{{ $json.id }}]\n\nLinkedIn:\n[https://www.linkedin.com/feed/update/{{ $json.urn }}]"},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"7b92c25a-8617-44c8-b3b6-c038f01d6bfa","connections":{"Post to X":{"main":[[{"node":"Append Linkedin And X Publishing Responses","type":"main","index":0}]]},"Format AI Output":{"ai_outputParser":[[{"node":"Generate AI Content","type":"ai_outputParser","index":0}]]},"Post to LinkedIn":{"main":[[{"node":"Append Linkedin And X Publishing Responses","type":"main","index":1}]]},"Receive Post Title":{"main":[[{"node":"Generate AI Content","type":"main","index":0}]]},"Generate AI Content":{"main":[[{"node":"Post to X","type":"main","index":0},{"node":"Post to LinkedIn","type":"main","index":0}]]},"Google Gemini Chat Model":{"ai_languageModel":[[{"node":"Generate AI Content","type":"ai_languageModel","index":0}]]},"Append Linkedin And X Publishing Responses":{"main":[[{"node":"Show Confirmation","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-06-19 22:49:32
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-06-19 22:49:44
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: Analyze Landing Page with OpenAI and Get Optimization Tips
author_name: Not Another Marketer
author_username: notanothermarketer
categories: []
created_at: 2025-03-06T15:24:25.565Z
updated_at: 2025-03-06T15:24:25.565Z
url: https://n8n.io/workflows/3100
scraped_at: 2025-06-19 22:50:19
description:
  Your Landing Page is Leaking Sales—Here’s How to Fix It in Seconds
  Visitors land on your page. But instead of converting, they bounce.

  Why? Something’s broken. Something’s missing. But what?

  ❌ Is your CTA too weak?
  ❌ Is your messaging unclear?
  ❌ Is your design creating friction?

  You know something is off, but don’t know what. What if you could get an instant, expert-level report on exactly what to fix?

  This workflow will do an AI Analysis of your landing page, provide a CRO Audit, so you can optimize your landing page.

  Who is This For?
  SaaS Founders & Startups**: Stop leaving money on the table. Make every visitor count.
  Marketers & Growth Experts**: Turn landing pages into high-converting assets.
  E-commerce & Lead Gen Businesses**: More conversions = more revenue.

  How It Works
  Paste your URL
  Get an instant roast + fix list
  Implement changes & watch conversions 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, roasts the landing page, and provides 10 Conversion Rate Optimization Tips to improve your landing page. 

  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 workflow has been completed, select Logs to get a readable version. 

  Below is an example.

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

workflow_json:
  {"id":"gsra9JToRDftNEvH","meta":{"instanceId":"e8ec316b54e91908f34cbfdc330e5d1d5e97aa0ea8f7277c00d8a8a3892c9983","templateCredsSetupCompleted":true},"name":"🤓 Conversion Rate Optimizer","tags":[{"id":"QUoce1Blvhtuie7K","name":"Business","createdAt":"2025-03-06T15:17:58.728Z","updatedAt":"2025-03-06T15:17:58.728Z"}],"nodes":[{"id":"8aca34c2-65d6-432a-a7a5-fede59c3f4cb","name":"Landing Page Url","type":"n8n-nodes-base.formTrigger","position":[-180,0],"webhookId":"0818531a-3892-49f6-af78-cde8d538b205","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":"61e17805-93aa-46a3-a5a1-36c02da6432a","name":"Scrape Website","type":"n8n-nodes-base.httpRequest","position":[20,0],"parameters":{"url":"={{ $json['Landing Page Url'] }}","options":{}},"typeVersion":4.2},{"id":"cbe8bed2-37a0-4459-a34c-47b87c012875","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[240,0],"parameters":{"text":"=You are a professional expert in Conversion Rate Optimization who helps business founders & CMOs improve their landing pages. You are a world-class expert in analysing landing pages, roasting them, and providing valuable Conversion Rate Optimization Ideas to help businesses increase conversions.  \n\nGOAL\nI want you to roast my landing page and deliver recommendations to improve the Conversion Rate. I will use this roast to understand what's wrong with my landing page and make improvements based on your recommendations. \n\nROAST STRUCTURE\nThis framework consists of 2 blocks of insights: \nRoast: a detailed roast of my landing page.\nRecommendations: 10 conversion rate optimization ideas based on your roast and analysis.\n\nROAST & RECOMMENDATIONS CRITERIA\nFor the Roast: Be friendly & casual. Talk like a human to another human. \nFor the Roast: Be unconventional & fun. I don't want to be bored. A roast must agitate the reader's feelings. \nFor the Roast: You will make a full landing page analysis, and explain what's wrong. You will use this analysis to make recommendations for The Recommendations.  \nFor the Recommendations: Be specific. Write exactly what I need to do. Your detailed description for each Conversion Rate Optimization Idea should be self-explanatory. For example, instead of saying “Rewrite your headline”, give me improved ideas for the headline. Your job is to return advanced insights personalised only for my specific landing page. This is a critical law for you.\nFor the Recommendations: Be creative. Don't return trivial and outdated Conversion Rate Optimization ideas that the average marketer would recommend. Prioritise unconventional CRO tactics so I get real value from you here. Think like the top 0.1% conversion rate optimization expert.\nFor the Recommendations: Prioritise Conversion Rate Optimization Ideas that are relevant in the 2024 digital marketing space. \nFor the Recommendations: Your Conversion Rate Optimization ideas must be impactful. Prioritise Conversion Rate Optimization Ideas that adds a wow effect.\nFor the Recommendations: Your Conversion Rate Optimization ideas must be easy to implement.\nFor the Recommendations: Personalise your ideas with references to the Roast you made. I don’t want to read 10 generic ideas that can work for anyone (for example, “add a live chat” or “offer a free trial”). I need a 100% personalised response.\n\nHere is the content of my landing page: {{ $json.data }}","options":{},"promptType":"define"},"typeVersion":1.7},{"id":"37786922-d64b-4e84-916e-1df8daeb0287","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[200,220],"parameters":{"model":{"__rl":true,"mode":"list","value":"o1","cachedResultName":"o1"},"options":{"reasoningEffort":"high"}},"credentials":{"openAiApi":{"id":"MtyWeuRTqwi3Yx9H","name":"OpenAi account"}},"typeVersion":1.2}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"38d9dab2-07ed-49cb-836e-a4b3ecf9d7da","connections":{"AI Agent":{"main":[[]]},"Scrape Website":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Landing Page Url":{"main":[[{"node":"Scrape Website","type":"main","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","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-06-19 22:49:49
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-06-19 22:48:56
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-06-19 22:49:07
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}]]}}}


