# templates

name: Scrape LinkedIn Job Listings for Hiring Signals & Prospecting with Bright Data
author_name: Yaron Been
author_username: yaron-nofluff
nodes_used: ["n8n-nodes-base.googleSheets","n8n-nodes-base.httpRequest","n8n-nodes-base.code"]
categories: []
created_at: 2025-04-16T18:34:57.146Z
updated_at: 2025-04-16T18:34:57.146Z
url: https://n8n.io/workflows/3580
scraped_at: 2025-06-19 22:49:55
description:
  LinkedIn Hiring Signal Scraper — Jobs & Prospecting Using Bright Data

  Purpose:
  Discover recent job posts from LinkedIn using Bright Data's Dataset API, clean the results, and log them into Google Sheets — for both job hunting and identifying high-intent B2B leads based on hiring activity.

  Use Cases:
  Job Seekers** – Spot relevant openings filtered by role, city, and country.  
  Sales & Prospecting** – Use job posts as buying signals.  
    If a company is hiring for a role you support (e.g. marketers, developers, ops) —  
    it's the perfect time to reach out and offer your services.

  Tools Needed:
  n8n Nodes:**
    Form Trigger  
    HTTP Request  
    Wait  
    If  
    Code  
    Google Sheets  
    Sticky Notes (for embedded guidance)
  External Services:**
    Bright Data (Dataset API)  
    Google Sheets

  API Keys & Authentication Required:
  Bright Data API Key**  
    → Add in the HTTP Request headers:  
    Authorization: Bearer YOUR_BRIGHTDATA_API_KEY

  Google Sheets OAuth2**  
    → Connect your account in n8n to allow read/write access to the spreadsheet.

  General Guidelines:
  Use descriptive names for all nodes.  
  Include retry logic in polling to avoid infinite loops.  
  Flatten nested fields (like job_poster and base_salary).  
  Strip out HTML tags from job descriptions for clean output.

  Things to be Aware Of:
  Bright Data snapshots take ~1–3 minutes — use a Wait node and polling.  
  Form filters affect output significantly:  
    🔍 We recommend filtering by "Last 7 days" or "Past 24 hours" for fresher data.  
  Avoid hardcoding values in the form — leave optional filters empty if unsure.

  Post-Processing & Outreach:
  After data lands in Google Sheets, you can use it to:  
    Personalize cold emails based on job titles, locations, and hiring signals.  
    Send thoughtful LinkedIn messages (e.g., "Saw you're hiring a CMO...")  
    Prioritize outreach to companies actively growing in your niche.

  Additional Notes:
  📄 Copy the Google Sheet Template:  
    Click here to make your copy  
    → Rename for each campaign or client.

  Form fields include:  
    Job Location (city or region)  
    Keyword (e.g., CMO, Backend Developer)  
    Country (2-letter code, e.g., US, UK)

  This workflow gives you a competitive edge —  
  📌 For candidates: Be first to apply.  
  📌 For sellers: Be first to pitch.  
  All based on live hiring signals from LinkedIn.

  STEP-BY-STEP WALKTHROUGH

  Step 1: Set up your Google Sheet
  Open this template
  Go to File → Make a copy
  You'll use this copy as the destination for the scraped job posts

  Step 2: Fill out the Input Form in n8n
  The form allows you to define what kind of job posts you want to scrape.

  Fields:
  Job Location** → e.g. New York, Berlin, Remote  
  Keyword** → e.g. CMO, AI Architect, Ecommerce Manager  
  Country Code (2-letter)** → e.g. US, UK, IL

  💡 Pro Tip:  
  For best results, set the filter inside the workflow to:  
  time_range = "Past 24 hours" or "Last 7 days"  
  This keeps results relevant and fresh.

  Step 3: Trigger Bright Data Snapshot
  The workflow sends a request to Bright Data with your input.

  Example API Call Body:
  [
    {
      "location": "New York",
      "keyword": "Marketing Manager",
      "country": "US",
      "time_range": "Past 24 hours",
      "job_type": "Part-time",
      "experience_level": "",
      "remote": "",
      "company": ""
    }
  ]

  Bright Data will start preparing the dataset in the background.

  Step 4: Wait for the Snapshot to Complete
  The workflow includes a Wait Node and Polling Loop that checks every few minutes until the data is ready.

  You don't need to do anything here — it's all automated.

  Step 5: Clean Up the Results
  Once Bright Data responds with the full job post list:

  ✔️ Nested fields like job_poster and base_salary are flattened  
  ✔️ HTML in job descriptions is removed  
  ✔️ Final data is formatted for export

  Step 6: Export to Google Sheets
  The final cleaned list is added to your Google Sheet (first tab).

  Each row = one job post, with columns like:

  job_title, company_name, location, salary_min, apply_link, job_description_plain

  Step 7: Use the Data for Outreach or Research
  Example for Job Seekers:
  You search for:

  Location: Berlin
  Keyword: Product Designer
  Country: DE
  Time range: Past 7 days

  Now you've got a live list of roles — with salary, recruiter info, and apply links.
  → Use it to apply faster than others.

  Example for Prospecting (Sales / SDR):
  You search for:

  Location: London
  Keyword: Growth Marketing
  Country: UK

  And find companies hiring growth marketers.
  → That's your signal to offer help with media buying, SEO, CRO, or your relevant service.

  Use the data to:
  Write personalized cold emails ("Saw you're hiring a Growth Marketer…")
  Start warm LinkedIn outreach
  Build lead lists of companies actively expanding in your niche

  API Credentials Required:
  Bright Data API Key**  
    Used in HTTP headers: Authorization: Bearer YOUR_BRIGHTDATA_API_KEY

  Google Sheets OAuth2**  
    Allows n8n to read/write to your spreadsheet

  Adjustments & Customization Tips:
  Modify the HTTP Request body to add more filters (e.g. job_type, remote, company)
  Increase or reduce polling wait time depending on Bright Data speed
  Add scoring logic to prioritize listings based on title or location

  Final Notes:
  📄 Google Sheet Template:  
    Make your copy here

  ⚙️ Bright Data Dataset API:  
    Visit BrightData.com

  📬 Personalization works best when you act quickly.  
    Use the freshest data to reach out with context — not generic pitches.

  This workflow turns LinkedIn job posts into sales insights and job leads.
  All in one click. Fully automated. Ready for your next move.

workflow_json:
  {"meta":{"instanceId":"1eadd5bc7c3d70c587c28f782511fd898c6bf6d97963d92e836019d2039d1c79"},"nodes":[{"id":"bee233ee-7212-4fbd-b151-0bb49919ca42","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[0,280],"parameters":{"color":4,"width":1289,"height":4398,"content":"LinkedIn Job Data Scraper to Google Sheets\nScrape live job posts from LinkedIn via Bright Data, clean them, and send to Google Sheets. Use for:\n✅ Job Hunting — fresh, filtered roles\n✅ Sales Prospecting — find companies hiring (aka growing)\n⚙️ What's Used\nn8n Nodes: Form → HTTP Request → Wait → If → Code → Google Sheets\nExternal Tools:\n\nBright Data – Dataset API\nGoogle Sheets – Template Copy\n\n🔑 Setup – Credentials Needed\n\nBright Data API Key → Add to HTTP headers as: Authorization: Bearer YOUR_KEY\nGoogle Sheets OAuth2 → Connect account in n8n\n\n📝 Input Form – Fields\nUsed to define what job data to scrape.\nFieldDescriptionExampleLocationCity/regionNew York, BerlinKeywordRole to searchCMO, Data AnalystCountry2-letter ISO codeUS, UK, DETime RangeHow recent the jobs should be\"Past 24 hours\" or \"Last 7 days\" (recommended)Job TypeFull-time / Part-time / Contract(Optional)ExperienceEntry, Mid, Senior(Optional)RemoteFilter by remote-friendly roles(Optional)CompanyFilter by specific employer(Optional)\n🚀 Workflow Steps\n\nUser fills input form\nTrigger snapshot via Bright Data Dataset API\nWait node + polling checks when data is ready (~1–3 mins)\nCleanup step:\n\nFlattens nested fields (job_poster, base_salary, etc.)\nRemoves HTML from job descriptions\n\n\nSend to Google Sheet\n\nSheet is pre-linked, 1 job per row\nExample columns: job_title, company_name, location, salary_min, apply_link, job_description_plain\n\n\nYou use the data\n\nJob seekers → Apply fast\nSalespeople → Spot buyers & offer help\n\n\n\n💡 Pro Tips\n\nUse \"Past 24 hours\" or \"Last 7 days\" for fresher results\nLeave filters empty if unsure — Bright Data will return broader results\nUse cleaned data for:\n\nCold email personalization\nLinkedIn outreach\nBuilding ICP-based lead lists\n\n\n\n🧪 Example API Body\njson[ \n  { \n    \"location\": \"New York\", \n    \"keyword\": \"Marketing Manager\", \n    \"country\": \"US\", \n    \"time_range\": \"Past 24 hours\", \n    \"job_type\": \"Part-time\", \n    \"experience_level\": \"\", \n    \"remote\": \"\", \n    \"company\": \"\" \n  } \n]\n📄 Template & Resources\n\n📋 Google Sheet Template (Make a Copy)\n📘 Bright Data API Reference\n\n🛠️ Customize It\n\nAdd filters to HTTP Body (remote, experience_level, etc.)\nChange polling interval if Bright Data is slow\nAdd custom logic to score/prioritize listings\nSend filtered lists to CRM, Slack, etc.\n\nThis gives you a live stream of hiring signals — whether you're finding a job or pitching a service. One form. One click. Fully automated."},"typeVersion":1},{"id":"0fa9d0fe-b3ba-48be-99b9-2bc3aeb18b43","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[0,-60],"parameters":{"color":4,"width":1300,"height":320,"content":"=======================================\n            WORKFLOW ASSISTANCE\n=======================================\nFor any questions or support, please contact:\n    Yaron@nofluff.online\n\nExplore more tips and tutorials here:\n   - YouTube: https://www.youtube.com/@YaronBeen/videos\n   - LinkedIn: https://www.linkedin.com/in/yaronbeen/\n=======================================\n"},"typeVersion":1},{"id":"33cb416e-a7ff-4b55-9701-9b9e95d76f12","name":"Snapshot Progress","type":"n8n-nodes-base.httpRequest","position":[2840,360],"parameters":{"url":"=https://api.brightdata.com/datasets/v3/progress/{{ $('HTTP Request- Post API call to Bright Data').item.json.snapshot_id }}","options":{},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"Bearer <YOUR_BRIGHT_DATA_API_KEY>"}]}},"typeVersion":4.2},{"id":"6b8c9405-8f8c-4a24-85ca-343d33e06141","name":"Sticky Note10","type":"n8n-nodes-base.stickyNote","position":[3680,140],"parameters":{"width":195,"height":646,"content":"In this workflow, I use Google Sheets to store the results. \n\nYou can use my template to get started faster:\n\n1. [Click on this link to get the template](https://docs.google.com/spreadsheets/d/1_jbr5zBllTy_pGbogfGSvyv1_0a77I8tU-Ai7BjTAw4/edit?usp=sharing)\n2. Make a copy of the Sheets\n3. Add the URL to this node \n\n\n"},"typeVersion":1},{"id":"3d3cd92a-9ea7-4a4f-a9b5-aae689f719e5","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[1320,-60],"parameters":{"width":480,"height":2240,"content":"# 🔍 LinkedIn Jobs API – Parameter Guide\n\nUse this object to query LinkedIn job listings.  \nEach field lets you filter results based on different criteria.\n\n```json\n{\n  \"location\": \"{{ $json.Location }}\",\n  \"keyword\": \"{{ $json.Keyword }}\",\n  \"country\": \"{{ $json.Country }}\",\n  \"time_range\": \"Past 24 hours\",\n  \"job_type\": \"Part-time\",\n  \"experience_level\": \"\",\n  \"remote\": \"\",\n  \"company\": \"\"\n}\n```\n\n## 🧾 Field Explanations & Valid Options\n\n### 🗺️ location\nCity or region where the job is located.\nUse a city or region name.\n✅ Example: \"Berlin\", \"New York\"\n\n### 🧠 keyword\nJob title or search keywords.\nUse terms like role names or skills.\n✅ Example: \"Data Scientist\", \"Growth Marketing\"\n\n### 🌍 country\nCountry code in ISO 3166-1 alpha-2 format.\n✅ Example: \"US\", \"DE\", \"IL\"\n\n### ⏱️ time_range\nPosting date filter.\nLimits results based on how recently jobs were posted.\nAccepted values:\n- Any Time\n- Past 24 hours\n- Past Week\n- Past Month\n✅ Example: \"Past Week\"\n\n### 💼 job_type\nType of employment.\nUse a single value or comma-separated list.\nAccepted values:\n- Full-time\n- Part-time\n- Contract\n- Temporary\n- Internship\n- Volunteer\n- Other\n✅ Example: \"Full-time,Contract\"\n\n### 🎯 experience_level\nSeniority level of the job.\nAccepted values:\n- Internship\n- Entry level\n- Associate\n- Mid-Senior level\n- Director\n- Executive\n✅ Example: \"Mid-Senior level\"\n\n### 🌐 remote\nWorkplace type.\nAccepted values:\n- Remote\n- On-site\n- Hybrid\n- (leave blank for no preference)\n✅ Example: \"Remote\"\n\n### 🏢 company\nFilter by company name.\nOptional. Use plain text.\n✅ Example: \"Google\", \"Spotify\"\n\n## ✅ Full Example\n\n```json\n{\n  \"location\": \"New York\",\n  \"keyword\": \"UI Designer\",\n  \"country\": \"US\",\n  \"time_range\": \"Past Week\",\n  \"job_type\": \"Full-time,Contract\",\n  \"experience_level\": \"Mid-Senior level\",\n  \"remote\": \"Hybrid\",\n  \"company\": \"Spotify\"\n}\n```\n\n"},"typeVersion":1},{"id":"1d7a7bb0-1531-4516-9373-5e85a090b143","name":"On form submission - Discover Jobs","type":"n8n-nodes-base.formTrigger","position":[1700,580],"webhookId":"8d0269c7-d1fc-45a1-a411-19634a1e0b82","parameters":{"options":{},"formTitle":"Linkedin High Intent Prospects And Job Post Hunt","formFields":{"values":[{"fieldLabel":"Job Location","placeholder":"example: new york","requiredField":true},{"fieldLabel":"Keyword","placeholder":"example: CMO, AI architect","requiredField":true},{"fieldLabel":"Country (2 letters)","placeholder":"example: US,UK,IL","requiredField":true}]},"formDescription":"This form lets you customize your job search / prospecting by choosing:\n\nLocation (city or region)\n\nJob title or keywords\n\nCountry code\n\nFilters like posting date, job type, experience level, and remote options\n\nYou can also optionally narrow results by company name.\n\n🧠 Tip: Leave fields blank if you want broader results."},"typeVersion":2.2},{"id":"aea569df-eedd-441f-aba5-c3c26a50fa87","name":"HTTP Request- Post API call to Bright Data","type":"n8n-nodes-base.httpRequest","position":[2260,620],"parameters":{"url":"https://api.brightdata.com/datasets/v3/trigger","method":"POST","options":{},"jsonBody":"=[\n  {\n    \"location\": \"{{ $json['Job Location'] }}\",\n    \"keyword\": \"{{ $json.Keyword }}\",\n    \"country\": \"{{ $json['Country (2 letters)'] }}\",\n    \"time_range\": \"Past 24 hours\",\n    \"job_type\": \"Part-time\",\n    \"experience_level\": \"\",\n    \"remote\": \"\",\n    \"company\": \"\"\n  }\n] ","sendBody":true,"sendQuery":true,"sendHeaders":true,"specifyBody":"json","queryParameters":{"parameters":[{"name":"dataset_id","value":"gd_lpfll7v5hcqtkxl6l"},{"name":"endpoint","value":"https://yaron-nofluff.app.n8n.cloud/webhook-test/8c42463d-a631-4a17-a084-4bcbbb3bfc68"},{"name":"notify","value":"https://yaron-nofluff.app.n8n.cloud/webhook-test/8c42463d-a631-4a17-a084-4bcbbb3bfc68"},{"name":"format","value":"json"},{"name":"uncompressed_webhook","value":"true"},{"name":"type","value":"discover_new"},{"name":"discover_by","value":"=keyword"}]},"headerParameters":{"parameters":[{"name":"Authorization","value":"Bearer <YOUR_BRIGHT_DATA_API_KEY>"}]}},"typeVersion":4.2},{"id":"8837f055-7243-44b6-87a2-e679d75839d0","name":"Wait - Polling Bright Data","type":"n8n-nodes-base.wait","position":[2600,360],"webhookId":"8005a2b3-2195-479e-badb-d90e4240e699","parameters":{"unit":"minutes"},"executeOnce":false,"typeVersion":1.1},{"id":"1f0ebefa-42a1-450c-b30a-64edabdaedaf","name":"If - Checking status of Snapshot - if data is ready or not","type":"n8n-nodes-base.if","position":[3040,360],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"7932282b-71bb-4bbb-ab73-4978e554de7e","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.status }}","rightValue":"running"}]}},"typeVersion":2.2},{"id":"e17b4da0-3f9c-45d5-acdf-ab634acfef97","name":"HTTP Request - Getting data from Bright Data","type":"n8n-nodes-base.httpRequest","position":[3320,380],"parameters":{"url":"=https://api.brightdata.com/datasets/v3/snapshot/{{ $json.snapshot_id }}","options":{},"sendQuery":true,"sendHeaders":true,"queryParameters":{"parameters":[{"name":"format","value":"json"}]},"headerParameters":{"parameters":[{"name":"Authorization","value":"Bearer <YOUR_BRIGHT_DATA_API_KEY>"}]}},"typeVersion":4.2},{"id":"b5bd6a55-f80d-46f9-a59a-beff28de9da7","name":"Code - Cleaning Up","type":"n8n-nodes-base.code","position":[3600,400],"parameters":{"jsCode":"// Helper function to strip HTML tags\nfunction stripHtml(html) {\n  return html\n    .replace(/<[^>]+>/g, '')    // remove all HTML tags\n    .replace(/&nbsp;/g, ' ')     // decode HTML entities\n    .replace(/&[a-z]+;/g, '')    // remove other HTML entities\n    .replace(/\\s+/g, ' ')        // normalize whitespace\n    .trim();\n}\n\nreturn items.map(item => {\n  const data = item.json;\n\n  // Flatten job_poster\n  if (data.job_poster) {\n    data.job_poster_name = data.job_poster.name || '';\n    data.job_poster_title = data.job_poster.title || '';\n    data.job_poster_url = data.job_poster.url || '';\n    delete data.job_poster;\n  }\n\n  // Flatten base_salary\n  if (data.base_salary) {\n    data.salary_min = data.base_salary.min_amount || '';\n    data.salary_max = data.base_salary.max_amount || '';\n    data.salary_currency = data.base_salary.currency || '';\n    data.salary_period = data.base_salary.payment_period || '';\n    delete data.base_salary;\n  }\n\n  // Clean up job description HTML\n  if (data.job_description_formatted) {\n    data.job_description_plain = stripHtml(data.job_description_formatted);\n  }\n\n  return { json: data };\n});\n"},"typeVersion":2},{"id":"70f4a4a0-b9ce-4b7a-b232-86014a7f8a3f","name":"Google Sheets - Adding All Job Posts","type":"n8n-nodes-base.googleSheets","position":[3940,440],"parameters":{"columns":{"value":{"country_code":"={{ $json.country_code }}"},"schema":[{"id":"url","type":"string","display":true,"removed":false,"required":false,"displayName":"url","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_posting_id","type":"string","display":true,"removed":false,"required":false,"displayName":"job_posting_id","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_title","type":"string","display":true,"removed":false,"required":false,"displayName":"job_title","defaultMatch":false,"canBeUsedToMatch":true},{"id":"company_name","type":"string","display":true,"removed":false,"required":false,"displayName":"company_name","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_location","type":"string","display":true,"removed":false,"required":false,"displayName":"job_location","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_description_plain","type":"string","display":true,"removed":false,"required":false,"displayName":"job_description_plain","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_poster_name","type":"string","display":true,"removed":false,"required":false,"displayName":"job_poster_name","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_poster_title","type":"string","display":true,"removed":false,"required":false,"displayName":"job_poster_title","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_poster_url","type":"string","display":true,"removed":false,"required":false,"displayName":"job_poster_url","defaultMatch":false,"canBeUsedToMatch":true},{"id":"salary_min","type":"string","display":true,"removed":false,"required":false,"displayName":"salary_min","defaultMatch":false,"canBeUsedToMatch":true},{"id":"salary_max","type":"string","display":true,"removed":false,"required":false,"displayName":"salary_max","defaultMatch":false,"canBeUsedToMatch":true},{"id":"salary_currency","type":"string","display":true,"removed":false,"required":false,"displayName":"salary_currency","defaultMatch":false,"canBeUsedToMatch":true},{"id":"salary_period","type":"string","display":true,"removed":false,"required":false,"displayName":"salary_period","defaultMatch":false,"canBeUsedToMatch":true},{"id":"application_availability","type":"string","display":true,"removed":false,"required":false,"displayName":"application_availability","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_posted_date","type":"string","display":true,"removed":false,"required":false,"displayName":"job_posted_date","defaultMatch":false,"canBeUsedToMatch":true},{"id":"company_logo","type":"string","display":true,"removed":false,"required":false,"displayName":"company_logo","defaultMatch":false,"canBeUsedToMatch":true},{"id":"country_code","type":"string","display":true,"removed":false,"required":false,"displayName":"country_code","defaultMatch":false,"canBeUsedToMatch":true},{"id":"timestamp","type":"string","display":true,"removed":false,"required":false,"displayName":"timestamp","defaultMatch":false,"canBeUsedToMatch":true},{"id":"company_id","type":"string","display":true,"removed":false,"required":false,"displayName":"company_id","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_summary","type":"string","display":true,"removed":false,"required":false,"displayName":"job_summary","defaultMatch":false,"canBeUsedToMatch":true},{"id":"company_url","type":"string","display":true,"removed":false,"required":false,"displayName":"company_url","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_posted_time","type":"string","display":true,"removed":false,"required":false,"displayName":"job_posted_time","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_num_applicants","type":"string","display":true,"removed":false,"required":false,"displayName":"job_num_applicants","defaultMatch":false,"canBeUsedToMatch":true},{"id":"discovery_input","type":"string","display":true,"removed":false,"required":false,"displayName":"discovery_input","defaultMatch":false,"canBeUsedToMatch":true},{"id":"apply_link","type":"string","display":true,"removed":false,"required":false,"displayName":"apply_link","defaultMatch":false,"canBeUsedToMatch":true},{"id":"title_id","type":"string","display":true,"removed":false,"required":false,"displayName":"title_id","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_description_formatted","type":"string","display":true,"removed":false,"required":false,"displayName":"job_description_formatted","defaultMatch":false,"canBeUsedToMatch":true},{"id":"input","type":"string","display":true,"removed":false,"required":false,"displayName":"input","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_seniority_level","type":"string","display":true,"removed":false,"required":false,"displayName":"job_seniority_level","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_function","type":"string","display":true,"removed":false,"required":false,"displayName":"job_function","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_employment_type","type":"string","display":true,"removed":false,"required":false,"displayName":"job_employment_type","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_industries","type":"string","display":true,"removed":false,"required":false,"displayName":"job_industries","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_base_pay_range","type":"string","display":true,"removed":false,"required":false,"displayName":"job_base_pay_range","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"autoMapInputData","matchingColumns":["row_number"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{"handlingExtraData":"insertInNewColumn"},"operation":"append","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1_jbr5zBllTy_pGbogfGSvyv1_0a77I8tU-Ai7BjTAw4/edit#gid=0","cachedResultName":"input"},"documentId":{"__rl":true,"mode":"list","value":"1_jbr5zBllTy_pGbogfGSvyv1_0a77I8tU-Ai7BjTAw4","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1_jbr5zBllTy_pGbogfGSvyv1_0a77I8tU-Ai7BjTAw4/edit?usp=drivesdk","cachedResultName":"NoFluff-N8N-Sheet-Template-Job Scraping WIth Bright Data"}},"credentials":{"googleSheetsOAuth2Api":{"id":"4RJOMlGAcB9ZoYfm","name":"Google Sheets account 2"}},"typeVersion":4.3,"alwaysOutputData":true},{"id":"297d778f-afa5-4d2d-baea-3b1fb199f77c","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[1940,-40],"parameters":{"width":300,"height":880,"content":"🧠 Bright Data Trigger – Customize Your Job Query\n\nThis HTTP Request sends a POST call to Bright Data to start a new dataset snapshot based on your filters.\n\n👋 If you don’t want to use the Form Trigger,\nyou can directly adjust the filters here in this node.\n\nYou can customize:\n\n\"location\" → city, region, or keyword (e.g. \"New York\", \"Remote\")\n\n\"keyword\" → job title or role (e.g. \"CMO\", \"AI Engineer\")\n\n\"country\" → 2-letter country code (e.g. \"US\", \"UK\")\n\n\"time_range\" → \"Past 24 hours\", \"Last 7 days\", etc.\n\n\"job_type\", \"experience_level\", \"remote\", \"company\" → optional filters\n\n📌 Tip:\nUse \"Past 24 hours\" or \"Last 7 days\" for the freshest results."},"typeVersion":1},{"id":"54303791-b269-4930-85b5-33e50ae08f33","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[2320,220],"parameters":{"color":4,"width":940,"height":360,"content":"Bright Data Getting Jobs\n"},"typeVersion":1},{"id":"cccb03cb-0432-43ff-9c3a-233de510a775","name":"Edit Fields","type":"n8n-nodes-base.set","position":[1920,580],"parameters":{"options":{},"assignments":{"assignments":[{"id":"12067869-0249-4cd2-b9e2-8e4055a0d917","name":"","type":"string","value":""}]}},"typeVersion":3.4}],"pinData":{},"connections":{"Edit Fields":{"main":[[{"node":"HTTP Request- Post API call to Bright Data","type":"main","index":0}]]},"Snapshot Progress":{"main":[[{"node":"If - Checking status of Snapshot - if data is ready or not","type":"main","index":0}]]},"Code - Cleaning Up":{"main":[[{"node":"Google Sheets - Adding All Job Posts","type":"main","index":0}]]},"Wait - Polling Bright Data":{"main":[[{"node":"Snapshot Progress","type":"main","index":0}]]},"On form submission - Discover Jobs":{"main":[[{"node":"Edit Fields","type":"main","index":0}]]},"HTTP Request- Post API call to Bright Data":{"main":[[{"node":"Wait - Polling Bright Data","type":"main","index":0}]]},"HTTP Request - Getting data from Bright Data":{"main":[[{"node":"Code - Cleaning Up","type":"main","index":0}]]},"If - Checking status of Snapshot - if data is ready or not":{"main":[[{"node":"Wait - Polling Bright Data","type":"main","index":0}],[{"node":"HTTP Request - Getting data from Bright Data","type":"main","index":0}]]}}}


name: High-Level Service Page SEO Blueprint Report Generator
author_name: Custom Workflows AI
author_username: customworkflowsai
categories: []
created_at: 2025-04-17T10:36:18.449Z
updated_at: 2025-04-17T10:36:18.449Z
url: https://n8n.io/workflows/3583
scraped_at: 2025-06-19 22:50:13
description:
  Introduction
  The "High-Level Service Page SEO Blueprint Report" workflow is a powerful, AI-driven solution designed to generate comprehensive SEO content strategies for service-based businesses.

  By analyzing competitor websites and user intent, this workflow creates a detailed blueprint that outlines the optimal structure, content, and conversion elements for a service page. The workflow leverages the JINA Reader API to extract content from competitor websites and uses Google Gemini AI to perform deep analysis across multiple dimensions: competitor content structure, user intent, strategic opportunities, and conversion optimization.

  The final output is a professionally formatted Markdown document that provides actionable guidance for creating a high-performing service page that satisfies both user needs and search engine requirements. This workflow eliminates the time-consuming process of manually analyzing competitors and developing content strategies, providing a data-driven foundation for service page creation that would typically require hours of expert analysis.

  Who is this for?
  This workflow is designed for digital marketers, SEO specialists, content strategists, and web developers who need to create or optimize service pages for businesses. It's particularly valuable for marketing agencies and freelancers who regularly develop content strategies for clients across various industries. 

  Users should have a basic understanding of SEO concepts, content marketing, and website structure. While technical SEO knowledge is beneficial, the workflow is designed to provide comprehensive guidance even for those with intermediate-level expertise. 

  The ideal user is someone who wants to streamline their content planning process and ensure their service pages are built on data-driven insights rather than guesswork.

  What problem is this workflow solving?
  Creating effective service pages that rank well in search engines while converting visitors is a complex challenge that typically requires extensive competitive research, content planning, and conversion optimization expertise. This workflow addresses several key pain points:

  Time-consuming competitor analysis: Manually analyzing multiple competitor websites to identify content patterns, heading structures, and meta tag strategies can take hours.

  Difficulty identifying content gaps: Determining what topics competitors are missing that could provide a competitive advantage requires deep analysis and industry knowledge.

  Balancing SEO and conversion elements: Creating content that satisfies both search engines and user needs while driving conversions is a delicate balance that many struggle to achieve.

  Lack of structured approach: Many content creators work without a comprehensive blueprint, leading to inconsistent results and missed opportunities.

  Difficulty translating analysis into actionable recommendations: Even when analysis is performed, turning those insights into a concrete content plan can be challenging.

  This workflow automates these processes, providing a structured, data-driven approach to service page creation that saves hours of research and planning time.

  What this workflow does
  Overview
  The workflow takes a list of competitor URLs and a target keyword as input, then performs a multi-stage analysis to generate a comprehensive service page blueprint. It extracts and analyzes competitor content, evaluates user intent, identifies strategic opportunities, and creates detailed recommendations for page structure, content, and conversion elements. 

  The final output is a professionally formatted Markdown document that serves as a complete roadmap for creating an effective service page.

  Process
  Data Collection: The workflow begins with a form that collects essential information: competitor URLs, target keyword, services offered, brand name, and whether the page is a homepage.

  Competitor Content Extraction: The workflow processes each competitor URL, using the JINA Reader API to extract the HTML content from each site.

  Content Structure Analysis: For each competitor site, the workflow extracts and analyzes heading structures, meta tags, schema markup, and recurring phrases (n-grams).

  Competitor Analysis Report: The AI synthesizes the competitive data to identify patterns in meta titles/descriptions, common outline sections, key heading concepts, and structural elements.

  User Intent Analysis: The workflow analyzes the target keyword to determine primary and secondary user intents, user personas, and their position in the buyer's journey.

  Gap Analysis: The AI identifies content overlaps ("table stakes"), content gaps (opportunities), SEO keyword priorities, and potential UX/conversion advantages.

  Page Outline Generation: Based on the previous analyses, the workflow creates an optimal page structure with H1, H2s, H3s, and potentially H4s, with justifications for each section.

  UX & Conversion Recommendations: The workflow adds detailed recommendations for calls-to-action, trust signals, copywriting tone, visual elements, and risk reversal strategies.

  Final Blueprint Creation: All analyses and recommendations are compiled into a comprehensive, well-structured Markdown document that serves as a complete service page blueprint.

  Setup
  Download or import the "High-Level Service Page SEO Blueprint Report" workflow JSON file into your n8n instance.

  Create a JINA Reader API key by visiting https://jina.ai/api-dashboard/key-manager. You can claim a free API key that allows up to 1 million tokens.

  Set up Google Gemini (PaLM) credentials by following the guide at https://docs.n8n.io/integrations/builtin/credentials/googleai/#using-geminipalm-api-key.

  Update the "Edit Fields" node with:
     Your JINA Reader API Key
     Adjust the "Waiting Time" to 20 seconds if using the free Google Gemini API tier (which limits to 5 requests per minute)
     Optionally change the Gemini model if needed

  Activate the workflow and start the form trigger.

  Complete the form with:
     Competitors (up to 5 direct competitor URLs)
     Target Keyword (the query related to your service)
     Services Offered (details of your complete service offerings)
     Brand Name (your company name)
     Whether the page is a homepage

  After processing, download the generated .txt file, which contains the blueprint in Markdown format.

  How to customize this workflow to your needs
  Adjust AI parameters: Modify the temperature settings in the Google Gemini Chat Model nodes to control creativity vs. precision in the AI outputs.

  Customize extraction logic: Edit the "Extract HTML Elements" code node to focus on specific HTML elements that are most relevant to your industry or content type.

  Modify analysis prompts: Customize the prompts in the various analysis nodes to focus on specific aspects of SEO or content strategy that are most important for your use case.

  Add industry-specific guidance: Enhance the prompts with industry-specific instructions or examples to make the output more relevant to particular sectors.

  Integrate with content management systems: Extend the workflow to automatically send the blueprint to content management systems, project management tools, or document storage platforms.

  Add competitor scoring: Implement a scoring system to evaluate and rank competitors based on specific criteria relevant to your strategy.

  Expand the analysis: Add additional analysis nodes to evaluate other aspects of competitor websites, such as page speed, mobile-friendliness, or backlink profiles.

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

workflow_json:
  {"id":"WETMyIJCbD3et6Rh","meta":{"instanceId":"ddfdf733df99a65c801a91865dba5b7c087c95cc22a459ff3647e6deddf2aee6"},"name":"High-Level Service Page SEO Blueprint Report","tags":[],"nodes":[{"id":"49aa0dd2-1d64-4047-9988-8e4f386d557a","name":"Convert URLs to Items","type":"n8n-nodes-base.code","position":[600,500],"parameters":{"jsCode":"// Get the raw input string from the \"Start\" node\nconst input = $('Start').item.json.Competitors;\n\n// Split the string by line breaks and filter out any empty lines\nconst urls = input\n  .split('\\n')\n  .map(url => url.trim())\n  .filter(url => url.length > 0);\n\n// Return the array as output with \"competitor_url\" field\nreturn urls.map(url => ({ json: { competitor_url: url } }));"},"typeVersion":2},{"id":"ec7b74db-43fc-4041-b63e-02ff21b9442e","name":"Start","type":"n8n-nodes-base.formTrigger","position":[240,500],"webhookId":"dafbc2ba-7397-4f83-b84d-630294e636b0","parameters":{"options":{},"formTitle":"Competitors Analysis for Service-Based Queries","formFields":{"values":[{"fieldType":"textarea","fieldLabel":"Competitors","placeholder":"competitor1.com\ncompetitor2.com","requiredField":true},{"fieldLabel":"Target Keyword","requiredField":true},{"fieldType":"textarea","fieldLabel":"Services Offered","requiredField":true},{"fieldLabel":"Brand Name","requiredField":true},{"fieldType":"dropdown","fieldLabel":"Is Homepage?","fieldOptions":{"values":[{"option":"Yes"},{"option":"No"}]}}]},"formDescription":"Generate a high-level service page content blueprint report to follow to beat the competition. \n\nNote: Do not add more than 5 competitors otherwise this could dilute the context and quality of the final report."},"typeVersion":2.2},{"id":"c517d397-4962-4281-962e-a57e3a12bea0","name":"Loop Over Items","type":"n8n-nodes-base.splitInBatches","position":[880,500],"parameters":{"options":{}},"typeVersion":3},{"id":"ac532215-626d-4690-9c99-d11f09fa86dc","name":"Get URL HTML","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","maxTries":5,"position":[1100,340],"parameters":{"url":"=https://r.jina.ai/{{ $json.competitor_url }}","options":{},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"=Bearer {{ $('Edit Fields').first().json['JINA Reader API Key'] }}"},{"name":"X-Return-Format","value":"html"}]}},"executeOnce":false,"retryOnFail":true,"typeVersion":4.2,"waitBetweenTries":5000},{"id":"ed03887c-9996-4dfb-b46a-a745bc64864a","name":"Extract HTML Elements","type":"n8n-nodes-base.code","position":[1300,340],"parameters":{"jsCode":"// Function to remove inner HTML tags and decode common HTML entities\nfunction cleanText(text) {\n  // Remove any HTML tags inside the text\n  let cleaned = text.replace(/<\\/?[^>]+(>|$)/g, '');\n\n  // Decode common HTML entities\n  cleaned = cleaned\n    .replace(/&nbsp;/g, ' ')  // Non-breaking space\n    .replace(/&amp;/g, '&')   // Ampersand\n    .replace(/&quot;/g, '\"')  // Double quote\n    .replace(/&lt;/g, '<')    // Less-than\n    .replace(/&gt;/g, '>')    // Greater-than\n    .replace(/&#8217;/g, \"'\")  // Right single quotation mark\n    .replace(/&#8220;/g, '\"')  // Left double quotation mark\n    .replace(/&#8221;/g, '\"')  // Right double quotation mark\n    .replace(/&rsquo;/g, \"'\")  // Right single quotation mark\n    .replace(/&lsquo;/g, \"'\")  // Left single quotation mark\n    .replace(/&rdquo;/g, '\"')  // Right double quotation mark\n    .replace(/&ldquo;/g, '\"')  // Left double quotation mark\n    .replace(/&mdash;/g, '—')  // Em dash\n    .replace(/&ndash;/g, '–')  // En dash\n    .replace(/&hellip;/g, '…') // Ellipsis\n    .replace(/&#(\\d+);/g, (match, dec) => String.fromCharCode(dec)); // Handle numeric entities\n\n  return cleaned.trim();  // Remove extra whitespace\n}\n\n// Function to generate n-grams from text\nfunction generateNgrams(text, n) {\n  // Convert text to lowercase and split into words\n  const words = text.toLowerCase()\n    .replace(/[^\\w\\s]|_/g, ' ')  // Replace punctuation and underscores with spaces\n    .replace(/\\s+/g, ' ')        // Replace multiple spaces with a single space\n    .trim()                       // Remove leading/trailing spaces\n    .split(' ');                  // Split into words\n  \n  // Filter out stop words and very short words (optional)\n  const filteredWords = words.filter(word => word.length > 1);\n  \n  // Generate n-grams\n  const ngrams = [];\n  for (let i = 0; i <= filteredWords.length - n; i++) {\n    ngrams.push(filteredWords.slice(i, i + n).join(' '));\n  }\n  \n  return ngrams;\n}\n\n// Function to count n-grams\nfunction countNgrams(textArray, n) {\n  const ngramCounts = {};\n  \n  textArray.forEach(text => {\n    const ngrams = generateNgrams(text, n);\n    \n    ngrams.forEach(ngram => {\n      ngramCounts[ngram] = (ngramCounts[ngram] || 0) + 1;\n    });\n  });\n  \n  // Convert to array of objects and sort by count (descending)\n  return Object.entries(ngramCounts)\n    .map(([phrase, count]) => ({ phrase, count }))\n    .sort((a, b) => b.count - a.count);\n}\n\n// Initialize an array to store the results for each item\nlet results = [];\n\n// Iterate through all items (each item corresponds to one URL in the loop)\nitems.forEach(item => {\n  // Get the raw HTML content for the current item\n  const html = item.json.data || '';  // Ensure you're getting the correct field where HTML is stored\n\n  // Initialize arrays to store the extracted outline\n  let outline = [];\n  let meta = {};\n  let schemas = [];\n  let headingTexts = []; // Store all heading texts for n-gram analysis\n\n  // Store all headings with their positions to maintain original order\n  let headingsWithPositions = [];\n  \n  // Extract heading content with a more robust approach\n  for (let i = 1; i <= 6; i++) {\n    // This regex pattern matches h1-h6 tags, capturing everything between opening and closing tags\n    // even if there are nested elements\n    const pattern = new RegExp(`<h${i}[^>]*>((?:.|\\n)*?)<\\/h${i}>`, 'gi');\n    let match;\n    \n    while ((match = pattern.exec(html)) !== null) {\n      const fullContent = match[1];\n      const cleanedText = cleanText(fullContent);\n      \n      // Only add non-empty headings\n      if (cleanedText && cleanedText.trim().length > 0) {\n        headingsWithPositions.push({\n          position: match.index,\n          level: i,\n          tag: `h${i}`,\n          text: cleanedText\n        });\n        \n        // Add to headingTexts for n-gram analysis\n        headingTexts.push(cleanedText);\n      }\n    }\n  }\n  \n  // Sort headings by their position in the HTML to maintain the original order\n  headingsWithPositions.sort((a, b) => a.position - b.position);\n  \n  // Process the sorted headings\n  headingsWithPositions.forEach(heading => {\n    // Build the outline based on the heading level with dot-based indentation\n    const indentation = '.'.repeat(heading.level - 1);  // No dots for H1, one for H2, etc.\n    outline.push(`${indentation}${heading.tag.toUpperCase()}: ${heading.text}`);\n  });\n\n  // Generate n-grams (2-gram, 3-gram, and 4-gram) from all headings\n  const ngrams = {\n    '2gram': countNgrams(headingTexts, 2),\n    '3gram': countNgrams(headingTexts, 3),\n    '4gram': countNgrams(headingTexts, 4)\n  };\n  \n  // Filter out n-grams with only one occurrence (optional)\n  // This can be adjusted based on preference\n  const filteredNgrams = {\n    '2gram': ngrams['2gram'].filter(item => item.count > 1),\n    '3gram': ngrams['3gram'].filter(item => item.count > 1),\n    '4gram': ngrams['4gram'].filter(item => item.count > 1)\n  };\n\n  // Extract title tag\n  const titleMatch = html.match(/<title>(.*?)<\\/title>/i);\n  if (titleMatch && titleMatch[1]) {\n    meta.title = cleanText(titleMatch[1]);\n  }\n\n  // Extract meta tags\n  const metaTags = [\n    { name: 'description', regex: /<meta\\s+name=\"description\"\\s+content=\"([^\"]*)\"[^>]*>/i },\n    { name: 'canonical', regex: /<link\\s+rel=\"canonical\"\\s+href=\"([^\"]*)\"[^>]*>/i },\n    { name: 'og:locale', regex: /<meta\\s+property=\"og:locale\"\\s+content=\"([^\"]*)\"[^>]*>/i },\n    { name: 'og:type', regex: /<meta\\s+property=\"og:type\"\\s+content=\"([^\"]*)\"[^>]*>/i },\n    { name: 'og:title', regex: /<meta\\s+property=\"og:title\"\\s+content=\"([^\"]*)\"[^>]*>/i },\n    { name: 'og:description', regex: /<meta\\s+property=\"og:description\"\\s+content=\"([^\"]*)\"[^>]*>/i },\n    { name: 'og:url', regex: /<meta\\s+property=\"og:url\"\\s+content=\"([^\"]*)\"[^>]*>/i },\n    { name: 'og:site_name', regex: /<meta\\s+property=\"og:site_name\"\\s+content=\"([^\"]*)\"[^>]*>/i },\n    { name: 'article:publisher', regex: /<meta\\s+property=\"article:publisher\"\\s+content=\"([^\"]*)\"[^>]*>/i },\n    { name: 'article:modified_time', regex: /<meta\\s+property=\"article:modified_time\"\\s+content=\"([^\"]*)\"[^>]*>/i },\n    { name: 'og:image', regex: /<meta\\s+property=\"og:image\"\\s+content=\"([^\"]*)\"[^>]*>/i },\n    { name: 'og:image:width', regex: /<meta\\s+property=\"og:image:width\"\\s+content=\"([^\"]*)\"[^>]*>/i },\n    { name: 'og:image:height', regex: /<meta\\s+property=\"og:image:height\"\\s+content=\"([^\"]*)\"[^>]*>/i },\n    { name: 'og:image:type', regex: /<meta\\s+property=\"og:image:type\"\\s+content=\"([^\"]*)\"[^>]*>/i },\n    { name: 'twitter:card', regex: /<meta\\s+name=\"twitter:card\"\\s+content=\"([^\"]*)\"[^>]*>/i },\n    { name: 'twitter:title', regex: /<meta\\s+name=\"twitter:title\"\\s+content=\"([^\"]*)\"[^>]*>/i },\n    { name: 'twitter:site', regex: /<meta\\s+name=\"twitter:site\"\\s+content=\"([^\"]*)\"[^>]*>/i }\n  ];\n\n  // Extract each meta tag\n  metaTags.forEach(tag => {\n    const match = html.match(tag.regex);\n    if (match && match[1]) {\n      meta[tag.name] = cleanText(match[1]);\n    }\n  });\n\n  // Extract all meta tags with name or property attributes (more general approach)\n  const generalMetaRegex = /<meta\\s+(?:name|property)=\"([^\"]*)\"\\s+content=\"([^\"]*)\"[^>]*>/gi;\n  let metaMatch;\n  while ((metaMatch = generalMetaRegex.exec(html)) !== null) {\n    const name = metaMatch[1];\n    const content = cleanText(metaMatch[2]);\n    \n    // Only add if not already captured and has content\n    if (content && !meta[name]) {\n      meta[name] = content;\n    }\n  }\n\n  // Extract JSON-LD schema data\n  const schemaRegex = /<script\\s+type=\"application\\/ld\\+json\"[^>]*>([\\s\\S]*?)<\\/script>/gi;\n  let schemaMatch;\n  \n  while ((schemaMatch = schemaRegex.exec(html)) !== null) {\n    try {\n      const schemaText = schemaMatch[1].trim();\n      if (schemaText) {\n        const schemaData = JSON.parse(schemaText);\n        schemas.push(schemaData);\n      }\n    } catch (e) {\n      // If JSON parsing fails, add the raw text\n      schemas.push({ raw: schemaMatch[1].trim() });\n    }\n  }\n\n  // Add the outline, meta, schema, and ngrams for the current item to the results array\n  results.push({\n    json: {\n      outline: outline,  // Array containing the hierarchy of headings with dot-based indentation\n      meta: Object.keys(meta).length > 0 ? meta : undefined,  // Only include if meta tags were found\n      schema: schemas.length > 0 ? schemas : undefined,  // Only include if schema data was found\n      ngrams: headingTexts.length > 0 ? filteredNgrams : undefined  // Only include if headings were found\n    }\n  });\n});\n\n// Return the results for all items (all URLs in the loop)\nreturn results;"},"typeVersion":2},{"id":"9c873ba5-84b2-4366-ac96-a1380ce66701","name":"Set URL Data","type":"n8n-nodes-base.set","position":[1480,340],"parameters":{"options":{},"assignments":{"assignments":[{"id":"186daf52-90b2-4608-9c94-243187069bf4","name":"Competitor URL","type":"string","value":"={{ $('Loop Over Items').item.json.competitor_url }}"},{"id":"3bb3057c-d84f-4eac-8da2-22740a2c293c","name":"Outline","type":"string","value":"={{ JSON.stringify($json.outline) }}"},{"id":"53c1b42c-14ce-48a0-8802-5b175d7ab127","name":"Meta","type":"string","value":"={{ JSON.stringify($json.meta) }}"},{"id":"ca84a96b-f370-42b6-9f4d-a1e4d1ab066a","name":"Ngrams","type":"string","value":"={{ JSON.stringify($json.ngrams) }}"}]}},"typeVersion":3.4},{"id":"5fae604a-d44d-4022-905a-51742ab23144","name":"Code","type":"n8n-nodes-base.code","position":[1100,520],"parameters":{"jsCode":"let output = '';\n\nfor (const [index, item] of items.entries()) {\n  const data = item.json;\n\n  const formatField = (value) => {\n    if (typeof value === 'string') {\n      try {\n        const parsed = JSON.parse(value);\n        return JSON.stringify(parsed, null, 2); // Pretty print with 2-space indent\n      } catch {\n        return value; // Not JSON, return as-is\n      }\n    }\n    return value;\n  };\n\n  output += `<competitor${index + 1}>\\n`;\n  output += `  <competitor url>\\n    ${data[\"Competitor URL\"]}\\n  </competitor url>\\n\\n`;\n  output += `  <outline>\\n    ${formatField(data[\"Outline\"])}\\n  </outline>\\n\\n`;\n  output += `  <meta>\\n${formatField(data[\"Meta\"])}\\n  </meta>\\n\\n`;\n  output += `  <ngrams>\\n${formatField(data[\"Ngrams\"])}\\n  </ngrams>\\n`;\n  output += `</competitor${index + 1}>\\n\\n`;\n}\n\nreturn [\n  {\n    json: {\n      competitors_data: output.trim()\n    }\n  }\n];\n"},"typeVersion":2},{"id":"a2d9be92-5a1e-448c-a4c8-e7ca8d6ce8ca","name":"Edit Fields1","type":"n8n-nodes-base.set","position":[1300,520],"parameters":{"options":{},"assignments":{"assignments":[{"id":"27ea4c8c-3cd1-47e4-9f22-a4bd5b4b6b3a","name":"competitors_data","type":"string","value":"={{ $json.competitors_data }}"}]}},"typeVersion":3.4},{"id":"715317ae-e896-48cf-b732-31a0a1ee7999","name":"Google Gemini Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[320,880],"parameters":{"options":{"temperature":0.4},"modelName":"=models/{{ $('Edit Fields').first().json['Google Gemini Model'] }}"},"credentials":{"googlePalmApi":{"id":"E9AQr0xc0FLNxbSQ","name":"Google Gemini(PaLM) Api account"}},"typeVersion":1},{"id":"e96eeecb-9b82-4cba-bf2c-3c5041b724b1","name":"Wait","type":"n8n-nodes-base.wait","position":[940,720],"webhookId":"2231c6d5-575e-46be-b1e3-6fac3af1a830","parameters":{"amount":"={{ $('Edit Fields').first().json['Waiting Time (Seconds)'] }}"},"typeVersion":1.1},{"id":"998ac0b0-d3e6-4e4a-b8a6-ae8994dbfa58","name":"Google Gemini Chat Model1","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[1040,920],"parameters":{"options":{"temperature":0.4},"modelName":"=models/{{ $('Edit Fields').first().json['Google Gemini Model'] }}"},"credentials":{"googlePalmApi":{"id":"E9AQr0xc0FLNxbSQ","name":"Google Gemini(PaLM) Api account"}},"typeVersion":1},{"id":"6ee11671-eb61-4d9f-a4f3-93898809d4e1","name":"Set Competitor Analysis","type":"n8n-nodes-base.set","position":[740,720],"parameters":{"options":{},"assignments":{"assignments":[{"id":"5f9f0ff2-7e00-449a-a5c4-14233315125a","name":"Competitor Analysis Report","type":"string","value":"={{ $json.text.replace(/[\\s\\S]*<competitor_analysis_report>/, '').replace(/<\\/competitor_analysis_report>[\\s\\S]*/, '') }}"}]}},"typeVersion":3.4},{"id":"728cf9c2-7988-4b23-8e00-7511a0f10858","name":"Set User Intent Analysis","type":"n8n-nodes-base.set","position":[1480,720],"parameters":{"options":{},"assignments":{"assignments":[{"id":"c5b72bf5-a084-4dfe-aad8-d77c64138c54","name":"User Intent Analysis Report","type":"string","value":"={{ $json.text.replace(/[\\s\\S]*<user_intent_report>/, '').replace(/<\\/user_intent_report>[\\s\\S]*/, '') }}"}]}},"typeVersion":3.4},{"id":"ecf01be1-fe6a-49f2-836f-8fb2c37a5da5","name":"Wait1","type":"n8n-nodes-base.wait","position":[1660,720],"webhookId":"2231c6d5-575e-46be-b1e3-6fac3af1a830","parameters":{"amount":"={{ $('Edit Fields').first().json['Waiting Time (Seconds)'] }}"},"typeVersion":1.1},{"id":"8ac6dc7a-d32f-4366-9b21-fb20aaf1043f","name":"Google Gemini Chat Model2","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[420,1220],"parameters":{"options":{"temperature":0.4},"modelName":"=models/{{ $('Edit Fields').first().json['Google Gemini Model'] }}"},"typeVersion":1},{"id":"ac65fd5d-6e4b-47cc-a8e2-778295651723","name":"Competitors Analysis","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[400,720],"parameters":{"text":"=<target_query>{{ $('Start').first().json['Target Keyword'] }}</target_query>\n<competitors_data>\n{{ $json.competitors_data }}\n</competitors_data>","messages":{"messageValues":[{"message":"=You are a Data Analyst specializing in SEO and Content Structure Analysis. Your task is to meticulously analyze the provided data from top-ranking competitor pages for a specific target query. Focus on identifying recurring patterns, themes, and structural elements.\n\nAnalyze the following inputs:\n<target_query>{target_query}</target_query>\n<competitors_data>\n{competitors_data}\n</competitors_data>\n\nBased on your analysis, generate a report summarizing:\n1. **List of Competitors**: Create a numbered coding system for competitors by assigning each competitor a unique code (e.g., C1, C2, C3) followed by their full brand name. For example: 'C1 = Nike, C2 = Adidas, C3 = Under Armour'. This coding system will be used for efficient reference throughout the remainder of the report.\n2.  **Meta Title & Description Trends:** Common keywords, angles (e.g., benefit-driven, location-focused, speed-focused), and calls-to-action observed.\n3.  **Common Outline Sections/Topics:** Identify frequently recurring sections (based on H2s/H3s) across competitors (e.g., \"What is X?\", \"Our Process\", \"Pricing\", \"Why Choose Us\", \"FAQs\", specific service features/types).\n4.  **Key Heading Concepts (from N-grams):** List the most prominent and recurring 2, 3, and 4-word phrases found in competitor headings. Highlight concepts that appear critical for demonstrating topic relevance.\n5.  **Structural & Content Element Observations:** Note any common patterns in page structure (e.g., typical flow of sections), use of specific elements (e.g., lists, tables, videos, forms, calculators), and perceived content depth/length.\n\nStructure your entire output within a single XML tag: <competitor_analysis_report>"}]},"promptType":"define"},"typeVersion":1.5},{"id":"97d45dd2-4278-4294-8759-7b076e41d684","name":"User Intent Analysis","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[1140,720],"parameters":{"text":"=<target_query>{{ $('Start').first().json['Target Keyword'] }}</target_query>","messages":{"messageValues":[{"message":"=You are a User Experience (UX) Researcher and Intent Analyst. Your task is to analyze the provided target query to understand the underlying user needs and expectations, completely independent of any competitor implementations.\n\nAnalyze the following input:\n<target_query>{target_query}</target_query>\n\nGenerate a report based *only* on the query, covering:\n1.  **Primary User Intent:** What is the main goal? (Informational, Navigational, Transactional, Commercial Investigation).\n2.  **Secondary Intents:** What related questions or needs might the user have?\n3.  **Implicit User Persona:** Describe the likely searcher (e.g., role, pain points, context).\n4.  **Stage in Buyer's Journey:** (Awareness, Consideration, Decision).\n5.  **Expected Services/Content:** What specific services or information types would this user logically expect to find on a page satisfying their intent?\n6.  **Problem/Solution Framing:** How should the user's core problem be articulated, and how should a service be positioned as the solution for this specific query?\n\nStructure your entire output within a single XML tag: <user_intent_report>"}]},"promptType":"define"},"typeVersion":1.5},{"id":"731d7b56-fa16-4f7d-a1af-f7908664e477","name":"Synthesis & Gap Analysis","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[500,1060],"parameters":{"text":"=<target_query>{{ $('Start').first().json['Target Keyword'] }}</target_query>\n<competitor_analysis_report>\n{{ $('Set Competitor Analysis').first().json['Competitor Analysis Report'] }}\n</competitor_analysis_report>\n<user_intent_report>\n{{ $('Set User Intent Analysis').first().json['User Intent Analysis Report'] }}\n</user_intent_report>","messages":{"messageValues":[{"message":"=You are an SEO Content Strategist and UX Architect. Your task is to synthesize the findings from the competitor analysis and the user intent analysis to identify strategic opportunities.\n\nAnalyze the following inputs:\n<target_query>{target_query}</target_query>\n<competitor_analysis_report>\n{competitor_analysis_report}\n</competitor_analysis_report>\n<user_intent_report>\n{user_intent_report}\n</user_intent_report>\n\nGenerate a synthesis report identifying:\n1.  **Content Overlaps (\"Table Stakes\"):** List the topics, sections, and information points that are BOTH expected by users (from user intent report) AND commonly covered by competitors (from competitor analysis). These are essential baseline requirements.\n2.  **Content & UX Gaps (Opportunities):** Identify user needs/expectations (from user intent report) that competitors are NOT addressing well or are missing entirely (based on competitor analysis). Highlight areas where you can provide superior value or a better user experience.\n3.  **SEO Keyword/Topic Priorities:** Based on both competitor heading N-grams/themes and user intent, list the most critical keywords, concepts, and semantic topics that the page structure and content must address for relevance and ranking potential.\n4.  **Potential UX/Conversion Advantages:** Suggest high-level ways to improve upon common competitor weaknesses in presentation, clarity, navigation, or calls-to-action, based on the combined analysis.\n\nStructure your entire output within a single XML tag: <synthesis_and_gap_analysis>"}]},"promptType":"define"},"typeVersion":1.5},{"id":"144f8050-c395-4f02-a786-5dca80bf1f3b","name":"Set Synthesis & Gap Analysis","type":"n8n-nodes-base.set","position":[840,1060],"parameters":{"options":{},"assignments":{"assignments":[{"id":"4d580b58-4843-43c1-9aa2-a46d82842465","name":"Synthesis & Gap Analysis","type":"string","value":"={{ $json.text.replace(/[\\s\\S]*<synthesis_and_gap_analysis>/, '').replace(/<\\/synthesis_and_gap_analysis>[\\s\\S]*/, '') }}"}]}},"typeVersion":3.4},{"id":"9b5739a8-ac4a-47c5-882d-5f8ecfe08831","name":"Wait2","type":"n8n-nodes-base.wait","position":[1020,1060],"webhookId":"2231c6d5-575e-46be-b1e3-6fac3af1a830","parameters":{"amount":"={{ $('Edit Fields').first().json['Waiting Time (Seconds)'] }}"},"typeVersion":1.1},{"id":"0282d60c-c030-4ccd-8716-dd56bbc636e2","name":"Google Gemini Chat Model3","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[1160,1260],"parameters":{"options":{"temperature":0.4},"modelName":"=models/{{ $('Edit Fields').first().json['Google Gemini Model'] }}"},"credentials":{"googlePalmApi":{"id":"E9AQr0xc0FLNxbSQ","name":"Google Gemini(PaLM) Api account"}},"typeVersion":1},{"id":"1f156e28-7b4c-441d-9626-7762d47acd93","name":"Ideal Page Outline Generation","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[1200,1060],"parameters":{"text":"=<target_query>{{ $('Start').first().json['Target Keyword'] }}</target_query>\n<synthesis_and_gap_analysis>\n{{ $('Set Synthesis & Gap Analysis').first().json['Synthesis & Gap Analysis'] }}\n</synthesis_and_gap_analysis>\n<is_homepage>{{ $('Start').first().json['Is Homepage?'] }}</is_homepage>\n<brand_name>{{ $('Start').first().json['Brand Name'] }}</brand_name>\n<services_offered>\n{{ $('Start').first().json['Services Offered'] }}\n</services_offered>","messages":{"messageValues":[{"message":"=You are an SEO Content Architect, Information Designer, **and Conversion-Focused Structuring Expert.** Your task is to create the optimal page outline (H1, H2s, H3s, potentially H4s) for the target query, based on the strategic insights from the synthesis and gap analysis. The outline must satisfy user intent, incorporate SEO best practices derived from competitors, provide a logical user experience, **and be structured to effectively persuade and convert visitors.**\n\nAnalyze the following inputs:\n<target_query>{target_query}</target_query>\n<synthesis_and_gap_analysis>\n{synthesis_and_gap_analysis}\n</synthesis_and_gap_analysis>\n<is_homepage>{is_homepage}</is_homepage>\n<brand_name>{brand_name}</brand_name>\n<services_offered>{services_offered}</services_offered>\n\nBased on the inputs, generate a recommended page outline:\n1.  **H1:** Propose a compelling, keyword-rich, **and benefit-oriented** H1 tag.\n2.  **Logical & Persuasive Section Flow (H2s):** Structure the main sections (H2s) in a sequence that guides the user naturally (e.g., addressing the problem, introducing the solution/value proposition, detailing the service & benefits, building trust/credibility, addressing potential objections, clear call to action path).\n    *   Incorporate the \"Table Stakes\" sections identified in the synthesis.\n    *   Strategically place sections that address the identified \"Gaps\" to offer unique value.\n    *   **Ensure key persuasive elements are included as distinct sections or integrated strategically:** Strong Value Proposition, Key Benefits/Outcomes, Social Proof (e.g., Testimonials/Case Studies placeholder), How it Works/Process, Pricing/Investment (or how pricing is determined), Why Choose Us/Unique Differentiators.\n3.  **Detailed Sub-sections (H3s/H4s):** Flesh out each H2 section with relevant H3s (and H4s if needed) that cover specific details, features, benefits, process steps, etc. Naturally weave in the \"SEO Keyword/Topic Priorities\" identified in the synthesis within these headings. **Ensure H3s under benefit/value sections clearly articulate positive outcomes for the user.**\n4.  **Homepage Consideration:** If <is_homepage> is \"Yes\", adjust the structure to be broader, potentially summarizing multiple services and directing users deeper, while still strongly addressing the core <target_query> intent **and presenting a compelling overall brand value proposition.** If \"No\", keep it focused specifically on the service related to the query.\n5.  **Justification:** Briefly explain the rationale behind the placement and content focus of major H2 sections, linking back to user intent, competitor insights, gap-filling, **and persuasive flow.**\n\nStructure your entire output within a single XML tag: <recommended_page_outline>"}]},"promptType":"define"},"typeVersion":1.5},{"id":"95003089-66bc-4c5c-b281-71009be099ea","name":"Set Page Outline","type":"n8n-nodes-base.set","position":[1560,1060],"parameters":{"options":{},"assignments":{"assignments":[{"id":"7c205f79-bdaf-4fd5-8fae-14713a0d2eff","name":"Page Outline","type":"string","value":"={{ $json.text.replace(/[\\s\\S]*<recommended_page_outline>/, '').replace(/<\\/recommended_page_outline>[\\s\\S]*/, '') }}"}]}},"typeVersion":3.4},{"id":"e101cf81-973a-44af-8c7c-3c316398ccda","name":"Wait3","type":"n8n-nodes-base.wait","position":[1740,1060],"webhookId":"2231c6d5-575e-46be-b1e3-6fac3af1a830","parameters":{"amount":"={{ $('Edit Fields').first().json['Waiting Time (Seconds)'] }}"},"typeVersion":1.1},{"id":"bd098536-18dd-4f23-98da-d86c3f0baf2a","name":"Google Gemini Chat Model4","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[500,1540],"parameters":{"options":{"temperature":0.4},"modelName":"=models/{{ $('Edit Fields').first().json['Google Gemini Model'] }}"},"typeVersion":1},{"id":"5429f86e-2883-4547-a69f-dd8c356b0247","name":"UX, Conversion & Copywriting Enhancement","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[600,1400],"parameters":{"text":"=<target_query>{{ $('Start').first().json['Target Keyword'] }}</target_query>\n<recommended_page_outline>\n{{ $('Set Page Outline').first().json['Page Outline'] }}\n</recommended_page_outline>\n<user_intent_report>\n{{ $('Set User Intent Analysis').first().json['User Intent Analysis Report'] }}\n</user_intent_report>\n<brand_name>{{ $('Start').first().json['Brand Name'] }}</brand_name>\n<services_offered>\n{{ $('Start').first().json['Services Offered'] }}\n</services_offered>","messages":{"messageValues":[{"message":"=You are a Conversion Rate Optimization (CRO) Specialist and UX Copywriter. Your task is to take the recommended page outline and layer on specific, actionable recommendations to maximize user experience, conversions, and persuasive communication.\n\nAnalyze the following inputs:\n<target_query>{target_query}</target_query>\n<recommended_page_outline>\n{recommended_page_outline}\n</recommended_page_outline>\n<user_intent_report>\n{user_intent_report} <!-- Reference for user needs/pain points -->\n</user_intent_report>\n<brand_name>{brand_name}</brand_name>\n<services_offered>{services_offered}</services_offered> <!-- Reference for service specifics -->\n\nBased on the inputs, provide detailed recommendations covering:\n1.  **Calls-to-Action (CTAs):**\n    *   Suggest specific wording for Primary and Secondary CTAs relevant to the service and user journey stage.\n    *   Recommend optimal placement within the proposed outline (e.g., above the fold, after key sections, end of page).\n    *   Advise on visual prominence/design.\n2.  **Trust Signals:** Recommend specific types of trust signals (e.g., testimonials, case studies, logos, certifications, guarantees, team bios) and suggest where they should be integrated into the outline structure. Tailor suggestions to the likely concerns of the user persona identified in the <user_intent_report>.\n3.  **Copywriting & Tone:**\n    *   Advise on the overall tone of voice (e.g., professional, empathetic, urgent, reassuring) suitable for the <target_query> and <brand_name>.\n    *   Emphasize using benefit-driven language (translating service features into user outcomes) throughout the content. Provide examples related to <services_offered>.\n    *   Suggest how to address user pain points (from <user_intent_report>) directly in the copy.\n4.  **Visual & Interactive Elements:** Recommend types of visuals (e.g., high-quality photos, videos, infographics, icons) or interactive elements (e.g., calculators, quizzes, forms) that would enhance understanding, engagement, and trust, suggesting where they fit within the outline.\n5.  **Risk Reversal:** Suggest potential guarantees, free consultations, trials, or clear explanations of processes that can reduce perceived risk for the user.\n6.  **Readability & UX:** Reinforce the importance of short paragraphs, bullet points, clear headings (already outlined), whitespace, and mobile responsiveness.\n\nStructure your entire output within a single XML tag: <ux_conversion_copy_recommendations>"}]},"promptType":"define"},"typeVersion":1.5},{"id":"4478e4a6-604b-4a5c-a7a8-bfadcbf0103d","name":"Set UX & Conversions Enhancements","type":"n8n-nodes-base.set","position":[960,1400],"parameters":{"options":{},"assignments":{"assignments":[{"id":"a35489c5-7db5-4d5e-8a3a-9a27ea21c241","name":"UX & Conversions Enhancements","type":"string","value":"={{ $json.text.replace(/[\\s\\S]*<ux_conversion_copy_recommendations>/, '').replace(/<\\/ux_conversion_copy_recommendations>[\\s\\S]*/, '') }}"}]}},"typeVersion":3.4},{"id":"1e9482a5-6b59-456c-8a92-49cdea47e973","name":"Google Gemini Chat Model5","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[1100,1560],"parameters":{"options":{"temperature":0.4},"modelName":"=models/{{ $('Edit Fields').first().json['Google Gemini Model'] }}"},"typeVersion":1},{"id":"de163dd6-9e8b-462e-a125-84dfdfbff8ab","name":"Final Service Page Blueprint","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[1160,1400],"parameters":{"text":"=<target_query>{{ $('Start').first().json['Target Keyword'] }}</target_query>\n<brand_name>{{ $('Start').first().json['Brand Name'] }}</brand_name>\n<services_offered>\n{{ $('Start').first().json['Services Offered'] }}\n</services_offered>\n<is_homepage>{{ $('Start').first().json['Is Homepage?'] }}</is_homepage>\n<competitor_analysis_report>\n{{ $('Set Competitor Analysis').first().json['Competitor Analysis Report'] }}\n</competitor_analysis_report>\n<user_intent_report>\n{{ $('Set User Intent Analysis').first().json['User Intent Analysis Report'] }}\n</user_intent_report>\n<synthesis_and_gap_analysis>\n{{ $('Set Synthesis & Gap Analysis').first().json['Synthesis & Gap Analysis'] }}\n</synthesis_and_gap_analysis>\n<recommended_page_outline>\n{{ $('Set Page Outline').first().json['Page Outline'] }}\n</recommended_page_outline>\n<ux_conversion_copy_recommendations>\n{{ $json['UX & Conversions Enhancements'] }}\n</ux_conversion_copy_recommendations>","messages":{"messageValues":[{"message":"=You are a Senior Digital Marketing Strategist. Your final task is to compile all the preceding analyses and recommendations into a single, comprehensive, and actionable Service Page Blueprint. This document will serve as the definitive guide for creating the page.\n\nImportant Context: Remember, this blueprint is for a service page. While comprehensive analysis is crucial, the final page structure and content recommendations should prioritize clarity, conciseness, and a direct path towards user action or conversion, rather than exhaustive detail suitable for a long-form blog post.\n\nConsolidate the following inputs:\n<target_query>{target_query}</target_query>\n<brand_name>{brand_name}</brand_name>\n<services_offered>{services_offered}</services_offered>\n<is_homepage>{is_homepage}</is_homepage>\n<competitor_analysis_report>\n{competitor_analysis_report}\n</competitor_analysis_report>\n<user_intent_report>\n{user_intent_report}\n</user_intent_report>\n<synthesis_and_gap_analysis>\n{synthesis_and_gap_analysis}\n</synthesis_and_gap_analysis>\n<recommended_page_outline>\n{recommended_page_outline}\n</recommended_page_outline>\n<ux_conversion_copy_recommendations>\n{ux_conversion_copy_recommendations}\n</ux_conversion_copy_recommendations>\n\n**Output Requirements:**\n\n*   Generate the final blueprint entirely in **Markdown format**.\n*   Enclose the *entire* Markdown output within a single XML tag: `<final_service_page_blueprint>`.\n*   **Do NOT use any XML tags *inside* the `<final_service_page_blueprint>` tag.** Use Markdown headings (`#`, `##`, `###`) to structure the content as specified below.\n*   Ensure the final output is highly readable, well-organized, and suitable for direct presentation to a client.\n\n**Blueprint Structure (Use Markdown Headings):**\n\n#   **1. Executive Summary**\n    *   Briefly state the target query, the primary user intent, and the overall strategy for the page (e.g., \"Create a focused service page for '{target_query}' targeting users with [primary intent]. The strategy is to highlight [key benefit/service aspect], address the common gap of [identified gap], aiming to outperform competitors by offering [unique value proposition] and convert users seeking [user goal].\"). Reference `{brand_name}` where appropriate.\n\n#   **2. User Intent Deep Dive**\n    *   Summarize the key findings from the `<user_intent_report>`.\n    *   Clearly state Primary and Secondary Intents.\n    *   Describe the Target User Persona(s).\n    *   Identify the typical User Journey Stage(s).\n    *   List the Core User Needs and Pain Points this page must address.\n\n#   **3. Competitor Landscape Summary**\n    *   Summarize the key findings from the `<competitor_analysis_report>`.\n    *   Highlight common tactics, topics covered, and keywords targeted by top competitors.\n    *   Describe typical page structures and common elements observed (e.g., types of CTAs, content sections, trust signals used).\n\n#   **4. Strategic Opportunities & Gaps**\n    *   Summarize the core findings from the `<synthesis_and_gap_analysis>`.\n    *   Identify key content/feature overlaps between user intent and competitor offerings.\n    *   Pinpoint specific content, angle, or feature gaps the `{brand_name}` page can exploit for differentiation.\n    *   List the priority SEO elements (keywords, themes, E-E-A-T considerations) based on the analysis.\n\n#   **5. Recommended Page Outline**\n    *   **Page Structure:**\n        *   Present the recommended page structure derived from `<recommended_page_outline>`.\n        *   Use nested Markdown headings (`H1`, `H2`, `H3`, `H4`) to represent the hierarchy.\n        *   Use indentation (e.g., two spaces per level) for visual clarity.\n        *   **Example Structure Format (Illustrates Formatting Only):**\n            H1: Primary Heading\n              H2: First Subheading\n              H2: Second Subheading\n                H3: First Sub-subheading under Second H2\n                H3: Second Sub-subheading under Second H2\n                  H4: Detail under Second H3\n              H2: Third Subheading\n    *   **Heading Justifications:**\n        *   Immediately following the structure, provide a list detailing the justification/purpose for *each* heading included in the structure above. Reference the heading text clearly. (e.g., \"**H1: [Actual H1 Text]:** Justification for H1...\" \"**H2: [Actual H2 Text]:** Justification for H2...\")\n\n#   **6. UX, Conversion & Copywriting Plan**\n    *   Consolidate and present the detailed recommendations from `<ux_conversion_copy_recommendations>`.\n    *   Use subheadings (e.g., `## Calls to Action (CTAs)`, `## Trust Signals`, `## Copywriting & Tone of Voice`, `## Visual Elements`, `## Risk Reversal`, `## Readability & Accessibility`) for clarity.\n    *   Ensure recommendations are actionable and specific to this service page.\n\n#   **7. Key Success Factors**\n    *   Conclude with a bulleted list summarizing the 3-5 most critical elements required for this page's success.\n    *   Focus on factors directly related to satisfying user intent, achieving SEO goals (ranking), and driving conversions based on the preceding analysis."}]},"promptType":"define"},"typeVersion":1.5},{"id":"35812205-2573-4c30-9c66-168b7af5a530","name":"Edit Fields2","type":"n8n-nodes-base.set","position":[1520,1400],"parameters":{"options":{},"assignments":{"assignments":[{"id":"4ec86dd3-14e7-420b-94f0-2e13b11ec622","name":"Final Blueprint","type":"string","value":"={{ $json.text.replace(/[\\s\\S]*<final_service_page_blueprint>/, '').replace(/<\\/final_service_page_blueprint>[\\s\\S]*/, '') }}"}]}},"typeVersion":3.4},{"id":"780a5e01-6f26-43da-b650-5cd3cdf1cfa0","name":"Convert to File","type":"n8n-nodes-base.convertToFile","position":[1740,1400],"parameters":{"options":{"fileName":"Blueprint.txt"},"operation":"toText","sourceProperty":"Final Blueprint"},"typeVersion":1.1},{"id":"008ec54d-0791-41b0-bad6-38db3ae42bde","name":"Edit Fields","type":"n8n-nodes-base.set","position":[420,500],"parameters":{"options":{},"assignments":{"assignments":[{"id":"d279426b-1764-4989-9202-9bab9ce295fa","name":"JINA Reader API Key","type":"string","value":"YOUR_API_KEY"},{"id":"74cc4b3d-6256-453c-ac16-f860c01549ec","name":"Google Gemini Model","type":"string","value":"gemini-2.5-pro-preview-03-25"},{"id":"eaa9f0cb-478e-4ebc-972a-8e8bd4945602","name":"Waiting Time (Seconds)","type":"string","value":"1"}]}},"typeVersion":3.4},{"id":"54ad00ab-6e54-49a2-a8dc-5d258e6ae64a","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[0,0],"parameters":{"width":1020,"height":460,"content":"## Generate High-Level Service Page Blueprint Report\nThis powerful workflow generates comprehensive SEO blueprints for service pages by analyzing competitor websites and user intent. By examining the structure, headings, and meta information of top-ranking competitors for a specific target keyword, the workflow creates a detailed content strategy tailored to your brand and services, designed to outperform the competition and maximize conversions.\n\n### Setup Instructions:\n1. Create a new Jina Reader API key [here](https://jina.ai/api-dashboard/key-manager). You can claim a free API key, which allow you to use up to 1m tokens for free.  \n2. Create a new Google Gemini(PaLM) credentials by following the guide [here](https://docs.n8n.io/integrations/builtin/credentials/googleai/#using-geminipalm-api-key). Please note, if you are using the free tier, you need to set the \"Waiting Time\" to 20s as the free tier allow a maximum of 5 requests per minute.\n3. Update the node \"Set Fields\" with your Jina API Key. Change the Waiting Time to \"20\" if using free Google Gemini API key. You can change the Gemini model from here as well, in the case Gemini make changes to their Gemini models.\n4. Start the form trigger and answer to the following questions:\n4.1. Competitors: A list of direct competitors. Up to 5, use their direct service page URL.\n4.2. Target Keyword: The query related with your service. (E.g. International accounting services, Chicago cleaning services, etc...)\n4.3. Services Offered: Details your complete service offerings. This will be ensure the outline recommended align with your services.\n4.4. Brand Name: The name of your brand, your company name.\n4.5. Homepage: If you try to rank for a homepage, check that box.\n5. Download the .txt file generated at the end, copy/paste it's content (Markdown format) and copy it [here](https://markdownlivepreview.com/). You can after copy/paste the rendered results in Gdocs and share with your client/team.\n\nYou can see a demo of the report [here](https://docs.google.com/document/d/1XDJV3zNB7cLPBzaMXstzEl7ZvPrjiuBbet5C5ZlC4bo/edit). "},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"443f606c-8007-41cd-959e-71d17bbabec5","connections":{"Code":{"main":[[{"node":"Edit Fields1","type":"main","index":0}]]},"Wait":{"main":[[{"node":"User Intent Analysis","type":"main","index":0}]]},"Start":{"main":[[{"node":"Edit Fields","type":"main","index":0}]]},"Wait1":{"main":[[{"node":"Synthesis & Gap Analysis","type":"main","index":0}]]},"Wait2":{"main":[[{"node":"Ideal Page Outline Generation","type":"main","index":0}]]},"Wait3":{"main":[[{"node":"UX, Conversion & Copywriting Enhancement","type":"main","index":0}]]},"Edit Fields":{"main":[[{"node":"Convert URLs to Items","type":"main","index":0}]]},"Edit Fields1":{"main":[[{"node":"Competitors Analysis","type":"main","index":0}]]},"Edit Fields2":{"main":[[{"node":"Convert to File","type":"main","index":0}]]},"Get URL HTML":{"main":[[{"node":"Extract HTML Elements","type":"main","index":0}]]},"Set URL Data":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Loop Over Items":{"main":[[{"node":"Code","type":"main","index":0}],[{"node":"Get URL HTML","type":"main","index":0}]]},"Set Page Outline":{"main":[[{"node":"Wait3","type":"main","index":0}]]},"Competitors Analysis":{"main":[[{"node":"Set Competitor Analysis","type":"main","index":0}]]},"User Intent Analysis":{"main":[[{"node":"Set User Intent Analysis","type":"main","index":0}]]},"Convert URLs to Items":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Extract HTML Elements":{"main":[[{"node":"Set URL Data","type":"main","index":0}]]},"Set Competitor Analysis":{"main":[[{"node":"Wait","type":"main","index":0}]]},"Google Gemini Chat Model":{"ai_languageModel":[[{"node":"Competitors Analysis","type":"ai_languageModel","index":0}]]},"Set User Intent Analysis":{"main":[[{"node":"Wait1","type":"main","index":0}]]},"Synthesis & Gap Analysis":{"main":[[{"node":"Set Synthesis & Gap Analysis","type":"main","index":0}]]},"Google Gemini Chat Model1":{"ai_languageModel":[[{"node":"User Intent Analysis","type":"ai_languageModel","index":0}]]},"Google Gemini Chat Model2":{"ai_languageModel":[[{"node":"Synthesis & Gap Analysis","type":"ai_languageModel","index":0}]]},"Google Gemini Chat Model3":{"ai_languageModel":[[{"node":"Ideal Page Outline Generation","type":"ai_languageModel","index":0}]]},"Google Gemini Chat Model4":{"ai_languageModel":[[{"node":"UX, Conversion & Copywriting Enhancement","type":"ai_languageModel","index":0}]]},"Google Gemini Chat Model5":{"ai_languageModel":[[{"node":"Final Service Page Blueprint","type":"ai_languageModel","index":0}]]},"Final Service Page Blueprint":{"main":[[{"node":"Edit Fields2","type":"main","index":0}]]},"Set Synthesis & Gap Analysis":{"main":[[{"node":"Wait2","type":"main","index":0}]]},"Ideal Page Outline Generation":{"main":[[{"node":"Set Page Outline","type":"main","index":0}]]},"Set UX & Conversions Enhancements":{"main":[[{"node":"Final Service Page Blueprint","type":"main","index":0}]]},"UX, Conversion & Copywriting Enhancement":{"main":[[{"node":"Set UX & Conversions Enhancements","type":"main","index":0}]]}}}


name: 🤖 AI Restaurant Assistant for WhatsApp, Instagram & Messenger
author_name: Amanda Benks
author_username: amanda
categories: []
created_at: 2025-04-17T11:46:33.900Z
updated_at: 2025-04-17T11:46:33.900Z
url: https://n8n.io/workflows/3585
scraped_at: 2025-06-19 22:50:39
description:
  Hi, I’m Amanda! 💌

  This workflow was created with so much love, care, and attention… especially for you, who runs a restaurant, a cozy little burger place, or a delivery business full of heart. 🥰

  I know how busy your days can be, so I made this sweet AI assistant to help you take care of your customers on WhatsApp, Instagram, Messenger (or Evolution API). It sends your beautiful menu, checks ZIP codes, creates payment links, and even notifies the kitchen when the order is ready. All gentle, all automatic, all with love. 💛

  💡 What this workflow does

  Replies to customers via WhatsApp API, Instagram Direct, Messenger, and Evolution API  
  Checks ZIP codes to see if delivery is available using Google Maps  
  Sends your menu as images, because food should look as good as it tastes 🍕  
  Collects item selections and offers lovely upsells like drinks or extras  
  Creates payment links with the Asaas API  
  Confirms when the payment is complete and sends the order to the kitchen  
  Stores all messages and session data safely in Supabase  
  Uses OpenAI GPT-4o to talk naturally and kindly with your customers

  ⚙️ How to set it up (I’ll guide you with care 🧸)

  Connect your webhook from WhatsApp, Instagram, Messenger, or Evolution API  
  Create a Supabase table called n8n_workflow_followup  
     You can use this ready-made template here:  
       👉 Supabase Sheet Template  
  Add your API keys (OpenAI, Supabase, Google Maps, and Asaas) securely in n8n  
  Customize the AI prompt with your brand’s voice and sweet style 💫  
  Set your delivery radius (default is 10km, but you can change it!)  
  Upload your menu images (from Google Drive, your website, or any link)  
  That’s it! Your assistant is now ready to serve with kindness and automation 💕

  🍯 Works with:

  ✅ n8n Cloud and Self-Hosted n8n  
  🔐 All API credentials are safely stored using n8n’s secure credential manager

  Want something customized just for you?
  Chat with me, I’d love to help 💻💛 Chat via WhatsApp (+55 17 99155-7874)
  .
  .
  .
  Tradução em Português:
  Oi, eu sou a Amanda! 💌
  Esse workflow foi feito com muito carinho, dedicação e cuidado... pensando especialmente em você, que tem um restaurante, lanchonete ou delivery cheio de amor pelo que faz. 🥰

  Eu sei como o dia a dia pode ser corrido, e foi por isso que eu criei esse atendente com IA: pra te ajudar a responder clientes no WhatsApp, Instagram, Messenger (ou Evolution API), enviar cardápio com imagens lindas, calcular entregas, gerar links de pagamento e até avisar a cozinha. Tudo com jeitinho, sem complicação, e com muito coração. 💛

  💡 O que esse fluxo faz

  Atende clientes pelo WhatsApp API, Instagram Direct, Messenger e Evolution API  
  Valida CEP e calcula se o cliente está dentro da área de entrega (usando Google Maps)  
  Envia cardápio com imagens, porque comer começa pelos olhos 🍕  
  Coleta os pedidos e também oferece bebidas e adicionais  
  Gera link de pagamento automaticamente com a API do Asaas  
  Confirma o pagamento e avisa a cozinha quando estiver tudo certo  
  Armazena mensagens, horários e histórico no Supabase  
  Usa o GPT-4o da OpenAI pra conversar de forma educada e natural com seus clientes

  ⚙️ Como configurar (com meu passo a passo cheio de cuidado 🧸)

  Conecte seu webhook do WhatsApp, Instagram, Messenger ou Evolution API  
  Crie uma tabela no Supabase chamada n8n_workflow_followup  
     Você pode usar esse modelo aqui:  
       👉 Planilha modelo Supabase  
  Adicione suas chaves de API do OpenAI, Google Maps, Supabase e Asaas no gerenciador do n8n  
  Personalize o prompt da IA com o nome do seu restaurante, estilo de fala e sua magia 💫  
  Defina a distância máxima de entrega (padrão: 10km)  
  Coloque seus próprios links de imagens do cardápio (pode ser do Drive, site ou CDN)  
  Prontinho! Agora o seu restaurante tem um atendente inteligente, gentil e muito eficiente 💕

  🍯 Funciona com:

  ✅ n8n Cloud e n8n auto-hospedado  
  🔐 E suas credenciais ficam guardadinhas com segurança no próprio n8n, tá bom?

  Quer algo feito especialmente pra você?
  Fala comigo com todo carinho 💻💛 Falar no WhatsApp (+55 17 99155-7874)

nodes_used:
  ["n8n-nodes-base.httpRequest","n8n-nodes-base.googleDrive","n8n-nodes-base.supabase","n8n-nodes-base.code","@n8n/n8n-nodes-langchain.agent","@n8n/n8n-nodes-langchain.chainLlm","@n8n/n8n-nodes-langchain.embeddingsOpenAi","@n8n/n8n-nodes-langchain.lmChatOpenAi","@n8n/n8n-nodes-langchain.outputParserStructured","@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter","@n8n/n8n-nodes-langchain.toolCalculator","@n8n/n8n-nodes-langchain.vectorStoreSupabase","@n8n/n8n-nodes-langchain.documentDefaultDataLoader","@n8n/n8n-nodes-langchain.openAi","@n8n/n8n-nodes-langchain.memoryPostgresChat","@n8n/n8n-nodes-langchain.toolHttpRequest","@n8n/n8n-nodes-langchain.toolVectorStore"]

workflow_json:
  {"id":"8G1HLmgwWqKGDJc9","meta":{"instanceId":"6a52f06a38696cfa8d3a5b70f84891fab02c428a5c2d448dcef39b1f17adf12b"},"name":"Agente IA Restaurante [template]","tags":[],"nodes":[{"id":"9f6e01ca-2b49-4a4c-8f6f-8dad88a0b777","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[2300,380],"parameters":{"content":""},"typeVersion":1},{"id":"a1c8cc8e-8b91-4ec4-acb3-6a663e9ab69d","name":"Variaveis","type":"n8n-nodes-base.set","position":[2360,620],"parameters":{},"typeVersion":3.3},{"id":"332a5298-6b17-462a-a919-f9e07a9caa40","name":"Data&Hora","type":"n8n-nodes-base.code","position":[280,500],"parameters":{},"typeVersion":2},{"id":"889184fd-c14c-43f3-a5ab-6a2f2a578432","name":"Converter Img","type":"n8n-nodes-base.convertToFile","position":[620,720],"parameters":{},"typeVersion":1.1},{"id":"588f841e-8429-4b1d-817a-b1e8eb896663","name":"Maps","type":"n8n-nodes-base.set","position":[760,480],"parameters":{},"typeVersion":3.4},{"id":"69ce9853-94d5-4add-92c5-a92571092200","name":"Maps1","type":"n8n-nodes-base.set","position":[960,1280],"parameters":{},"typeVersion":3.4},{"id":"3c44786a-f33b-4aa4-8457-8ca1523278c4","name":"Maps2","type":"n8n-nodes-base.set","position":[900,720],"parameters":{},"typeVersion":3.4},{"id":"2038f534-cc5f-4f41-9b4d-46ebaf790623","name":"TranscAudio","type":"@n8n/n8n-nodes-langchain.openAi","position":[820,1280],"parameters":{},"typeVersion":1.3},{"id":"20e4f88b-4afa-4483-a587-e7caa83b283e","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[3160,380],"parameters":{"content":""},"typeVersion":1},{"id":"3279bc11-9bbc-4a0d-9b67-165fc30571f6","name":"Sticky Note14","type":"n8n-nodes-base.stickyNote","position":[2300,960],"parameters":{"content":""},"typeVersion":1},{"id":"7afde04d-aff1-4e53-9191-c4cc002e1f51","name":"MsgType","type":"n8n-nodes-base.switch","position":[100,1000],"parameters":{},"notesInFlow":false,"typeVersion":3},{"id":"f18c214b-bc1e-4753-8cfe-fcbb1e8ecd74","name":"Aguarda","type":"n8n-nodes-base.wait","position":[3620,500],"webhookId":"61f6a178-fc48-439e-9585-d7cea564fd5b","parameters":{},"typeVersion":1.1},{"id":"340d9e3b-314b-4b05-8dbc-c3a8248410a1","name":"CalculoTime","type":"n8n-nodes-base.set","position":[3900,500],"parameters":{},"typeVersion":3.4},{"id":"87f67078-2612-4950-aa28-ed90ccb4c90b","name":"JSONhistorico1","type":"n8n-nodes-base.code","position":[2840,1220],"parameters":{},"typeVersion":2},{"id":"45307cb5-26ab-4ed9-8c0a-2aff5a59d31d","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[480,380],"parameters":{"content":""},"typeVersion":1},{"id":"50a15265-55c7-486f-9760-c0009a8e4a68","name":"Prompt","type":"n8n-nodes-base.set","position":[3200,820],"parameters":{},"typeVersion":3.3,"alwaysOutputData":true},{"id":"20e1c94d-7627-40ec-8e49-005d9f89cec3","name":"Converte PDF","type":"n8n-nodes-base.convertToFile","position":[620,1660],"parameters":{},"typeVersion":1.1},{"id":"84ffdf57-99b0-4e21-b428-65961ac513dc","name":"Extract PDF","type":"n8n-nodes-base.extractFromFile","position":[760,1660],"parameters":{},"typeVersion":1},{"id":"19a81cdd-def9-41cd-9d3e-ad2013698fa3","name":"Maps5","type":"n8n-nodes-base.set","position":[900,1660],"parameters":{},"typeVersion":3.4},{"id":"8d3fa33a-ec19-4ee4-a634-ad298edbc67c","name":"Calculator","type":"@n8n/n8n-nodes-langchain.toolCalculator","position":[4060,1500],"parameters":{},"typeVersion":1},{"id":"d201f6e2-2d14-468f-9390-059330bc1024","name":"Modelo IA","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[3640,780],"parameters":{},"typeVersion":1},{"id":"f9396d23-1a47-42c0-ab78-1c232d74c84d","name":"OpenAI2","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[3940,940],"parameters":{},"typeVersion":1},{"id":"f5e909bc-0dfd-4b32-9446-3b84acf366c7","name":"Segmentos","type":"n8n-nodes-base.splitOut","position":[4300,840],"parameters":{},"typeVersion":1},{"id":"9a58d1c8-6296-44e3-8aa5-b0ec37e6c0dc","name":"1,2s","type":"n8n-nodes-base.wait","position":[5040,940],"webhookId":"a22bed12-9af7-4e4c-ac1b-3c7fa5fc19ef","parameters":{},"typeVersion":1.1},{"id":"9998a7aa-0e37-4dd4-aec8-85de828115b8","name":"Loop Over Items1","type":"n8n-nodes-base.splitInBatches","position":[4480,900],"parameters":{},"typeVersion":3,"alwaysOutputData":true},{"id":"bcb6639d-2499-43a1-b989-268a369e25f1","name":"no.op2","type":"n8n-nodes-base.noOp","position":[4300,980],"parameters":{},"typeVersion":1},{"id":"956f3a09-be1a-47b0-9b84-27dd23d9bc02","name":"OutputParser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[4080,940],"parameters":{},"typeVersion":1.2},{"id":"5935f012-f371-4203-866a-7ab064055a3a","name":"Sticky Note11","type":"n8n-nodes-base.stickyNote","position":[4220,680],"parameters":{"content":""},"typeVersion":1},{"id":"536138c9-87ea-42a1-90f7-0f098a4a8cee","name":"JSONhistorico","type":"n8n-nodes-base.code","position":[4400,500],"parameters":{},"typeVersion":2},{"id":"6ea74834-7cf4-4399-97a6-e7e81b95a108","name":"Filtro Reset","type":"n8n-nodes-base.filter","position":[4260,500],"parameters":{},"typeVersion":2.2},{"id":"44c730a3-22cd-46fa-90eb-37bfd1e8f0f4","name":"JSONhistorico2","type":"n8n-nodes-base.code","position":[3340,500],"parameters":{},"typeVersion":2},{"id":"3845fd7b-fc26-47c1-9526-36c531cdc186","name":"Interferencia","type":"n8n-nodes-base.filter","position":[4040,500],"parameters":{},"retryOnFail":false,"typeVersion":2},{"id":"72b19179-74cf-49ea-a565-5fc9cd7c4d0b","name":"Desbloqueia IA","type":"n8n-nodes-base.if","position":[2500,1200],"parameters":{},"typeVersion":2.2},{"id":"de86b99b-4d4b-403c-a8b6-96e493e0ba1b","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-180,40],"parameters":{"content":""},"typeVersion":1},{"id":"dcc9d5ab-a82d-4c43-aaf1-efe40ae58134","name":"Bloquear IA","type":"n8n-nodes-base.supabase","position":[2500,1060],"parameters":{},"typeVersion":1},{"id":"485afa76-03a3-4d1a-84ff-e64f31f85299","name":"Desbloquear IA","type":"n8n-nodes-base.supabase","position":[2840,1060],"parameters":{},"typeVersion":1},{"id":"dedaefe8-0f44-4399-8f31-c3e199d28d6d","name":"SalvaHistorico1","type":"n8n-nodes-base.supabase","position":[2980,1220],"parameters":{},"typeVersion":1},{"id":"653a2e6e-9d5b-4626-b417-954d512f2afe","name":"Add Timeout","type":"n8n-nodes-base.supabase","position":[3480,500],"parameters":{},"typeVersion":1},{"id":"47924a3b-2210-4c77-914a-b4f2a739c537","name":"Busca Timeout","type":"n8n-nodes-base.supabase","position":[3760,500],"parameters":{},"typeVersion":1},{"id":"041344d1-2cc1-4c7b-91aa-d80e31967d8a","name":"SalvaHistorico","type":"n8n-nodes-base.supabase","position":[4540,500],"parameters":{},"typeVersion":1},{"id":"d260bbc3-6385-4d80-bfc9-c1f09f11ee30","name":"Postgres Memory","type":"@n8n/n8n-nodes-langchain.memoryPostgresChat","position":[3300,1060],"parameters":{},"typeVersion":1.3},{"id":"3e6efb2b-0e0c-4384-b65e-e3c69918f7f2","name":"WH Asaas","type":"n8n-nodes-base.webhook","position":[1220,2680],"webhookId":"9a671ae3-e425-458e-9280-bfdcbe5f7cef","parameters":{},"typeVersion":2},{"id":"31ede119-05a9-4d04-8484-cb85ab1c06d5","name":"Response Asaas","type":"n8n-nodes-base.respondToWebhook","position":[2060,2600],"parameters":{},"typeVersion":1.1},{"id":"3c2f16e1-38ac-46e9-9aa5-dd4b0f69ebaa","name":"get_consumer","type":"n8n-nodes-base.supabaseTool","position":[3700,1500],"parameters":{},"typeVersion":1},{"id":"25136af2-4609-463a-ac17-14ff40cbe1bc","name":"up_consumer","type":"n8n-nodes-base.supabaseTool","disabled":true,"position":[3820,1500],"parameters":{},"typeVersion":1},{"id":"799e944f-8880-4f4a-8089-c3b81d860cb9","name":"Criar Cliente","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[1640,2680],"parameters":{},"typeVersion":4.2},{"id":"d443bf39-c127-4105-94fe-bf55cd9ad047","name":"Criar Cobrança","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[1780,2600],"parameters":{},"typeVersion":4.2},{"id":"86c13d6b-7573-4c73-a739-544d28f499d2","name":"Add Link","type":"n8n-nodes-base.supabase","position":[1920,2600],"parameters":{},"typeVersion":1},{"id":"5d4c8ed1-a629-4adc-9baf-e82e6017a9d8","name":"PhoneID","type":"@splainez/n8n-nodes-phonenumber-parser.phoneNumberParser","position":[1500,2660],"parameters":{},"typeVersion":1},{"id":"fd704aaa-b1a9-4c52-94c8-0348a0acdbf9","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[1180,2580],"parameters":{"content":""},"typeVersion":1},{"id":"1ab810a0-ca5c-4713-8267-1620c685dffb","name":"Sem Dados","type":"n8n-nodes-base.if","position":[1360,2680],"parameters":{},"typeVersion":2.2},{"id":"2777316d-5873-47b0-90e8-fa473d11a546","name":"Asaas Erro","type":"n8n-nodes-base.respondToWebhook","position":[1500,2760],"parameters":{},"typeVersion":1.1},{"id":"36d64f71-ecdc-40e9-8868-3e5e52b402b5","name":"Asaas Erro1","type":"n8n-nodes-base.respondToWebhook","position":[1780,2760],"parameters":{},"typeVersion":1.1},{"id":"57725415-9a74-4807-89c5-ba1aeed2b0dd","name":"Asaas Erro2","type":"n8n-nodes-base.respondToWebhook","position":[1920,2760],"parameters":{},"typeVersion":1.1},{"id":"5e1bbae9-1d8a-40fe-9b7e-5c66d5883ec9","name":"checar_cpf","type":"@n8n/n8n-nodes-langchain.toolHttpRequest","position":[4060,1360],"parameters":{},"typeVersion":1.1},{"id":"a85e65fd-1652-4695-997b-55f4b624a5b2","name":"START","type":"n8n-nodes-base.webhook","position":[-140,500],"webhookId":"e071510e-4108-408a-9de1-a6fdc3fda03b","parameters":{},"typeVersion":2},{"id":"4abad2e4-c91d-4158-bd28-358e19be2461","name":"up_dados","type":"n8n-nodes-base.supabaseTool","disabled":true,"position":[3940,1500],"parameters":{},"typeVersion":1},{"id":"3173ba80-7c52-4e31-b83e-a0bf599c1f2c","name":"Sticky Note13","type":"n8n-nodes-base.stickyNote","position":[480,620],"parameters":{"content":""},"typeVersion":1},{"id":"f02c4a11-5360-4978-aaa8-f76d4dd8762c","name":"Img Instagram","type":"@n8n/n8n-nodes-langchain.openAi","position":[760,880],"parameters":{},"typeVersion":1.6},{"id":"2cb414c2-054a-4483-8537-00fdfb6a4337","name":"Img WhatsApp","type":"@n8n/n8n-nodes-langchain.openAi","position":[760,720],"parameters":{},"typeVersion":1.6},{"id":"75c7e443-9ea0-4236-a664-7236095153d3","name":"Maps6","type":"n8n-nodes-base.set","position":[900,880],"parameters":{},"typeVersion":3.4},{"id":"51a46d51-aae8-48c4-a5c5-f045ab277ab0","name":"Sticky Note16","type":"n8n-nodes-base.stickyNote","position":[480,1060],"parameters":{"content":""},"typeVersion":1},{"id":"1b86e89f-a860-41c9-b4cc-7f9c02e416fa","name":"Convert File Wp","type":"n8n-nodes-base.convertToFile","position":[680,1420],"parameters":{},"typeVersion":1.1},{"id":"9882ce9b-c273-4522-bf92-c0e39c6644bb","name":"Sticky Note17","type":"n8n-nodes-base.stickyNote","position":[480,1580],"parameters":{"content":""},"typeVersion":1},{"id":"7d340711-0fd8-47aa-aa37-655ae434366b","name":"Add Response","type":"n8n-nodes-base.aggregate","position":[1140,700],"parameters":{},"typeVersion":1},{"id":"2d5f432a-a3e4-4b96-95fc-c68eb7056244","name":"Sticky Note18","type":"n8n-nodes-base.stickyNote","position":[-180,800],"parameters":{"content":""},"typeVersion":1},{"id":"029343c6-6856-4463-87a1-c09cefc59ca7","name":"Filter WhatsApp","type":"n8n-nodes-base.filter","position":[1360,800],"parameters":{},"typeVersion":2.2},{"id":"14583a83-7f42-4def-b81c-4d564f23b97a","name":"Reply Message Insta","type":"n8n-nodes-base.if","position":[1500,620],"parameters":{},"typeVersion":2.2},{"id":"a5d986e7-20cf-482e-bbce-12aa8e379df4","name":"Reply Message Wp","type":"n8n-nodes-base.if","position":[1500,800],"parameters":{},"typeVersion":2.2},{"id":"e99a60d0-b84d-4146-9433-c32d5c80fada","name":"Fixed Credentials","type":"n8n-nodes-base.set","position":[140,500],"parameters":{},"typeVersion":3.4},{"id":"25172917-c4e3-4148-bb70-2bf094a6fffe","name":"Get Reply Insta","type":"n8n-nodes-base.httpRequest","position":[1820,480],"parameters":{},"typeVersion":4.2},{"id":"48e9047a-4694-4c8f-95a5-dda28708e5df","name":"Message Markup Wp","type":"n8n-nodes-base.set","position":[1660,880],"parameters":{},"typeVersion":3.4},{"id":"847b6dd2-4ca3-4fa6-821c-333d530432f9","name":"No Marking","type":"n8n-nodes-base.set","position":[1660,740],"parameters":{},"typeVersion":3.4},{"id":"9ad0741f-f139-49ae-9e8d-b2f717055b5f","name":"Message Markup Insta","type":"n8n-nodes-base.set","position":[1980,480],"parameters":{},"typeVersion":3.4},{"id":"95085869-84a1-486b-bf3a-c8432617d5a5","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[1120,380],"parameters":{"content":""},"typeVersion":1},{"id":"00fbdacb-a0b5-4818-97e1-f286b608a88d","name":"Response Refined","type":"n8n-nodes-base.aggregate","position":[2160,740],"parameters":{},"typeVersion":1,"alwaysOutputData":true},{"id":"90a415be-d82b-4874-8018-e24b44ac0d72","name":"Filter Insta&Face","type":"n8n-nodes-base.filter","position":[1360,620],"parameters":{},"typeVersion":2.2},{"id":"2c187272-1368-4ec7-8a05-fded00b26aa9","name":"Get Reply Facebook","type":"n8n-nodes-base.httpRequest","position":[1820,620],"parameters":{},"typeVersion":4.2},{"id":"b0804da9-155c-43a4-b6d2-52bea8cd37ef","name":"Channel","type":"n8n-nodes-base.switch","position":[1660,560],"parameters":{},"typeVersion":3.2,"alwaysOutputData":true},{"id":"8daf1393-d8a5-4a2c-9dd7-87a9a72db7c2","name":"Message Markup Face","type":"n8n-nodes-base.set","position":[1980,620],"parameters":{},"typeVersion":3.4},{"id":"740c9ae9-c3c2-400a-b9d1-eec5d2543fd2","name":"Sticky Note19","type":"n8n-nodes-base.stickyNote","position":[-180,380],"parameters":{"content":""},"typeVersion":1},{"id":"af404bbe-004e-42fa-b97a-bd156fa4d186","name":"Block IA","type":"n8n-nodes-base.if","position":[2340,1140],"parameters":{},"typeVersion":2.2},{"id":"2c606ed1-d708-4e82-8f0f-c1474a9a6291","name":"MapTextHuman","type":"n8n-nodes-base.set","position":[2700,1220],"parameters":{},"typeVersion":3.3,"alwaysOutputData":true},{"id":"50852610-11cd-4171-840e-6891c072fe01","name":"Lead Search","type":"n8n-nodes-base.supabase","position":[2560,520],"parameters":{},"typeVersion":1,"alwaysOutputData":true},{"id":"f91e3d86-1d0f-470d-9f35-389c5bc36b75","name":"Lead Found","type":"n8n-nodes-base.if","position":[2720,520],"parameters":{},"typeVersion":2.2,"alwaysOutputData":true},{"id":"6d3fda7f-aa5f-4264-8fdc-774d1c3ef5c7","name":"Waiting","type":"n8n-nodes-base.wait","position":[2720,740],"webhookId":"4c675f89-81ce-4920-b8fc-1212a29d1170","parameters":{},"typeVersion":1.1},{"id":"1abbd969-7a7d-42c3-87fc-925382781eff","name":"Register New Lead","type":"n8n-nodes-base.supabase","position":[2580,740],"parameters":{},"typeVersion":1},{"id":"86e18f32-1793-4c1a-ae42-8d172bc3edb5","name":"Text Wrap","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[3920,760],"parameters":{},"typeVersion":1.4},{"id":"7aa79ed7-fc52-4f7c-b052-98a6888ee9fb","name":"Send Instagram","type":"n8n-nodes-base.httpRequest","position":[4860,700],"parameters":{},"typeVersion":4.2},{"id":"a8a3009c-0e4b-403f-8e1e-133d4a420832","name":"Send Facebook","type":"n8n-nodes-base.httpRequest","position":[4860,840],"parameters":{},"typeVersion":4.2},{"id":"27983069-963e-4266-a1ab-b2183b6ca121","name":"Get Audio WpAPI","type":"n8n-nodes-base.httpRequest","position":[540,1280],"parameters":{},"typeVersion":4.2,"alwaysOutputData":true},{"id":"f1c476c9-4ea6-459f-a80d-306a016a7af8","name":"Send Evolution","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[4860,1120],"parameters":{},"retryOnFail":true,"typeVersion":4.2,"waitBetweenTries":5000},{"id":"03949798-7367-40fa-bfad-8afb1fa0c1d1","name":"Send WhatsApp","type":"n8n-nodes-base.httpRequest","position":[4860,980],"parameters":{},"typeVersion":4.2},{"id":"8898a108-7ec0-40b4-8e8e-4dfca1fcfe77","name":"Bloqueio de IA","type":"n8n-nodes-base.filter","position":[3200,500],"parameters":{},"retryOnFail":false,"typeVersion":2},{"id":"700b48c9-58df-41a5-b514-09bc152a2b1e","name":"Best Agent AI","type":"@n8n/n8n-nodes-langchain.agent","position":[3540,900],"parameters":{},"typeVersion":1.6},{"id":"9d6b9f00-a9d4-43b3-9a4a-08db14ce92ed","name":"Respond to Webhook","type":"n8n-nodes-base.respondToWebhook","position":[520,60],"parameters":{},"typeVersion":1.1},{"id":"a6a15a16-1aec-401c-9577-e0eb365b4f63","name":"Send via Evolution","type":"n8n-nodes-base.filter","position":[4700,1120],"parameters":{},"typeVersion":2.2},{"id":"8bfd9d8b-d99f-47f2-a1f8-1963a05be5ab","name":"Send via Instagram","type":"n8n-nodes-base.filter","position":[4700,700],"parameters":{},"typeVersion":2.2},{"id":"f1937a48-8d5b-443f-990e-ab192a530c6e","name":"Send via Face","type":"n8n-nodes-base.filter","position":[4700,840],"parameters":{},"typeVersion":2.2},{"id":"2f25fbb3-2b5d-4012-b1b7-d37d1cae1a62","name":"Send via WAAPI","type":"n8n-nodes-base.filter","position":[4700,980],"parameters":{},"typeVersion":2.2},{"id":"1eb522df-eda6-486e-9775-4d418488e39a","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[4220,380],"parameters":{"content":""},"typeVersion":1},{"id":"76730c44-f2fb-41dc-9c4f-42f4b4f93e47","name":"reagir_waapi","type":"@n8n/n8n-nodes-langchain.toolHttpRequest","position":[3700,1360],"parameters":{},"typeVersion":1.1},{"id":"39757a2d-093a-4d72-adca-6de2e70cb1b6","name":"origem","type":"n8n-nodes-base.code","position":[0,500],"parameters":{},"typeVersion":2},{"id":"a864453e-744e-4ea8-84d5-4aa6f12ad0eb","name":"FromMe WhatsApp","type":"n8n-nodes-base.filter","position":[2980,600],"parameters":{},"typeVersion":2.2},{"id":"b0bd8ae2-78bf-457a-901c-36b11e82ec08","name":"FromMe Insta&Face&Wp","type":"n8n-nodes-base.filter","position":[2980,780],"parameters":{},"typeVersion":2.2},{"id":"fd3b01b2-b708-42b1-a3b3-0d8cdf6e02b5","name":"FromMe Insta&Face","type":"n8n-nodes-base.filter","position":[2980,420],"parameters":{},"typeVersion":2.2},{"id":"18a3db33-216f-4a2a-92e6-6c3179a45636","name":"reagir_evo","type":"@n8n/n8n-nodes-langchain.toolHttpRequest","position":[3580,1360],"parameters":{},"typeVersion":1.1},{"id":"5f75da9e-6dde-435a-bafa-bd5c2ea6d570","name":"update_name","type":"n8n-nodes-base.supabaseTool","position":[3580,1500],"parameters":{},"typeVersion":1},{"id":"2df876db-68c6-4bcc-91c8-cd61a2acfe09","name":"create_payment","type":"@n8n/n8n-nodes-langchain.toolHttpRequest","position":[3460,1500],"parameters":{},"typeVersion":1.1},{"id":"adc97ca5-aac0-4114-a344-dabd28efe12a","name":"n8n","type":"n8n-nodes-base.n8n","position":[20,1660],"parameters":{},"typeVersion":1},{"id":"45422e2c-8929-46b4-837a-2ba482e377fd","name":"n8n1","type":"n8n-nodes-base.n8n","position":[160,1660],"parameters":{},"typeVersion":1},{"id":"10c97a26-cceb-4c34-bc03-40b614269bfe","name":"No Operation1","type":"n8n-nodes-base.noOp","position":[300,1660],"parameters":{},"typeVersion":1},{"id":"2b38bfde-a17c-46d5-87f8-2405c926394f","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[-180,1540],"parameters":{"content":""},"typeVersion":1},{"id":"375887df-a96d-4854-9640-6d1455a6485e","name":"Start Deletion","type":"n8n-nodes-base.scheduleTrigger","position":[-120,1660],"parameters":{},"typeVersion":1.2},{"id":"35b90adc-7f46-4898-aaf6-b707b21987b1","name":"Down Audio WpAPI","type":"n8n-nodes-base.httpRequest","position":[680,1280],"parameters":{},"typeVersion":4.2},{"id":"e5b62ea7-f0b5-4463-9836-523a8d3cdb9e","name":"Down Audio Insta&Face","type":"n8n-nodes-base.httpRequest","position":[540,1140],"parameters":{},"typeVersion":4.2},{"id":"736cd360-c767-47d2-9f1d-99fd23ef6704","name":"MapAudioEvo","type":"n8n-nodes-base.set","position":[540,1420],"parameters":{},"typeVersion":3.4},{"id":"0de66ff3-5e10-4f4a-835e-34db9ba6e80f","name":"Down Img Insta&Face","type":"n8n-nodes-base.httpRequest","position":[620,880],"parameters":{},"typeVersion":4.2},{"id":"7ef1c4f5-f6d7-46ab-98e6-e75fd687dcdc","name":"Code4","type":"n8n-nodes-base.code","position":[1680,2260],"parameters":{},"typeVersion":2},{"id":"949276d3-c0e5-44c0-8d65-6729baf65bd1","name":"Code Resposta","type":"n8n-nodes-base.code","position":[1680,2400],"parameters":{},"typeVersion":2},{"id":"db7b6382-6b9b-49c7-a35c-f9678c68c910","name":"Se Erro","type":"n8n-nodes-base.if","position":[1820,2400],"parameters":{},"typeVersion":2.2},{"id":"8c099fef-1957-409a-ba68-300a7dcd9247","name":"Response Address Sucess","type":"n8n-nodes-base.respondToWebhook","position":[2060,2400],"parameters":{},"typeVersion":1.1},{"id":"66c0ed2d-f6ab-40f5-904c-4ab28bed2f67","name":"Response Address Error","type":"n8n-nodes-base.respondToWebhook","position":[2060,2260],"parameters":{},"typeVersion":1.1},{"id":"86fbf13a-69c0-4b88-a5f2-5e1853ba0015","name":"Mapbox Cliente","type":"n8n-nodes-base.httpRequest","position":[1500,2380],"parameters":{},"typeVersion":4.2},{"id":"f76cd0f3-f7f8-4c08-8d15-7c35cf73ae93","name":"Mapbox Distancia","type":"n8n-nodes-base.httpRequest","position":[1820,2260],"parameters":{},"typeVersion":4.2},{"id":"9d6be5c7-572b-4f8a-a401-8546b98634fa","name":"Apontamentos","type":"n8n-nodes-base.set","position":[1360,2380],"parameters":{},"typeVersion":3.4},{"id":"1fe577a7-4b33-40a2-b310-64ea60694eaf","name":"TriggerMapbox","type":"n8n-nodes-base.webhook","position":[1220,2380],"webhookId":"b2851493-5c5f-4b3f-b620-57b217fca6ef","parameters":{},"typeVersion":2},{"id":"c8662f61-3948-4f68-adc2-64df11141076","name":"CalculateDelivery","type":"@n8n/n8n-nodes-langchain.toolHttpRequest","position":[3220,1500],"parameters":{},"typeVersion":1.1},{"id":"ac0dae0b-add2-49f0-805a-cf6e5f7735c4","name":"Sticky Note10","type":"n8n-nodes-base.stickyNote","position":[1180,2240],"parameters":{"content":""},"typeVersion":1},{"id":"b0ac597a-2759-4cb3-ac3e-8dab8dfbff50","name":"CPF exist","type":"n8n-nodes-base.if","position":[3280,2360],"parameters":{},"typeVersion":2.2},{"id":"ff4428d5-f188-40de-a760-1c39ae3a8b27","name":"Sticky Note12","type":"n8n-nodes-base.stickyNote","position":[3100,2240],"parameters":{"content":""},"typeVersion":1},{"id":"45ff4517-4d38-43c8-ab47-622f0a4c610e","name":"RespondCPF2","type":"n8n-nodes-base.respondToWebhook","position":[3780,2260],"parameters":{},"typeVersion":1.1},{"id":"84032bed-e5f8-4580-aed4-7ab43e8b5f2c","name":"RespondCPF3","type":"n8n-nodes-base.respondToWebhook","position":[3780,2400],"parameters":{},"typeVersion":1.1},{"id":"625bc425-6138-4ec7-ba65-9dadb33bebc6","name":"checar_cep","type":"@n8n/n8n-nodes-langchain.toolHttpRequest","position":[3940,1360],"parameters":{},"typeVersion":1.1},{"id":"11fcd45b-5925-483c-bc77-f1a81ef9126a","name":"send_img_wp","type":"@n8n/n8n-nodes-langchain.toolHttpRequest","position":[3460,1360],"parameters":{},"typeVersion":1.1},{"id":"3b372599-cdb9-4a48-ba3c-2e497d047f81","name":"send_img_evo","type":"@n8n/n8n-nodes-langchain.toolHttpRequest","position":[3340,1360],"parameters":{},"typeVersion":1.1},{"id":"67c5630c-52d4-4efd-a2db-59cef1811c26","name":"Sticky Note15","type":"n8n-nodes-base.stickyNote","position":[2260,2240],"parameters":{"content":""},"typeVersion":1},{"id":"b471c7fd-54d4-4b3c-835d-9008d63df55d","name":"Send Images","type":"n8n-nodes-base.webhook","position":[2300,2340],"webhookId":"de327165-89b8-400a-8775-0d50762f1e5e","parameters":{},"typeVersion":2},{"id":"6c2fab8c-a58b-4029-a4fd-9ab1b6f293f4","name":"Evolution Imagem","type":"n8n-nodes-evolution-api.evolutionApi","onError":"continueErrorOutput","position":[2580,2340],"parameters":{},"typeVersion":1},{"id":"1c3f6f52-b5da-4bc5-a2b8-7eeef3d85648","name":"Set Field Evo","type":"n8n-nodes-base.set","position":[2440,2340],"parameters":{},"typeVersion":3.4},{"id":"b5f16b3d-224b-420d-9e8d-14bcff7e4a3f","name":"Response Img","type":"n8n-nodes-base.respondToWebhook","position":[2900,2300],"parameters":{},"typeVersion":1.1},{"id":"e1a1b163-161c-4ad1-845b-a19af70e8967","name":"Response Img Erro","type":"n8n-nodes-base.respondToWebhook","position":[2760,2420],"parameters":{},"typeVersion":1.1},{"id":"d78f9de2-cb54-4453-9441-bff9cfee975e","name":"Wait","type":"n8n-nodes-base.wait","position":[2760,2300],"webhookId":"04bc78dd-6988-44ac-ad1f-8276242d82c3","parameters":{},"typeVersion":1.1},{"id":"206df0b8-5b8e-4050-aa30-079f123a5d82","name":"AI Agent Products","type":"@n8n/n8n-nodes-langchain.agent","position":[2440,2680],"parameters":{},"typeVersion":1.8},{"id":"bf88b2e6-5b7f-4525-9ef6-2f8aae1ecdc7","name":"Model20","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[2760,2780],"parameters":{},"typeVersion":1.2},{"id":"5e57da67-efb1-4d4c-9c84-c97c3e55a5b4","name":"Calculator1","type":"@n8n/n8n-nodes-langchain.toolCalculator","position":[2860,2780],"parameters":{},"typeVersion":1},{"id":"d4d553bf-ae7a-49c9-9a0c-b2dfd0f5d1bd","name":"Check Bebidas","type":"n8n-nodes-base.webhook","position":[2300,2680],"webhookId":"dc8fa9a7-ce70-45ed-92b0-3e0b7ab5b526","parameters":{},"typeVersion":2},{"id":"bf822f7e-ea70-4e9e-8a37-6e3b7d7d01dd","name":"consulta_bebidas","type":"@n8n/n8n-nodes-langchain.toolHttpRequest","position":[3340,1500],"parameters":{},"typeVersion":1.1},{"id":"7274854d-e1a7-4797-87ee-d1598fdc3ffd","name":"Respond Bebida","type":"n8n-nodes-base.respondToWebhook","position":[2900,2620],"parameters":{},"typeVersion":1.1},{"id":"e9043eed-5a9d-4bf8-b107-f8559f3eb667","name":"Sticky Note20","type":"n8n-nodes-base.stickyNote","position":[2260,2580],"parameters":{"content":""},"typeVersion":1},{"id":"d56933ba-1291-4044-aeee-98d60cdc50a0","name":"Checa CEP","type":"n8n-nodes-base.function","position":[3480,2620],"parameters":{},"typeVersion":1},{"id":"35c2c803-4cb7-468f-b99b-a91cd042bcd7","name":"CPF","type":"n8n-nodes-base.webhook","position":[3140,2360],"webhookId":"ff5d96c2-3868-450c-a378-6b5b1fa83331","parameters":{},"typeVersion":1},{"id":"608ccafb-5ad0-41ec-b92e-85039467da39","name":"CEP","type":"n8n-nodes-base.webhook","position":[3140,2700],"webhookId":"8cd7eb71-54af-4254-8740-7b7eab0f10b2","parameters":{},"typeVersion":1},{"id":"83127c5e-d24d-4554-8846-50bc0c28a4a4","name":"RespondCEP","type":"n8n-nodes-base.respondToWebhook","position":[3780,2600],"parameters":{},"typeVersion":1.1},{"id":"1d8c98d4-6a67-4a60-a3b4-40a30ba18e3c","name":"CEP exist","type":"n8n-nodes-base.if","position":[3280,2700],"parameters":{},"typeVersion":2.2},{"id":"0eae5f0f-2185-4ad6-8a03-794827d087d2","name":"Validate CPF","type":"n8n-nodes-base.function","position":[3480,2280],"parameters":{},"typeVersion":1},{"id":"900f4fb5-c91d-4157-926a-56bf50cf995b","name":"CPF Válido","type":"n8n-nodes-base.if","position":[3620,2280],"parameters":{},"typeVersion":2.2},{"id":"30ddae55-e58c-449b-b2d8-c88f7238d96d","name":"Sticky Note21","type":"n8n-nodes-base.stickyNote","position":[3100,2580],"parameters":{"content":""},"typeVersion":1},{"id":"287c2824-a35e-49a5-bcd7-c3f3ba18d212","name":"RespondCEP Erro","type":"n8n-nodes-base.respondToWebhook","position":[3780,2740],"parameters":{},"typeVersion":1.1},{"id":"c808cc70-f019-4940-a123-9a72c6cc494d","name":"CEP Válido","type":"n8n-nodes-base.if","position":[3620,2620],"parameters":{},"typeVersion":2.2},{"id":"a527d253-7d59-4e02-8642-107000d99f47","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[1140,2160],"parameters":{"content":""},"typeVersion":1},{"id":"36246ea5-8484-4538-9d94-1ffef78d6670","name":"Sticky Note22","type":"n8n-nodes-base.stickyNote","position":[3100,3260],"parameters":{"content":""},"typeVersion":1},{"id":"1efff009-ee40-4db7-b3d8-f07df8213cd7","name":"Wait1","type":"n8n-nodes-base.wait","position":[3600,3320],"webhookId":"999608b3-2907-4149-aee1-99120828aff0","parameters":{},"typeVersion":1.1},{"id":"ac1427c7-fb53-4b7c-9681-1bc4afd254a8","name":"Response4","type":"n8n-nodes-base.respondToWebhook","position":[3740,3320],"parameters":{},"typeVersion":1.1},{"id":"faf41707-434f-467f-b7bc-524b93cf49c3","name":"Set Field Pedido","type":"n8n-nodes-base.set","position":[3280,3360],"parameters":{},"typeVersion":3.4},{"id":"69bccb28-d2d7-43d5-8db9-19156c894ce7","name":"send_pedido","type":"@n8n/n8n-nodes-langchain.toolHttpRequest","position":[3820,1360],"parameters":{},"typeVersion":1.1},{"id":"2010c1b4-f1ae-492e-bc70-18dbfaa0e2a0","name":"Send Pedido","type":"n8n-nodes-base.webhook","position":[3140,3360],"webhookId":"68693d8a-3b09-4af1-a5ae-121ed923e647","parameters":{},"typeVersion":2},{"id":"f361f054-a5f2-435e-9759-0bcf9a1b412e","name":"Delete Old Doc Rows","type":"n8n-nodes-base.supabase","position":[1720,3060],"parameters":{},"typeVersion":1,"alwaysOutputData":true},{"id":"1ca6a4ee-ad8d-4c91-b778-a6b37847db75","name":"Download File","type":"n8n-nodes-base.googleDrive","position":[2080,3360],"parameters":{},"executeOnce":true,"typeVersion":3},{"id":"22c3060c-65af-4274-b03f-da7935929d3c","name":"If","type":"n8n-nodes-base.if","onError":"continueRegularOutput","position":[1560,3060],"parameters":{},"typeVersion":2.2},{"id":"a7418a17-4c72-45f9-9b95-5b5d8b222d02","name":"Aggregate","type":"n8n-nodes-base.aggregate","position":[2440,3260],"parameters":{},"typeVersion":1},{"id":"779c3355-1eb9-4bd2-92c9-20db996fec49","name":"Summarize","type":"n8n-nodes-base.summarize","position":[2580,3260],"parameters":{},"typeVersion":1},{"id":"6a1fabcb-a54c-41cc-a49f-058c8762ffea","name":"Delete File1","type":"n8n-nodes-base.googleDrive","position":[2440,3400],"parameters":{},"typeVersion":3},{"id":"b22359e5-5848-47f9-9c2a-4dda08a39db5","name":"File Updated","type":"n8n-nodes-base.googleDriveTrigger","position":[1240,3060],"parameters":{},"typeVersion":1},{"id":"9a9cc7e7-9378-41f3-830d-6742e4a901cf","name":"Limit","type":"n8n-nodes-base.limit","position":[1420,3280],"parameters":{},"typeVersion":1},{"id":"f891f3b0-abf4-44d6-8f07-ddf0a43944d6","name":"Loop Over Items","type":"n8n-nodes-base.splitInBatches","position":[1900,3220],"parameters":{},"typeVersion":3},{"id":"95932770-e1f4-4497-b251-4418811cbe5a","name":"Definir ID","type":"n8n-nodes-base.set","position":[1420,3060],"parameters":{},"typeVersion":3.4},{"id":"71faaaa9-fda2-4bb6-a145-79b901211d5c","name":"Mensagem","type":"n8n-nodes-base.set","position":[2140,1580],"parameters":{},"typeVersion":3.4},{"id":"2e3f0a00-a73b-41bf-bf62-f87b37c61f6e","name":"Filter","type":"n8n-nodes-base.filter","position":[1980,1580],"parameters":{},"typeVersion":2.2},{"id":"630f2c64-9a49-456a-b5b8-6cf7f4b435c0","name":"Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[1600,1820],"parameters":{},"typeVersion":1},{"id":"5a0b5fb7-7d9c-4493-b48a-8fe06f82fb4d","name":"Start Time","type":"n8n-nodes-base.scheduleTrigger","position":[1180,1200],"parameters":{},"typeVersion":1.2},{"id":"0d63fe52-8137-4bf4-89c5-2ec90d2ce97f","name":"Data&Hora1","type":"n8n-nodes-base.code","position":[1980,1280],"parameters":{},"typeVersion":2},{"id":"f5851948-27b6-4c22-bf3c-83f7340e3039","name":"JSONhistorico3","type":"n8n-nodes-base.code","position":[2280,1820],"parameters":{},"typeVersion":2},{"id":"7460eb83-6832-4def-99b9-514a14d1eedd","name":"FollowUP Eu","type":"n8n-nodes-base.if","position":[1800,1220],"parameters":{},"typeVersion":2.2},{"id":"f7172c70-9bb1-4b4b-ae18-ca91f6f10017","name":"Loop","type":"n8n-nodes-base.splitInBatches","position":[1500,1160],"parameters":{},"typeVersion":3},{"id":"a24daea9-a8f4-419a-8085-a89edf3da60e","name":"SalvaHistorico2","type":"n8n-nodes-base.supabase","position":[2420,1820],"parameters":{},"typeVersion":1},{"id":"f3254ca1-14a8-4d14-93b4-75af876934d4","name":"24 Horas","type":"n8n-nodes-base.filter","position":[1420,1720],"parameters":{},"retryOnFail":false,"typeVersion":2},{"id":"ffac5203-7700-40a9-aae9-6b06bcf69cb5","name":"10 Min","type":"n8n-nodes-base.filter","position":[1420,1480],"parameters":{},"retryOnFail":false,"typeVersion":2},{"id":"ea3e3144-0616-4410-98ed-512a16b09758","name":"Sticky Note24","type":"n8n-nodes-base.stickyNote","position":[1140,1080],"parameters":{"content":""},"typeVersion":1},{"id":"4cb3cd05-3629-4154-89a7-7c7a98bd3e0b","name":"Sticky Note25","type":"n8n-nodes-base.stickyNote","position":[3100,2920],"parameters":{"content":""},"typeVersion":1},{"id":"fd03fc0a-c781-422e-affb-64ce0e150bd3","name":"Sticky Note23","type":"n8n-nodes-base.stickyNote","position":[1180,2920],"parameters":{"content":""},"typeVersion":1},{"id":"4ec80313-0720-4f85-8a28-806480c1765f","name":"Switch Type","type":"n8n-nodes-base.switch","position":[2080,3080],"parameters":{},"typeVersion":3},{"id":"922fde98-10f3-4c1d-8f58-aa2939544e63","name":"Extract PDF Text","type":"n8n-nodes-base.extractFromFile","position":[2300,2980],"parameters":{},"typeVersion":1},{"id":"ecdb81f2-40fa-4008-8212-a35c910bd0dd","name":"Extract from Text File","type":"n8n-nodes-base.extractFromFile","position":[2300,3120],"parameters":{},"typeVersion":1,"alwaysOutputData":true},{"id":"56c41587-da47-4679-8ddc-3f5a4ea5732a","name":"Extract from Excel","type":"n8n-nodes-base.extractFromFile","position":[2300,3260],"parameters":{},"typeVersion":1},{"id":"a3f08d9b-dc21-4a8a-bdad-284cab0f6f3b","name":"Convert to Google Doc","type":"n8n-nodes-base.httpRequest","position":[2300,3400],"parameters":{},"typeVersion":4.1},{"id":"b1e11fef-545a-454c-b04c-c8144df85bc8","name":"Embed AI","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[2740,3300],"parameters":{},"typeVersion":1.1},{"id":"aa5895e5-30b8-4a7f-b813-34ac068b0e6c","name":"Recursive Character","type":"@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter","position":[2880,3300],"parameters":{},"typeVersion":1},{"id":"2f152322-7c72-4967-9d4d-2bac8e0112b4","name":"Update Data RAG","type":"@n8n/n8n-nodes-langchain.vectorStoreSupabase","position":[2740,2980],"parameters":{},"typeVersion":1},{"id":"a19a0cb0-7af4-4139-9645-0d59505173f3","name":"Enhanced Default","type":"@n8n/n8n-nodes-langchain.documentDefaultDataLoader","position":[2780,3160],"parameters":{},"typeVersion":1},{"id":"b9b5f102-757e-47e0-9d43-198a1d3074b7","name":"Set File Version","type":"@n8n/n8n-nodes-langchain.openAi","position":[1560,3280],"parameters":{},"typeVersion":1.7},{"id":"7b7f27ab-af33-42d5-b78b-c04e65fb93f2","name":"Calc6301","type":"@n8n/n8n-nodes-langchain.toolCalculator","position":[1640,3420],"parameters":{},"typeVersion":1},{"id":"8851d54f-576f-41c0-b4e8-24b8620e448a","name":"n8n_chat_histories","type":"@n8n/n8n-nodes-langchain.toolVectorStore","position":[4280,1500],"parameters":{},"typeVersion":1},{"id":"f654c13f-6d56-43e6-9b1e-83c80325ae3e","name":"instrucoes","type":"@n8n/n8n-nodes-langchain.toolVectorStore","position":[4280,1360],"parameters":{},"typeVersion":1},{"id":"1a305a54-2a3b-4fae-972c-a33610891c5d","name":"Supabase instrucoes","type":"@n8n/n8n-nodes-langchain.vectorStoreSupabase","position":[4600,1360],"parameters":{},"typeVersion":1},{"id":"4726cc4d-673d-41b8-8044-5a076245e9b7","name":"ModelB2","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[5060,1360],"parameters":{},"typeVersion":1},{"id":"494ac359-0b3d-4aef-93f6-264b03de7b90","name":"ModelB3","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[4940,1500],"parameters":{},"typeVersion":1.1},{"id":"3ab247f1-8103-4bab-93f5-34577e66ddae","name":"Embed02","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[4940,1360],"parameters":{},"typeVersion":1.1},{"id":"28e65ea7-445e-4b14-af2b-cdab5a91a56f","name":"Embed03","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[5060,1500],"parameters":{},"typeVersion":1.2},{"id":"79f67420-9a69-4dfe-be67-583004ef8746","name":"Sticky Note26","type":"n8n-nodes-base.stickyNote","position":[4220,1280],"parameters":{"content":""},"typeVersion":1},{"id":"1eab31b3-d1ed-476a-bb01-50af7eaa4cf9","name":"Sticky Note27","type":"n8n-nodes-base.stickyNote","position":[3160,680],"parameters":{"content":""},"typeVersion":1},{"id":"f13fde7b-49a2-4975-8549-c562d5cc859f","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[3160,1280],"parameters":{"content":""},"typeVersion":1},{"id":"3bb1e6ad-ad96-433f-ba4a-e8a168d94762","name":"SB n8n_chat_histories","type":"@n8n/n8n-nodes-langchain.vectorStoreSupabase","position":[4600,1500],"parameters":{},"typeVersion":1},{"id":"32e304ac-b63c-4245-869a-46e3a7798084","name":"Follow Up Search","type":"n8n-nodes-base.supabase","position":[1320,1200],"parameters":{},"typeVersion":1},{"id":"494cdcdb-95cf-4087-a647-b9f6d0068f8e","name":"Individual Followup","type":"n8n-nodes-base.supabase","position":[1660,1220],"parameters":{},"typeVersion":1},{"id":"5c004c43-3e07-4b76-936e-13d5d0f60ac6","name":"Map FollowUP","type":"n8n-nodes-base.set","position":[2120,1280],"parameters":{},"typeVersion":3.4},{"id":"f3c4cbdb-275c-41ae-9eda-3ba40135fa57","name":"Calculate Time","type":"n8n-nodes-base.code","position":[1220,1620],"parameters":{},"typeVersion":2},{"id":"36e8f29f-f0fc-42ad-a043-3eb2098e2ce8","name":"Sticky Note28","type":"n8n-nodes-base.stickyNote","position":[120,440],"parameters":{"content":""},"typeVersion":1},{"id":"158c3af2-42ec-475b-96d7-f02e3d4b5518","name":"Sticky Note29","type":"n8n-nodes-base.stickyNote","position":[2340,560],"parameters":{"content":""},"typeVersion":1},{"id":"6c9cf354-a5ef-48cd-87ea-3f44121562b8","name":"2 Horas","type":"n8n-nodes-base.filter","position":[1420,1600],"parameters":{},"retryOnFail":false,"typeVersion":2},{"id":"f878789a-f1b0-4ed1-b767-eb189f2c9033","name":"Sticky Note30","type":"n8n-nodes-base.stickyNote","position":[2260,1420],"parameters":{"content":""},"typeVersion":1},{"id":"2302f012-1786-433d-9a0f-f5404dd58017","name":"Calc201","type":"@n8n/n8n-nodes-langchain.toolCalculator","position":[1800,1820],"parameters":{},"typeVersion":1},{"id":"9e6bc4c2-0aec-4a33-b589-3a25e8466a22","name":"Memory50","type":"@n8n/n8n-nodes-langchain.memoryPostgresChat","position":[1700,1820],"parameters":{},"typeVersion":1.3},{"id":"d1518ed5-4fc7-4394-a0cb-02010cdf180e","name":"Fixed Credentials1","type":"n8n-nodes-base.set","position":[2420,1640],"parameters":{},"typeVersion":3.4},{"id":"9179e1f6-6f86-4d0b-8adc-66ba539da34d","name":"Sticky Note31","type":"n8n-nodes-base.stickyNote","position":[2400,1580],"parameters":{"content":""},"typeVersion":1},{"id":"f9a3a8b2-eb5a-47be-b5fd-f6f8da216268","name":"Send Instagram1","type":"n8n-nodes-base.httpRequest","position":[2800,1440],"parameters":{},"typeVersion":4.2},{"id":"29ee2b39-ed31-45f9-b5fb-6944b7061b9d","name":"Send Facebook1","type":"n8n-nodes-base.httpRequest","position":[2800,1580],"parameters":{},"typeVersion":4.2},{"id":"9a1b334f-df3b-4e38-9022-889eedd430e4","name":"Send Evolution1","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[2800,1860],"parameters":{},"retryOnFail":true,"typeVersion":4.2,"waitBetweenTries":5000},{"id":"6334c9d6-c01b-4c3d-8986-482a51cd7bc0","name":"Send WhatsApp1","type":"n8n-nodes-base.httpRequest","position":[2800,1720],"parameters":{},"typeVersion":4.2},{"id":"baf5c816-b114-43c5-a6a3-83408fc06973","name":"Send via Evolution1","type":"n8n-nodes-base.filter","position":[2660,1860],"parameters":{},"typeVersion":2.2},{"id":"3724a061-5561-41c4-a131-77fdf27cd20a","name":"Send via Instagram1","type":"n8n-nodes-base.filter","position":[2660,1440],"parameters":{},"typeVersion":2.2},{"id":"72869ce9-d82e-4ed4-866f-7785aa330ee4","name":"Send via Face1","type":"n8n-nodes-base.filter","position":[2660,1580],"parameters":{},"typeVersion":2.2},{"id":"f3957dac-7740-4ae8-ba95-299c1d2b8700","name":"Send via WAAPI1","type":"n8n-nodes-base.filter","position":[2660,1720],"parameters":{},"typeVersion":2.2},{"id":"5836dd69-122c-452b-b70d-6d47a0fad4c9","name":"72 Horas","type":"n8n-nodes-base.filter","position":[1420,1840],"parameters":{},"retryOnFail":false,"typeVersion":2},{"id":"1c9ac2ad-bdb5-416f-ac19-e52cffdbcc9f","name":"SB Historico","type":"n8n-nodes-base.supabaseTool","position":[1900,1820],"parameters":{},"typeVersion":1},{"id":"6facfb27-df2a-4a98-bf7a-8c5331b6ca17","name":"AI Agent FollowUP","type":"@n8n/n8n-nodes-langchain.agent","position":[1640,1580],"parameters":{},"typeVersion":1.7},{"id":"5a0ba796-7e32-4442-9d41-84d3823b83d3","name":"QntFollowUP","type":"n8n-nodes-base.code","position":[2140,1820],"parameters":{},"typeVersion":2},{"id":"b92cec1e-5d64-4c5d-9d28-b49305910da7","name":"NoOperation","type":"n8n-nodes-base.noOp","position":[2980,1660],"parameters":{},"typeVersion":1},{"id":"76d7e893-be4d-41f6-8e9b-c4e9880e8ad6","name":"NoOperation1","type":"n8n-nodes-base.noOp","position":[1980,1120],"parameters":{},"typeVersion":1}],"active":false,"pinData":{},"settings":{"timezone":"America/Sao_Paulo","callerPolicy":"workflowsFromSameOwner","executionOrder":"v1","executionTimeout":180},"versionId":"681c9aa4-c38c-43eb-8823-ea46052ac842","connections":{"If":{"main":[[],[{"node":"Delete Old Doc Rows","type":"main","index":0}]]},"CEP":{"main":[[{"node":"CEP exist","type":"main","index":0}]]},"CPF":{"main":[[{"node":"CPF exist","type":"main","index":0}]]},"n8n":{"main":[[{"node":"n8n1","type":"main","index":0}]]},"1,2s":{"main":[[{"node":"no.op2","type":"main","index":0}]]},"Loop":{"main":[[{"node":"NoOperation1","type":"main","index":0}],[{"node":"Individual Followup","type":"main","index":0}]]},"Maps":{"main":[[{"node":"Add Response","type":"main","index":0}]]},"Wait":{"main":[[{"node":"Response Img","type":"main","index":0}]]},"n8n1":{"main":[[{"node":"No Operation1","type":"main","index":0}]]},"Code4":{"main":[[{"node":"Mapbox Distancia","type":"main","index":0}]]},"Limit":{"main":[[{"node":"Set File Version","type":"main","index":0}]]},"Maps1":{"main":[[{"node":"Add Response","type":"main","index":0}]]},"Maps2":{"main":[[{"node":"Add Response","type":"main","index":0}]]},"Maps5":{"main":[[{"node":"Add Response","type":"main","index":0}]]},"Maps6":{"main":[[{"node":"Add Response","type":"main","index":0}]]},"Model":{"ai_languageModel":[[{"node":"AI Agent FollowUP","type":"ai_languageModel","index":0}]]},"START":{"main":[[{"node":"origem","type":"main","index":0}]]},"Wait1":{"main":[[{"node":"Response4","type":"main","index":0}]]},"10 Min":{"main":[[{"node":"AI Agent FollowUP","type":"main","index":0}]]},"Filter":{"main":[[{"node":"Mensagem","type":"main","index":0}]]},"Prompt":{"main":[[{"node":"Best Agent AI","type":"main","index":0}]]},"no.op2":{"main":[[{"node":"Loop Over Items1","type":"main","index":0}]]},"origem":{"main":[[{"node":"Fixed Credentials","type":"main","index":0}]]},"2 Horas":{"main":[[{"node":"AI Agent FollowUP","type":"main","index":0}]]},"Aguarda":{"main":[[{"node":"Busca Timeout","type":"main","index":0}]]},"Calc201":{"ai_tool":[[{"node":"AI Agent FollowUP","type":"ai_tool","index":0}]]},"Channel":{"main":[[{"node":"Get Reply Insta","type":"main","index":0}],[{"node":"Get Reply Facebook","type":"main","index":0}]]},"Embed02":{"ai_embedding":[[{"node":"Supabase instrucoes","type":"ai_embedding","index":0}]]},"Embed03":{"ai_embedding":[[{"node":"SB n8n_chat_histories","type":"ai_embedding","index":0}]]},"Model20":{"ai_languageModel":[[{"node":"AI Agent Products","type":"ai_languageModel","index":0}]]},"ModelB2":{"ai_languageModel":[[{"node":"instrucoes","type":"ai_languageModel","index":0}]]},"ModelB3":{"ai_languageModel":[[{"node":"n8n_chat_histories","type":"ai_languageModel","index":0}]]},"MsgType":{"main":[[{"node":"Maps","type":"main","index":0}],[{"node":"Maps","type":"main","index":0}],[{"node":"Maps","type":"main","index":0}],[{"node":"Converter Img","type":"main","index":0}],[{"node":"Down Img Insta&Face","type":"main","index":0}],[{"node":"Down Audio Insta&Face","type":"main","index":0}],[{"node":"Get Audio WpAPI","type":"main","index":0}],[{"node":"MapAudioEvo","type":"main","index":0}],[{"node":"Converte PDF","type":"main","index":0}]]},"OpenAI2":{"ai_languageModel":[[{"node":"Text Wrap","type":"ai_languageModel","index":0}]]},"PhoneID":{"main":[[{"node":"Criar Cliente","type":"main","index":0}]]},"Se Erro":{"main":[[{"node":"Response Address Error","type":"main","index":0}],[{"node":"Response Address Sucess","type":"main","index":0}]]},"Waiting":{"main":[[{"node":"Lead Search","type":"main","index":0}]]},"24 Horas":{"main":[[{"node":"AI Agent FollowUP","type":"main","index":0}]]},"72 Horas":{"main":[[{"node":"AI Agent FollowUP","type":"main","index":0}]]},"Add Link":{"main":[[{"node":"Response Asaas","type":"main","index":0}]]},"Block IA":{"main":[[{"node":"Bloquear IA","type":"main","index":0}],[{"node":"Desbloqueia IA","type":"main","index":0}]]},"Calc6301":{"ai_tool":[[{"node":"Set File Version","type":"ai_tool","index":0}]]},"Embed AI":{"ai_embedding":[[{"node":"Update Data RAG","type":"ai_embedding","index":0}]]},"Memory50":{"ai_memory":[[{"node":"AI Agent FollowUP","type":"ai_memory","index":0}]]},"Mensagem":{"main":[[{"node":"QntFollowUP","type":"main","index":0},{"node":"Fixed Credentials1","type":"main","index":0}]]},"WH Asaas":{"main":[[{"node":"Sem Dados","type":"main","index":0}]]},"up_dados":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"Aggregate":{"main":[[{"node":"Summarize","type":"main","index":0}]]},"CEP exist":{"main":[[{"node":"Checa CEP","type":"main","index":0}],[{"node":"RespondCEP Erro","type":"main","index":0}]]},"CPF exist":{"main":[[{"node":"Validate CPF","type":"main","index":0}],[{"node":"RespondCPF3","type":"main","index":0}]]},"Checa CEP":{"main":[[{"node":"CEP Válido","type":"main","index":0}]]},"Data&Hora":{"main":[[{"node":"MsgType","type":"main","index":0}]]},"Modelo IA":{"ai_languageModel":[[{"node":"Best Agent AI","type":"ai_languageModel","index":0}]]},"Segmentos":{"main":[[{"node":"Loop Over Items1","type":"main","index":0}]]},"Sem Dados":{"main":[[{"node":"PhoneID","type":"main","index":0}],[{"node":"Asaas Erro","type":"main","index":0}]]},"Summarize":{"main":[[{"node":"Update Data RAG","type":"main","index":0}]]},"Text Wrap":{"main":[[{"node":"Segmentos","type":"main","index":0},{"node":"Filtro Reset","type":"main","index":0}]]},"Variaveis":{"main":[[{"node":"Lead Search","type":"main","index":0}]]},"Calculator":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"Data&Hora1":{"main":[[{"node":"Map FollowUP","type":"main","index":0}]]},"Definir ID":{"main":[[{"node":"If","type":"main","index":0}]]},"Lead Found":{"main":[[{"node":"FromMe Insta&Face","type":"main","index":0},{"node":"FromMe Insta&Face&Wp","type":"main","index":0},{"node":"FromMe WhatsApp","type":"main","index":0}],[{"node":"Register New Lead","type":"main","index":0}]]},"No Marking":{"main":[[{"node":"Response Refined","type":"main","index":0}]]},"Start Time":{"main":[[{"node":"Follow Up Search","type":"main","index":0}]]},"checar_cep":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"checar_cpf":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"instrucoes":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"reagir_evo":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"Add Timeout":{"main":[[{"node":"Aguarda","type":"main","index":0}]]},"CEP Válido":{"main":[[{"node":"RespondCEP","type":"main","index":0}],[{"node":"RespondCEP Erro","type":"main","index":0}]]},"CPF Válido":{"main":[[{"node":"RespondCPF2","type":"main","index":0}],[{"node":"RespondCPF3","type":"main","index":0}]]},"Calculator1":{"ai_tool":[[{"node":"AI Agent Products","type":"ai_tool","index":0}]]},"CalculoTime":{"main":[[{"node":"Interferencia","type":"main","index":0}]]},"Extract PDF":{"main":[[{"node":"Maps5","type":"main","index":0}]]},"FollowUP Eu":{"main":[[{"node":"Data&Hora1","type":"main","index":0}],[{"node":"Loop","type":"main","index":0}]]},"Lead Search":{"main":[[{"node":"Lead Found","type":"main","index":0}]]},"MapAudioEvo":{"main":[[{"node":"Convert File Wp","type":"main","index":0}]]},"QntFollowUP":{"main":[[{"node":"JSONhistorico3","type":"main","index":0}]]},"Send Images":{"main":[[{"node":"Set Field Evo","type":"main","index":0}]]},"Send Pedido":{"main":[[{"node":"Set Field Pedido","type":"main","index":0}]]},"Switch Type":{"main":[[{"node":"Extract PDF Text","type":"main","index":0}],[{"node":"Extract from Text File","type":"main","index":0}],[{"node":"Extract from Excel","type":"main","index":0}],[{"node":"Convert to Google Doc","type":"main","index":0}],[{"node":"Convert to Google Doc","type":"main","index":0}],[{"node":"Convert to Google Doc","type":"main","index":0}]]},"TranscAudio":{"main":[[{"node":"Maps1","type":"main","index":0}]]},"send_img_wp":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"send_pedido":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"up_consumer":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"update_name":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"Add Response":{"main":[[{"node":"Filter Insta&Face","type":"main","index":0},{"node":"Filter WhatsApp","type":"main","index":0}]]},"Apontamentos":{"main":[[{"node":"Mapbox Cliente","type":"main","index":0}]]},"Converte PDF":{"main":[[{"node":"Extract PDF","type":"main","index":0}]]},"File Updated":{"main":[[{"node":"Definir ID","type":"main","index":0}]]},"Filtro Reset":{"main":[[{"node":"JSONhistorico","type":"main","index":0}]]},"Img WhatsApp":{"main":[[{"node":"Maps2","type":"main","index":0}]]},"Map FollowUP":{"main":[[{"node":"Calculate Time","type":"main","index":0}]]},"MapTextHuman":{"main":[[{"node":"JSONhistorico1","type":"main","index":0}]]},"OutputParser":{"ai_outputParser":[[{"node":"Text Wrap","type":"ai_outputParser","index":0}]]},"Response Img":{"main":[[]]},"SB Historico":{"ai_tool":[[{"node":"AI Agent FollowUP","type":"ai_tool","index":0}]]},"Validate CPF":{"main":[[{"node":"CPF Válido","type":"main","index":0}]]},"get_consumer":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"reagir_waapi":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"send_img_evo":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"Best Agent AI":{"main":[[{"node":"Text Wrap","type":"main","index":0}]]},"Busca Timeout":{"main":[[{"node":"CalculoTime","type":"main","index":0}]]},"Check Bebidas":{"main":[[{"node":"AI Agent Products","type":"main","index":0}]]},"Code Resposta":{"main":[[{"node":"Se Erro","type":"main","index":0}]]},"Converter Img":{"main":[[{"node":"Img WhatsApp","type":"main","index":0}]]},"Criar Cliente":{"main":[[{"node":"Criar Cobrança","type":"main","index":0}],[{"node":"Asaas Erro1","type":"main","index":0}]]},"Download File":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Img Instagram":{"main":[[{"node":"Maps6","type":"main","index":0}]]},"Interferencia":{"main":[[{"node":"Prompt","type":"main","index":0}]]},"JSONhistorico":{"main":[[{"node":"SalvaHistorico","type":"main","index":0}]]},"Send Facebook":{"main":[[{"node":"1,2s","type":"main","index":0}]]},"Send WhatsApp":{"main":[[{"node":"1,2s","type":"main","index":0}]]},"Send via Face":{"main":[[{"node":"Send Facebook","type":"main","index":0}]]},"Set Field Evo":{"main":[[{"node":"Evolution Imagem","type":"main","index":0}]]},"TriggerMapbox":{"main":[[{"node":"Apontamentos","type":"main","index":0}]]},"Bloqueio de IA":{"main":[[{"node":"JSONhistorico2","type":"main","index":0}]]},"Calculate Time":{"main":[[{"node":"10 Min","type":"main","index":0},{"node":"24 Horas","type":"main","index":0},{"node":"2 Horas","type":"main","index":0}]]},"Desbloqueia IA":{"main":[[{"node":"Desbloquear IA","type":"main","index":0}],[{"node":"MapTextHuman","type":"main","index":0}]]},"JSONhistorico1":{"main":[[{"node":"SalvaHistorico1","type":"main","index":0}]]},"JSONhistorico2":{"main":[[{"node":"Add Timeout","type":"main","index":0}]]},"JSONhistorico3":{"main":[[{"node":"SalvaHistorico2","type":"main","index":0}]]},"Mapbox Cliente":{"main":[[{"node":"Code4","type":"main","index":0}]]},"Send Evolution":{"main":[[{"node":"1,2s","type":"main","index":0}],[{"node":"1,2s","type":"main","index":0}]]},"Send Facebook1":{"main":[[{"node":"NoOperation","type":"main","index":0}]]},"Send Instagram":{"main":[[{"node":"1,2s","type":"main","index":0}]]},"Send WhatsApp1":{"main":[[{"node":"NoOperation","type":"main","index":0}]]},"Send via Face1":{"main":[[{"node":"Send Facebook1","type":"main","index":0}]]},"Send via WAAPI":{"main":[[{"node":"Send WhatsApp","type":"main","index":0}]]},"Start Deletion":{"main":[[{"node":"n8n","type":"main","index":0}]]},"create_payment":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"Convert File Wp":{"main":[[{"node":"TranscAudio","type":"main","index":0}]]},"Criar Cobrança":{"main":[[{"node":"Add Link","type":"main","index":0}],[{"node":"Asaas Erro2","type":"main","index":0}]]},"Filter WhatsApp":{"main":[[{"node":"Reply Message Wp","type":"main","index":0}]]},"FromMe WhatsApp":{"main":[[{"node":"Bloqueio de IA","type":"main","index":0}]]},"Get Audio WpAPI":{"main":[[{"node":"Down Audio WpAPI","type":"main","index":0}]]},"Get Reply Insta":{"main":[[{"node":"Message Markup Insta","type":"main","index":0}]]},"Loop Over Items":{"main":[[{"node":"Switch Type","type":"main","index":0}],[{"node":"Download File","type":"main","index":0}]]},"Postgres Memory":{"ai_memory":[[{"node":"Best Agent AI","type":"ai_memory","index":0}]]},"Send Evolution1":{"main":[[{"node":"NoOperation","type":"main","index":0}]]},"Send Instagram1":{"main":[[{"node":"NoOperation","type":"main","index":0}]]},"Send via WAAPI1":{"main":[[{"node":"Send WhatsApp1","type":"main","index":0}]]},"Down Audio WpAPI":{"main":[[{"node":"TranscAudio","type":"main","index":0}]]},"Enhanced Default":{"ai_document":[[{"node":"Update Data RAG","type":"ai_document","index":0}]]},"Evolution Imagem":{"main":[[{"node":"Wait","type":"main","index":0}],[{"node":"Response Img Erro","type":"main","index":0}]]},"Extract PDF Text":{"main":[[{"node":"Update Data RAG","type":"main","index":0}]]},"Follow Up Search":{"main":[[{"node":"Loop","type":"main","index":0}]]},"Loop Over Items1":{"main":[[],[{"node":"Send via Evolution","type":"main","index":0},{"node":"Send via Instagram","type":"main","index":0},{"node":"Send via Face","type":"main","index":0},{"node":"Send via WAAPI","type":"main","index":0}]]},"Mapbox Distancia":{"main":[[{"node":"Code Resposta","type":"main","index":0}]]},"Reply Message Wp":{"main":[[{"node":"No Marking","type":"main","index":0}],[{"node":"Message Markup Wp","type":"main","index":0}]]},"Response Refined":{"main":[[{"node":"Variaveis","type":"main","index":0}]]},"Set Field Pedido":{"main":[[{"node":"Wait1","type":"main","index":0}]]},"Set File Version":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"consulta_bebidas":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"AI Agent FollowUP":{"main":[[{"node":"Filter","type":"main","index":0}]]},"AI Agent Products":{"main":[[{"node":"Respond Bebida","type":"main","index":0}]]},"CalculateDelivery":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"Filter Insta&Face":{"main":[[{"node":"Reply Message Insta","type":"main","index":0}]]},"Fixed Credentials":{"main":[[{"node":"Data&Hora","type":"main","index":0}]]},"FromMe Insta&Face":{"main":[[{"node":"Bloqueio de IA","type":"main","index":0}]]},"Message Markup Wp":{"main":[[{"node":"Response Refined","type":"main","index":0}]]},"Register New Lead":{"main":[[{"node":"Waiting","type":"main","index":0}]]},"Extract from Excel":{"main":[[{"node":"Aggregate","type":"main","index":0}]]},"Fixed Credentials1":{"main":[[{"node":"Send via Instagram1","type":"main","index":0},{"node":"Send via Face1","type":"main","index":0},{"node":"Send via WAAPI1","type":"main","index":0},{"node":"Send via Evolution1","type":"main","index":0}]]},"Get Reply Facebook":{"main":[[{"node":"Message Markup Face","type":"main","index":0}]]},"Send via Evolution":{"main":[[{"node":"Send Evolution","type":"main","index":0}]]},"Send via Instagram":{"main":[[{"node":"Send Instagram","type":"main","index":0}]]},"n8n_chat_histories":{"ai_tool":[[{"node":"Best Agent AI","type":"ai_tool","index":0}]]},"Delete Old Doc Rows":{"main":[[{"node":"Limit","type":"main","index":0}]]},"Down Img Insta&Face":{"main":[[{"node":"Img Instagram","type":"main","index":0}]]},"Individual Followup":{"main":[[{"node":"FollowUP Eu","type":"main","index":0}]]},"Message Markup Face":{"main":[[{"node":"Response Refined","type":"main","index":0}]]},"Recursive Character":{"ai_textSplitter":[[{"node":"Enhanced Default","type":"ai_textSplitter","index":0}]]},"Reply Message Insta":{"main":[[{"node":"Channel","type":"main","index":0}],[{"node":"No Marking","type":"main","index":0}]]},"Send via Evolution1":{"main":[[{"node":"Send Evolution1","type":"main","index":0}]]},"Send via Instagram1":{"main":[[{"node":"Send Instagram1","type":"main","index":0}]]},"Supabase instrucoes":{"ai_vectorStore":[[{"node":"instrucoes","type":"ai_vectorStore","index":0}]]},"FromMe Insta&Face&Wp":{"main":[[{"node":"Block IA","type":"main","index":0}]]},"Message Markup Insta":{"main":[[{"node":"Response Refined","type":"main","index":0}]]},"Convert to Google Doc":{"main":[[{"node":"Delete File1","type":"main","index":0}]]},"Down Audio Insta&Face":{"main":[[{"node":"TranscAudio","type":"main","index":0}]]},"SB n8n_chat_histories":{"ai_vectorStore":[[{"node":"n8n_chat_histories","type":"ai_vectorStore","index":0}]]},"Extract from Text File":{"main":[[{"node":"Update Data RAG","type":"main","index":0}]]}}}


name: AI-Powered WhatsApp Chatbot 🤖📲 for Text, Voice, Images & PDFs with memory 🧠
author_name: Davide
author_username: n3witalia
categories: []
created_at: 2025-04-17T14:22:12.162Z
updated_at: 2025-04-17T14:22:12.162Z
url: https://n8n.io/workflows/3586
scraped_at: 2025-06-19 22:48:46
description:
  This workflow is a highly advanced multimodal AI assistant designed to operate through WhatsApp. It can understand and respond to text, images, voice messages, and PDF documents by combining OpenAI models with smart logic to adapt to the content received.

  🎯 Core Features

  📥 1. Automatic Message Type Detection
  Using the Input type node, the bot detects whether the user has sent:
  Text
  Voice messages
  Images
  Files (PDF)
  Other unsupported content

  💬 2. Smart Text Message Handling
  Text messages are processed by an OpenAI GPT-4o-mini agent with a customized system prompt.
  Replies are concise, accurate, and formatted for mobile readability.

  🖼️ 3. Image Analysis & Description
  Images are downloaded, converted to base64, and analyzed by an image-aware AI model.
  The output is a rich, structured description, designed for visually impaired users or visual content interpretation.

  🎙️ 4. Voice Message Transcription & Reply
  Audio messages are downloaded and transcribed using OpenAI Whisper.
  The transcribed text is analyzed and answered by the AI.
  Optionally, the AI reply can be converted back to voice using OpenAI's text-to-speech, and sent as an audio message.

  📄 5. PDF Document Extraction & Summary
  Only PDFs are allowed (filtered via MIME type).
  The document’s content is extracted and combined with the user's message.
  The AI then provides a relevant summary or answer.

  🧠 6. Contextual Memory
  Each user has a personalized session ID with a memory window of 10 interactions.
  This ensures a more natural and contextual conversation flow.

  How It Works  

  Thisworkflow is designed to handle incoming WhatsApp messages and process different types of inputs (text, audio, images, and PDF documents) using AI-powered analysis. Here’s how it functions:  

  Trigger: The workflow starts with the **WhatsApp Trigger node, which listens for incoming messages (text, audio, images, or documents).  
  Input Routing: The **Input type (Switch node) checks the message type and routes it to the appropriate processing branch:  
    Text: Directly forwards the message to the AI agent for response generation.  
    Audio: Downloads the audio file, transcribes it using OpenAI, and sends the transcription to the AI agent.  
    Image: Downloads the image, analyzes it with OpenAI’s GPT-4 model, and generates a detailed description.  
    PDF Document: Downloads the file, extracts text, and processes it with the AI agent.  
    Unsupported Formats: Sends an error message if the input is not supported.  
  AI Processing: The **AI Agent1 node, powered by OpenAI, processes the input (text, transcribed audio, image description, or PDF content) and generates a response.  
  Response Handling**:  
    For audio inputs, the AI’s response is converted back into speech (using OpenAI’s TTS) and sent as a voice message.  
    For other inputs, the response is sent as a text message via WhatsApp.  
  Memory: The **Simple Memory node maintains conversation context for follow-up interactions.  

  Setup Steps  
  To deploy this workflow in n8n, follow these steps:  

  Configure WhatsApp API Credentials:  
     Set up WhatsApp Business API credentials (Meta Developer Account).  
     Add the credentials in the WhatsApp Trigger, Get Image/Audio/File URL, and Send Message nodes.  

  Set Up OpenAI Integration:  
     Provide an OpenAI API key in the Analyze Image, Transcribe Audio, Generate Audio Response, and AI Agent1 nodes.  

   Adjust Input Handling (Optional):  
     Modify the Switch node ("Input type") to handle additional message types if needed.  
     Update the "Only PDF File" IF node to support other document formats.  

  Test & Deploy:  
     Activate the workflow and test with different message types (text, audio, image, PDF).  
     Ensure responses are correctly generated and sent back via WhatsApp.  

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

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

workflow_json:
  {"id":"zMtPPjJ80JJznrJP","meta":{"instanceId":"a4bfc93e975ca233ac45ed7c9227d84cf5a2329310525917adaf3312e10d5462","templateCredsSetupCompleted":true},"name":"AI-Powered WhatsApp Chatbot for Text, Voice, Images & PDFs","tags":[],"nodes":[{"id":"38246f5d-0cf4-49ed-957e-0189243d0dec","name":"WhatsApp Trigger","type":"n8n-nodes-base.whatsAppTrigger","position":[-700,80],"webhookId":"d3978cae-2aca-4553-8ac7-ab89068deabc","parameters":{"options":{},"updates":["messages"]},"credentials":{"whatsAppTriggerApi":{"id":"gylriO2te7NRPXxN","name":"WhatsApp OAuth account"}},"typeVersion":1},{"id":"4cc0b70b-3ecc-4415-af2f-e50d4f302786","name":"Download Image","type":"n8n-nodes-base.httpRequest","position":[720,120],"parameters":{"url":"={{ $json.url }}","options":{},"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"FDP9FxauzJt9rkjr","name":"WhatsApp"}},"typeVersion":4.2},{"id":"528984be-b9ad-41c7-8b2e-ccbf275f7805","name":"Analyze Image","type":"@n8n/n8n-nodes-langchain.openAi","position":[960,120],"parameters":{"text":"=You are an advanced image description AI assistant . Your primary function is to provide detailed, accurate descriptions of images submitted through WhatsApp.\n\nCORE FUNCTIONALITY:\n- When presented with an image, you will analyze it thoroughly and provide a comprehensive description in English.\n- Your descriptions should capture both the obvious and subtle elements within the image.\n\nIMAGE DESCRIPTION GUIDELINES:\n- Begin with a broad overview of what the image contains\n- Describe key subjects, people, objects, and their relationships\n- Note significant visual elements such as colors, lighting, composition, and perspective\n- Identify any text visible in the image\n- Describe the setting or environment\n- Mention any notable actions or events taking place\n- Comment on mood, tone, or atmosphere when relevant\n- If applicable, identify landmarks, famous people, or cultural references\n\nRESPONSE FORMAT:\n- Start with \"Image Description:\" followed by your analysis\n- Structure your description in a logical manner (general to specific)\n- Use clear, precise language appropriate for visual description\n- Format longer descriptions with paragraphs to enhance readability\n- End with any notable observations that might require special attention\n\nLIMITATIONS:\n- If the image is blurry, low resolution, or difficult to interpret, acknowledge these limitations\n- If an image contains potentially sensitive content, provide a factual description without judgment\n- Do not make assumptions about elements that cannot be clearly determined\n\nYour descriptions should be informative, objective, and thorough, enabling someone who cannot see the image to form an accurate mental picture of its contents.","modelId":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"GPT-4O-MINI"},"options":{"detail":"auto"},"resource":"image","inputType":"base64","operation":"analyze"},"credentials":{"openAiApi":{"id":"4zwP0MSr8zkNvvV9","name":"OpenAi account"}},"typeVersion":1.8},{"id":"b8898138-f987-4ef7-a5c1-d6d6b9c815f0","name":"Download Audio","type":"n8n-nodes-base.httpRequest","position":[720,-180],"parameters":{"url":"={{ $json.url }}","options":{},"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"FDP9FxauzJt9rkjr","name":"WhatsApp"}},"typeVersion":4.2},{"id":"e68bea55-f43a-4143-afca-1348b35e5879","name":"Transcribe Audio","type":"@n8n/n8n-nodes-langchain.openAi","position":[960,-180],"parameters":{"options":{},"resource":"audio","operation":"transcribe"},"credentials":{"openAiApi":{"id":"4zwP0MSr8zkNvvV9","name":"OpenAi account"}},"typeVersion":1.8},{"id":"1c0aa0c3-cee4-40f1-9e13-9365cc06443a","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[160,1440],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"4zwP0MSr8zkNvvV9","name":"OpenAi account"}},"typeVersion":1.2},{"id":"d2215cf8-49e1-433b-b9c3-a219e6432cba","name":"AI Agent1","type":"@n8n/n8n-nodes-langchain.agent","position":[160,1220],"parameters":{"text":"={{ $json.text }}","options":{"systemMessage":"You are an intelligent assistant. Your purpose is to analyze various types of input and provide helpful, accurate responses.\n\nCAPABILITIES:\n- Process and respond to text messages\n- Analyze uploaded files\n- Interpret and describe images\n- Transcribe and understand voice messages\n\nINPUT HANDLING:\n1. For text messages: Analyze the content, understand the intent, and provide a relevant response.\n2. For file analysis: Examine the file content, extract key information, and summarize important points also based on the questions asked.\n3. For image analysis: Describe what you see in the image, identify key elements, and respond to any questions about the image.\n4. For voice messages: Transcribe the audio, understand the message, and respond appropriately.\n\nRESPONSE GUIDELINES:\n- Be concise but thorough\n- Prioritize accuracy over speculation\n- Maintain a professional and helpful tone\n- When uncertain, acknowledge limitations\n- Format responses for easy reading on mobile devices\n- Include actionable information when appropriate\n\nLIMITATIONS:\n- Mention if you're unable to process certain file formats\n- Indicate if an image is unclear or if details are difficult to discern\n- Note if audio quality impacts transcription accuracy\n\nSECURITY & PRIVACY:\n- Do not store or remember sensitive information shared in files, images, or voice notes\n- Do not share personal information across different user interactions\n- Inform users about data privacy limitations when relevant\n\nAnalyze all inputs carefully before responding. Your goal is to provide value through accurate information and helpful assistance."},"promptType":"define"},"typeVersion":1.8},{"id":"103825d0-8521-43c7-8246-9cc1faca42e1","name":"Download File","type":"n8n-nodes-base.httpRequest","position":[720,460],"parameters":{"url":"={{ $json.url }}","options":{},"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"FDP9FxauzJt9rkjr","name":"WhatsApp"}},"typeVersion":4.2},{"id":"98077f98-6dcf-4932-9363-19bf1fdc299e","name":"Extract from File","type":"n8n-nodes-base.extractFromFile","position":[980,460],"parameters":{"options":{},"operation":"pdf"},"typeVersion":1},{"id":"fefc8b87-d64e-4ff9-9f62-1ac3af2bf17e","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[300,1440],"parameters":{"sessionKey":"=memory_{{ $('WhatsApp Trigger').item.json.contacts[0].wa_id }}","sessionIdType":"customKey","contextWindowLength":10},"typeVersion":1.3},{"id":"83ac997d-6ba0-4eb7-bd6c-80671f03c56c","name":"Get File Url","type":"n8n-nodes-base.whatsApp","position":[500,460],"webhookId":"280bd5de-32d7-4d8f-93d2-e91e3b0bc161","parameters":{"resource":"media","operation":"mediaUrlGet","mediaGetId":"={{ $('WhatsApp Trigger').item.json.messages[0].document.id }}"},"credentials":{"whatsAppApi":{"id":"HDUOWQXeRXMVjo0Z","name":"WhatsApp account"}},"typeVersion":1},{"id":"56b23f60-57c3-4ea7-a4e8-64029a2e44c1","name":"Only PDF File","type":"n8n-nodes-base.if","position":[220,480],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"f52d2aaa-e0b2-45e5-8c4b-ceef42182a0d","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.messages[0].document.mime_type }}","rightValue":"application/pdf"}]}},"typeVersion":2.2},{"id":"fa733b7b-16a7-4a9b-86b3-88395535ecd5","name":"Fix mimeType for Audio","type":"n8n-nodes-base.code","position":[1040,1080],"parameters":{"jsCode":"for (const item of $input.all()) {\n  if (item.binary) {\n    const binaryPropertyNames = Object.keys(item.binary);\n    for (const propName of binaryPropertyNames) {\n      if (item.binary[propName].mimeType === 'audio/mp3') {\n        item.binary[propName].mimeType = 'audio/mpeg';\n      }\n    }\n  }\n}\n\nreturn $input.all();"},"typeVersion":2},{"id":"0d99c2fa-945b-487a-b929-742e8b1b6859","name":"Send message","type":"n8n-nodes-base.whatsApp","position":[840,1360],"webhookId":"23834751-5066-48ba-8e19-549680df2b27","parameters":{"textBody":"={{ $json.output }}","operation":"send","phoneNumberId":"470271332838881","additionalFields":{},"recipientPhoneNumber":"={{ $('WhatsApp Trigger').item.json.messages[0].from }}"},"credentials":{"whatsAppApi":{"id":"HDUOWQXeRXMVjo0Z","name":"WhatsApp account"}},"typeVersion":1},{"id":"046328e9-e948-479c-ac42-567877350f1e","name":"Send audio","type":"n8n-nodes-base.whatsApp","position":[1260,1080],"webhookId":"d18b2c98-84e4-43cf-a532-0c47d5161684","parameters":{"mediaPath":"useMedian8n","operation":"send","messageType":"audio","phoneNumberId":"470271332838881","additionalFields":{},"recipientPhoneNumber":"={{ $('Input type').item.json.contacts[0].wa_id }}"},"credentials":{"whatsAppApi":{"id":"HDUOWQXeRXMVjo0Z","name":"WhatsApp account"}},"typeVersion":1},{"id":"aa20a408-42ab-4011-9cea-331e23cda4ce","name":"Incorrect format","type":"n8n-nodes-base.whatsApp","position":[500,700],"webhookId":"23834751-5066-48ba-8e19-549680df2b27","parameters":{"textBody":"=Sorry but you can only send PDF files","operation":"send","phoneNumberId":"470271332838881","additionalFields":{},"recipientPhoneNumber":"={{ $('WhatsApp Trigger').item.json.messages[0].from }}"},"credentials":{"whatsAppApi":{"id":"HDUOWQXeRXMVjo0Z","name":"WhatsApp account"}},"typeVersion":1},{"id":"23b3750d-3638-4fd0-bab8-6082f53f19f9","name":"Text","type":"n8n-nodes-base.set","position":[1240,-520],"parameters":{"options":{},"assignments":{"assignments":[{"id":"c53cd9f9-77c1-4331-98ff-bfc9bdf95a3c","name":"text","type":"string","value":"={{ $('WhatsApp Trigger').item.json.messages[0].text.body }}"}]}},"typeVersion":3.4},{"id":"435c020b-826b-4946-b19e-f9663f4f9f23","name":"Audio","type":"n8n-nodes-base.set","position":[1240,-180],"parameters":{"options":{},"assignments":{"assignments":[{"id":"219577d5-b028-48fc-90be-980f4171ab68","name":"text","type":"string","value":"={{ $json.text }}"}]}},"typeVersion":3.4},{"id":"0139bb33-651e-4f37-901d-ccc705c9833a","name":"Image","type":"n8n-nodes-base.set","position":[1220,120],"parameters":{"options":{},"assignments":{"assignments":[{"id":"67552183-de2e-494a-878e-c2948e8cb6bb","name":"text","type":"string","value":"=User request on the image:\n{{ \"Describe the following image\" || $('WhatsApp Trigger').item.json.messages[0].image.caption }}\n\nImage description:\n{{ $json.content }}"}]}},"typeVersion":3.4},{"id":"d66b7190-f83b-483e-b3f3-8c220e2c815f","name":"File","type":"n8n-nodes-base.set","position":[1240,460],"parameters":{"options":{},"assignments":{"assignments":[{"id":"67552183-de2e-494a-878e-c2948e8cb6bb","name":"text","type":"string","value":"=User request on the file:\n{{ \"Describe this file\" || $('Only PDF File').item.json.messages[0].document.caption }}\n\nFile content:\n{{ $json.text }}"}]}},"typeVersion":3.4},{"id":"20239933-418c-436f-b15b-c293043a0328","name":"Not supported","type":"n8n-nodes-base.whatsApp","position":[-260,360],"webhookId":"23834751-5066-48ba-8e19-549680df2b27","parameters":{"textBody":"=You can only send text messages, images, audio files and PDF documents.","operation":"send","phoneNumberId":"470271332838881","additionalFields":{},"recipientPhoneNumber":"={{ $('WhatsApp Trigger').item.json.messages[0].from }}"},"credentials":{"whatsAppApi":{"id":"HDUOWQXeRXMVjo0Z","name":"WhatsApp account"}},"typeVersion":1},{"id":"117fd705-1f64-4bcc-88db-357df679fa3d","name":"Get Image Url","type":"n8n-nodes-base.whatsApp","position":[480,120],"webhookId":"280bd5de-32d7-4d8f-93d2-e91e3b0bc161","parameters":{"resource":"media","operation":"mediaUrlGet","mediaGetId":"={{ $('WhatsApp Trigger').item.json.messages[0].image.id }}"},"credentials":{"whatsAppApi":{"id":"HDUOWQXeRXMVjo0Z","name":"WhatsApp account"}},"typeVersion":1},{"id":"3bf7364c-6263-4825-aec5-693adaed7d03","name":"Get Audio Url","type":"n8n-nodes-base.whatsApp","position":[460,-180],"webhookId":"87caa300-7204-47b5-959a-94f4a8fbf8cf","parameters":{"resource":"media","operation":"mediaUrlGet","mediaGetId":"={{ $('WhatsApp Trigger').item.json.messages[0].audio.id }}"},"credentials":{"whatsAppApi":{"id":"HDUOWQXeRXMVjo0Z","name":"WhatsApp account"}},"typeVersion":1},{"id":"b23f8467-480a-45c1-a7df-e512290a8e13","name":"Generate Audio Response","type":"@n8n/n8n-nodes-langchain.openAi","position":[840,1080],"parameters":{"input":"={{ $('AI Agent1').item.json.output }}","voice":"onyx","options":{},"resource":"audio"},"credentials":{"openAiApi":{"id":"4zwP0MSr8zkNvvV9","name":"OpenAi account"}},"typeVersion":1.8},{"id":"0b139e60-fbf3-43ae-ae3f-40588f135443","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[120,-560],"parameters":{"width":1340,"height":240,"content":"## Text"},"typeVersion":1},{"id":"3622ad4c-79c7-479f-a050-ff21d3077c77","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[120,-240],"parameters":{"width":1340,"height":240,"content":"## Voice"},"typeVersion":1},{"id":"1f35e179-22d1-4019-a807-21803df51a46","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[120,80],"parameters":{"width":1340,"height":240,"content":"## Image"},"typeVersion":1},{"id":"314b8ae2-e518-44a3-80a5-dc8482ab1fa9","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[120,420],"parameters":{"width":1340,"height":240,"content":"## Document"},"typeVersion":1},{"id":"a55cc899-3490-4b7c-b793-4f20605fc711","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[120,960],"parameters":{"color":5,"width":1340,"height":600,"content":"## Response"},"typeVersion":1},{"id":"f37e975b-c112-4af8-badd-1fdbdb90d2f5","name":"From audio to audio?","type":"n8n-nodes-base.if","position":[580,1220],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"b9d1d759-f585-4791-a743-b9d72951e77c","operator":{"type":"object","operation":"exists","singleValue":true},"leftValue":"={{ $('WhatsApp Trigger').item.json.messages[0].audio }}","rightValue":""}]}},"typeVersion":2.2},{"id":"864be43a-e280-4c6d-bab4-878b88304807","name":"Input type","type":"n8n-nodes-base.switch","position":[-420,40],"parameters":{"rules":{"values":[{"outputKey":"Text","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"08fd0c80-307e-4f45-b1de-35192ee4ec5e","operator":{"type":"string","operation":"exists","singleValue":true},"leftValue":"={{ $json.messages[0].text.body }}","rightValue":""}]},"renameOutput":true},{"outputKey":"Voice","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"b7b64446-f1ea-4622-990c-22f3999a8269","operator":{"type":"object","operation":"exists","singleValue":true},"leftValue":"={{ $json.messages[0].audio }}","rightValue":""}]},"renameOutput":true},{"outputKey":"Image","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"202af928-a324-411a-bf15-68a349e7bf9e","operator":{"type":"object","operation":"exists","singleValue":true},"leftValue":"={{ $json.messages[0].image }}","rightValue":""}]},"renameOutput":true},{"outputKey":"Document","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"c63299e9-6069-4bc6-afb9-7beebf6e3d69","operator":{"type":"object","operation":"exists","singleValue":true},"leftValue":"={{ $json.messages[0].document }}","rightValue":""}]},"renameOutput":true}]},"options":{"fallbackOutput":"extra"}},"typeVersion":3.2},{"id":"cf327372-d2cc-40db-a057-9bfb10d6a520","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-1580,-1140],"parameters":{"color":3,"width":780,"height":2680,"content":"How to obtain Whatsapp API?\n\n\n### ✅ Prerequisites\nBefore you begin, make sure you have:\n- A **Meta Business Account**\n- A **Facebook Developer Account**\n- A **Verified Business**\n- A **Phone Number** to link to WhatsApp\n- Access to **Meta's Graph API Explorer** or **Meta for Developers portal**\n\n---\n\n### 🪜 STEP 1: Create a Meta App\n\n1. Go to [https://developers.facebook.com/apps](https://developers.facebook.com/apps)\n2. Click **“Create App”**\n3. Choose **\"Business\"** as the app type, then click **Next**\n4. Give your app a name and enter a contact email\n5. Choose your Business Account (or create one)\n6. Click **Create App**\n\n---\n\n### 🪜 STEP 2: Add WhatsApp Product\n\n1. In your app dashboard, scroll down to **\"Add a Product\"**\n2. Find **\"WhatsApp\"** and click **“Set Up”**\n3. Link your **Business Manager Account**\n\n---\n\n### 🪜 STEP 3: Create a WhatsApp Business Account (if needed)\n\n1. If you haven’t already, go to [https://business.facebook.com/](https://business.facebook.com/)\n2. Click **“Create Account”**, and complete your business information\n3. Go to **Business Settings > Accounts > WhatsApp Accounts**\n4. Add a **Phone Number** (you'll receive a verification code)\n\n---\n\n### 🪜 STEP 4: Generate a Temporary Access Token (for development)\n\n1. In the **App Dashboard**, go to **WhatsApp > Getting Started**\n2. Choose your test phone number\n3. Copy the **temporary access token** (valid for 24 hours)\n4. Copy the **Phone Number ID** and **WhatsApp Business Account ID**\n\n✅ Save these 3 values:\n- **Access Token**\n- **Phone Number ID**\n- **WABA ID**\n\n📝 Tip: For production, you will later need to create a **permanent token** (see step 7).\n\n---\n\n### 🪜 STEP 5: Set Up a Webhook URL (n8n)\n\n1. In n8n, set up a **Webhook node** (or use the `WhatsApp Trigger` node)\n2. Copy the webhook URL\n3. In the Meta Developer Dashboard:\n   - Go to **WhatsApp > Configuration**\n   - Click **“Edit Callback URL”**\n   - Paste your n8n webhook URL and add a random **verify token**\n4. In n8n, configure your webhook to respond to the verification request\n\n---\n\n### 🪜 STEP 6: Subscribe to Webhook Fields\n\n1. Still under **WhatsApp > Configuration**, click **\"Manage Subscriptions\"**\n2. Enable:\n   - `messages`\n   - `message_status`\n   - (Optionally `message_template_status_update`)\n\n---\n\n### 🪜 STEP 7: (Optional but recommended) Generate a Permanent Token\n\n1. Go to [https://developers.facebook.com/tools/access_token/](https://developers.facebook.com/tools/access_token/)\n2. Select your app\n3. Click **Get Token > System User Token**\n4. Select the permissions:\n   - `whatsapp_business_management`\n   - `whatsapp_business_messaging`\n   - `business_management`\n5. Click **Generate Token**\n6. Copy and securely store this token\n\n---\n\n### 🪜 STEP 8: Configure Credentials in n8n\n\n1. Go to **n8n > Settings > Credentials**\n2. Create new credentials of type **HTTP Header Auth**\n   - **Name:** WhatsApp\n   - **Header Name:** `Authorization`\n   - **Value:** `Bearer <your_access_token>`\n3. Save\n\nThen, in your workflows:\n- Use the HTTP Request node or WhatsApp node\n- Set the `phone_number_id` in the node parameters\n- Connect it to your WhatsApp credential\n\n---\n\n### 🧪 STEP 9: Test the Connection\n\n1. Use a WhatsApp number to send a message to your business phone\n2. Your n8n workflow should be triggered\n3. You can now send and receive messages programmatically 🎉\n"},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"4dfe4c80-3a9a-4292-bcb2-3f68bbea5a3a","connections":{"File":{"main":[[{"node":"AI Agent1","type":"main","index":0}]]},"Text":{"main":[[{"node":"AI Agent1","type":"main","index":0}]]},"Audio":{"main":[[{"node":"AI Agent1","type":"main","index":0}]]},"Image":{"main":[[{"node":"AI Agent1","type":"main","index":0}]]},"AI Agent1":{"main":[[{"node":"From audio to audio?","type":"main","index":0}]]},"Input type":{"main":[[{"node":"Text","type":"main","index":0}],[{"node":"Get Audio Url","type":"main","index":0}],[{"node":"Get Image Url","type":"main","index":0}],[{"node":"Only PDF File","type":"main","index":0}],[{"node":"Not supported","type":"main","index":0}]]},"Get File Url":{"main":[[{"node":"Download File","type":"main","index":0}]]},"Analyze Image":{"main":[[{"node":"Image","type":"main","index":0}]]},"Download File":{"main":[[{"node":"Extract from File","type":"main","index":0}]]},"Get Audio Url":{"main":[[{"node":"Download Audio","type":"main","index":0}]]},"Get Image Url":{"main":[[{"node":"Download Image","type":"main","index":0}]]},"Only PDF File":{"main":[[{"node":"Get File Url","type":"main","index":0}],[{"node":"Incorrect format","type":"main","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"AI Agent1","type":"ai_memory","index":0}]]},"Download Audio":{"main":[[{"node":"Transcribe Audio","type":"main","index":0}]]},"Download Image":{"main":[[{"node":"Analyze Image","type":"main","index":0}]]},"Transcribe Audio":{"main":[[{"node":"Audio","type":"main","index":0}]]},"WhatsApp Trigger":{"main":[[{"node":"Input type","type":"main","index":0}]]},"Extract from File":{"main":[[{"node":"File","type":"main","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"AI Agent1","type":"ai_languageModel","index":0}]]},"From audio to audio?":{"main":[[{"node":"Generate Audio Response","type":"main","index":0}],[{"node":"Send message","type":"main","index":0}]]},"Fix mimeType for Audio":{"main":[[{"node":"Send audio","type":"main","index":0}]]},"Generate Audio Response":{"main":[[{"node":"Fix mimeType for Audio","type":"main","index":0}]]}}}


name: Extract Business Leads from Google Maps with Dumpling AI to Google Sheets
author_name: Yang
author_username: yang
nodes_used: ["n8n-nodes-base.googleSheets","n8n-nodes-base.httpRequest"]
categories: []
created_at: 2025-04-17T20:51:09.545Z
updated_at: 2025-04-17T20:51:09.545Z
url: https://n8n.io/workflows/3593
scraped_at: 2025-06-19 22:49:44
description:
  Who is this for?

  This workflow is built for marketers, sales teams, agencies, virtual assistants, and anyone who regularly researches or contacts local businesses. It's ideal for building lead lists, tracking competitors, or creating location-specific outreach campaigns.

  What problem is this workflow solving?

  Instead of manually searching Google Maps and copying business info into spreadsheets, this automation pulls structured business data (e.g. restaurants, gyms, service providers) and logs it directly into Google Sheets. It saves hours of work and ensures cleaner, more usable data.

  What this workflow does

  The workflow takes a Google Maps search query (like "best restaurants in New York") and sends it to Dumpling AI. It returns a list of places including their name, address, website, phone number, rating, and more. Each result is split into a row and automatically added to a Google Sheet.

  Setup

  Dumpling AI  
     Sign up at Dumpling AI  
     Generate your API key  
     In the HTTP Request node, select Header Auth and paste your key in the Authorization field

  Google Sheets  
     Create a sheet with tab name Leads  
     Add the following column headers to row 1:  
       Name, Address, Phone number, Website, Rating, Price Level, Type, Booking Link, Position  
     Connect your Google Sheets account and link this sheet in the node

  Customize the Query  
     In the HTTP node, replace the query string (e.g., "best+restaurants+in+New+York") with your own search term

  Run It  
     Use the manual trigger to test  
     Optionally swap in a Schedule or Webhook node to run it automatically

  How to customize this workflow to your needs

  Change the search query to target different cities or business types  
  Use filters to only save leads with a minimum rating or price level  
  Add GPT to summarize listings or qualify leads  
  Swap Google Sheets for Airtable or a CRM system for deeper integration

workflow_json:
  {"id":"YZpFvpXOTYkBpiUU","meta":{"instanceId":"a1ae5c8dc6c65e674f9c3947d083abcc749ef2546dff9f4ff01de4d6a36ebfe6"},"name":"Extract Business Leads from Google Maps with Dumpling AI to Google Sheets","tags":[{"id":"TlcNkmb96fUfZ2eA","name":"Tutorials","createdAt":"2025-04-15T17:02:00.249Z","updatedAt":"2025-04-15T17:02:00.249Z"}],"nodes":[{"id":"3a49e594-6c62-4128-825e-99cdfd7e6ed5","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-660,-200],"parameters":{"width":600,"height":700,"content":"#### 🔍 Workflow Goal\nAutomatically search Google Maps using Dumpling AI based on a keyword (e.g., best restaurants in New York), extract results, and log them into a structured Google Sheet.\n\n## 🚀 Workflow Steps\n1. **Manual Trigger**\n   - Starts the workflow when testing manually.\n\n2. **Dumpling AI Google Search**\n   - Sends a POST request to Dumpling AI to search for locations on Google Maps based on your query.\n\n3. **Split Out Node**\n   - Breaks the `places[]` array into individual items so each result can be handled separately.\n\n4. **Google Sheets Node**\n   - Appends each place’s data (name, address, phone, website, rating, etc.) into a specific tab of your Google Sheets.\n\n##### 🧠 Notes\n- The search query is currently set to: `\"best+restaurants+in+New+York\"`\n- Output columns include rating, price level, website, phone, booking links, etc.\n- Each run consumes Dumpling AI credits per query.\n- You can customize search keywords or location in the HTTP Request body.\n\n#### ✅ Tip\nTo automate this regularly, change the trigger node to a **Schedule Trigger** and add dynamic query input using a **Set** or **Webhook** node.\n\n"},"typeVersion":1},{"id":"0a4ee00a-19cf-4d1e-a145-b5c5619ce636","name":"Trigger: Manual Test Run","type":"n8n-nodes-base.manualTrigger","position":[0,120],"parameters":{},"typeVersion":1},{"id":"26fdb640-93a0-4312-beaf-4c07fff87751","name":"Search Google Maps via Dumpling AI","type":"n8n-nodes-base.httpRequest","position":[220,120],"parameters":{"url":"https://app.dumplingai.com/api/v1/search-maps","method":"POST","options":{},"jsonBody":"={\n  \"query\": \"best+restaurants+in+New+York\", \n  \"language\": \"en\"\n}","sendBody":true,"specifyBody":"json","authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"xamyMqCpAech5BeT","name":"Header Auth account"}},"typeVersion":4.2},{"id":"d3fafc2c-0b9d-4e83-83aa-de24d11fc0e1","name":"Split Places List for Processing","type":"n8n-nodes-base.splitOut","position":[440,120],"parameters":{"options":{},"fieldToSplitOut":"places"},"typeVersion":1},{"id":"83b48532-b1fb-4ab3-9596-6e96526bfd49","name":"Save Results to Google Sheet (Place Info)","type":"n8n-nodes-base.googleSheets","position":[660,120],"parameters":{"columns":{"value":{"type":"={{ $json.type }}","Name ":"={{ $json.title }}","rating":"={{ $json.rating }}","Address":"={{ $json.address }}","Website":"={{ $json.website }}","Position":"={{ $json.position }}","priceLevel":"={{ $json.priceLevel }}","Booking Link":"={{ $json.bookingLinks[0] }}","Phone number":"={{ $json.phoneNumber }}"},"schema":[{"id":"Name ","type":"string","display":true,"required":false,"displayName":"Name ","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Address","type":"string","display":true,"required":false,"displayName":"Address","defaultMatch":false,"canBeUsedToMatch":true},{"id":"rating","type":"string","display":true,"required":false,"displayName":"rating","defaultMatch":false,"canBeUsedToMatch":true},{"id":"priceLevel","type":"string","display":true,"required":false,"displayName":"priceLevel","defaultMatch":false,"canBeUsedToMatch":true},{"id":"type","type":"string","display":true,"required":false,"displayName":"type","defaultMatch":false,"canBeUsedToMatch":true},{"id":"I use an HTTP request in n8n, I returned up to 10","type":"string","display":true,"removed":false,"required":false,"displayName":"I use an HTTP request in n8n, I returned up to 10","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Booking Link","type":"string","display":true,"required":false,"displayName":"Booking Link","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Website","type":"string","display":true,"removed":false,"required":false,"displayName":"Website","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Phone number","type":"string","display":true,"removed":false,"required":false,"displayName":"Phone number","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Position","type":"string","display":true,"removed":false,"required":false,"displayName":"Position","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"list","value":"","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1pb4WLqv2EruLM1z9-utehcINolSj0vlUqZionyLoRUs/edit#gid=1069765279","cachedResultName":"Google Maps"},"documentId":{"__rl":true,"mode":"list","value":"","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1pb4WLqv2EruLM1z9-utehcINolSj0vlUqZionyLoRUs/edit?usp=drivesdk","cachedResultName":"Places"}},"credentials":{"googleSheetsOAuth2Api":{"id":"GaJqJHuS5mQxap7q","name":"Google Sheets account"}},"typeVersion":4.5}],"active":false,"pinData":{"Search Google Maps via Dumpling AI":[{"json":{"ll":"@40.7381076,-73.9928178,13z","places":[{"cid":"14366891226444778354","fid":"0x89c25993862d9fab:0xc76173738eeacb72","type":"French restaurant","title":"Boucherie West Village","types":["French restaurant"],"rating":4.7,"address":"99 7th Ave S, New York, NY 10014","placeId":"ChIJq58thpNZwokRcsvqjnNzYcc","website":"https://www.boucherieus.com/","latitude":40.733047,"position":1,"longitude":-74.0028772,"priceLevel":"$50–100","description":"Two-floor bistro serving dry-aged steaks and other French fare, with a bar that's strong on absinthe.","phoneNumber":"(212) 837-1616","ratingCount":6138,"bookingLinks":["https://www.opentable.com/restaurant/profile/346609?ref=1068","https://www.google.com/maps/reserve/v/dine/c/ECNC2O-BTkI?source=pa&opi=79508299"],"openingHours":{"Friday":"11 AM–12 AM","Monday":"11 AM–12 AM","Sunday":"10 AM–12 AM","Tuesday":"11 AM–12 AM","Saturday":"10 AM–12 AM","Thursday":"11 AM–12 AM","Wednesday":"11 AM–12 AM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipOIjrjzX_gCxhEnqpn_1KwaVrrTIdgTOZv9FrJY"},{"cid":"13799948123386944265","fid":"0x89c259892cccb7b7:0xbf8343b3f54c1b09","type":"French restaurant","title":"Balthazar","types":["French restaurant","Bakery","Seafood restaurant"],"rating":4.4,"address":"80 Spring St, New York, NY 10012","placeId":"ChIJt7fMLIlZwokRCRtM9bNDg78","website":"http://www.balthazarny.com/","latitude":40.722668,"position":2,"longitude":-73.99822979999999,"priceLevel":"$50–100","description":"Iconic French brasserie with steak frites, brunch & pastries in a classy space with red banquettes.","phoneNumber":"(212) 965-1414","ratingCount":7020,"bookingLinks":["https://resy.com/cities/new-york-ny/venues/balthazar-nyc?rwg_token=AAiGsoaFc5Wv1TTL-PUVXIuvsKOdGTH7uz27wICtr-QZZbjYmtOgFXVt1boLwB31S7tdch1sPVym_QaoNS3VfiwZhmQrQOLWbA%3D%3D"],"openingHours":{"Friday":"8 AM–12 AM","Monday":"8 AM–12 AM","Sunday":"9 AM–12 AM","Tuesday":"8 AM–12 AM","Saturday":"9 AM–12 AM","Thursday":"8 AM–12 AM","Wednesday":"8 AM–12 AM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipMPYp_acWrBa6fa2F0TsosyYI-wDt_rL9wFVcvC"},{"cid":"3132777853886366741","fid":"0x89c259a1820824bd:0x2b79dcdc251b8415","type":"Restaurant","title":"Gramercy Tavern","types":["Restaurant","American restaurant","Bar","Fine dining restaurant","Lunch restaurant","New American restaurant"],"rating":4.6,"address":"42 E 20th St, New York, NY 10003","placeId":"ChIJvSQIgqFZwokRFYQbJdzceSs","website":"http://www.gramercytavern.com/?utm_source=GoogleBusinessProfile&utm_medium=Website&utm_campaign=MapLabs","latitude":40.7384555,"position":3,"longitude":-73.98850639999999,"priceLevel":"$100+","description":"Danny Meyer's Flatiron District tavern with a fixed-price-only dining room & a bustling bar area.","phoneNumber":"(212) 477-0777","ratingCount":4319,"openingHours":{"Friday":"11:30 AM–10:30 PM","Monday":"11:30 AM–10:30 PM","Sunday":"11:30 AM–10:30 PM","Tuesday":"11:30 AM–10:30 PM","Saturday":"11:30 AM–10:30 PM","Thursday":"11:30 AM–10:30 PM","Wednesday":"11:30 AM–10:30 PM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipP-6Q-5hmlzRWjc4E5FDa7K2OeNqJS3BxQMp_ln"},{"cid":"7298340055988969067","fid":"0x89c25947ea10b457:0x6548e99cd73a1e6b","type":"French restaurant","title":"Le Bernardin","types":["French restaurant","Fine dining restaurant","Restaurant"],"rating":4.6,"address":"155 W 51st St, New York, NY 10019","placeId":"ChIJV7QQ6kdZwokRax4615zpSGU","website":"https://www.le-bernardin.com/home","latitude":40.7614218,"position":4,"longitude":-73.9817558,"priceLevel":"$100+","description":"Elite French restaurant offers chef Eric Ripert's refined seafood, expert service & luxurious decor.","phoneNumber":"(212) 554-1515","ratingCount":3762,"openingHours":{"Friday":"12–2:30 PM, 5–11 PM","Monday":"12–2:30 PM, 5–10:30 PM","Sunday":"Closed","Tuesday":"12–2:30 PM, 5–10:30 PM","Saturday":"5–11 PM","Thursday":"12–2:30 PM, 5–10:30 PM","Wednesday":"12–2:30 PM, 5–10:30 PM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipMC-dJ9gfcpFIX8PS-8yPYhjCMfjl6q35zAn1t8"},{"cid":"3442553861032018645","fid":"0x89c259a1ec5f5573:0x2fc6687f46f682d5","type":"French restaurant","title":"Boucherie Union Square","types":["French restaurant","Steak house"],"rating":4.7,"address":"225 Park Ave S, New York, NY 10003","placeId":"ChIJc1Vf7KFZwokR1YL2Rn9oxi8","website":"https://www.boucherieus.com/","latitude":40.7372552,"position":5,"longitude":-73.9882246,"priceLevel":"$50–100","description":"Bistro for dry-aged steaks and other French fare, with a bar that's strong on absinthe.","phoneNumber":"(212) 353-0200","ratingCount":3890,"bookingLinks":["https://www.opentable.com/restaurant/profile/1004143?ref=1068","https://www.google.com/maps/reserve/v/dine/c/4rmpVcuKUVY?source=pa&opi=79508299"],"openingHours":{"Friday":"11 AM–12 AM","Monday":"11 AM–12 AM","Sunday":"11 AM–12 AM","Tuesday":"11 AM–12 AM","Saturday":"11 AM–12 AM","Thursday":"11 AM–12 AM","Wednesday":"11 AM–12 AM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipOa4JTlKpkY1_xlxnfahmd6H2FquTfCHzJJWto7"},{"cid":"5472139628830047106","fid":"0x89c2598c596508a3:0x4bf0f1fff1c0bb82","type":"Italian restaurant","title":"Piccola Cucina Osteria Siciliana","types":["Italian restaurant","Sicilian restaurant"],"rating":4.6,"address":"196 Spring St, New York, NY 10012","placeId":"ChIJowhlWYxZwokRgrvA8f_x8Es","website":"http://www.piccolacucinagroup.com/","latitude":40.7250308,"position":6,"longitude":-74.0032774,"priceLevel":"$30–50","description":"Simple Italian outpost serving salads & homestyle pastas along with an extensive wine list.","phoneNumber":"(646) 478-7488","ratingCount":2199,"bookingLinks":["https://www.opentable.com/restaurant/profile/105838?ref=1068","https://www.google.com/maps/reserve/v/dine/c/Psao8Sv98GA?source=pa&opi=79508299"],"openingHours":{"Friday":"11:30 AM–11 PM","Monday":"11:30 AM–11 PM","Sunday":"11:30 AM–11 PM","Tuesday":"11:30 AM–11 PM","Saturday":"11:30 AM–11 PM","Thursday":"11:30 AM–11 PM","Wednesday":"11:30 AM–11 PM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipMk3ppXOP_aW2Yrb-krDInf1tjUY6K8adRhg5XT"},{"cid":"12751425680490052044","fid":"0x89c258fbc4a06f31:0xb0f62a18b16739cc","type":"Restaurant","title":"The Modern","types":["Restaurant","American restaurant","Fine dining restaurant","French restaurant","Lunch restaurant","New American restaurant"],"rating":4.6,"address":"9 W 53rd St, New York, NY 10019","placeId":"ChIJMW-gxPtYwokRzDlnsRgq9rA","website":"https://www.themodernnyc.com/?utm_source=GoogleBusinessProfile&utm_medium=Website&utm_campaign=MapLabs","latitude":40.761081,"position":7,"longitude":-73.976753,"priceLevel":"$100+","description":"French/New American fare in a modernist space with garden views at the Museum of Modern Art.","phoneNumber":"(212) 333-1220","ratingCount":2477,"bookingLinks":["https://resy.com/cities/new-york-ny/venues/the-modern?rwg_token=AAiGsobdabLYAQWI0wKR3bXQzJR2xZTshjVp3Uxere391AzDkVal9-Ur8wUduvr_d8bjXUYgsQ2UBTV3fUaQ4cK8AL4sIDHf9g%3D%3D","https://www.google.com/maps/reserve/v/dine/c/IqhMF1j7prg?source=pa&opi=79508299"],"openingHours":{"Friday":"12–2 PM, 5–9 PM","Monday":"12–2 PM, 5:30–9 PM","Sunday":"12–2 PM","Tuesday":"12–2 PM, 5:30–9 PM","Saturday":"12–2 PM, 5–9 PM","Thursday":"12–2 PM, 5:30–9 PM","Wednesday":"12–2 PM, 5:30–9 PM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipPFegcqnHSeW_Ngyd9kDff_bofmJx6cA0Woh95o"},{"cid":"12769026215543562150","fid":"0x89c259941967edc9:0xb134b1b0991fdfa6","type":"French restaurant","title":"Petite Boucherie","types":["French restaurant"],"rating":4.7,"address":"First Floor, 14 Christopher St, New York, NY 10014","placeId":"ChIJye1nGZRZwokRpt8fmbCxNLE","website":"https://www.boucherieus.com/","latitude":40.733870599999996,"position":8,"longitude":-74.0004319,"priceLevel":"$50–100","description":"Parisian-style cafe serving comforting French fare in a snug space with an open kitchen.","phoneNumber":"(646) 756-4145","ratingCount":1787,"bookingLinks":["https://www.opentable.com/restaurant/profile/157048?ref=1068","https://www.google.com/maps/reserve/v/dine/c/E_LrlO_LqlY?source=pa&opi=79508299"],"openingHours":{"Friday":"11 AM–12 AM","Monday":"11 AM–12 AM","Sunday":"10 AM–12 AM","Tuesday":"11 AM–12 AM","Saturday":"10 AM–12 AM","Thursday":"11 AM–12 AM","Wednesday":"11 AM–12 AM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipO9zp1up2rYreJpE-GCYOSwGAiFxyl_iQO2No91"},{"cid":"6967162704871465124","fid":"0x89c25bc797d635a1:0x60b055910436a0a4","type":"Restaurant","title":"Manhatta","types":["Restaurant","Bar","Cocktail bar","Event venue","Fine dining restaurant","New American restaurant","Wine bar"],"rating":4.7,"address":"28 Liberty St 60th floor, New York, NY 10005","placeId":"ChIJoTXWl8dbwokRpKA2BJFVsGA","website":"https://www.manhattarestaurant.com/?utm_source=GoogleBusinessProfile&utm_medium=Website&utm_campaign=MapLabs","latitude":40.707997399999996,"position":9,"longitude":-74.00888259999999,"priceLevel":"$100+","description":"Set on the 60th floor, this ritzy, high-end restaurant features New American cuisine and city views.","phoneNumber":"(212) 230-5788","ratingCount":2764,"bookingLinks":["https://www.google.com/maps/reserve/v/dine/c/pyjjUZqJ9lQ?source=pa&opi=79508299"],"openingHours":{"Friday":"11:30 AM–10:30 PM","Monday":"11:30 AM–9:30 PM","Sunday":"11:30 AM–9:30 PM","Tuesday":"11:30 AM–9:30 PM","Saturday":"11:30 AM–10:30 PM","Thursday":"11:30 AM–9:30 PM","Wednesday":"11:30 AM–9:30 PM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipObmWt-zmje4apfGS8o6xO7AQ2Y38KE_0Nzlo3L"},{"cid":"8813431814842646952","fid":"0x89c25986daaa7ce7:0x7a4f998a3fd281a8","type":"American restaurant","title":"Russ & Daughters Cafe","types":["American restaurant","Breakfast restaurant","Brunch restaurant","Jewish restaurant","Lunch restaurant","Restaurant"],"rating":4.6,"address":"127 Orchard St, New York, NY 10002","placeId":"ChIJ53yq2oZZwokRqIHSP4qZT3o","website":"https://russanddaughterscafe.com/","latitude":40.7196181,"position":10,"longitude":-73.9895779,"priceLevel":"$20–30","description":"From a legendary appetizing shop comes this retro, full-service outpost serving Jewish comfort food.","phoneNumber":"(212) 475-4881","ratingCount":3319,"openingHours":{"Friday":"8:30 AM–3:30 PM","Monday":"8:30 AM–2:30 PM","Sunday":"8:30 AM–3:30 PM","Tuesday":"8:30 AM–2:30 PM","Saturday":"8:30 AM–3:30 PM","Thursday":"8:30 AM–2:30 PM","Wednesday":"8:30 AM–2:30 PM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipPCCdN4u4VxmoNVS3aFIXzgR3lvU2XOcmHf_our"},{"cid":"2975234135803511093","fid":"0x89c25996bd0915fd:0x294a27aedc2f4135","type":"Italian restaurant","title":"OLIO E PIÙ","types":["Italian restaurant","Restaurant"],"rating":4.7,"address":"3 Greenwich Ave, New York, NY 10014","placeId":"ChIJ_RUJvZZZwokRNUEv3K4nSik","website":"https://www.olioepiu.com/","latitude":40.7338208,"position":11,"longitude":-73.99979309999999,"priceLevel":"$50–100","description":"Naples meets NYC at this trattoria with thin-crust pizza, Italian wines & ample sidewalk seating.","phoneNumber":"(212) 243-6546","ratingCount":8301,"bookingLinks":["https://www.opentable.com/restaurant/profile/55837?ref=1068","https://www.google.com/maps/reserve/v/dine/c/2Ujk-qKjG0Y?source=pa&opi=79508299"],"openingHours":{"Friday":"11 AM–12 AM","Monday":"11 AM–12 AM","Sunday":"10 AM–12 AM","Tuesday":"11 AM–12 AM","Saturday":"10 AM–12 AM","Thursday":"11 AM–12 AM","Wednesday":"11 AM–12 AM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipNdy8VOWBkFpkuFzY4WdZ0v7TRcquFXviC1hFyW"},{"cid":"5618924015427954654","fid":"0x89c2585492286ae9:0x4dfa6d9f277ea7de","type":"Taco restaurant","title":"LOS TACOS No.1","types":["Taco restaurant","Mexican restaurant"],"rating":4.8,"address":"229 W 43rd St, New York, NY 10036","placeId":"ChIJ6WooklRYwokR3qd-J59t-k0","website":"http://www.lostacos1.com/","latitude":40.757321399999995,"position":12,"longitude":-73.98765399999999,"priceLevel":"$10–20","description":"Small pit stop with standing tables serving authentic Mexican street food.","ratingCount":12659,"openingHours":{"Friday":"11 AM–11 PM","Monday":"11 AM–11 PM","Sunday":"11 AM–9 PM","Tuesday":"11 AM–11 PM","Saturday":"11 AM–11 PM","Thursday":"11 AM–11 PM","Wednesday":"11 AM–11 PM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipPaLR3wTNi8SIIqvDFYGFJ-nG_sAiR6sZCOFqOZ"},{"cid":"16472713729583313083","fid":"0x89c259937f4eb1af:0xe49ad5dc628370bb","type":"Italian restaurant","title":"Via Carota","types":["Italian restaurant"],"rating":4.4,"address":"51 Grove St, New York, NY 10014","placeId":"ChIJr7FOf5NZwokRu3CDYtzVmuQ","website":"http://viacarota.com/","latitude":40.7331437,"position":13,"longitude":-74.0036671,"priceLevel":"$50–100","description":"Italian trattoria serving traditional plates & apéritifs in a rustic, cozy space.","phoneNumber":"(212) 255-1962","ratingCount":2842,"openingHours":{"Friday":"10 AM–11 PM","Monday":"11 AM–11 PM","Sunday":"10 AM–11 PM","Tuesday":"11 AM–11 PM","Saturday":"10 AM–11 PM","Thursday":"11 AM–11 PM","Wednesday":"11 AM–11 PM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipOpMXlOGFvZovcoxb-XjqCV2kdYQHODTlpUbc8I"},{"cid":"9312603855358623759","fid":"0x89c259f337272b95:0x813d03ddbc95800f","type":"American restaurant","title":"RH Rooftop Restaurant at RH New York","types":["American restaurant","Restaurant"],"rating":4.4,"address":"9 9th Ave, New York, NY 10014","placeId":"ChIJlSsnN_NZwokRD4CVvN0DPYE","website":"http://www.rh.com/newyork/restaurant","latitude":40.73985,"position":14,"longitude":-74.00639,"priceLevel":"$50–100","description":"Glamorous rooftop restaurant offering American fare amid chandeliers, greenery, and skyline views.","phoneNumber":"(212) 217-2210","ratingCount":2176,"bookingLinks":["https://www.opentable.com/restaurant/profile/1050247?ref=1068","https://www.google.com/maps/reserve/v/dine/c/YEEToh7bBlo?source=pa&opi=79508299"],"openingHours":{"Friday":"11:30 AM–9 PM","Monday":"11:30 AM–9 PM","Sunday":"10 AM–9 PM","Tuesday":"11:30 AM–9 PM","Saturday":"10 AM–9 PM","Thursday":"11:30 AM–9 PM","Wednesday":"11:30 AM–9 PM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipNrIo_odwUa7D5xnOrEfdeOq7vGMprNLMPnyOhT"},{"cid":"18303949408079626176","fid":"0x89c25b5ac3fc353f:0xfe04b102174ebfc0","type":"Taco restaurant","title":"LOS TACOS No.1","types":["Taco restaurant","Restaurant"],"rating":4.7,"address":"75 9th Ave, New York, NY 10011","placeId":"ChIJPzX8w1pbwokRwL9OFwKxBP4","website":"https://www.lostacos1.com/","latitude":40.742252099999995,"position":15,"longitude":-74.0059635,"priceLevel":"$10–20","description":"Bustling taqueria serving tacos, quesadillas & aguas frescas in a street-style setup (no seating).","ratingCount":4772,"openingHours":{"Friday":"11 AM–10 PM","Monday":"11 AM–10 PM","Sunday":"11 AM–9 PM","Tuesday":"11 AM–10 PM","Saturday":"11 AM–10 PM","Thursday":"11 AM–10 PM","Wednesday":"11 AM–10 PM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipPqkAkh_eP9f-WUBiRoN-_nlyKVWCSTUp-47dpu"},{"cid":"1412917795118885020","fid":"0x89c2598c5dde0695:0x139bb13faae3a89c","type":"Italian restaurant","title":"Piccola Cucina Estiatorio","types":["Italian restaurant","Seafood market"],"rating":4.7,"address":"75 Thompson St, New York, NY 10012","placeId":"ChIJlQbeXYxZwokRnKjjqj-xmxM","website":"http://www.piccolacucinagroup.com/","latitude":40.7246336,"position":16,"longitude":-74.00297619999999,"priceLevel":"$30–50","phoneNumber":"(646) 781-9183","ratingCount":1660,"bookingLinks":["https://www.opentable.com/restaurant/profile/343939?ref=1068","https://www.google.com/maps/reserve/v/dine/c/pcvDAa-RKIU?source=pa&opi=79508299"],"openingHours":{"Friday":"11:30 AM–12 AM","Monday":"11:30 AM–11 PM","Sunday":"11:30 AM–11 PM","Tuesday":"11:30 AM–11 PM","Saturday":"11:30 AM–12 AM","Thursday":"11:30 AM–11 PM","Wednesday":"11:30 AM–11 PM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipNoIV4fOazNCv4q04hA-CLCxMmuV9q3-ua81HR8"},{"cid":"6783566240304368229","fid":"0x89c258f62fec73a7:0x5e24118dffac8a65","type":"Fine dining restaurant","title":"Per Se","types":["Fine dining restaurant","French restaurant"],"rating":4.5,"address":"10 Columbus Cir, New York, NY 10019","placeId":"ChIJp3PsL_ZYwokRZYqs_40RJF4","website":"https://www.thomaskeller.com/perseny","latitude":40.768217799999995,"position":17,"longitude":-73.9828988,"priceLevel":"$100+","description":"Chef Thomas Keller's New American restaurant offers luxe fixed-price menus, with Central Park views.","phoneNumber":"(212) 823-9335","ratingCount":1863,"openingHours":{"Friday":"4:30–8:30 PM","Monday":"4:30–8:30 PM","Sunday":"4:30–8:30 PM","Tuesday":"4:30–8:30 PM","Saturday":"4:30–8:30 PM","Thursday":"4:30–8:30 PM","Wednesday":"4:30–8:30 PM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipO7nQNiCyD5Fw4CUQ17RSfRfjX-pDQkD26wXJHy"},{"cid":"3538632692129109557","fid":"0x89c258f6339d1b6f:0x311bbfaf5cf09635","type":"American restaurant","title":"ROBERT","types":["American restaurant"],"rating":4.5,"address":"2 Columbus Cir, New York, NY 10019","placeId":"ChIJbxudM_ZYwokRNZbwXK-_GzE","website":"https://robertnyc.com/","latitude":40.767438,"position":18,"longitude":-73.9819871,"priceLevel":"$$$","description":"New American fare & city views in an arty space on the top-floor of the Museum of Arts & Design.","phoneNumber":"(212) 299-7730","ratingCount":1719,"bookingLinks":["https://www.opentable.com/r/robert-new-york"],"openingHours":{"Friday":"12–11 PM","Monday":"12–10 PM","Sunday":"11 AM–11 PM","Tuesday":"12–10 PM","Saturday":"11 AM–11 PM","Thursday":"12–10 PM","Wednesday":"12–10 PM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipMn17D7rwlR14fK8bCmgxV_UqzsK4fBzNP6fFaw"},{"cid":"3545819340560108778","fid":"0x89c2598f7ff4aa09:0x313547e757cb8cea","type":"Restaurant","title":"Katz's Delicatessen","types":["Restaurant","American restaurant","Jewish restaurant","Deli","Sandwich shop"],"rating":4.5,"address":"205 E Houston St, New York, NY 10002","placeId":"ChIJCar0f49ZwokR6ozLV-dHNTE","website":"https://katzsdelicatessen.com/","latitude":40.722232999999996,"position":19,"longitude":-73.98742899999999,"priceLevel":"$20–30","description":"No-frills deli with theatrically cranky service serving mile-high sandwiches since 1888.","phoneNumber":"(212) 254-2246","ratingCount":44962,"openingHours":{"Friday":"8 AM–11:30 PM","Monday":"8 AM–11 PM","Sunday":"12 AM–11 PM","Tuesday":"8 AM–11 PM","Saturday":"Open 24 hours","Thursday":"8 AM–11 PM","Wednesday":"8 AM–11 PM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipNedb29MPPEqzCoheQ79l26VPnn6dcTGtcvF4w7"},{"cid":"1614607817747620329","fid":"0x89c25a1f689722d3:0x16683d41746a61e9","type":"Cajun restaurant","title":"1803 NYC","types":["Cajun restaurant","Bar","Brunch restaurant","Creole restaurant","Event venue","Live music venue","Lunch restaurant","Restaurant","Seafood restaurant","Soul food restaurant"],"rating":4.5,"address":"82 Reade St, New York, NY 10007","placeId":"ChIJ0yKXaB9awokR6WFqdEE9aBY","website":"https://1803nyc.com/","latitude":40.7154539,"position":20,"longitude":-74.00733009999999,"priceLevel":"$30–50","description":"Elevated Cajun-Creole food and drinks served in a New Orleans's French quarters-inspired restaurant.","phoneNumber":"(212) 267-3000","ratingCount":1791,"bookingLinks":["https://1803nyc.com/#reservation","https://resy.com/cities/new-york-ny/venues/1803?rwg_token=AAiGsoZQZUVMZ4dhDz6Sg9qsvG6tjLIhQZvXBSU9opEklGTc20X2Oby6LmmRgAp1IrhjAUd79G_k3s0VP3tEuEu5J_T1DCCazwmMhQpGVRyVaiJWH8RBrM0%3D","https://www.google.com/maps/reserve/v/dine/c/knKVX6xdexM?source=pa&opi=79508299"],"openingHours":{"Friday":"11:30 AM–11 PM","Monday":"11:30 AM–11 PM","Sunday":"11 AM–11 PM","Tuesday":"11:30 AM–11 PM","Saturday":"11 AM–12 AM","Thursday":"11:30 AM–11 PM","Wednesday":"11:30 AM–11 PM"},"thumbnailUrl":"https://lh3.googleusercontent.com/p/AF1QipMD6CTvhAgGtyrqyIkqwTB_iiJh1FKAdDcV_XKA"}],"credits":3,"searchParameters":{"q":"best+restaurants+in+New+York","hl":"en","type":"maps","engine":"google"}}}],"Save Results to Google Sheet (Place Info)":[{"json":{"type":"French restaurant","Name ":"Boucherie West Village","rating":4.7,"Address":"99 7th Ave S, New York, NY 10014","Website":"https://www.boucherieus.com/","Position":1,"priceLevel":"$50–100","Description":"Two-floor bistro serving dry-aged steaks and other French fare, with a bar that's strong on absinthe.","Booking Link":"https://www.opentable.com/restaurant/profile/346609?ref=1068","Phone number":"(212) 837-1616"}},{"json":{"type":"French restaurant","Name ":"Balthazar","rating":4.4,"Address":"80 Spring St, New York, NY 10012","Website":"http://www.balthazarny.com/","Position":2,"priceLevel":"$50–100","Description":"Iconic French brasserie with steak frites, brunch & pastries in a classy space with red banquettes.","Booking Link":"https://resy.com/cities/new-york-ny/venues/balthazar-nyc?rwg_token=AAiGsoaFc5Wv1TTL-PUVXIuvsKOdGTH7uz27wICtr-QZZbjYmtOgFXVt1boLwB31S7tdch1sPVym_QaoNS3VfiwZhmQrQOLWbA%3D%3D","Phone number":"(212) 965-1414"}},{"json":{"type":"Restaurant","Name ":"Gramercy Tavern","rating":4.6,"Address":"42 E 20th St, New York, NY 10003","Website":"http://www.gramercytavern.com/?utm_source=GoogleBusinessProfile&utm_medium=Website&utm_campaign=MapLabs","Position":3,"priceLevel":"$100+","Description":"Danny Meyer's Flatiron District tavern with a fixed-price-only dining room & a bustling bar area.","Phone number":"(212) 477-0777"}},{"json":{"type":"French restaurant","Name ":"Le Bernardin","rating":4.6,"Address":"155 W 51st St, New York, NY 10019","Website":"https://www.le-bernardin.com/home","Position":4,"priceLevel":"$100+","Description":"Elite French restaurant offers chef Eric Ripert's refined seafood, expert service & luxurious decor.","Phone number":"(212) 554-1515"}},{"json":{"type":"French restaurant","Name ":"Boucherie Union Square","rating":4.7,"Address":"225 Park Ave S, New York, NY 10003","Website":"https://www.boucherieus.com/","Position":5,"priceLevel":"$50–100","Description":"Bistro for dry-aged steaks and other French fare, with a bar that's strong on absinthe.","Booking Link":"https://www.opentable.com/restaurant/profile/1004143?ref=1068","Phone number":"(212) 353-0200"}},{"json":{"type":"Italian restaurant","Name ":"Piccola Cucina Osteria Siciliana","rating":4.6,"Address":"196 Spring St, New York, NY 10012","Website":"http://www.piccolacucinagroup.com/","Position":6,"priceLevel":"$30–50","Description":"Simple Italian outpost serving salads & homestyle pastas along with an extensive wine list.","Booking Link":"https://www.opentable.com/restaurant/profile/105838?ref=1068","Phone number":"(646) 478-7488"}},{"json":{"type":"Restaurant","Name ":"The Modern","rating":4.6,"Address":"9 W 53rd St, New York, NY 10019","Website":"https://www.themodernnyc.com/?utm_source=GoogleBusinessProfile&utm_medium=Website&utm_campaign=MapLabs","Position":7,"priceLevel":"$100+","Description":"French/New American fare in a modernist space with garden views at the Museum of Modern Art.","Booking Link":"https://resy.com/cities/new-york-ny/venues/the-modern?rwg_token=AAiGsobdabLYAQWI0wKR3bXQzJR2xZTshjVp3Uxere391AzDkVal9-Ur8wUduvr_d8bjXUYgsQ2UBTV3fUaQ4cK8AL4sIDHf9g%3D%3D","Phone number":"(212) 333-1220"}},{"json":{"type":"French restaurant","Name ":"Petite Boucherie","rating":4.7,"Address":"First Floor, 14 Christopher St, New York, NY 10014","Website":"https://www.boucherieus.com/","Position":8,"priceLevel":"$50–100","Description":"Parisian-style cafe serving comforting French fare in a snug space with an open kitchen.","Booking Link":"https://www.opentable.com/restaurant/profile/157048?ref=1068","Phone number":"(646) 756-4145"}},{"json":{"type":"Restaurant","Name ":"Manhatta","rating":4.7,"Address":"28 Liberty St 60th floor, New York, NY 10005","Website":"https://www.manhattarestaurant.com/?utm_source=GoogleBusinessProfile&utm_medium=Website&utm_campaign=MapLabs","Position":9,"priceLevel":"$100+","Description":"Set on the 60th floor, this ritzy, high-end restaurant features New American cuisine and city views.","Booking Link":"https://www.google.com/maps/reserve/v/dine/c/pyjjUZqJ9lQ?source=pa&opi=79508299","Phone number":"(212) 230-5788"}},{"json":{"type":"American restaurant","Name ":"Russ & Daughters Cafe","rating":4.6,"Address":"127 Orchard St, New York, NY 10002","Website":"https://russanddaughterscafe.com/","Position":10,"priceLevel":"$20–30","Description":"From a legendary appetizing shop comes this retro, full-service outpost serving Jewish comfort food.","Phone number":"(212) 475-4881"}},{"json":{"type":"Italian restaurant","Name ":"OLIO E PIÙ","rating":4.7,"Address":"3 Greenwich Ave, New York, NY 10014","Website":"https://www.olioepiu.com/","Position":11,"priceLevel":"$50–100","Description":"Naples meets NYC at this trattoria with thin-crust pizza, Italian wines & ample sidewalk seating.","Booking Link":"https://www.opentable.com/restaurant/profile/55837?ref=1068","Phone number":"(212) 243-6546"}},{"json":{"type":"Taco restaurant","Name ":"LOS TACOS No.1","rating":4.8,"Address":"229 W 43rd St, New York, NY 10036","Website":"http://www.lostacos1.com/","Position":12,"priceLevel":"$10–20","Description":"Small pit stop with standing tables serving authentic Mexican street food."}},{"json":{"type":"Italian restaurant","Name ":"Via Carota","rating":4.4,"Address":"51 Grove St, New York, NY 10014","Website":"http://viacarota.com/","Position":13,"priceLevel":"$50–100","Description":"Italian trattoria serving traditional plates & apéritifs in a rustic, cozy space.","Phone number":"(212) 255-1962"}},{"json":{"type":"American restaurant","Name ":"RH Rooftop Restaurant at RH New York","rating":4.4,"Address":"9 9th Ave, New York, NY 10014","Website":"http://www.rh.com/newyork/restaurant","Position":14,"priceLevel":"$50–100","Description":"Glamorous rooftop restaurant offering American fare amid chandeliers, greenery, and skyline views.","Booking Link":"https://www.opentable.com/restaurant/profile/1050247?ref=1068","Phone number":"(212) 217-2210"}},{"json":{"type":"Taco restaurant","Name ":"LOS TACOS No.1","rating":4.7,"Address":"75 9th Ave, New York, NY 10011","Website":"https://www.lostacos1.com/","Position":15,"priceLevel":"$10–20","Description":"Bustling taqueria serving tacos, quesadillas & aguas frescas in a street-style setup (no seating)."}},{"json":{"type":"Italian restaurant","Name ":"Piccola Cucina Estiatorio","rating":4.7,"Address":"75 Thompson St, New York, NY 10012","Website":"http://www.piccolacucinagroup.com/","Position":16,"priceLevel":"$30–50","Booking Link":"https://www.opentable.com/restaurant/profile/343939?ref=1068","Phone number":"(646) 781-9183"}},{"json":{"type":"Fine dining restaurant","Name ":"Per Se","rating":4.5,"Address":"10 Columbus Cir, New York, NY 10019","Website":"https://www.thomaskeller.com/perseny","Position":17,"priceLevel":"$100+","Description":"Chef Thomas Keller's New American restaurant offers luxe fixed-price menus, with Central Park views.","Phone number":"(212) 823-9335"}},{"json":{"type":"American restaurant","Name ":"ROBERT","rating":4.5,"Address":"2 Columbus Cir, New York, NY 10019","Website":"https://robertnyc.com/","Position":18,"priceLevel":"$$$","Description":"New American fare & city views in an arty space on the top-floor of the Museum of Arts & Design.","Booking Link":"https://www.opentable.com/r/robert-new-york","Phone number":"(212) 299-7730"}},{"json":{"type":"Restaurant","Name ":"Katz's Delicatessen","rating":4.5,"Address":"205 E Houston St, New York, NY 10002","Website":"https://katzsdelicatessen.com/","Position":19,"priceLevel":"$20–30","Description":"No-frills deli with theatrically cranky service serving mile-high sandwiches since 1888.","Phone number":"(212) 254-2246"}},{"json":{"type":"Cajun restaurant","Name ":"1803 NYC","rating":4.5,"Address":"82 Reade St, New York, NY 10007","Website":"https://1803nyc.com/","Position":20,"priceLevel":"$30–50","Description":"Elevated Cajun-Creole food and drinks served in a New Orleans's French quarters-inspired restaurant.","Booking Link":"https://1803nyc.com/#reservation","Phone number":"(212) 267-3000"}}]},"settings":{"executionOrder":"v1"},"versionId":"171ef405-bac6-42c0-a3c3-c28cb49ff21a","connections":{"Trigger: Manual Test Run":{"main":[[{"node":"Search Google Maps via Dumpling AI","type":"main","index":0}]]},"Split Places List for Processing":{"main":[[{"node":"Save Results to Google Sheet (Place Info)","type":"main","index":0}]]},"Search Google Maps via Dumpling AI":{"main":[[{"node":"Split Places List for Processing","type":"main","index":0}]]}}}


name: Generate Monthly Financial Reports with Gemini AI, SQL, and Outlook
author_name: Amjid Ali
author_username: amjid
categories: []
created_at: 2025-04-19T20:25:03.594Z
updated_at: 2025-04-19T20:25:03.594Z
url: https://n8n.io/workflows/3617
scraped_at: 2025-06-19 22:49:28
description:
  🚀 AI-Powered Business Performance Reporting Automation

  Unlock executive-level insights with ZERO manual work!  
  This n8n template empowers you to automate your entire monthly business performance reporting using dynamic SQL queries, AI-driven analysis, and beautiful HTML dashboards — all delivered directly to your inbox.

  🎯 What This Automation Does

  📆 Triggers automatically every month (5th of each month)
  🧮 Fetches financial data from SQL (ERPNext or any database)
  🔁 Loops over cost centers to analyze each business unit individually
  📊 Generates Profit & Loss reports, WIP, Employee stats, and vertical breakdowns
  🤖 Uses Google Gemini 2.5 AI to perform advanced financial analysis
  💌 Delivers a polished HTML report to your email inbox
  🔧 Fully modular – replace data source with Excel, Google Sheets, or APIs

  🧑‍🏫 Step-by-Step Video Tutorial

  🎥 Watch the full tutorial on YouTube:  
    
  📌 Learn how each node works and see the AI-generated report in action.

  🌐 Useful Links

  🔗 Sign up for n8n Cloud (recommended for non-tech users):  
    👉 https://n8n.syncbricks.com

  📘 Download the step-by-step Guidebook (Free):  
    👉 https://lms.syncbricks.com/books/n8n

  📚 Explore the full course on n8n (includes templates, workflows, and AI integrations):  
    👉 https://lms.syncbricks.com/courses/n8n

  🛠 Requirements

  ✅ n8n (Self-hosted or Cloud)
  ✅ SQL Database (MySQL / PostgreSQL / ERPNext)
  ✅ Microsoft Outlook or Gmail (to send the report)
  ✅ Gemini API Key (for AI analysis)
  ✅ Basic understanding of your data schema

  💡 Why Use This Template?

  ⏱ Saves 2-3 days of manual work every month
  📈 Improves financial visibility across business units
  🤝 Great for CFOs, COOs, Finance Analysts, and BI teams
  🔄 Scales across multiple divisions and companies
  🧠 Leverages AI for actionable insights and recommendations

  🧩 Customize It Your Way

  Replace the SQL nodes with:
    Excel / Google Sheets
    Airtable / APIs
    Custom Applications

  Swap the AI model:
    OpenAI GPT
    Claude
    DeepSeek

  Adjust the report structure or HTML style

  🙌 Get Started Now

  🎯 Import the JSON template → Connect your data → Receive business insights via email.  
  Don’t let manual reporting slow down your decision-making.

  👉 Sign up for n8n Cloud  
  👉 Learn n8n with Amjid  
  👉 Download Guide

  Created by Amjid Ali | SyncBricks™ – Automation for Everyone

nodes_used:
  ["n8n-nodes-base.mySql","n8n-nodes-base.microsoftOutlook","n8n-nodes-base.code","n8n-nodes-base.html","@n8n/n8n-nodes-langchain.agent","@n8n/n8n-nodes-langchain.toolCalculator","@n8n/n8n-nodes-langchain.lmChatGoogleGemini","@n8n/n8n-nodes-langchain.toolThink"]

workflow_json:
  {"meta":{"instanceId":"32d80f55a35a7b57f8e47a2ac19558d9f5bcec983a5519d9c29ba713ff4f12c7"},"nodes":[{"id":"fdd55253-5cb6-4b1f-9c93-6915f254f700","name":"Schedule Trigger","type":"n8n-nodes-base.scheduleTrigger","position":[-60,-240],"parameters":{"rule":{"interval":[{"field":"months","triggerAtDayOfMonth":5}]}},"typeVersion":1.2},{"id":"c8d6064a-3fd7-478d-891c-6ade336daa1f","name":"YTD vs Prevoius Month1","type":"n8n-nodes-base.mySql","onError":"continueRegularOutput","position":[640,0],"parameters":{"query":"SELECT\n  --  budget_data.fiscal_year AS `Year`,\n  --  budget_data.cost_center AS `Cost Center`,\n    budget_data.budget_group AS `Budget Group`,\n--    budget_data.sort_order AS `Sort Order`,\n\n    -- YTD Totals up to previous month (up to dynamic month)\n    SUM(budget_data.budget_amount) AS `Budget YTD`,\n    SUM(COALESCE(actual_data.actual_amount, 0)) AS `Actual YTD`,\n    SUM(COALESCE(actual_data.actual_amount, 0)) - SUM(budget_data.budget_amount) AS `Variance YTD`,\n\n    -- Previous Month Totals Only\n    SUM(CASE WHEN budget_data.budget_month = {{ $('PreviousMonth').item.json.previousMonth }} THEN budget_data.budget_amount ELSE 0 END) AS `Budget PM`,\n    SUM(CASE WHEN budget_data.budget_month = {{ $('PreviousMonth').item.json.previousMonth }} THEN COALESCE(actual_data.actual_amount, 0) ELSE 0 END) AS `Actual PM`,\n    SUM(CASE WHEN budget_data.budget_month = {{ $('PreviousMonth').item.json.previousMonth }} THEN COALESCE(actual_data.actual_amount, 0) ELSE 0 END) -\n    SUM(CASE WHEN budget_data.budget_month = {{ $('PreviousMonth').item.json.previousMonth }} THEN budget_data.budget_amount ELSE 0 END) AS `Variance PM`\n\nFROM\n    (\n        SELECT\n            bg.budget_group_name AS budget_group,\n            bg.sort_order,\n            bgd.fiscal_year,\n            bgd.budget_month,\n            bgd.cost_center,\n            CAST(bgd.budget_amount AS DECIMAL(18,6)) AS budget_amount\n        FROM\n            `tabBudget Group Detail` bgd\n        JOIN\n            `tabBudget Group` bg ON bg.name = bgd.parent\n        WHERE\n            bgd.fiscal_year = {{ $('PreviousMonth').item.json.year }}\n            AND bgd.budget_month <= {{ $('PreviousMonth').item.json.previousMonth }}\n            AND bgd.cost_center = '{{ $json.CostCenter }}'\n    ) AS budget_data\n\nLEFT JOIN (\n    SELECT\n        acc.budget_group AS budget_group,\n        YEAR(gl.posting_date) AS fiscal_year,\n        MONTH(gl.posting_date) AS budget_month,\n        gl.cost_center,\n        SUM(\n            CASE \n                WHEN acc.root_type = 'Income' THEN gl.credit - gl.debit\n                WHEN acc.root_type = 'Expense' THEN gl.debit - gl.credit\n                ELSE 0\n            END\n        ) AS actual_amount\n    FROM\n        `tabGL Entry` gl\n    JOIN\n        `tabAccount` acc ON gl.account = acc.name\n    WHERE\n        acc.budget_group IS NOT NULL\n        AND acc.root_type IN ('Income', 'Expense')\n        AND gl.docstatus = 1\n        AND YEAR(gl.posting_date) = {{ $('PreviousMonth').item.json.year }}\n        AND MONTH(gl.posting_date) <= {{ $('PreviousMonth').item.json.previousMonth }}\n        AND gl.cost_center = '{{ $('Filter').item.json['Cost Center'] }}'\n    GROUP BY\n        acc.budget_group,\n        YEAR(gl.posting_date),\n        MONTH(gl.posting_date),\n        gl.cost_center\n) AS actual_data\nON\n    budget_data.budget_group = actual_data.budget_group AND\n    budget_data.fiscal_year = actual_data.fiscal_year AND\n    budget_data.budget_month = actual_data.budget_month AND\n    budget_data.cost_center = actual_data.cost_center\n\nGROUP BY\n    budget_data.fiscal_year,\n    budget_data.cost_center,\n    budget_data.budget_group,\n    budget_data.sort_order\n\nORDER BY\n    budget_data.cost_center,\n    budget_data.sort_order,\n    budget_data.budget_group;\n","options":{},"operation":"executeQuery"},"retryOnFail":false,"typeVersion":2.4},{"id":"13102b1c-8a06-4a23-8174-75254bf783ac","name":"Loop Over Items","type":"n8n-nodes-base.splitInBatches","position":[-40,200],"parameters":{"options":{}},"typeVersion":3},{"id":"da2a0b30-3df4-430c-8cac-cd9d735ce759","name":"CostCentrs","type":"n8n-nodes-base.set","position":[1100,-240],"parameters":{"options":{},"assignments":{"assignments":[{"id":"ac6bcf14-13e3-464d-b9cd-4adee56018d7","name":"Cost Center","type":"string","value":"={{ $json['Cost Center'] }}"}]}},"typeVersion":3.4},{"id":"7891d71c-18f8-4e07-aa30-f50bec10cef6","name":"Date & Time","type":"n8n-nodes-base.dateTime","position":[260,-240],"parameters":{"options":{}},"typeVersion":2},{"id":"3e69dc27-0850-4978-bf10-e81ff575ec60","name":"PreviousMonth","type":"n8n-nodes-base.code","position":[520,-240],"parameters":{"jsCode":"// Get the input date from the previous node\nconst inputDateStr = $input.first().json.currentDate;\nconst inputDate = new Date(inputDateStr);\n\n// Move to the first day of the current month\ninputDate.setDate(1);\n\n// Step back one day to land in the previous month\ninputDate.setDate(0);\n\n// Extract previous month and year\nconst previousMonth = inputDate.getMonth() + 1; // Months are 0-based\nconst year = inputDate.getFullYear(); // This will reflect the correct year, even in January\n\nreturn [\n  {\n    json: {\n      previousMonth: previousMonth.toString().padStart(2, '0'), // e.g., \"01\", \"12\"\n      year: year.toString()                                     // e.g., \"2024\"\n    }\n  }\n];\n"},"typeVersion":2},{"id":"f6776225-39d2-4746-a90f-b4d1b12a66ee","name":"Selected Cost Center","type":"n8n-nodes-base.set","position":[260,220],"parameters":{"options":{},"assignments":{"assignments":[{"id":"c4a6c71a-0df4-49df-9068-f039ddf7d507","name":"CostCenter","type":"string","value":"={{ $json['Cost Center'] }}"},{"id":"ade95f85-baa2-4f5d-a125-7360b17cf99b","name":"previousMonth","type":"string","value":"={{ $('PreviousMonth').item.json.previousMonth }}"},{"id":"36c1d772-5bb7-47a6-81f9-1b70208e558b","name":"year","type":"string","value":"={{ $('PreviousMonth').item.json.year }}"}]}},"typeVersion":3.4},{"id":"1e23d876-21be-4d90-b5e4-38f3543a0c3b","name":"Get Cost Centers with Budgets","type":"n8n-nodes-base.mySql","position":[800,-240],"parameters":{"query":"SELECT DISTINCT\n    budget_data.cost_center AS `Cost Center`\nFROM\n(\n    SELECT\n        bgd.cost_center,\n        bgd.fiscal_year,\n        bgd.budget_month\n    FROM\n        `tabBudget Group Detail` bgd\n    JOIN\n        `tabBudget Group` bg ON bg.name = bgd.parent\n    WHERE\n        bgd.fiscal_year = {{ $json.year }}\n        AND bgd.budget_month <= {{ $json.previousMonth }}\n) AS budget_data\n\nINNER JOIN\n(\n    SELECT DISTINCT\n        gl.cost_center,\n        YEAR(gl.posting_date) AS fiscal_year,\n        MONTH(gl.posting_date) AS budget_month\n    FROM\n        `tabGL Entry` gl\n    JOIN\n        `tabAccount` acc ON gl.account = acc.name\n    WHERE\n        acc.budget_group IS NOT NULL\n        AND acc.root_type IN ('Income', 'Expense')\n        AND gl.docstatus = 1\n        AND YEAR(gl.posting_date) = {{ $json.year }}\n        AND MONTH(gl.posting_date) <= {{ $json.previousMonth }}\n        AND gl.cost_center IS NOT NULL\n) AS gl_data\nON\n    budget_data.cost_center = gl_data.cost_center\n    AND budget_data.fiscal_year = gl_data.fiscal_year\n    AND budget_data.budget_month = gl_data.budget_month\n\nORDER BY\n    budget_data.cost_center;\n","options":{},"operation":"executeQuery"},"typeVersion":2.4},{"id":"d4429595-b1b9-4121-a612-24be11e6a36a","name":"Filter","type":"n8n-nodes-base.filter","position":[1380,-240],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"d7a13ce7-24d3-406a-934b-97f9a47b206c","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json['Cost Center'] }}","rightValue":"AI DEPARTMENT"}]}},"typeVersion":2.2},{"id":"67bbe834-ae40-4aad-b468-6fa73c9dc6c6","name":"HTML","type":"n8n-nodes-base.html","position":[40,920],"parameters":{"html":"{{ $json.html }}"},"typeVersion":1.2},{"id":"58d1dc63-9ba7-41b8-af39-b7c134ab3cea","name":"verticalPL","type":"n8n-nodes-base.code","position":[900,220],"parameters":{"jsCode":"const rows = items;\n\n// Get column names from the first row\nconst headers = Object.keys(rows[0].json);\n\n// Build header HTML\nlet headerHtml = headers.map(col => `<th>${col}</th>`).join('');\n\n// Build rows\nlet bodyHtml = rows.map(row => {\n  return `<tr>${headers.map(col => `<td>${row.json[col]}</td>`).join('')}</tr>`;\n}).join('');\n\n// Combine into one table\nconst tableHtml = `\n<table border=\"1\" cellpadding=\"6\" cellspacing=\"0\" style=\"border-collapse: collapse;\">\n  <thead><tr>${headerHtml}</tr></thead>\n  <tbody>${bodyHtml}</tbody>\n</table>\n`;\n\nreturn [{ json: { table: tableHtml } }];\n"},"typeVersion":2},{"id":"9a8bdb09-f9d4-4c4b-b1d5-dadb3c6ee567","name":"Merge","type":"n8n-nodes-base.merge","position":[1380,220],"parameters":{"numberInputs":4},"typeVersion":3.1},{"id":"d310db4d-183d-4f99-9bd0-863320d2db73","name":"Code","type":"n8n-nodes-base.code","position":[1420,580],"parameters":{"jsCode":"const table1 = $input.first().json.table; // From the first input node\nconst table2 = $items(\"verticalPL\")[0].json.table; // From the node named 'verticalPL'\nconst table3 = $items(\"WIP1\")[0].json.table; // From the node named 'WIP1'\nconst table4 = $items(\"Employees1\")[0].json.table; // From the node named 'Employees1'\n\nconst htmlOutput = `\n<!DOCTYPE html>\n<html>\n<head>\n  <style>\n    body { font-family: Arial, sans-serif; font-size: 14px; color: #333; }\n    h2 { margin-top: 30px; }\n    table { border-collapse: collapse; width: 100%; margin-top: 10px; }\n    th, td { border: 1px solid #ccc; padding: 8px; text-align: right; }\n    th:first-child, td:first-child { text-align: left; }\n    thead { background-color: #f0f0f0; }\n  </style>\n</head>\n<body>\n  <h2>📊 Financial Overview – YTD & PM Summary</h2>\n  ${table1}\n\n  <h2>📊 Financial Overview – Vertical Profit & Loss</h2>\n  ${table2}\n\n  <h2>📊 Financial Overview – WIP Summary</h2>\n  ${table3}\n\n  <h2>👥 Employees in the Business Unit</h2>\n  ${table4}\n</body>\n</html>\n`;\n\nreturn [{ json: { html: htmlOutput } }];\n"},"typeVersion":2},{"id":"ba5e60fb-d5cc-4a5f-9cb6-07808f7c7021","name":"Microsoft Outlook2","type":"n8n-nodes-base.microsoftOutlook","position":[1240,920],"webhookId":"0cdef86a-9910-49aa-bdd3-1beecb260035","parameters":{"subject":"=Business Performance Syncbricks","bodyContent":"={{ $json['Email Output'] }}","toRecipients":"amjid@amjidali.com","additionalFields":{"bodyContentType":"html"}},"typeVersion":2},{"id":"c3cdf21d-417f-420b-98f9-dfca33119c5a","name":"CostCenter","type":"n8n-nodes-base.code","position":[920,0],"parameters":{"jsCode":"const rows = items;\n\n// Get column names from the first row\nconst headers = Object.keys(rows[0].json);\n\n// Build header HTML\nlet headerHtml = headers.map(col => `<th>${col}</th>`).join('');\n\n// Build rows\nlet bodyHtml = rows.map(row => {\n  return `<tr>${headers.map(col => `<td>${row.json[col]}</td>`).join('')}</tr>`;\n}).join('');\n\n// Combine into one table\nconst tableHtml = `\n<table border=\"1\" cellpadding=\"6\" cellspacing=\"0\" style=\"border-collapse: collapse;\">\n  <thead><tr>${headerHtml}</tr></thead>\n  <tbody>${bodyHtml}</tbody>\n</table>\n`;\n\nreturn [{ json: { table: tableHtml } }];\n"},"typeVersion":2},{"id":"9d9fb099-5fca-4777-a753-f6791f37fd37","name":"WIP1","type":"n8n-nodes-base.code","position":[900,400],"parameters":{"jsCode":"const rows = items;\n\n// Get column names from the first row\nconst headers = Object.keys(rows[0].json);\n\n// Build header HTML\nlet headerHtml = headers.map(col => `<th>${col}</th>`).join('');\n\n// Build rows\nlet bodyHtml = rows.map(row => {\n  return `<tr>${headers.map(col => `<td>${row.json[col]}</td>`).join('')}</tr>`;\n}).join('');\n\n// Combine into one table\nconst tableHtml = `\n<table border=\"1\" cellpadding=\"6\" cellspacing=\"0\" style=\"border-collapse: collapse;\">\n  <thead><tr>${headerHtml}</tr></thead>\n  <tbody>${bodyHtml}</tbody>\n</table>\n`;\n\nreturn [{ json: { table: tableHtml } }];\n"},"typeVersion":2},{"id":"5a6626ed-c841-4fd7-9111-f686fcacaa37","name":"Employees","type":"n8n-nodes-base.mySql","onError":"continueRegularOutput","position":[640,600],"parameters":{"query":"SELECT\n   -- e.payroll_cost_center AS `Payroll Cost Center`,\n    COUNT(*) AS `Total Employees`,\n    COUNT(CASE WHEN YEAR(e.date_of_joining) = YEAR(CURDATE()) THEN 1 END) AS `Joined This Year`,\n    COUNT(CASE WHEN YEAR(e.date_of_joining) = YEAR(CURDATE()) AND MONTH(e.date_of_joining) = MONTH(CURDATE()) THEN 1 END) AS `Joined This Month`\nFROM\n    `tabEmployee` e\nWHERE\n    e.status = 'Active'\n    AND e.payroll_cost_center = '{{ $json.CostCenter }}'\nGROUP BY\n    e.payroll_cost_center;\n","options":{},"operation":"executeQuery"},"retryOnFail":false,"typeVersion":2.4},{"id":"bbfd2c19-9538-4106-8931-f65f0261d43c","name":"Employees1","type":"n8n-nodes-base.code","position":[900,600],"parameters":{"jsCode":"const rows = items;\n\n// Get column names from the first row\nconst headers = Object.keys(rows[0].json);\n\n// Build header HTML\nlet headerHtml = headers.map(col => `<th>${col}</th>`).join('');\n\n// Build rows\nlet bodyHtml = rows.map(row => {\n  return `<tr>${headers.map(col => `<td>${row.json[col]}</td>`).join('')}</tr>`;\n}).join('');\n\n// Combine into one table\nconst tableHtml = `\n<table border=\"1\" cellpadding=\"6\" cellspacing=\"0\" style=\"border-collapse: collapse;\">\n  <thead><tr>${headerHtml}</tr></thead>\n  <tbody>${bodyHtml}</tbody>\n</table>\n`;\n\nreturn [{ json: { table: tableHtml } }];\n"},"typeVersion":2},{"id":"b425da91-2faa-4063-93dd-4d997f7cd7eb","name":"Wait","type":"n8n-nodes-base.wait","position":[1480,1180],"webhookId":"83d7ae9a-e309-4bac-a0b4-5ff651e3afe3","parameters":{"unit":"minutes"},"typeVersion":1.1},{"id":"5deead0c-d386-4b51-9b96-bd58e85244c0","name":"Financial Performance","type":"n8n-nodes-base.code","position":[700,920],"parameters":{"jsCode":"let html = $input.first().json.output || '';\n\n// Remove ```html at the start and ``` at the end (if present)\nhtml = html.trim().replace(/^```html\\s*/i, '').replace(/```$/i, '');\n\nreturn [{\n  json: {\n    cleaned_html: html\n  }\n}];\n"},"typeVersion":2},{"id":"a472032f-42ba-4cb2-9bf7-55314083833e","name":"Email Data","type":"n8n-nodes-base.set","position":[940,920],"parameters":{"options":{},"assignments":{"assignments":[{"id":"b227e25f-99ce-4147-b22d-c2a6cabfcafa","name":"CostCenter","type":"string","value":"={{ $('Selected Cost Center').first().json.CostCenter }}\n"},{"id":"94e5a360-cbff-4498-bd75-98cafe08557b","name":"Email Output","type":"string","value":"={{ $json.cleaned_html }}"},{"id":"20cd6408-ab44-4632-8f0a-967604f16a1c","name":"For the Month","type":"string","value":"=Month : {{ $('PreviousMonth').first().json.previousMonth }} - {{ $('PreviousMonth').first().json.year }}"}]}},"typeVersion":3.4},{"id":"b7c1ae4d-cbe3-47fb-84fa-f34295f8dfee","name":"Calculator","type":"@n8n/n8n-nodes-langchain.toolCalculator","position":[620,1220],"parameters":{},"typeVersion":1},{"id":"2e59b7b8-d8f6-4433-98c5-f637f6b5eaf4","name":"Business Performance AI Agent (Analyst)","type":"@n8n/n8n-nodes-langchain.agent","onError":"continueRegularOutput","position":[300,920],"parameters":{"text":"=You are a Business Performance Analyst Expert in Financial Management of Syncbricks LLC,  you willbe given an input to Analyze the Financial Performance of syncbricks which is an AI and Automation Company.\nThe sections Given to you will be below\n\n1. Financial Overview – YTD & PM Summary (whis is income and expense of the Company, this data doesn't include the calculation of Gross Profit and Net Profit that you must do. This should be used together in one section only don't seperate them)\n2. Financial Overview – Vertical Profit & Loss (This containers the Verticials within the Cost Center, these are in fact the Sub Business Unit, you don't need to calculate anything but the information is for analysis to see how the Verticals within the Business Unit Perfored )\n3. Financial Overview – WIP Summary (This is the Projects Summary about how many projects are currently open and work is the WIP - Work in Process of the Project, the WIP figure should be added for Profit and Loss Statement Under Proejct Reveneu as expected WIP)\n4. Employees in the Business Unit (These will be the number of Employees who are directly working in this BU, which means these employees are only serving the Company, other staff which are in back office support are not included in this. )\n*** Your Role ***\n\nYour Role is to Prepare a comprehensive Report : \n1. Executive Summary : Tell how was the overall performance of the Business Unit.\n2. Analayze the Financial Overview - YTD together with PM Summary (Which is Previous Month) which is previous month Income and Expenses you must use Proper Strcuture of Financial Statement with Budget Vs Actuals (follow same input already given). \n\nYou must use the Section that will be shared with you in detail that says \"Financial Overview – YTD & PM Summary \" and from there you must ensure to create sections based on best Practices of Performance Analysis that should include;\n\nSection: Revenue\n-Projects - Revenue\n-Trading - Revenue\n-Service - Revenue\nNet Sales (Total)\nSection: Project Work in Process\nWIP (Revenue to Book)\nTotal: Gross Sale\nSection: Cost of Sale\nProjects - COGS\nTrading - COGS\nService - COGS\nTotal Cost of Sales\nGross Profit\nOther Income\nGross Income\n\nSection: Indirect Cost (here you must all the detail of expenses from \"Financial Overview – YTD & PM Summary\"\nThen you must calculate\nProfit / (Loss) before tax\nNP % to Revenue\n\nUse the calculator tool to ensure precise calculations.\n\n\n- Don't add decimals give format in currency but don't add symbol.\nUse the standard P&L Format where you should first use Sale, then Cost of Sale and GP, then use Indirect Expenses and then Net Profile. Ensure to calculate the Perentages as well.\n3. Provide the Summary of the Verticials Performance with their Profit and Loss and Percetage and Total of all Verticlals\n4. Current Project Progress.\n5. Employees Summary, Number of Employees, How many joined in this Year and what is per Eployee Revenue and Gross Profit \n\nAnalyze Overall Performance of the Company and provide the Business Managers an Overview of what should be done next. Calculate per employee profit as well and suggest what is the performance overall\n\n**Tools**\nUse calculator tool to do all calculations for accurate calculations\n\n** Formatting and Output **\n\nGive output in html format fully responsive in with beauty added using CSS,  ready to be shared with all possible tables, in hightly attracrtive format, headings, add colors green for good, red for bad, organge for acceptable and so on, also add remarks to show how the performance was, enusre to response as if you were as an Expert in Analyzing the Bususiness Performance. Don't add any other infomration or symbols which are not part of html. Don't give additional message saying ok, I will do and so on.\nAlign Text in table on left and numbers on right\nNumber formatting : ##,###\n\n\nHere is the data\n\nMonth : {{ $('PreviousMonth').first().json.previousMonth }}\nYear  : {{ $('PreviousMonth').first().json.year }}\n\n{{ $json.html }}\n\n","options":{},"promptType":"define"},"typeVersion":1.8},{"id":"3ac7b91e-ee61-4b40-9d2d-76d7916479ee","name":"Think","type":"@n8n/n8n-nodes-langchain.toolThink","position":[460,1220],"parameters":{},"typeVersion":1},{"id":"97bac1cb-8271-4169-98cf-6ea5b06ef5db","name":"Google Gemini Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[220,1220],"parameters":{"options":{},"modelName":"models/gemini-2.5-pro-exp-03-25"},"typeVersion":1},{"id":"27f40dc7-61b9-4e09-9b6d-6bb9d16c38c3","name":"Departments ","type":"n8n-nodes-base.mySql","onError":"continueRegularOutput","position":[640,200],"parameters":{"query":"SELECT\n   -- gl.vertical AS `Vertical`,\n\n    -- Total Income (based on root_type)\n    ROUND(SUM(CASE WHEN acc.root_type = 'Income' THEN gl.credit - gl.debit ELSE 0 END), 0) AS `Total Income`,\n\n    -- Total Expenses (based on root_type)\n    ROUND(SUM(CASE WHEN acc.root_type = 'Expense' THEN gl.debit - gl.credit ELSE 0 END), 0) AS `Total Expenses`,\n\n    -- Profit or Loss = Income - Expenses\n    ROUND(SUM(\n        CASE \n            WHEN acc.root_type = 'Income' THEN gl.credit - gl.debit\n            WHEN acc.root_type = 'Expense' THEN -1 * (gl.debit - gl.credit)\n            ELSE 0\n        END\n    ), 0) AS `Profit or Loss`\n\nFROM\n    `tabGL Entry` gl\nJOIN\n    `tabAccount` acc ON gl.account = acc.name\n\nWHERE\n    acc.root_type IN ('Income', 'Expense')\n    AND gl.docstatus = 1\n    AND gl.cost_center = '{{ $(\"Selected Cost Center\").item.json.CostCenter }}'\n    AND MONTH(gl.posting_date) = {{ $(\"Selected Cost Center\").item.json.previousMonth }}\n    AND YEAR(gl.posting_date) = {{ $(\"Selected Cost Center\").item.json.year }}\n\nGROUP BY\n    gl.vertical\n","options":{},"operation":"executeQuery"},"retryOnFail":false,"typeVersion":2.4},{"id":"b2a3ec7d-d400-4d1c-877d-f49f67ad742f","name":"Projects","type":"n8n-nodes-base.mySql","onError":"continueRegularOutput","position":[620,380],"parameters":{"query":"SELECT\n   -- p.cost_center AS `Cost Center`,\n    COUNT(DISTINCT p.name) AS `Projects`,\n\n    FORMAT(SUM(p.contract_value), 0) AS `Contract Value`,\n    FORMAT(SUM(p.total_opening_revenue), 0) AS `Opening Revenue`,\n    FORMAT(SUM(p.total_opening_cost), 0) AS `Opening Cost`,\n\n    -- New Revenue (GL)\n    IFNULL((\n        SELECT SUM(gl.credit - gl.debit)\n        FROM `tabGL Entry` gl\n        JOIN `tabAccount` acc ON acc.name = gl.account\n        WHERE gl.docstatus = 1 AND acc.root_type = 'Income' AND acc.is_group = 0\n          AND gl.project IN (SELECT name FROM `tabProject` WHERE cost_center = p.cost_center AND status = 'Open')\n          AND gl.posting_date <= LAST_DAY(CURDATE() - INTERVAL 1 MONTH)\n    ), 0) AS `New Revenue`,\n\n    -- New Cost (GL)\n    IFNULL((\n        SELECT SUM(gl.debit - gl.credit)\n        FROM `tabGL Entry` gl\n        JOIN `tabAccount` acc ON acc.name = gl.account\n        WHERE gl.docstatus = 1 AND acc.root_type = 'Expense' AND acc.is_group = 0\n          AND gl.project IN (SELECT name FROM `tabProject` WHERE cost_center = p.cost_center AND status = 'Open')\n          AND gl.posting_date <= LAST_DAY(CURDATE() - INTERVAL 1 MONTH)\n    ), 0) AS `New Cost`,\n\n    -- Actual Revenue\n    FORMAT(\n        SUM(p.total_opening_revenue) +\n        IFNULL((\n            SELECT SUM(gl.credit - gl.debit)\n            FROM `tabGL Entry` gl\n            JOIN `tabAccount` acc ON acc.name = gl.account\n            WHERE gl.docstatus = 1 AND acc.root_type = 'Income' AND acc.is_group = 0\n              AND gl.project IN (SELECT name FROM `tabProject` WHERE cost_center = p.cost_center AND status = 'Open')\n              AND gl.posting_date <= LAST_DAY(CURDATE() - INTERVAL 1 MONTH)\n        ), 0), 0\n    ) AS `Actual Revenue`,\n\n    -- Actual Cost\n    FORMAT(\n        SUM(p.total_opening_cost) +\n        IFNULL((\n            SELECT SUM(gl.debit - gl.credit)\n            FROM `tabGL Entry` gl\n            JOIN `tabAccount` acc ON acc.name = gl.account\n            WHERE gl.docstatus = 1 AND acc.root_type = 'Expense' AND acc.is_group = 0\n              AND gl.project IN (SELECT name FROM `tabProject` WHERE cost_center = p.cost_center AND status = 'Open')\n              AND gl.posting_date <= LAST_DAY(CURDATE() - INTERVAL 1 MONTH)\n        ), 0), 0\n    ) AS `Actual Cost`,\n\n    -- Invoice %\n    CONCAT(ROUND((\n        (\n            SUM(p.total_opening_revenue) +\n            IFNULL((\n                SELECT SUM(gl.credit - gl.debit)\n                FROM `tabGL Entry` gl\n                JOIN `tabAccount` acc ON acc.name = gl.account\n                WHERE gl.docstatus = 1 AND acc.root_type = 'Income' AND acc.is_group = 0\n                  AND gl.project IN (SELECT name FROM `tabProject` WHERE cost_center = p.cost_center AND status = 'Open')\n                  AND gl.posting_date <= LAST_DAY(CURDATE() - INTERVAL 1 MONTH)\n            ), 0)\n        ) / NULLIF(SUM(p.contract_value), 0) * 100\n    ), 0), '%') AS `Invoice %`,\n\n    -- Cost %\n    CONCAT(ROUND((\n        (\n            SUM(p.total_opening_cost) +\n            IFNULL((\n                SELECT SUM(gl.debit - gl.credit)\n                FROM `tabGL Entry` gl\n                JOIN `tabAccount` acc ON acc.name = gl.account\n                WHERE gl.docstatus = 1 AND acc.root_type = 'Expense' AND acc.is_group = 0\n                  AND gl.project IN (SELECT name FROM `tabProject` WHERE cost_center = p.cost_center AND status = 'Open')\n                  AND gl.posting_date <= LAST_DAY(CURDATE() - INTERVAL 1 MONTH)\n            ), 0)\n        ) / NULLIF(SUM(p.budgeted_project_cost), 0) * 100\n    ), 0), '%') AS `Cost %`,\n\n    -- WIP Calculation\n    FORMAT(\n        CASE\n            WHEN SUM(p.budgeted_project_cost) = 0 THEN 0\n            WHEN (\n                SUM(p.total_opening_cost) +\n                IFNULL((\n                    SELECT SUM(gl.debit - gl.credit)\n                    FROM `tabGL Entry` gl\n                    JOIN `tabAccount` acc ON acc.name = gl.account\n                    WHERE gl.docstatus = 1 AND acc.root_type = 'Expense' AND acc.is_group = 0\n                      AND gl.project IN (SELECT name FROM `tabProject` WHERE cost_center = p.cost_center AND status = 'Open')\n                      AND gl.posting_date <= LAST_DAY(CURDATE() - INTERVAL 1 MONTH)\n                ), 0)\n            ) > SUM(p.budgeted_project_cost)\n            THEN\n                SUM(p.contract_value) -\n                (SUM(p.total_opening_revenue) +\n                IFNULL((\n                    SELECT SUM(gl.credit - gl.debit)\n                    FROM `tabGL Entry` gl\n                    JOIN `tabAccount` acc ON acc.name = gl.account\n                    WHERE gl.docstatus = 1 AND acc.root_type = 'Income' AND acc.is_group = 0\n                      AND gl.project IN (SELECT name FROM `tabProject` WHERE cost_center = p.cost_center AND status = 'Open')\n                      AND gl.posting_date <= LAST_DAY(CURDATE() - INTERVAL 1 MONTH)\n                ), 0))\n            ELSE\n                (SUM(p.contract_value) * (\n                    (SUM(p.total_opening_cost) +\n                    IFNULL((\n                        SELECT SUM(gl.debit - gl.credit)\n                        FROM `tabGL Entry` gl\n                        JOIN `tabAccount` acc ON acc.name = gl.account\n                        WHERE gl.docstatus = 1 AND acc.root_type = 'Expense' AND acc.is_group = 0\n                          AND gl.project IN (SELECT name FROM `tabProject` WHERE cost_center = p.cost_center AND status = 'Open')\n                          AND gl.posting_date <= LAST_DAY(CURDATE() - INTERVAL 1 MONTH)\n                    ), 0)) / NULLIF(SUM(p.budgeted_project_cost), 0)\n                )) -\n                (SUM(p.total_opening_revenue) +\n                IFNULL((\n                    SELECT SUM(gl.credit - gl.debit)\n                    FROM `tabGL Entry` gl\n                    JOIN `tabAccount` acc ON acc.name = gl.account\n                    WHERE gl.docstatus = 1 AND acc.root_type = 'Income' AND acc.is_group = 0\n                      AND gl.project IN (SELECT name FROM `tabProject` WHERE cost_center = p.cost_center AND status = 'Open')\n                      AND gl.posting_date <= LAST_DAY(CURDATE() - INTERVAL 1 MONTH)\n                ), 0))\n        END,\n    0) AS `WIP`\n\nFROM\n    `tabProject` p\nWHERE\n    p.cost_center = '{{ $json.CostCenter }}'\n    AND p.status = 'Open'\nGROUP BY\n    p.cost_center;\n","options":{},"operation":"executeQuery"},"retryOnFail":false,"typeVersion":2.4},{"id":"a1c5f474-dc92-47e7-bf59-9cca756245cf","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-1260,-20],"parameters":{"width":1120,"height":1200,"content":"## Key Sections of n8n Workflow\n\n**🟢 Schedule Trigger**\n- Triggers the automation on the 5th of every month.\n- Sets the cadence for monthly reporting.\n\n**📅 Date & Time + 🧮 PreviousMonth**\n- Captures the current date and derives the previous month/year for dynamic filtering.\n- Used throughout all SQL queries for monthly slicing.\n\n**📊 Get Cost Centers with Budgets**\n- Dynamically fetches all cost centers that have relevant budget and GL data for the selected period.\n- Ensures only active, relevant divisions are processed.\n\n**🔍 Filter**\n- Narrows the analysis to a specific Cost Center (e.g., \"AI DEPARTMENT\") during testing or preview.\n\n**🔁 Loop Over Items**\n- Iterates over all fetched Cost Centers to individually generate reports for each business unit.\n- Powers multi-division reporting automation.\n\n**🧾 YTD vs Previous Month1**\n- Performs detailed financial comparison between Year-To-Date and Previous Month.\n- Outputs revenue, expenses, and variance figures.\n\n**🏢 Departments + 🧱 verticalPL**\n- Analyzes financial performance by sub-divisions (Verticals) within the cost center.\n- Data is transformed into an HTML table for final report.\n\n**🧱 Projects + 🧮 WIP1**\n- Gathers project status and WIP metrics.\n- Calculates % invoiced, cost % used, and revenue recognition stats.\n\n**👥 Employees + 📊 Employees1**\n- Counts total employees, joined this month/year for the selected cost center.\n- Used to calculate per-employee KPIs.\n\n**🔗 Merge + 🧾 Code**\n- Combines all HTML tables into a single responsive report with visual formatting.\n- Clean, structured layout for email and review.\n\n**💡 Business Performance AI Agent (Analyst)**\n- Uses Google Gemini 2.5 Pro to analyze financial HTML output.\n- Executes structured analysis and generates business insights, executive summary, profitability, and recommendations.\n\n**📩 Email Data + Microsoft Outlook**\n- Sends the final HTML report via email.\n- Ready for business manager distribution with personalized message.\n\n**⏳ Wait**\n- Enables looping and batch control across multiple cost centers.\n- Prevents overloading or email spamming.\n\n**🧠 Think + Calculator**\n- Used by the AI Agent to \"reason\" and perform precise financial computations.\n- Ensures accuracy in gross/net profit, percentages, and insights."},"typeVersion":1},{"id":"59500949-a8b9-4287-b6f7-be49e58e1842","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-1960,580],"parameters":{"color":4,"width":680,"height":560,"content":"## SQL Query Nodes \n(e.g., YTD vs Previous Month, Projects, Employees, Departments)\nThese nodes fetch structured financial data (like revenue, expenses, WIP, employee count) directly from your database (e.g., ERPNext on MySQL).\n\nYou can use any database (MySQL, PostgreSQL, MSSQL, etc.) as long as the schema is mapped accordingly.\n\nTo generate these queries faster, use ChatGPT or any AI chat tool:\n👉 Just describe what you want (e.g., “monthly budget vs actual grouped by cost center”), and it will write SQL for you.\n\nYou can also replace these SQL nodes with any other data source:\n\nExcel/CSV File (via Google Drive or n8n Read Binary File)\n\nGoogle Sheets\n\nAirtable\n\nREST APIs\n\nInternal apps\n\n✅ The key is to produce the same structured data format expected by the next steps in the workflow."},"typeVersion":1},{"id":"02f76680-0bbf-408f-826e-daef5e6e9b09","name":"Sticky Note11","type":"n8n-nodes-base.stickyNote","position":[-1960,0],"parameters":{"color":4,"width":675,"height":536,"content":"## Developed by Amjid Ali\n\nThank you for using this workflow template. It has taken me countless hours of hard work, research, and dedication to develop, and I sincerely hope it adds value to your work.\n\nIf you find this template helpful, I kindly ask you to consider supporting my efforts. Your support will help me continue improving and creating more valuable resources.\n\nYou can contribute via PayPal here:\n\nhttp://paypal.me/pmptraining\n\nFor Full Course about ERPNext or Automation using AI follow below link\n\nhttp://lms.syncbricks.com\n\nAdditionally, when sharing this template, I would greatly appreciate it if you include my original information to ensure proper credit is given.\n\nThank you for your generosity and support!\nEmail : amjid@amjidali.com\nhttps://linkedin.com/in/amjidali\nhttps://syncbricks.com\nhttps://youtube.com/@syncbricks"},"typeVersion":1}],"pinData":{},"connections":{"Code":{"main":[[{"node":"HTML","type":"main","index":0}]]},"HTML":{"main":[[{"node":"Business Performance AI Agent (Analyst)","type":"main","index":0}]]},"WIP1":{"main":[[{"node":"Merge","type":"main","index":2}]]},"Wait":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Merge":{"main":[[{"node":"Code","type":"main","index":0}]]},"Think":{"ai_tool":[[{"node":"Business Performance AI Agent (Analyst)","type":"ai_tool","index":0}]]},"Filter":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Projects":{"main":[[{"node":"WIP1","type":"main","index":0}]]},"Employees":{"main":[[{"node":"Employees1","type":"main","index":0}]]},"Calculator":{"ai_tool":[[{"node":"Business Performance AI Agent (Analyst)","type":"ai_tool","index":0}]]},"CostCenter":{"main":[[{"node":"Merge","type":"main","index":0}]]},"CostCentrs":{"main":[[{"node":"Filter","type":"main","index":0}]]},"Email Data":{"main":[[{"node":"Microsoft Outlook2","type":"main","index":0}]]},"Employees1":{"main":[[{"node":"Merge","type":"main","index":3}]]},"verticalPL":{"main":[[{"node":"Merge","type":"main","index":1}]]},"Date & Time":{"main":[[{"node":"PreviousMonth","type":"main","index":0}]]},"Departments ":{"main":[[{"node":"verticalPL","type":"main","index":0}]]},"PreviousMonth":{"main":[[{"node":"Get Cost Centers with Budgets","type":"main","index":0}]]},"Loop Over Items":{"main":[[],[{"node":"Selected Cost Center","type":"main","index":0}]]},"Schedule Trigger":{"main":[[{"node":"Date & Time","type":"main","index":0}]]},"Microsoft Outlook2":{"main":[[{"node":"Wait","type":"main","index":0}]]},"Selected Cost Center":{"main":[[{"node":"YTD vs Prevoius Month1","type":"main","index":0},{"node":"Departments ","type":"main","index":0},{"node":"Projects","type":"main","index":0},{"node":"Employees","type":"main","index":0}]]},"Financial Performance":{"main":[[{"node":"Email Data","type":"main","index":0}]]},"YTD vs Prevoius Month1":{"main":[[{"node":"CostCenter","type":"main","index":0}]]},"Google Gemini Chat Model":{"ai_languageModel":[[{"node":"Business Performance AI Agent (Analyst)","type":"ai_languageModel","index":0}]]},"Get Cost Centers with Budgets":{"main":[[{"node":"CostCentrs","type":"main","index":0}]]},"Business Performance AI Agent (Analyst)":{"main":[[{"node":"Financial Performance","type":"main","index":0}]]}}}


name: Build your own CUSTOM API MCP server
author_name: Jimleuk
author_username: jimleuk
categories: []
created_at: 2025-04-21T10:21:15.404Z
updated_at: 2025-04-21T10:21:15.404Z
url: https://n8n.io/workflows/3638
scraped_at: 2025-06-19 22:49:18
description:
  This n8n demonstrates how any organisation can quickly and easily build and offer MCP servers to their customers or internal staff to improve productivity.

  This MCP example uses PayCaptain.com as an example and shows how to create an MCP server which can search for and update employee data.

  How it works
  A MCP server trigger is used and connected to 3 custom workflow tools: Search Employee, Get Employee by ID and Update Employee.
  Each tool makes calls to the PayCaptain API to perform their respective tasks. Extra care  is performed to strip out sensitive data and ensure we're not sharing too much.
  The Update Employee too also guards against updating fields which would preferably remain readonly. When you control the MCP server, you can determine behaviour of the tool.
  Finally, a Google Sheet node is used to log all operations for later audit. This will add a tiny bit of latency but recommended if sensitive data is being accessed.

  How to use
  This MCP server allows any compatible MCP client to manage their PayCaptain employee database. You will need to have a PayCaptain account and developer key to use it.
  Connect your MCP client by following the n8n guidelines here - https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-langchain.mcptrigger/#integrating-with-claude-desktop
  Try the following queries in your MCP client:
    "When did Sarah start here employment at the company?"
    "Does Jack work Wednesdays or Fridays?"
    "Please update Tracy's NI number to ABCD123456"

  Requirements
  PayCaptain Account and Developer Key.
  Google Sheets to log actions for later audit.
  MCP Client or Agent for usage such as Claude Desktop - https://claude.ai/download

  Customising this workflow
  Add or remove employee attributes as required for your user case.
  If Google Sheets is too slow, consider an API call to a faster service to log calls to the MCP server.
  Remember to set the MCP server to require credentials before going to production and sharing this MCP server with others!

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

workflow_json:
  {"meta":{"instanceId":"408f9fb9940c3cb18ffdef0e0150fe342d6e655c3a9fac21f0f644e8bedabcd9","templateCredsSetupCompleted":true},"nodes":[{"id":"4bdd4360-b518-4b46-81fa-0d3183ce642d","name":"When Executed by Another Workflow","type":"n8n-nodes-base.executeWorkflowTrigger","position":[680,260],"parameters":{"workflowInputs":{"values":[{"name":"operation"},{"name":"query"},{"name":"employeeId"},{"name":"values","type":"object"}]}},"typeVersion":1.1},{"id":"74bdcff0-0615-4d81-82ff-ff8340939399","name":"Operation","type":"n8n-nodes-base.switch","position":[1040,260],"parameters":{"rules":{"values":[{"outputKey":"searchEmployee","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"81b134bc-d671-4493-b3ad-8df9be3f49a6","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $('When Executed by Another Workflow').first().json.operation }}","rightValue":"searchEmployees"}]},"renameOutput":true},{"outputKey":"getEmployeeById","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"8d57914f-6587-4fb3-88e0-aa1de6ba56c1","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $('When Executed by Another Workflow').first().json.operation }}","rightValue":"getEmployeeById"}]},"renameOutput":true},{"outputKey":"updateEmployee","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"7c38f238-213a-46ec-aefe-22e0bcb8dffc","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $('When Executed by Another Workflow').first().json.operation }}","rightValue":"updateEmployee"}]},"renameOutput":true}]},"options":{}},"typeVersion":3.2},{"id":"8850cd57-9bc1-43b7-9366-7d91afc7bc42","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-80,-120],"parameters":{"color":7,"width":680,"height":660,"content":"## 1. Set up an MCP Server Trigger\n[Read more about the MCP Server Trigger](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-langchain.mcptrigger)"},"typeVersion":1},{"id":"ad541df3-44ed-4ef4-af91-841dc9986b4c","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[620,-120],"parameters":{"color":7,"width":600,"height":260,"content":"## 2. Build Your MCP Server from Existing APIs\n[Read more about the HTTP Request Node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.httprequest)\n\nN8N allows any organisation to quickly build and host their own MCP server by leveraging existing APIs. Here's a quick example for PayCaptain.com - a cloud-based payroll software for modern companies.\n\nWith this set of tools, Paycaptain customers can simplify employee management from within their favourite MCP client such as Claude Desktop. Better yet, n8n also handles distribution so this MCP server can serve entire departments as well."},"typeVersion":1},{"id":"962cb379-8916-4a9f-8a7b-5aa9d31d5d88","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-80,-240],"parameters":{"color":5,"width":380,"height":100,"content":"### Always Authenticate Your Server!\nBefore going to production, it's always advised to enable authentication on your MCP server trigger."},"typeVersion":1},{"id":"27163110-36d7-46f3-92fc-dce7d000655e","name":"Paycaptain MCP Server","type":"@n8n/n8n-nodes-langchain.mcpTrigger","position":[80,40],"webhookId":"5f6728df-d3e8-48bb-9a38-0f2e54c7962c","parameters":{"path":"5f6728df-d3e8-48bb-9a38-0f2e54c7962c"},"typeVersion":1},{"id":"13a69580-de33-489a-85c8-582877efbfe0","name":"Update Employee","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[380,260],"parameters":{"name":"updateEmployee","workflowId":{"__rl":true,"mode":"id","value":"={{ $workflow.id }}"},"description":"Updates an employee's details.","workflowInputs":{"value":{"query":"null","values":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('values', ``, 'string') }}","operation":"updateEmployee","employeeId":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('employeeId', ``, 'string') }}"},"schema":[{"id":"operation","type":"string","display":true,"required":false,"displayName":"operation","defaultMatch":false,"canBeUsedToMatch":true},{"id":"query","type":"string","display":true,"removed":false,"required":false,"displayName":"query","defaultMatch":false,"canBeUsedToMatch":true},{"id":"employeeId","type":"string","display":true,"removed":false,"required":false,"displayName":"employeeId","defaultMatch":false,"canBeUsedToMatch":true},{"id":"values","type":"object","display":true,"required":false,"displayName":"values","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false}},"typeVersion":2.1},{"id":"68c066f0-657c-46cb-a9fe-b31e9850c512","name":"Get Employee","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[240,360],"parameters":{"name":"getEmployeeById","workflowId":{"__rl":true,"mode":"id","value":"={{ $workflow.id }}"},"description":"Returns an employee's details by employee ID.","workflowInputs":{"value":{"query":"null","values":"null","operation":"getEmployeeById","employeeId":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('employeeId', ``, 'string') }}"},"schema":[{"id":"operation","type":"string","display":true,"removed":false,"required":false,"displayName":"operation","defaultMatch":false,"canBeUsedToMatch":true},{"id":"query","type":"string","display":true,"removed":false,"required":false,"displayName":"query","defaultMatch":false,"canBeUsedToMatch":true},{"id":"employeeId","type":"string","display":true,"removed":false,"required":false,"displayName":"employeeId","defaultMatch":false,"canBeUsedToMatch":true},{"id":"values","type":"object","display":true,"removed":false,"required":false,"displayName":"values","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false}},"typeVersion":2.1},{"id":"87661e95-b618-4701-b0f3-9f0532d5fc75","name":"Get Employees","type":"n8n-nodes-base.httpRequest","position":[1380,60],"parameters":{"url":"https://api.paycaptain.com/employees","options":{"pagination":{"pagination":{"parameters":{"parameters":[{"name":"page","value":"={{ $request.qs.page + 1 }}"}]},"maxRequests":3,"requestInterval":1000,"limitPagesFetched":true}}},"sendQuery":true,"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","queryParameters":{"parameters":[{"name":"company","value":"paycaptain"},{"name":"page","value":"={{ $json.page ?? 1 }}"}]}},"credentials":{"httpHeaderAuth":{"id":"sPolCkoJ1zhzWabJ","name":"JWT TOKEN"}},"typeVersion":4.2},{"id":"866868e2-e0b0-4d8d-bf3c-57d68fea8b86","name":"Search Employees","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[100,260],"parameters":{"name":"searchEmployees","workflowId":{"__rl":true,"mode":"id","value":"={{ $workflow.id }}"},"description":"Searches for and returns an employee's details.","workflowInputs":{"value":{"query":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('query', ``, 'string') }}","values":"null","operation":"searchEmployees","employeeId":"null"},"schema":[{"id":"operation","type":"string","display":true,"removed":false,"required":false,"displayName":"operation","defaultMatch":false,"canBeUsedToMatch":true},{"id":"query","type":"string","display":true,"removed":false,"required":false,"displayName":"query","defaultMatch":false,"canBeUsedToMatch":true},{"id":"employeeId","type":"string","display":true,"removed":false,"required":false,"displayName":"employeeId","defaultMatch":false,"canBeUsedToMatch":true},{"id":"values","type":"object","display":true,"removed":false,"required":false,"displayName":"values","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false}},"typeVersion":2.1},{"id":"679a2413-448f-43d8-98fc-7fd8b83775e7","name":"Log Call","type":"n8n-nodes-base.googleSheets","position":[860,260],"parameters":{"columns":{"value":{"query":"={{ $json.query }}","values":"={{ $json.values.toJsonString() }}","operation":"={{ $json.operation }}","timestamp":"={{ $now.toISO() }}","employeeId":"={{ $json.employeeId }}"},"schema":[{"id":"timestamp","type":"string","display":true,"removed":false,"required":false,"displayName":"timestamp","defaultMatch":false,"canBeUsedToMatch":true},{"id":"operation","type":"string","display":true,"removed":false,"required":false,"displayName":"operation","defaultMatch":false,"canBeUsedToMatch":true},{"id":"query","type":"string","display":true,"removed":false,"required":false,"displayName":"query","defaultMatch":false,"canBeUsedToMatch":true},{"id":"employeeId","type":"string","display":true,"removed":false,"required":false,"displayName":"employeeId","defaultMatch":false,"canBeUsedToMatch":true},{"id":"values","type":"string","display":true,"removed":false,"required":false,"displayName":"values","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{"useAppend":true},"operation":"append","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1Ls_3pmzIafl1NUAzzflkJgyq1smPW6vfGjbVuVzdkac/edit#gid=0","cachedResultName":"Sheet1"},"documentId":{"__rl":true,"mode":"list","value":"1Ls_3pmzIafl1NUAzzflkJgyq1smPW6vfGjbVuVzdkac","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1Ls_3pmzIafl1NUAzzflkJgyq1smPW6vfGjbVuVzdkac/edit?usp=drivesdk","cachedResultName":"98. MCP Audit"}},"credentials":{"googleSheetsOAuth2Api":{"id":"XHvC7jIRR8A2TlUl","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"7723947c-94a3-4bf1-b6c8-b595027a33dc","name":"Filter Matches","type":"n8n-nodes-base.filter","position":[1580,60],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"baa681eb-d6d9-450b-99ab-58d33e81cef4","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{\n[\n  $json.hrEmployeeId,\n  $json.payrollCode,\n  $json.firstName + ' ' + $json.lastName,\n  $json.email,\n  $json.niNumber,\n  $json.mailingCity,\n  $json.jobTitle,\n  $json.jobGrade,\n  $json.department,\n  $json.team\n]\n  .join(' ')\n  .toLowerCase()\n}}","rightValue":"={{ $('When Executed by Another Workflow').first().json.query.toLowerCase() }}"}]}},"typeVersion":2.2},{"id":"f4d1ddd9-dde7-437f-9aa2-969ea0832f71","name":"Aggregate Search Results","type":"n8n-nodes-base.aggregate","position":[2020,60],"parameters":{"options":{},"aggregate":"aggregateAllItemData","destinationFieldName":"response"},"typeVersion":1},{"id":"45076cec-f554-44ae-b314-e43ba080abb5","name":"Get Employees1","type":"n8n-nodes-base.httpRequest","position":[1380,260],"parameters":{"url":"https://api.paycaptain.com/employees","options":{"pagination":{"pagination":{"parameters":{"parameters":[{"name":"page","value":"={{ $request.qs.page + 1 }}"}]},"maxRequests":3,"requestInterval":1000,"limitPagesFetched":true}}},"sendQuery":true,"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","queryParameters":{"parameters":[{"name":"company","value":"paycaptain"},{"name":"page","value":"={{ $json.page ?? 1 }}"}]}},"credentials":{"httpHeaderAuth":{"id":"sPolCkoJ1zhzWabJ","name":"JWT TOKEN"}},"typeVersion":4.2},{"id":"b6f3a56f-5cd2-4f4d-904b-49e82ec591b8","name":"Filter Matching ID","type":"n8n-nodes-base.filter","position":[1580,260],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"cfb2ba5b-14c0-4867-be4d-180306c896ae","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.hrEmployeeId }}","rightValue":"={{ $('When Executed by Another Workflow').first().json.employeeId }}"}]}},"typeVersion":2.2},{"id":"ecc2d8d5-4a23-4bfd-840b-63c28980462f","name":"Strip Sensitive Fields1","type":"n8n-nodes-base.set","position":[1800,260],"parameters":{"options":{},"assignments":{"assignments":[{"id":"e20217cf-7c70-4907-9da6-a114104a099e","name":"company","type":"string","value":"={{ $json.company }}"},{"id":"2dfe8342-c442-4ac3-90bd-92fe7d38d407","name":"hrEmployeeId","type":"string","value":"={{ $json.hrEmployeeId }}"},{"id":"57fe4519-246b-44aa-a0c9-22e1e865041c","name":"payrollCode","type":"string","value":"={{ $json.payrollCode }}"},{"id":"d296021c-09b2-43b2-8b8e-ebb5d7d9d14d","name":"firstName","type":"string","value":"={{ $json.firstName }}"},{"id":"661e0049-d28f-4f78-83fc-7a1b21f742c2","name":"lastName","type":"string","value":"={{ $json.lastName }}"},{"id":"59f7fd87-ba84-426a-ad61-c682cf8227bf","name":"email","type":"string","value":"={{ $json.email }}"},{"id":"9769c078-c5f5-4d56-b467-765dd73444f9","name":"phone","type":"string","value":"={{ $json.phone }}"},{"id":"e387bc11-dccf-4baf-b87f-a2abb5f61b5d","name":"mailingStreet","type":"string","value":"={{ $json.mailingStreet }}"},{"id":"415451c5-c3c1-42d4-9f5b-829277bfb7f3","name":"mailingStateProvince","type":"string","value":"={{ $json.mailingStateProvince }}"},{"id":"cf2a83f4-28a8-44bd-9d06-780db1406f8f","name":"mailingPostalCode","type":"string","value":"={{ $json.mailingPostalCode }}"},{"id":"94ee2e05-9969-43f2-a732-57356f8b4dfe","name":"mailingCountry","type":"string","value":"={{ $json.mailingCountry }}"},{"id":"b01a56c9-fc42-4bff-9443-27075699986f","name":"location","type":"string","value":"={{ $json.location }}"},{"id":"b9175d72-6976-4765-b773-f4521668d130","name":"department","type":"string","value":"={{ $json.department }}"},{"id":"d784e800-e13b-4d43-907c-11aaaf4ee24f","name":"team","type":"string","value":"={{ $json.team }}"},{"id":"1ff68eb6-35f9-4a2d-9a37-14b3a6f6e0ee","name":"jobGrade","type":"string","value":"={{ $json.jobGrade }}"},{"id":"5628bbf8-872d-4e3a-bf37-c36f13c0f4b1","name":"jobTitle","type":"string","value":"={{ $json.jobTitle }}"},{"id":"34f26d59-43b3-4f2c-955b-f6d5ab22a083","name":"jobEffectiveDate","type":"string","value":"={{ $json.jobEffectiveDate }}"},{"id":"e3023e94-fbc8-4e9b-b106-687ea533e3f8","name":"contractType","type":"string","value":"={{ $json.contractType }}"},{"id":"d3dcf24c-5e9b-40e5-9f54-fca930ab1528","name":"normalWeeklyHours","type":"number","value":"={{ $json.normalWeeklyHours }}"},{"id":"65ed75a6-1ec1-456f-b19b-4492e31f5c18","name":"daysWorkedPerWeek","type":"number","value":"={{ $json.daysWorkedPerWeek }}"}]}},"typeVersion":3.4},{"id":"77a71a55-f0cf-4f76-b697-b31dba447f30","name":"Strip Sensitive Fields","type":"n8n-nodes-base.set","position":[1800,60],"parameters":{"options":{},"assignments":{"assignments":[{"id":"e20217cf-7c70-4907-9da6-a114104a099e","name":"company","type":"string","value":"={{ $json.company }}"},{"id":"2dfe8342-c442-4ac3-90bd-92fe7d38d407","name":"hrEmployeeId","type":"string","value":"={{ $json.hrEmployeeId }}"},{"id":"57fe4519-246b-44aa-a0c9-22e1e865041c","name":"payrollCode","type":"string","value":"={{ $json.payrollCode }}"},{"id":"d296021c-09b2-43b2-8b8e-ebb5d7d9d14d","name":"firstName","type":"string","value":"={{ $json.firstName }}"},{"id":"661e0049-d28f-4f78-83fc-7a1b21f742c2","name":"lastName","type":"string","value":"={{ $json.lastName }}"},{"id":"59f7fd87-ba84-426a-ad61-c682cf8227bf","name":"email","type":"string","value":"={{ $json.email }}"},{"id":"9769c078-c5f5-4d56-b467-765dd73444f9","name":"phone","type":"string","value":"={{ $json.phone }}"},{"id":"e387bc11-dccf-4baf-b87f-a2abb5f61b5d","name":"mailingStreet","type":"string","value":"={{ $json.mailingStreet }}"},{"id":"415451c5-c3c1-42d4-9f5b-829277bfb7f3","name":"mailingStateProvince","type":"string","value":"={{ $json.mailingStateProvince }}"},{"id":"cf2a83f4-28a8-44bd-9d06-780db1406f8f","name":"mailingPostalCode","type":"string","value":"={{ $json.mailingPostalCode }}"},{"id":"94ee2e05-9969-43f2-a732-57356f8b4dfe","name":"mailingCountry","type":"string","value":"={{ $json.mailingCountry }}"},{"id":"b01a56c9-fc42-4bff-9443-27075699986f","name":"location","type":"string","value":"={{ $json.location }}"},{"id":"b9175d72-6976-4765-b773-f4521668d130","name":"department","type":"string","value":"={{ $json.department }}"},{"id":"d784e800-e13b-4d43-907c-11aaaf4ee24f","name":"team","type":"string","value":"={{ $json.team }}"},{"id":"1ff68eb6-35f9-4a2d-9a37-14b3a6f6e0ee","name":"jobGrade","type":"string","value":"={{ $json.jobGrade }}"},{"id":"5628bbf8-872d-4e3a-bf37-c36f13c0f4b1","name":"jobTitle","type":"string","value":"={{ $json.jobTitle }}"},{"id":"34f26d59-43b3-4f2c-955b-f6d5ab22a083","name":"jobEffectiveDate","type":"string","value":"={{ $json.jobEffectiveDate }}"},{"id":"e3023e94-fbc8-4e9b-b106-687ea533e3f8","name":"contractType","type":"string","value":"={{ $json.contractType }}"},{"id":"d3dcf24c-5e9b-40e5-9f54-fca930ab1528","name":"normalWeeklyHours","type":"number","value":"={{ $json.normalWeeklyHours }}"},{"id":"65ed75a6-1ec1-456f-b19b-4492e31f5c18","name":"daysWorkedPerWeek","type":"number","value":"={{ $json.daysWorkedPerWeek }}"}]}},"typeVersion":3.4},{"id":"86f73b12-afc8-4694-a79d-45c908cc88dd","name":"Update Employee1","type":"n8n-nodes-base.httpRequest","position":[1800,460],"parameters":{"url":"https://api.paycaptain.com/employee","method":"POST","options":{"pagination":{"pagination":{"parameters":{"parameters":[{"name":"page","value":"={{ $request.qs.page + 1 }}"}]},"maxRequests":3,"requestInterval":1000,"limitPagesFetched":true}}},"jsonBody":"={{\n{\n  hrEmployeeId: $('When Executed by Another Workflow').item.json.employeeId,\n  ..\n}\n}}","sendBody":true,"specifyBody":"json","authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"sPolCkoJ1zhzWabJ","name":"JWT TOKEN"}},"typeVersion":4.2},{"id":"122fe6f7-3bcd-4f29-a95c-c727a799e1fd","name":"Valid Fields Only","type":"n8n-nodes-base.set","position":[1380,460],"parameters":{"options":{},"assignments":{"assignments":[{"id":"4f3d0703-21f3-4ca1-bf7a-9c80d9efc936","name":"values","type":"object","value":"={{\n([\n  \"firstname\",\n  \"middlename\",\n  \"lastname\",\n  \"mailingStreet\",\n  \"mailingCity\",\n  \"mailingStateProvince\",\n  \"mailingPostalCode\",\n  \"mailingCountry\",\n  \"email\",\n  \"phone\",\n  \"niNumber\",\n  \"location\",\n  \"department\",\n  \"team\",\n  \"jobGrade\",\n  \"jobTitle\",\n]\n  .reduce((acc, key) => ({\n    ...acc,\n    [key]: $('When Executed by Another Workflow').item.json.values[key] ?? undefined\n  }), {}))\n}}"}]}},"typeVersion":3.4},{"id":"13e5f143-1abf-444c-b86c-ae51fe839894","name":"Has Valid Request?","type":"n8n-nodes-base.if","position":[1580,460],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"54d35a49-e698-427d-9fca-280b83f2827d","operator":{"type":"object","operation":"notEmpty","singleValue":true},"leftValue":"={{ $json.values }}","rightValue":""}]}},"typeVersion":2.2},{"id":"b98f1d73-a994-4040-b421-75e626ec4ce6","name":"Get Error Response","type":"n8n-nodes-base.set","position":[1800,640],"parameters":{"options":{},"assignments":{"assignments":[{"id":"b33ebf1d-d0e8-4dda-90e7-b53c21b2a410","name":"response","type":"string","value":"=Request included fields which cannot be updated. Editable fields are: {{ [\n  \"firstname\",\n  \"middlename\",\n  \"lastname\",\n  \"mailingStreet\",\n  \"mailingCity\",\n  \"mailingStateProvince\",\n  \"mailingPostalCode\",\n  \"mailingCountry\",\n  \"email\",\n  \"phone\",\n  \"niNumber\",\n  \"location\",\n  \"department\",\n  \"team\",\n  \"jobGrade\",\n  \"jobTitle\",\n].join(', ')}}"}]}},"typeVersion":3.4},{"id":"cb140f3f-571c-49a4-a24d-dcee11c5b7e1","name":"Get Success Response","type":"n8n-nodes-base.set","position":[2020,460],"parameters":{"options":{},"assignments":{"assignments":[{"id":"a1d245c9-b1e5-4cec-a901-4a6ecc9bd98d","name":"response","type":"string","value":"ok"}]}},"typeVersion":3.4},{"id":"39cd1188-5f2e-45ce-8bbc-0586812491ec","name":"Aggregate Get Response","type":"n8n-nodes-base.aggregate","position":[2020,260],"parameters":{"options":{},"aggregate":"aggregateAllItemData","destinationFieldName":"response"},"typeVersion":1},{"id":"d9c1ed21-29e4-41a6-9855-36f1568f7944","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[620,-360],"parameters":{"color":7,"width":400,"height":220,"content":"![](https://cdn.prod.website-files.com/6628137b611845ebff95551f/6628137b611845ebff9556e7_paycaptain-logo.svg#full-width)\n**Website**: https://paycaptain.com\n**DeveloperHub**: https://developer.paycaptain.com\n\n**Good to know:** PayCaptain also sponsors the n8n London Meetups - Definitely check them out!"},"typeVersion":1},{"id":"efc7ab35-202d-4a1f-98ce-7ae310c22250","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-540,-640],"parameters":{"width":440,"height":1180,"content":"## Try It Out!\n### This n8n demonstrates how any organisation can quickly and easily build and offer MCP servers to their customers or internal staff to improve productivity.\n\nThis MCP example uses PayCaptain.com as an example and shows how to create an MCP server which can search for and update employee data.\n\n### How it works\n* A MCP server trigger is used and connected to 3 custom workflow tools: Search Employee, Get Employee by ID and Update Employee.\n* Each tool makes calls to the PayCaptain API to perform their respective tasks. Extra care  is performed to strip out sensitive data and ensure we're not sharing too much.\n* The Update Employee too also guards against updating fields which would preferably remain readonly. When you control the MCP server, you can determine behaviour of the tool.\n* Finally, a Google Sheet node is used to log all operations for later audit. This will add a tiny bit of latency but recommended if sensitive data is being accessed.\n\n### How to use\n* This MCP server allows any compatible MCP client to manage their PayCaptain employee database. You will need to have a PayCaptain account and developer key to use it.\n* Connect your MCP client by following the n8n guidelines here - https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-langchain.mcptrigger/#integrating-with-claude-desktop\n* Try the following queries in your MCP client:\n  * \"When did Sarah start here employment at the company?\"\n  * \"Does Jack work Wednesdays or Fridays?\"\n  * \"Please update Tracy's NI number to ABCD123456\"\n\n### Requirements\n* PayCaptain Account and Developer Key.\n* Google Sheets to log actions for later audit.\n* MCP Client or Agent for usage such as Claude Desktop - https://claude.ai/download\n\n### Customising this workflow\n* Add or remove employee attributes as required for your user case.\n* If Google Sheets is too slow, consider an API call to a faster service to log calls to the MCP server.\n* Remember to set the MCP server to require credentials before going to production and sharing this MCP server with others!"},"typeVersion":1}],"pinData":{},"connections":{"Log Call":{"main":[[{"node":"Operation","type":"main","index":0}]]},"Operation":{"main":[[{"node":"Get Employees","type":"main","index":0}],[{"node":"Get Employees1","type":"main","index":0}],[{"node":"Valid Fields Only","type":"main","index":0}]]},"Get Employee":{"ai_tool":[[{"node":"Paycaptain MCP Server","type":"ai_tool","index":0}]]},"Get Employees":{"main":[[{"node":"Filter Matches","type":"main","index":0}]]},"Filter Matches":{"main":[[{"node":"Strip Sensitive Fields","type":"main","index":0}]]},"Get Employees1":{"main":[[{"node":"Filter Matching ID","type":"main","index":0}]]},"Update Employee":{"ai_tool":[[{"node":"Paycaptain MCP Server","type":"ai_tool","index":0}]]},"Search Employees":{"ai_tool":[[{"node":"Paycaptain MCP Server","type":"ai_tool","index":0}]]},"Update Employee1":{"main":[[{"node":"Get Success Response","type":"main","index":0}]]},"Valid Fields Only":{"main":[[{"node":"Has Valid Request?","type":"main","index":0}]]},"Filter Matching ID":{"main":[[{"node":"Strip Sensitive Fields1","type":"main","index":0}]]},"Has Valid Request?":{"main":[[{"node":"Update Employee1","type":"main","index":0}],[{"node":"Get Error Response","type":"main","index":0}]]},"Strip Sensitive Fields":{"main":[[{"node":"Aggregate Search Results","type":"main","index":0}]]},"Strip Sensitive Fields1":{"main":[[{"node":"Aggregate Get Response","type":"main","index":0}]]},"When Executed by Another Workflow":{"main":[[{"node":"Log Call","type":"main","index":0}]]}}}


name: Auto-create and publish AI social videos with Telegram, GPT-4 and Blotato
author_name: Dr. Firas
author_username: drfiras
categories: []
created_at: 2025-04-21T23:28:43.913Z
updated_at: 2025-04-21T23:28:43.913Z
url: https://n8n.io/workflows/3654
scraped_at: 2025-06-19 22:48:58
description:
  Auto-create and publish AI social videos with Telegram, GPT-4 and Blotato

  &gt; ⚠️ Disclaimer: This workflow uses Community Nodes and must be run on a self-hosted instance of n8n.

  Who is this for?

  This template is perfect for social media managers, content creators, AI enthusiasts, and automation pros who want to generate short-form videos (Reels) from a simple Telegram message, then publish them across multiple platforms—all without video editing or manual uploads.

  What problem is this workflow solving?

  Creating content is only half the job. The real bottleneck comes in:
  Rendering the video,
  Adding voice or music,
  Writing captions and titles,
  Publishing to multiple platforms.

  This workflow automates all of that using AI. It saves hours every week and guarantees consistent output.

  What this workflow does

  This end-to-end automation handles everything from AI video generation to social publishing:

  Starts with a Telegram message (text or image prompt)
  Generates video using Kling or Blotato, based on the input
  Creates music with Piapi and merges it with the video
  Generates text overlays and captions with GPT-4
  Builds a stylized video using JSON2Video
  Logs results to Google Sheets
  Sends final output back to Telegram
  Auto-posts the video to 9 platforms via Blotato (Instagram, TikTok, YouTube, Facebook, LinkedIn, Threads, Twitter/X, Pinterest, Bluesky)

  Setup

  Connect your Telegram bot to the trigger node.
  Add your OpenAI API key for all GPT nodes.
  Set up Kling and Piapi API access (for video and music generation).
  Connect your Cloudinary account to upload images.
  Link a Google Sheet with columns: Title, Caption, URL.
  Set your Blotato API key and fill in the platform-specific account IDs.

  How to customize this workflow to your needs

  Change prompt formatting** to control GPT responses and video tone.
  Edit text styling** in JSON2Video to match your brand.
  Add a Telegram approval step** before publishing, if needed.
  Disable platforms** you don’t use by deleting their HTTP Request nodes.
  Use a Google Sheet filter** to only process new rows or drafts.


  📄 Documentation: Notion Guide

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

workflow_json:
  {"id":"hiCTcf6srJl3Xsxh","meta":{"instanceId":"a2b23892dd6989fda7c1209b381f5850373a7d2b85609624d7c2b7a092671d44"},"name":"Auto-create and publish AI social videos with Telegram, GPT-4 and Blotato","tags":[],"nodes":[{"id":"b8a41b63-8c48-4964-befe-b949f3e9b755","name":"Upload Video to Blotato","type":"n8n-nodes-base.httpRequest","position":[2580,920],"parameters":{"url":"https://backend.blotato.com/v2/media","method":"POST","options":{},"sendBody":true,"sendHeaders":true,"bodyParameters":{"parameters":[{"name":"url","value":"={{ $('Append Video Data to Google Sheet').item.json['url '] }}"}]},"headerParameters":{"parameters":[{"name":"blotato-api-key"}]}},"typeVersion":4.2},{"id":"ac7a8bf1-b9ec-4a25-8c14-6d90abbc5568","name":"Post to Instagram","type":"n8n-nodes-base.httpRequest","position":[2800,120],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Platform IDs for Blotato').item.json.instagram_id }}\",\n    \"target\": {\n      \"targetType\": \"instagram\"\n    },\n    \"content\": {\n      \"text\": \"{{ $('Append Video Data to Google Sheet').item.json.caption }}\",\n      \"platform\": \"instagram\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ]\n    }\n  }\n}\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key"}]}},"typeVersion":4.2},{"id":"be0a1831-c0e3-4753-b114-2cd7cc66fae2","name":"Post to YouTube","type":"n8n-nodes-base.httpRequest","position":[2800,320],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Platform IDs for Blotato').item.json.youtube_id }}\",\n    \"target\": {\n      \"targetType\": \"youtube\",\n      \"title\": \"{{ $('Append Video Data to Google Sheet').item.json.Title }}\",\n      \"privacyStatus\": \"unlisted\",\n      \"shouldNotifySubscribers\": \"false\"\n    },\n    \"content\": {\n      \"text\": \"{{ $('Append Video Data to Google Sheet').item.json.caption }}\",\n      \"platform\": \"youtube\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ]\n    }\n  }\n}","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key"}]}},"typeVersion":4.2},{"id":"62087008-dd5a-49f4-a764-a10b1c82e4e0","name":"Post to TikTok","type":"n8n-nodes-base.httpRequest","position":[2800,520],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Platform IDs for Blotato').item.json.tiktok_id }}\",\n    \"target\": {\n      \"targetType\": \"tiktok\",\n      \"isYourBrand\": \"false\", \n      \"disabledDuet\": \"false\",\n      \"privacyLevel\": \"PUBLIC_TO_EVERYONE\",\n      \"isAiGenerated\": \"true\",\n      \"disabledStitch\": \"false\",\n      \"disabledComments\": \"false\",\n      \"isBrandedContent\": \"false\"\n      \n    },\n    \"content\": {\n      \"text\": \"{{ $('Append Video Data to Google Sheet').item.json.caption }}\",\n      \"platform\": \"tiktok\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ]\n    }\n  }\n}\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key"}]}},"typeVersion":4.2},{"id":"976b075d-c98b-45a4-bf76-06a34d5ccbf3","name":"Post to Facebook Page","type":"n8n-nodes-base.httpRequest","position":[2800,720],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Platform IDs for Blotato').item.json.facebook_id }}\",\n    \"target\": {\n      \"targetType\": \"facebook\",\n      \"pageId\": \"{{ $('Assign Platform IDs for Blotato').item.json.facebook_page_id }}\"\n\n      \n    },\n    \"content\": {\n      \"text\": \"{{ $('Append Video Data to Google Sheet').item.json.caption }}\",\n      \"platform\": \"facebook\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ]\n    }\n  }\n}","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key"}]}},"typeVersion":4.2},{"id":"c689c5d4-f63c-4fc2-b2d6-e1d2d03a236a","name":"Post to Threads","type":"n8n-nodes-base.httpRequest","position":[2800,920],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Platform IDs for Blotato').item.json.threads_id }}\",\n    \"target\": {\n      \"targetType\": \"threads\"\n      \n    },\n    \"content\": {\n      \"text\": \"{{ $('Append Video Data to Google Sheet').item.json.caption }}\",\n      \"platform\": \"threads\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ]\n    }\n  }\n}","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key"}]}},"typeVersion":4.2},{"id":"88c8bd03-342e-4844-9489-28a5a93426e0","name":"Post to Twitter (X)","type":"n8n-nodes-base.httpRequest","position":[2800,1120],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Platform IDs for Blotato').item.json.twitter_id }}\",\n    \"target\": {\n      \"targetType\": \"twitter\"\n      \n    },\n    \"content\": {\n      \"text\": \"{{ $('Append Video Data to Google Sheet').item.json.caption }}\",\n      \"platform\": \"twitter\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ]\n    }\n  }\n}\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key"}]}},"typeVersion":4.2},{"id":"db6fb042-731e-46ce-8f4d-07e2b427739c","name":"Post to LinkedIn","type":"n8n-nodes-base.httpRequest","position":[2800,1320],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Platform IDs for Blotato').item.json.linkedin_id }}\",\n    \"target\": {\n      \"targetType\": \"linkedin\"\n      \n    },\n    \"content\": {\n      \"text\": \"{{ $('Append Video Data to Google Sheet').item.json.caption }}\",\n      \"platform\": \"linkedin\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ]\n    }\n  }\n}\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key"}]}},"typeVersion":4.2},{"id":"2102531c-624a-49b6-8b99-7a43e5067585","name":"Post to Bluesky","type":"n8n-nodes-base.httpRequest","position":[2800,1520],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Platform IDs for Blotato').item.json.bluesky_id }}\",\n    \"target\": {\n      \"targetType\": \"bluesky\"\n      \n    },\n    \"content\": {\n      \"text\": \"{{ $('Append Video Data to Google Sheet').item.json.caption }}\",\n      \"platform\": \"bluesky\",\n      \"mediaUrls\": [\n        \"https://pbs.twimg.com/media/GE8MgIiWEAAfsK3.jpg\"\n      ]\n    }\n  }\n}\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key"}]}},"typeVersion":4.2},{"id":"a9826150-6e26-4174-af74-1b4dd8016638","name":"Post to Pinterest","type":"n8n-nodes-base.httpRequest","position":[2800,1720],"parameters":{"url":"https://backend.blotato.com/v2/posts","method":"POST","options":{},"jsonBody":"={\n  \"post\": {\n    \"accountId\": \"{{ $('Assign Platform IDs for Blotato').item.json.pinterest_id }}\",\n    \"target\": {\n      \"targetType\": \"pinterest\",\n      \"boardId\": \"{{ $('Assign Platform IDs for Blotato').item.json.pinterest_board_id }}\"      \n    },\n    \"content\": {\n      \"text\": \"{{ $('Append Video Data to Google Sheet').item.json.caption }}\",\n      \"platform\": \"pinterest\",\n      \"mediaUrls\": [\n        \"https://pbs.twimg.com/media/GE8MgIiWEAAfsK3.jpg\"\n      ]\n    }\n  }\n}\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key"}]}},"typeVersion":4.2},{"id":"fcd6f25a-f6e9-4952-8be8-37eafbf7d07f","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[2320,0],"parameters":{"color":3,"width":880,"height":1900,"content":"# 🟥 STEP 5 — Auto-Publish to 9 Social Platforms\n## The final step automates distribution using Blotato’s API.\n"},"typeVersion":1},{"id":"eb822c9d-cb51-4df7-98d6-a0941a9833bd","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[0,0],"parameters":{"width":2260,"height":760,"content":"# 🟫 STEP 1 — Create Video Using AI (image or text)\n## This step handles the full video creation pipeline using AI.\n### It starts from a Telegram message containing a prompt or image, \n"},"typeVersion":1},{"id":"1c209fe5-fd5a-45d7-9546-421710eb501d","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[0,840],"parameters":{"width":1500,"height":520,"content":"# 🟫 STEP 2 — Create Music\n## Here, a short-form voice-over script is generated using GPT-4 based on the topic.\n### The script is converted to speech, uploaded, and merged with the AI-generated video — resulting in a fully narrated visual asset.\n"},"typeVersion":1},{"id":"0bf198f2-16f9-4ae9-aef3-919b5755da5a","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[0,1440],"parameters":{"width":1500,"height":460,"content":"# 🟫 STEP 3 — Add Captions to Enhance Engagement\n## To increase accessibility and boost social engagement, \n## this step overlays professional-looking subtitles on the video using a styling template.\n### This results in a final video that includes visuals, voice-over, and captions.\n"},"typeVersion":1},{"id":"00c67803-c937-491e-bf2a-2d76774de07f","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[1580,840],"parameters":{"color":4,"width":680,"height":1060,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# 🟫 STEP 4 — Save Video & Notify via Telegram\n## This step generates a title and caption for the video, \n## saves the content metadata to a Google Sheet for future tracking, \n### And sends both the final video and its description to a Telegram chat for validation or reuse.\n### The script is converted to speech, uploaded, and merged with the AI-generated video — resulting in a fully narrated visual asset.\n"},"typeVersion":1},{"id":"5a08a003-68b1-48e5-8851-bb1a77d18a37","name":"Trigger Telegram Prompt or Image","type":"n8n-nodes-base.telegramTrigger","position":[80,280],"webhookId":"20261394-b809-4b76-9b7b-36a20af57673","parameters":{"updates":["message"],"additionalFields":{}},"credentials":{"telegramApi":{"id":"hcYH7o64erx701LY","name":"Telegram account 3"}},"typeVersion":1.1},{"id":"6c4d7dd5-7676-465a-ac02-cf7192bf70ab","name":"Split Prompt or Image Input","type":"n8n-nodes-base.code","position":[280,280],"parameters":{"jsCode":"const input = $input.first().json.message.text || $input.first().json.message.caption;\n\n// Remove optional \"generate video\" prefix\nconst cleaned = input.replace(/^generate video[:]?/i, '').trim();\n\n// Split by comma\nconst parts = cleaned.split(',').map(p => p.trim());\n\n// Assign values even if missing\nconst videoPrompt = parts[0] || \"\";\nconst captionIdea = parts[1] || \"\";\nconst musicStyle = parts[2] || \"\";\n\nreturn [\n  {\n    json: {\n      videoPrompt,\n      captionIdea,\n      musicStyle\n    }\n  }\n];\n"},"typeVersion":2},{"id":"3c203e0c-d133-4c6f-a801-2e5dab690b8a","name":"Condition Input Type (Image or Text)","type":"n8n-nodes-base.if","position":[460,280],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"8b4d3f92-c9e0-45e6-8b6a-4fa487e6b32f","operator":{"type":"string","operation":"notEmpty","singleValue":true},"leftValue":"={{ $('Trigger Telegram Prompt or Image').item.json.message.text }}","rightValue":""}]}},"typeVersion":2.2},{"id":"1898fd9c-2164-44d0-8ada-192107565b64","name":"Download Image from Telegram","type":"n8n-nodes-base.telegram","position":[760,440],"webhookId":"1d115d8e-62c9-4f43-898e-20892b25fdb9","parameters":{"fileId":"={{ $('Trigger Telegram Prompt or Image').item.json.message.photo[3].file_id }}","resource":"file"},"credentials":{"telegramApi":{"id":"hcYH7o64erx701LY","name":"Telegram account 3"}},"typeVersion":1.2},{"id":"6f9755e0-db11-4c3e-9d1b-f9c97c832cbd","name":"Extract Image File URL","type":"n8n-nodes-base.httpRequest","position":[960,440],"parameters":{"url":"=https://api.telegram.org/file/bot_YOURTOKEN/{{ $('Download Image from Telegram').item.json.result.file_path }}","options":{}},"typeVersion":4.2},{"id":"66abae9c-10ae-4845-9070-cd5f2d208782","name":"Upload Image to Cloudinary","type":"n8n-nodes-base.httpRequest","position":[1120,440],"parameters":{"url":"https://api.cloudinary.com/v1_1/dc5wapno3/image/upload","method":"POST","options":{},"sendBody":true,"contentType":"multipart-form-data","authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"file","parameterType":"formBinaryData","inputDataFieldName":"data"},{"name":"upload_preset","value":"n8n_video"}]},"genericAuthType":"httpBasicAuth"},"credentials":{"httpBasicAuth":{"id":"K1UGehJnDI8N25UA","name":"Unnamed credential"}},"typeVersion":4.2},{"id":"26979ac8-6f1d-4a9b-b0b5-42b4d7165ffe","name":"Convert Image to Video","type":"n8n-nodes-base.httpRequest","position":[1320,440],"parameters":{"url":"https://api.piapi.ai/api/v1/task","method":"POST","options":{},"jsonBody":"={\n\"model\": \"kling\",\n\"task_type\": \"video_generation\",\n\"input\": {\n\"prompt\": \"{{ $('Split Prompt or Image Input').item.json.videoPrompt }}\",\n\"image_url\": \"{{ $json.secure_url }}\",\n\"negative_prompt\": \"\",\n\"cfg_scale\": 0.5,\n\"duration\": 5,\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\": 0\n}\n},\n\"mode\": \"std\"\n},\n\"config\": {\n\"service_mode\": \"\",\n\"webhook_config\": {\n\"endpoint\": \"\",\n\"secret\": \"\"\n}\n}\n}","sendBody":true,"specifyBody":"json","authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth"},"credentials":{"httpBasicAuth":{"id":"K1UGehJnDI8N25UA","name":"Unnamed credential"},"httpHeaderAuth":{"id":"aoHHS9dlGs8ViUeX","name":"Header Auth account 3"}},"typeVersion":4.2},{"id":"36168808-54e8-4826-a3f5-bd8148da9a55","name":"Wait for Image-to-Video Rendering","type":"n8n-nodes-base.wait","position":[1520,440],"webhookId":"adf3489e-21ed-42de-8cc6-70c706cacbbf","parameters":{"unit":"minutes","amount":2},"typeVersion":1.1},{"id":"dd364492-ffcb-47e4-a24e-fb5b3c5b4ab5","name":"Get Image-Based Video URL","type":"n8n-nodes-base.httpRequest","position":[1720,440],"parameters":{"url":"=https://api.piapi.ai/api/v1/task/{{ $json.data.task_id }}","options":{"response":{"response":{"responseFormat":"json"}}},"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"aoHHS9dlGs8ViUeX","name":"Header Auth account 3"}},"typeVersion":4.2},{"id":"8a6b0c07-8304-403e-842e-ea60b0d5e939","name":"Generate Video with blotato","type":"n8n-nodes-base.httpRequest","position":[760,120],"parameters":{"url":"https://backend.blotato.com/v2/videos/creations","method":"POST","options":{},"jsonBody":"={\n  \"script\": \"{{ $json.videoPrompt }}\",\n  \"style\": \"cinematic\",\n  \"template\": {\n    \"id\": \"base/pov/wakeup\"\n  }\n}\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"blotato-api-key"}]}},"typeVersion":4.2},{"id":"14f39088-402d-477e-afe7-1fa8a3f0edf5","name":"Wait for blotato Video Rendering","type":"n8n-nodes-base.wait","position":[1520,120],"webhookId":"00fc9999-cacc-4c9b-b71b-75757c56f31e","parameters":{"unit":"minutes","amount":2},"typeVersion":1.1},{"id":"540a8cbf-0b41-4102-b2c3-a69480603cb6","name":"Get blotato Video URL","type":"n8n-nodes-base.httpRequest","position":[1720,120],"parameters":{"url":"=https://backend.blotato.com/v2/videos/creations/{{ $json.item.id }}","options":{"response":{"response":{"responseFormat":"json"}}},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"blotato-api-key"}]}},"typeVersion":4.2},{"id":"e549069b-0acb-44dd-ba58-d6fe76b4b782","name":"Merge Video Data (Image or Prompt)","type":"n8n-nodes-base.set","position":[2060,440],"parameters":{"options":{},"assignments":{"assignments":[{"id":"5ca907c0-f556-488d-ad59-714089b2a594","name":"url_video","type":"string","value":"={{ $json.item.mediaUrl }}{{ $json.data.output.video_url }} "}]}},"typeVersion":3.4},{"id":"4482e940-fdee-498a-9b4c-dd44a12f04a9","name":"Generate Music with Piapi","type":"n8n-nodes-base.httpRequest","position":[60,1040],"parameters":{"url":"https://api.piapi.ai/api/v1/task","method":"POST","options":{},"jsonBody":"={\n  \"model\": \"Qubico/diffrhythm\",\n  \"task_type\": \"txt2audio-base\",\n  \"input\": {\n    \"style_prompt\": \"{{ $('Split Prompt or Image Input').item.json.musicStyle }}\",\n    \"lyrics\": \"\",\n    \"style_audio\": \"\"\n  },\n  \"config\": {\n    \"webhook_config\": {\n      \"endpoint\": \"\",\n      \"secret\": \"\"\n    }\n  }\n}\n","sendBody":true,"specifyBody":"json","authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"aoHHS9dlGs8ViUeX","name":"Header Auth account 3"}},"typeVersion":4.2},{"id":"e2187d71-aace-4cf4-8ef3-b4b14d255f54","name":"Wait for Music Generation","type":"n8n-nodes-base.wait","position":[480,1040],"webhookId":"ecf06ea7-0f87-42f6-939f-688e7eb20da1","parameters":{"unit":"minutes","amount":2},"typeVersion":1.1},{"id":"8ea22e87-0803-4618-a4cb-08a6b720838e","name":"Get Music File URL","type":"n8n-nodes-base.httpRequest","position":[700,1040],"parameters":{"url":"=https://api.piapi.ai/api/v1/task/{{ $json.data.task_id }}","options":{"response":{"response":{"responseFormat":"json"}}},"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"aoHHS9dlGs8ViUeX","name":"Header Auth account 3"}},"typeVersion":4.2},{"id":"61b49201-e9d5-44b8-be6c-d0175596d261","name":"Generate Script (GPT-4o-mini)","type":"@n8n/n8n-nodes-langchain.openAi","position":[920,1040],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"GPT-4O-MINI"},"options":{},"messages":{"values":[{"content":"=You are a copywriter for short-form vertical videos.\nVideo topic:\n{{ $('Split Prompt or Image Input').first().json.captionIdea }}\nWrite two short lines of overlay text:\n\ntext1: Hook (no period)\n\ntext2: Emotional or curiosity payoff (ends with \"...\")\n\nExample:\ntext1: Why I broke up with ChatGPT\ntext2: this other AI gets me so much better...\n\nRules:\n\nMax 50 characters per line\n\nOutput only:\ntext1: ...\ntext2: ...\n\nNo quotes, brackets, emojis, hashtags, or titles\n\n"}]}},"credentials":{"openAiApi":{"id":"6h3DfVhNPw9I25nO","name":"OpenAi account"}},"typeVersion":1.8},{"id":"30394110-bc11-4139-8303-f536e22733d4","name":"Split Script","type":"n8n-nodes-base.code","position":[1300,1040],"parameters":{"jsCode":"const input = $input.first().json;\n\n// Auto-detect AI output path\nlet aiOutput = \"\";\n\nif (input?.choices?.[0]?.message?.content) {\n  aiOutput = input.choices[0].message.content;\n} else if (input?.message?.content) {\n  aiOutput = input.message.content;\n} else if (typeof input?.content === \"string\") {\n  aiOutput = input.content;\n} else {\n  // Optional: expose the input in case of failure for debug\n  throw new Error(\"❌ No valid AI output found. Check the structure of the input.\");\n}\n\nconst lines = aiOutput.split('\\n').map(l => l.trim());\nlet text1 = \"\";\nlet text2 = \"\";\n\nfor (const line of lines) {\n  if (line.toLowerCase().startsWith(\"text1:\")) {\n    text1 = line.replace(/^text1:\\s*/i, '');\n  } else if (line.toLowerCase().startsWith(\"text2:\")) {\n    text2 = line.replace(/^text2:\\s*/i, '');\n  }\n}\n\nreturn [\n  {\n    json: {\n      text1,\n      text2\n    }\n  }\n];\n"},"typeVersion":2},{"id":"15d7845c-0e0b-4f06-b48e-5ea8add6501a","name":"Merge Video + Music","type":"n8n-nodes-base.httpRequest","position":[80,1640],"parameters":{"url":"https://api.json2video.com/v2/movies","method":"POST","options":{},"jsonBody":"={\n  \"id\": \"qbaasr7s\",\n  \"resolution\": \"instagram-story\",\n  \"quality\": \"high\",\n  \"scenes\": [\n    {\n      \"id\": \"qyjh9lwj\",\n      \"comment\": \"Scene 1\",\n      \"elements\": []\n    }\n  ],\n  \"elements\": [\n    {\n      \"id\": \"q6dznzcv\",\n      \"type\": \"video\",\n      \"src\": \"{{ $('Merge Video Data (Image or Prompt)').item.json.url_video }}\",\n      \"resize\": \"cover\"\n    },\n    {\n      \"id\": \"top-text\",\n      \"type\": \"text\",\n      \"text\": \"{{ $json.text1 }}\",\n      \"settings\": {\n        \"font-family\": \"Libre Baskerville\",\n        \"font-size\": \"80px\",\n        \"color\": \"#ffffff\",\n        \"horizontal-position\": \"center\",\n        \"vertical-position\": \"top\",\n        \"margin-top\": \"100px\",\n        \"word-break\": \"break-word\",\n        \"overflow-wrap\": \"break-word\",\n        \"font-weight\": \"normal\",\n        \"text-shadow\": \"3px 3px 0 #000, -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000, 0px 3px 0 #000, 3px 0px 0 #000, -3px 0px 0 #000, 0px -3px 0 #000\"\n      }\n    },\n    {\n      \"id\": \"bottom-text\",\n      \"type\": \"text\",\n      \"text\": \"{{ $json.text2 }}\",\n      \"settings\": {\n        \"font-family\": \"Libre Baskerville\",\n        \"font-size\": \"80px\",\n        \"color\": \"#ffffff\",\n        \"horizontal-position\": \"center\",\n        \"vertical-position\": \"bottom\",\n        \"margin-bottom\": \"250px\",\n        \"word-break\": \"break-word\",\n        \"overflow-wrap\": \"break-word\",\n        \"font-weight\": \"normal\",\n        \"text-shadow\": \"3px 3px 0 #000, -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000, 0px 3px 0 #000, 3px 0px 0 #000, -3px 0px 0 #000, 0px -3px 0 #000\"\n      }\n    },\n    {\n      \"id\": \"music-track\",\n      \"type\": \"audio\",\n      \"src\": \"{{ $('Get Music File URL').item.json.data.output.audio_url }}\",\n      \"volume\": 0.5,\n      \"duration\": -2\n    }\n  ]\n}\n","sendBody":true,"specifyBody":"json","authentication":"genericCredentialType","genericAuthType":"httpCustomAuth"},"credentials":{"httpCustomAuth":{"id":"GELGbE2ThQ80HY5A","name":"Custom Auth account"}},"typeVersion":4.2},{"id":"5b014111-3dfc-4190-83cf-b5915a47df1b","name":"Wait for Fusion Completion","type":"n8n-nodes-base.wait","position":[260,1640],"webhookId":"8d188124-8aeb-49b0-bdf8-5a9f42e205e5","parameters":{"unit":"minutes","amount":1},"typeVersion":1.1},{"id":"fdc02ec0-b3ce-49e3-9f20-096c679eacbe","name":"Get Final Video URL","type":"n8n-nodes-base.httpRequest","position":[500,1640],"parameters":{"url":"=https://api.json2video.com/v2/movies?id={{ $json.project }}","options":{},"authentication":"genericCredentialType","genericAuthType":"httpCustomAuth"},"credentials":{"httpCustomAuth":{"id":"GELGbE2ThQ80HY5A","name":"Custom Auth account"}},"typeVersion":4.2},{"id":"9b865654-337a-4dd5-89d4-4a131f6eed75","name":"Generate Social Caption (GPT-4)","type":"@n8n/n8n-nodes-langchain.openAi","position":[720,1640],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"GPT-4O-MINI"},"options":{},"messages":{"values":[{"content":"=Write a short social media caption from this topic:\n{{ $('Split Prompt or Image Input').first().json.captionIdea }}\n\nMake it actionable, not generic or motivational.\nAdd 1 problem + 1 specific solution.\nUse 1 sentence per line, with an empty line between each.\ndon't asking them to comment.\nMaximum 150 characters\n\n🧠 Caption Guidelines:\nKeep it short, compelling, and value-driven.\n\nAvoid generic motivational fluff — focus on real, actionable insight or highlight a problem/solution pattern.\n\n\nStructure:\n\nOne sentence per line.\n\nNote: Do not use this character: \" in the result.\nReturn a single short paragraph with no line breaks and no special characters.\nNote: Do not use this character: \" in the result."}]}},"credentials":{"openAiApi":{"id":"6h3DfVhNPw9I25nO","name":"OpenAi account"}},"typeVersion":1.8},{"id":"99a4282b-5d68-4f4d-8b1e-c7975221b92f","name":"Generate SEO Title (GPT-4)","type":"@n8n/n8n-nodes-langchain.openAi","position":[1160,1640],"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4o-mini","cachedResultName":"GPT-4O-MINI"},"options":{},"messages":{"values":[{"content":"=Act as a YouTube Title Expert.\nBased on the following video description:\n{{ $('Split Prompt or Image Input').first().json.captionIdea }}\nGenerate a short, punchy, and curiosity-driven YouTube video title that makes people want to click.\nMake it feel urgent, valuable, or surprising — and avoid generic or boring phrases.\nKeep it under 70 characters. Return only the title, no explanations.\nNote: The title must be free of special characters and the character \". Return only a plain text title.\n- Do not start the title with this character : \"\n- Do not finish the title with this character : \"\n- You Never user this character : \" in the title\n"}]}},"credentials":{"openAiApi":{"id":"6h3DfVhNPw9I25nO","name":"OpenAi account"}},"typeVersion":1.8},{"id":"3cbe9fb8-1685-4169-9ee1-3ae72f3190e3","name":"Append Video Data to Google Sheet","type":"n8n-nodes-base.googleSheets","position":[1640,920],"parameters":{"columns":{"value":{"url ":"={{ $('Get Final Video URL').item.json.movie.url }}","Title":"={{ $json.message.content }}","caption":"={{ $('Generate Social Caption (GPT-4)').item.json.message.content }}"},"schema":[{"id":"url ","type":"string","display":true,"required":false,"displayName":"url ","defaultMatch":false,"canBeUsedToMatch":true},{"id":"caption","type":"string","display":true,"required":false,"displayName":"caption","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Title","type":"string","display":true,"removed":false,"required":false,"displayName":"Title","defaultMatch":false,"canBeUsedToMatch":true},{"id":"status","type":"string","display":true,"removed":true,"required":false,"displayName":"status","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"id","value":"="},"documentId":{"__rl":true,"mode":"id","value":"="}},"credentials":{"googleSheetsOAuth2Api":{"id":"51us92xkOlrvArhV","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"dd947cd3-747f-484f-93ea-990d977ab113","name":"Send Final Video to Telegram","type":"n8n-nodes-base.telegram","position":[1860,920],"webhookId":"3046e11e-60db-4fcf-9351-22758c833f83","parameters":{"text":"=Here's your scheduled video:\n----------------\nCaption Text: {{ $json.caption }}\n----------------\nVideo Link: {{ $json['url '] }}","chatId":"={{ $('Trigger Telegram Prompt or Image').first().json.message.chat.id }}","additionalFields":{}},"credentials":{"telegramApi":{"id":"hcYH7o64erx701LY","name":"Telegram account 3"}},"typeVersion":1.2},{"id":"c17efd9a-2428-4c36-acd8-69c47d01b961","name":"Send Caption to Telegram","type":"n8n-nodes-base.telegram","position":[2060,920],"webhookId":"1282505d-dcc3-4dbd-9657-fb1362033382","parameters":{"file":"={{ $('Append Video Data to Google Sheet').item.json['url '] }}","chatId":"={{ $json.result.chat.id }}","operation":"sendVideo","additionalFields":{}},"credentials":{"telegramApi":{"id":"hcYH7o64erx701LY","name":"Telegram account 3"}},"typeVersion":1.2},{"id":"b3311fa9-c473-4bd1-8de7-0930c4e799cd","name":"Assign Platform IDs for Blotato","type":"n8n-nodes-base.set","position":[2360,920],"parameters":{"mode":"raw","options":{},"jsonOutput":"{\n  \"instagram_id\": \"1111\",\n  \"youtube_id\": \"2222\",\n  \"threads_id\": \"3333\",\n  \"tiktok_id\": \"4444\",\n  \"facebook_id\": \"5555\",\n  \"facebook_page_id\": \"6666\",\n  \"twitter_id\": \"7777\",\n  \"linkedin_id\": \"8888\",\n  \"pinterest_id\": \"9999\",\n  \"pinterest_board_id\": \"1010\",\n  \"bluesky_id\": \"11111111\"\n}\n"},"typeVersion":3.4}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"2e5e291a-63f6-4680-9cf5-a3baa2ee917d","connections":{"Split Script":{"main":[[{"node":"Merge Video + Music","type":"main","index":0}]]},"Get Music File URL":{"main":[[{"node":"Generate Script (GPT-4o-mini)","type":"main","index":0}]]},"Get Final Video URL":{"main":[[{"node":"Generate Social Caption (GPT-4)","type":"main","index":0}]]},"Merge Video + Music":{"main":[[{"node":"Wait for Fusion Completion","type":"main","index":0}]]},"Get blotato Video URL":{"main":[[{"node":"Merge Video Data (Image or Prompt)","type":"main","index":0}]]},"Convert Image to Video":{"main":[[{"node":"Wait for Image-to-Video Rendering","type":"main","index":0}]]},"Extract Image File URL":{"main":[[{"node":"Upload Image to Cloudinary","type":"main","index":0}]]},"Upload Video to Blotato":{"main":[[{"node":"Post to Instagram","type":"main","index":0},{"node":"Post to YouTube","type":"main","index":0},{"node":"Post to TikTok","type":"main","index":0},{"node":"Post to Facebook Page","type":"main","index":0},{"node":"Post to Threads","type":"main","index":0},{"node":"Post to Twitter (X)","type":"main","index":0},{"node":"Post to LinkedIn","type":"main","index":0},{"node":"Post to Bluesky","type":"main","index":0},{"node":"Post to Pinterest","type":"main","index":0}]]},"Send Caption to Telegram":{"main":[[{"node":"Assign Platform IDs for Blotato","type":"main","index":0}]]},"Generate Music with Piapi":{"main":[[{"node":"Wait for Music Generation","type":"main","index":0}]]},"Get Image-Based Video URL":{"main":[[{"node":"Merge Video Data (Image or Prompt)","type":"main","index":0}]]},"Wait for Music Generation":{"main":[[{"node":"Get Music File URL","type":"main","index":0}]]},"Generate SEO Title (GPT-4)":{"main":[[{"node":"Append Video Data to Google Sheet","type":"main","index":0}]]},"Upload Image to Cloudinary":{"main":[[{"node":"Convert Image to Video","type":"main","index":0}]]},"Wait for Fusion Completion":{"main":[[{"node":"Get Final Video URL","type":"main","index":0}]]},"Generate Video with blotato":{"main":[[{"node":"Wait for blotato Video Rendering","type":"main","index":0}]]},"Split Prompt or Image Input":{"main":[[{"node":"Condition Input Type (Image or Text)","type":"main","index":0}]]},"Download Image from Telegram":{"main":[[{"node":"Extract Image File URL","type":"main","index":0}]]},"Send Final Video to Telegram":{"main":[[{"node":"Send Caption to Telegram","type":"main","index":0}]]},"Generate Script (GPT-4o-mini)":{"main":[[{"node":"Split Script","type":"main","index":0}]]},"Assign Platform IDs for Blotato":{"main":[[{"node":"Upload Video to Blotato","type":"main","index":0}]]},"Generate Social Caption (GPT-4)":{"main":[[{"node":"Generate SEO Title (GPT-4)","type":"main","index":0}]]},"Trigger Telegram Prompt or Image":{"main":[[{"node":"Split Prompt or Image Input","type":"main","index":0}]]},"Wait for blotato Video Rendering":{"main":[[{"node":"Get blotato Video URL","type":"main","index":0}]]},"Append Video Data to Google Sheet":{"main":[[{"node":"Send Final Video to Telegram","type":"main","index":0}]]},"Wait for Image-to-Video Rendering":{"main":[[{"node":"Get Image-Based Video URL","type":"main","index":0}]]},"Merge Video Data (Image or Prompt)":{"main":[[{"node":"Generate Music with Piapi","type":"main","index":0}]]},"Condition Input Type (Image or Text)":{"main":[[{"node":"Generate Video with blotato","type":"main","index":0}],[{"node":"Download Image from Telegram","type":"main","index":0}]]}}}


name: Create Animated Stories using GPT-4o-mini, Midjourney, Kling and Creatomate API
author_name: PiAPI
author_username: piapi
nodes_used: ["n8n-nodes-base.httpRequest","n8n-nodes-base.code"]
categories: []
created_at: 2025-04-22T01:47:37.016Z
updated_at: 2025-04-22T01:47:37.016Z
url: https://n8n.io/workflows/3655
scraped_at: 2025-06-19 22:49:12
description:
  What does the workflow do? 
  This workflow is designed to generate high-quality short videos, primarily uses GPT-4o-mini (unofficial), Midjourney (unofficial) and Kling (unofficial) APIs from PiAPI and Creatomate API mainly for content creator, social media bloggers and short-form video creators. Through this short video workflow, users can quickly validate their creative ideas and focus more on enhancing the quality of their video concepts.

  Who is the workflow for?
  Social Media Influencers: produce content videos based on inspiration efficiently.

  Vloggers: generate vlogs based on inspiration.

  Educational Creators: explain specific topics via animated short videos or demonstrate a specific imagined scenario to students for enhanced educational impact.

  Advertising Agencies: generate short videos based on specific products.

  AI Tool Developers: automatically generate product demo videos.

  Step-by-step Instructions
  Fill in X-API-key of PiAPI account in Basic Params node.
  Fill in the scenario of the image and video prompt.
  Set a video template on Creatomate and make an API call in the final node with core and processing modules provided in Creatomate. Before full video generation, you can first use basic assets in Creatomate for a prototype demo, then integrate with n8n after verifying the expected results.

  Fill in your Creatomate account settings following the image guildline.
  Click Test Workflow and wait for a generation (within 10~20min).

  In this workflow, we've established a basic structure for image-to-video generation with subtitle integration. You can further enhance it by adding music nodes using either PiAPI's audio models or your preferred music solution. All video elements will ultimately be composited through Creatomate. For best practice, please refer to PiAPI's official API documentation or Creatomate's API documentation to comprehend more use cases.

  Use Case
  Params Settings
   style: a children’s book cover, ages 6-10. --s 500 --sref 4028286908  --niji 6

  character: A gentle girl and a fluffy rabbit explore a sunlit forest together, playing by a sparkling stream
  situational_keywords: Butterflies flutter around them as golden sunlight filters through green leaves. Warm and peaceful atmosphere

  Output Video
   

workflow_json:
  {"id":"MfKB97VVSuXMo3Fm","meta":{"instanceId":"1e003a7ea4715b6b35e9947791386a7d07edf3b5bf8d4c9b7ee4fdcbec0447d7"},"name":"Create Animated Stories using GPT-4o-mini, Midjourney, Kling and Creatomate API","tags":[],"nodes":[{"id":"4e9ed246-e4d7-4a9f-9bb1-cf74e16c3c6f","name":"output1","type":"n8n-nodes-base.set","position":[3980,260],"parameters":{"options":{},"assignments":{"assignments":[{"id":"0107a930-1d7a-459c-a3ab-ceb28b43b8b8","name":"video1","type":"string","value":"={{ $json.data.output.video_url }}"}]}},"typeVersion":3.4},{"id":"d696b66a-3726-4fe5-989e-9405b53c62e1","name":"output2","type":"n8n-nodes-base.set","position":[4680,240],"parameters":{"options":{},"assignments":{"assignments":[{"id":"0107a930-1d7a-459c-a3ab-ceb28b43b8b8","name":"video2","type":"string","value":"={{ $json.data.output.video_url }}"}]}},"typeVersion":3.4},{"id":"33e054fb-b747-4227-9884-f020e78ef5d5","name":"Get Prompt","type":"n8n-nodes-base.code","position":[600,-80],"parameters":{"jsCode":"const content = $input.first().json.choices[0].message.content;\n\nconst prompts = JSON.parse(content);\n\nreturn { prompts };"},"typeVersion":2},{"id":"af4dee94-7bb0-4cb9-9372-a2a1e96d0b19","name":"Basic Params","type":"n8n-nodes-base.set","position":[220,-80],"parameters":{"mode":"raw","options":{},"jsonOutput":"{\n  \"x-api-key\":\"\",\n  \"style\": \"a children’s book cover, ages 6-10. --s 500 --sref 4028286908  --niji 6\",\n  \"character\": \"A gentle girl and a fluffy rabbit explore a sunlit forest together, playing by a sparkling stream\",\n  \"situational_keywords\": \"Butterflies flutter around them as golden sunlight filters through green leaves. Warm and peaceful atmosphere\"\n}\n"},"typeVersion":3.4},{"id":"c0890cdd-642a-48cd-b770-05fbae86abb4","name":"Get Task ID of the First Image","type":"n8n-nodes-base.set","position":[380,140],"parameters":{"options":{},"assignments":{"assignments":[{"id":"d52d19d1-3a37-47bb-ad23-e809323c0c54","name":"image1","type":"string","value":"={{ $('Midjourney Generator of the First Image').item.json.data.task_id }}"}]}},"typeVersion":3.4},{"id":"a2d1e854-53c3-4115-a206-f55c2cff54f1","name":"Midjourney Generator of the First Image","type":"n8n-nodes-base.httpRequest","position":[160,140],"parameters":{"url":"https://api.piapi.ai/api/v1/task","method":"POST","options":{},"jsonBody":"={\n  \"model\": \"midjourney\",\n  \"task_type\": \"imagine\",\n  \"input\": {\n    \"prompt\": \"{{ $('Basic Params').item.json.character }},{{ $json.prompts.prompt1 }},{{ $('Basic Params').item.json.style }}\",\n    \"aspect_ratio\": \"2:3\",\n    \"process_mode\": \"turbo\",\n    \"skip_prompt_check\": false\n  }\n}","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"x-api-key","value":"={{ $('Basic Params').item.json['x-api-key'] }}"}]}},"typeVersion":4.2},{"id":"ac342912-7d94-4019-a0c8-43b555d8566f","name":"Wait for the First Image Generation","type":"n8n-nodes-base.wait","position":[220,400],"webhookId":"af79053d-1291-4dd2-889e-4593dbbb2512","parameters":{},"typeVersion":1.1},{"id":"cd774311-252a-43ec-aaea-28eb7d87ccc1","name":"Verify the first image generation status","type":"n8n-nodes-base.if","position":[600,400],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"or","conditions":[{"id":"e97a02cc-8d1d-4500-bce5-0a296c792b76","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"completed"},{"id":"50b63a7a-52b5-4766-a859-96ac1ff949ec","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"failed"}]}},"typeVersion":2.2},{"id":"a4b8ce31-0ffd-4c9a-b102-162139fa553b","name":"Get the First Image URL","type":"n8n-nodes-base.set","position":[1000,200],"parameters":{"options":{},"assignments":{"assignments":[{"id":"d52d19d1-3a37-47bb-ad23-e809323c0c54","name":"image_urls1","type":"array","value":"={{ $json.data.output.temporary_image_urls }}"},{"id":"f519111b-5cb4-4562-bb8c-944a500e2df3","name":"","type":"string","value":""}]}},"typeVersion":3.4},{"id":"c28e46a7-999c-4a63-a3ae-aa813d7669cd","name":"Midjourney Generator of the Second Image","type":"n8n-nodes-base.httpRequest","position":[1220,200],"parameters":{"url":"https://api.piapi.ai/api/v1/task","method":"POST","options":{},"jsonBody":"={\n  \"model\": \"midjourney\",\n  \"task_type\": \"imagine\",\n  \"input\": {\n    \"prompt\": \"{{ $('Basic Params').item.json.character }},{{ $('Get Prompt').item.json.prompts.prompt2 }},{{ $('Basic Params').item.json.style }}\",\n    \"aspect_ratio\": \"2:3\",\n    \"process_mode\": \"turbo\",\n    \"skip_prompt_check\": false\n  }\n}","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"x-api-key","value":"={{ $('Basic Params').item.json['x-api-key'] }}"}]}},"typeVersion":4.2},{"id":"529f0561-d29f-4df2-b61d-0720d33bf6b9","name":"Midjourney Generator of the Third Image","type":"n8n-nodes-base.httpRequest","position":[1920,220],"parameters":{"url":"https://api.piapi.ai/api/v1/task","method":"POST","options":{},"jsonBody":"={\n  \"model\": \"midjourney\",\n  \"task_type\": \"imagine\",\n  \"input\": {\n    \"prompt\": \"{{ $('Basic Params').item.json.character }},{{ $('Get Prompt').item.json.prompts.prompt3 }},{{ $('Basic Params').item.json.style }}\",\n    \"aspect_ratio\": \"2:3\",\n    \"process_mode\": \"turbo\",\n    \"skip_prompt_check\": false\n  }\n}","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"x-api-key","value":"={{ $('Basic Params').item.json['x-api-key'] }}"}]}},"typeVersion":4.2},{"id":"a1a0b0f4-ac4e-4eca-9aa4-52f815731875","name":"Get the First Image Generation Status","type":"n8n-nodes-base.switch","position":[800,200],"parameters":{"rules":{"values":[{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"5f61ee56-4ebe-411f-95e6-b47d9741e7a2","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"completed"}]}}]},"options":{}},"typeVersion":3.2},{"id":"6f2b83a9-2557-461e-9d5b-9f96440182f0","name":"Get the Second Image Generation Status","type":"n8n-nodes-base.switch","position":[1480,220],"parameters":{"rules":{"values":[{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"5f61ee56-4ebe-411f-95e6-b47d9741e7a2","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"completed"}]}}]},"options":{}},"typeVersion":3.2},{"id":"10802f7a-d262-4f6f-aa48-0dce95c6fa41","name":"Get the Third Image Generation Status","type":"n8n-nodes-base.switch","position":[2380,220],"parameters":{"rules":{"values":[{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"5f61ee56-4ebe-411f-95e6-b47d9741e7a2","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"completed"}]}}]},"options":{}},"typeVersion":3.2},{"id":"c968472d-29e6-428d-99bc-1d3f79b3f0ac","name":"Get the Second Image URL","type":"n8n-nodes-base.set","position":[1720,220],"parameters":{"options":{},"assignments":{"assignments":[{"id":"d52d19d1-3a37-47bb-ad23-e809323c0c54","name":"image_urls1","type":"array","value":"={{ $json.data.output.temporary_image_urls }}"},{"id":"f519111b-5cb4-4562-bb8c-944a500e2df3","name":"","type":"string","value":""}]}},"typeVersion":3.4},{"id":"44fe09ee-b16a-4c00-b589-4634a5f795d2","name":"Get the Third Image URL","type":"n8n-nodes-base.set","position":[2560,220],"parameters":{"options":{},"assignments":{"assignments":[{"id":"d52d19d1-3a37-47bb-ad23-e809323c0c54","name":"image_urls1","type":"array","value":"={{ $json.data.output.temporary_image_urls }}"},{"id":"f519111b-5cb4-4562-bb8c-944a500e2df3","name":"","type":"string","value":""}]}},"typeVersion":3.4},{"id":"472804c0-3f58-4ff3-aaca-b970bef425df","name":"Wait for the Second Image Generation","type":"n8n-nodes-base.wait","position":[900,440],"webhookId":"af79053d-1291-4dd2-889e-4593dbbb2512","parameters":{},"typeVersion":1.1},{"id":"f4004d5a-fd04-4d1c-9376-026d12d690d5","name":"Get Task of the First Image","type":"n8n-nodes-base.httpRequest","position":[420,400],"parameters":{"url":"=https://api.piapi.ai/api/v1/task/{{ $('Get Task ID of the First Image').item.json.image1 }}","options":{},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-api-key","value":"={{ $('Basic Params').item.json['x-api-key'] }}"}]}},"typeVersion":4.2},{"id":"ce09e4ec-97f7-4575-a133-a2c98a55b60e","name":"Get Task of the Second Image","type":"n8n-nodes-base.httpRequest","position":[1100,440],"parameters":{"url":"=https://api.piapi.ai/api/v1/task/{{ $json.data.task_id }}","options":{},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-api-key","value":"={{ $('Basic Params').item.json['x-api-key'] }}"}]}},"typeVersion":4.2},{"id":"2fa361f8-d580-4aa8-ae76-ca336669b0e1","name":"Verify the second image generation status","type":"n8n-nodes-base.if","position":[1300,440],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"or","conditions":[{"id":"e97a02cc-8d1d-4500-bce5-0a296c792b76","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"completed"},{"id":"50b63a7a-52b5-4766-a859-96ac1ff949ec","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"failed"}]}},"typeVersion":2.2},{"id":"a01d33a5-8419-4919-ae53-d90005244734","name":"Verify the third image generation status","type":"n8n-nodes-base.if","position":[2100,460],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"or","conditions":[{"id":"e97a02cc-8d1d-4500-bce5-0a296c792b76","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"completed"},{"id":"50b63a7a-52b5-4766-a859-96ac1ff949ec","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"failed"}]}},"typeVersion":2.2},{"id":"e2ed41b1-daf4-4da2-a320-b2c10d11e6b1","name":"Get Task of the Third Image","type":"n8n-nodes-base.httpRequest","position":[1880,460],"parameters":{"url":"=https://api.piapi.ai/api/v1/task/{{ $json.data.task_id }}","options":{},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-api-key","value":"={{ $('Basic Params').item.json['x-api-key'] }}"}]}},"typeVersion":4.2},{"id":"1d9a3356-2f3e-4829-af75-cdb6f02d3375","name":"Wait for the Third Image Generation","type":"n8n-nodes-base.wait","position":[1680,460],"webhookId":"af79053d-1291-4dd2-889e-4593dbbb2512","parameters":{},"typeVersion":1.1},{"id":"e7a4f69a-bf86-4469-8135-9fc5b18bf54d","name":"Get three Image URLs","type":"n8n-nodes-base.set","position":[2740,220],"parameters":{"options":{},"assignments":{"assignments":[{"id":"d52d19d1-3a37-47bb-ad23-e809323c0c54","name":"image_output1","type":"string","value":"={{ $('Get the First Image URL').item.json.image_urls1[0] }}"},{"id":"333c0676-342a-40ea-bcc7-c13e9145818f","name":"image_output2","type":"string","value":"={{ $('Get the Second Image URL').item.json.image_urls1[1] }}"},{"id":"cc21180a-d88a-40ed-b5d1-0abcfd86bf86","name":"image_output3","type":"string","value":"={{ $json.image_urls1[2] }}"}]}},"typeVersion":3.4},{"id":"83c07d12-31c5-4364-9fff-f82d30530925","name":"Generate the First Video","type":"n8n-nodes-base.httpRequest","position":[2960,40],"parameters":{"url":"https://api.piapi.ai/api/v1/task","method":"POST","options":{},"jsonBody":"={\n    \"model\": \"kling\",\n    \"task_type\": \"video_generation\",\n    \"input\": {\n        \"version\": \"1.6\",\n        \"mode\": \"pro\",\n        \"image_url\": \"{{ $json.image_output1 }}\",\n        \"prompt\": \"Natural swing\"\n    }\n} ","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"x-api-key","value":"={{ $('Basic Params').first().json['x-api-key'] }}"}]}},"typeVersion":4.2},{"id":"5bd0161c-c217-4234-b36b-4826f2ffc0c9","name":"Generate the Second Video","type":"n8n-nodes-base.httpRequest","position":[3160,40],"parameters":{"url":"https://api.piapi.ai/api/v1/task","method":"POST","options":{},"jsonBody":"={\n    \"model\": \"kling\",\n    \"task_type\": \"video_generation\",\n    \"input\": {\n        \"version\": \"1.6\",\n        \"mode\": \"pro\",\n        \"image_url\": \"{{ $('Get three Image URLs').item.json.image_output2 }}\",\n        \"prompt\": \"Natural swing\"\n    }\n} ","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"x-api-key","value":"={{ $('Basic Params').first().json['x-api-key'] }}"}]}},"typeVersion":4.2},{"id":"bf701aa9-ccdc-48d8-885f-193c2b1042f3","name":"Generate the Third Video","type":"n8n-nodes-base.httpRequest","position":[3360,40],"parameters":{"url":"https://api.piapi.ai/api/v1/task","method":"POST","options":{},"jsonBody":"={\n    \"model\": \"kling\",\n    \"task_type\": \"video_generation\",\n    \"input\": {\n        \"version\": \"1.6\",\n        \"mode\": \"pro\",\n        \"image_url\": \"{{ $('Get three Image URLs').item.json.image_output3 }}\",\n        \"prompt\": \"Natural swing\"\n    }\n} ","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"x-api-key","value":"={{ $('Basic Params').first().json['x-api-key'] }}"}]}},"typeVersion":4.2},{"id":"ebf87efe-f5b6-4c96-8c12-5c7a37680851","name":"Final Video Combination","type":"n8n-nodes-base.httpRequest","position":[5700,220],"parameters":{"url":"https://api.creatomate.com/v1/renders","method":"POST","options":{},"jsonBody":"={\n  \"template_id\": \"c10c62b6-d515-4f36-a730-f4646d1b7ee2\",\n\"modifications\": {\n    \"Video-1.source\": \"{{ $('output1').item.json.video1 }}\",\n    \"Video-2.source\": \"{{ $('output2').item.json.video2 }}\",\n    \"Video-3.source\": \"{{ $('Get the Third Video URL').item.json.video3 }}\",\n    \"Text-1.text\": \"{{ $('Get Prompt').item.json.prompts.title }}\"\n  }\n}","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"Authorization","value":"Bearer "},{"name":"Content-Type","value":"application/json"}]}},"executeOnce":true,"typeVersion":4.2},{"id":"d73069fa-f24d-4972-87cb-24c20112f251","name":"Get the Third Video URL","type":"n8n-nodes-base.set","position":[5480,220],"parameters":{"options":{},"assignments":{"assignments":[{"id":"0107a930-1d7a-459c-a3ab-ceb28b43b8b8","name":"video3","type":"string","value":"={{ $json.data.output.video_url }}"}]}},"typeVersion":3.4},{"id":"cb26d84e-55aa-4de1-819e-7704dcc2b45d","name":"Get Video Task IDs","type":"n8n-nodes-base.set","position":[3560,40],"parameters":{"options":{},"assignments":{"assignments":[{"id":"d20160df-8be0-4bd0-8960-f49ebb596a64","name":"video_task1","type":"string","value":"={{ $('Generate the First Video').first().json.data.task_id }}"},{"id":"1be26a8b-1ba3-4de3-a458-778a33f99730","name":"video_task2","type":"string","value":"={{ $('Generate the Second Video').first().json.data.task_id }}"},{"id":"9718a718-8e19-4001-a0c9-2d35710d904e","name":"video_task3","type":"string","value":"={{ $json.data.task_id }}"}]}},"typeVersion":3.4},{"id":"7b6def7e-2712-42c8-8e2b-ac5f70ef146f","name":"Get the First Video Task","type":"n8n-nodes-base.httpRequest","position":[3380,420],"parameters":{"url":"=https://api.piapi.ai/api/v1/task/{{ $('Get Video Task IDs').item.json.video_task1 }}","options":{},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-api-key","value":"={{ $('Basic Params').first().json['x-api-key'] }}"}]}},"typeVersion":4.2},{"id":"8c5a2fe8-75b1-42b5-b861-db3e11ba03d7","name":"Verify the First Video Generation","type":"n8n-nodes-base.if","position":[3580,420],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"or","conditions":[{"id":"e97a02cc-8d1d-4500-bce5-0a296c792b76","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"completed"},{"id":"50b63a7a-52b5-4766-a859-96ac1ff949ec","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"failed"}]}},"typeVersion":2.2},{"id":"9b6925e2-3f9a-46b9-acea-06abbce4033a","name":"Verify the Second Video Generation","type":"n8n-nodes-base.if","position":[4320,420],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"or","conditions":[{"id":"e97a02cc-8d1d-4500-bce5-0a296c792b76","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"completed"},{"id":"50b63a7a-52b5-4766-a859-96ac1ff949ec","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"failed"}]}},"typeVersion":2.2},{"id":"a591a522-65d8-4a4d-a326-64bc2e6463c5","name":"Verify the Third Video Generation","type":"n8n-nodes-base.if","position":[5040,420],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"or","conditions":[{"id":"e97a02cc-8d1d-4500-bce5-0a296c792b76","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"completed"},{"id":"50b63a7a-52b5-4766-a859-96ac1ff949ec","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"failed"}]}},"typeVersion":2.2},{"id":"376176c5-20c5-4a16-9fd5-10f9f2560575","name":"Wait for Video Generation for at Least 4 min","type":"n8n-nodes-base.wait","position":[3780,40],"webhookId":"d7fc1084-fd2e-4aac-98aa-60c719d73c4c","parameters":{"unit":"minutes","amount":4},"typeVersion":1.1},{"id":"dba60967-840b-4c3e-8673-080eae901185","name":"Wait for the First Video Generation","type":"n8n-nodes-base.wait","position":[3800,440],"webhookId":"db4734c5-f793-4b3b-a660-ae87c516dfc1","parameters":{},"typeVersion":1.1},{"id":"b337b044-7da8-494d-9d55-3685b2585e93","name":"Wait for the Second Video Generation","type":"n8n-nodes-base.wait","position":[4480,460],"webhookId":"d9cde4b3-5755-4fde-b58e-9b5849a21c2b","parameters":{},"typeVersion":1.1},{"id":"372f89ed-b771-4c6f-9bc2-faa7e31bfc6d","name":"Wait for the Third Video Generation","type":"n8n-nodes-base.wait","position":[5260,460],"webhookId":"d077385d-bd8f-4d14-b332-22a974f98ea7","parameters":{},"typeVersion":1.1},{"id":"756d9cb7-da96-4515-a391-f152d3ca8ea9","name":"Get the First Video Generation","type":"n8n-nodes-base.switch","position":[3800,260],"parameters":{"rules":{"values":[{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"5f61ee56-4ebe-411f-95e6-b47d9741e7a2","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"completed"}]}}]},"options":{}},"typeVersion":3.2},{"id":"7b96363c-55f3-4773-9d50-f2e71c7ac4eb","name":"Get the Second Video Generation","type":"n8n-nodes-base.switch","position":[4520,240],"parameters":{"rules":{"values":[{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"5f61ee56-4ebe-411f-95e6-b47d9741e7a2","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"completed"}]}}]},"options":{}},"typeVersion":3.2},{"id":"eb19ddd9-1bd3-430b-997b-ad288a4731b9","name":"Get the Third Video Generation","type":"n8n-nodes-base.switch","position":[5280,220],"parameters":{"rules":{"values":[{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"5f61ee56-4ebe-411f-95e6-b47d9741e7a2","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"completed"}]}}]},"options":{}},"typeVersion":3.2},{"id":"4a1468b4-d183-423f-8360-93044bcf323a","name":"Get the Second Video Task","type":"n8n-nodes-base.httpRequest","position":[4160,420],"parameters":{"url":"=https://api.piapi.ai/api/v1/task/{{ $('Get Video Task IDs').item.json.video_task2 }}","options":{},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-api-key","value":"={{ $('Basic Params').first().json['x-api-key'] }}"}]}},"typeVersion":4.2},{"id":"ff51a9b2-f17a-494d-afa7-a4fc0137d239","name":"Get the Third Video Task","type":"n8n-nodes-base.httpRequest","position":[4840,420],"parameters":{"url":"=https://api.piapi.ai/api/v1/task/{{ $('Get Video Task IDs').item.json.video_task3 }}","options":{},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-api-key","value":"={{ $('Basic Params').first().json['x-api-key'] }}"}]}},"typeVersion":4.2},{"id":"3db3e156-67ca-41cd-b9f2-5a03330ab33c","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[20,-280],"parameters":{"width":360,"content":"## Basic Setting Instruction\nFill in **Basic Params** based on user's need. \nThe node concludes three section: style, character and situation_keyword.\nGPT-4o-mini will generate image description based on basic params mentioned above."},"typeVersion":1},{"id":"31419df4-39d4-4393-8e80-7cdceb24778e","name":"When clicking Test workflow","type":"n8n-nodes-base.manualTrigger","position":[20,-80],"parameters":{},"typeVersion":1},{"id":"e0510fc2-4570-4cd6-8438-42a7acd26414","name":"GPT-4o-mini Generate Image Scenario Prompt","type":"n8n-nodes-base.httpRequest","position":[420,-80],"parameters":{"url":"https://api.piapi.ai/v1/chat/completions","method":"POST","options":{},"jsonBody":"={\n    \"model\": \"gpt-4o-mini\",\n    \"messages\": [\n       {\n          \"role\": \"system\",\n          \"content\": \"You are a helpful assistant.\"\n        },\n        {\n          \"role\": \"user\",\n          \"content\": \"Character is {{ $json.character }}, style is {{ $json.style }}, context keywords are {{ $json.situational_keywords }}, please generate a short story containing relevant elements and styles based on Character and context keywords. It should be concise and clear and divided into three sections. The return format is {'title':'','prompt1':'','prompt2':'','prompt3':''}, directly return json data format, not markdo2t include unusual characters such as hyphens,The key and value are enclosed in double quotes, but if you need to use quotes in the value string, please use single quotes.\"\n        }\n      ]\n  }","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"Authorization","value":"=Bearer {{ $('Basic Params').first().json['x-api-key'] }}"}]}},"typeVersion":4.2},{"id":"f94354e2-066d-4bf0-ada1-edade772852d","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[180,660],"parameters":{"height":120,"content":"### Generate the first image\nThis workflow section is uesd to generate the first Midjourney image. "},"typeVersion":1},{"id":"86e4d54d-8046-4400-a327-b04e8f12a09c","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[880,660],"parameters":{"height":120,"content":"### Generate the second image\nThis workflow section is uesd to generate the second Midjourney image. "},"typeVersion":1},{"id":"950a3dcb-83dc-4ee1-abb1-b33927edf1c2","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[1660,680],"parameters":{"height":120,"content":"### Generate the third image\nThis workflow section is uesd to generate the third Midjourney image. "},"typeVersion":1},{"id":"0a179107-17a4-4e38-998d-5845104199d0","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[2960,-120],"parameters":{"height":120,"content":"### Generate three Kling videos\nThis section is used to generate three Kliong videos."},"typeVersion":1},{"id":"dc589738-4130-4686-a4e2-cf07d9d22013","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[5640,400],"parameters":{"content":"### Combine Videos in Creatomate\nSet a video template in Creatomate, then set the node with instruction."},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"d16d0b20-c14e-4d0e-83ea-467e0d7c8280","connections":{"output1":{"main":[[{"node":"Get the Second Video Task","type":"main","index":0}]]},"output2":{"main":[[{"node":"Get the Third Video Task","type":"main","index":0}]]},"Get Prompt":{"main":[[{"node":"Midjourney Generator of the First Image","type":"main","index":0}]]},"Basic Params":{"main":[[{"node":"GPT-4o-mini Generate Image Scenario Prompt","type":"main","index":0}]]},"Get Video Task IDs":{"main":[[{"node":"Wait for Video Generation for at Least 4 min","type":"main","index":0}]]},"Get three Image URLs":{"main":[[{"node":"Generate the First Video","type":"main","index":0}]]},"Get the First Image URL":{"main":[[{"node":"Midjourney Generator of the Second Image","type":"main","index":0}]]},"Get the Third Image URL":{"main":[[{"node":"Get three Image URLs","type":"main","index":0}]]},"Get the Third Video URL":{"main":[[{"node":"Final Video Combination","type":"main","index":0}]]},"Generate the First Video":{"main":[[{"node":"Generate the Second Video","type":"main","index":0}]]},"Generate the Third Video":{"main":[[{"node":"Get Video Task IDs","type":"main","index":0}]]},"Get the First Video Task":{"main":[[{"node":"Verify the First Video Generation","type":"main","index":0}]]},"Get the Second Image URL":{"main":[[{"node":"Midjourney Generator of the Third Image","type":"main","index":0}]]},"Get the Third Video Task":{"main":[[{"node":"Verify the Third Video Generation","type":"main","index":0}]]},"Generate the Second Video":{"main":[[{"node":"Generate the Third Video","type":"main","index":0}]]},"Get the Second Video Task":{"main":[[{"node":"Verify the Second Video Generation","type":"main","index":0}]]},"Get Task of the First Image":{"main":[[{"node":"Verify the first image generation status","type":"main","index":0}]]},"Get Task of the Third Image":{"main":[[{"node":"Verify the third image generation status","type":"main","index":0}]]},"When clicking Test workflow":{"main":[[{"node":"Basic Params","type":"main","index":0}]]},"Get Task of the Second Image":{"main":[[{"node":"Verify the second image generation status","type":"main","index":0}]]},"Get Task ID of the First Image":{"main":[[{"node":"Wait for the First Image Generation","type":"main","index":0}]]},"Get the First Video Generation":{"main":[[{"node":"output1","type":"main","index":0}]]},"Get the Third Video Generation":{"main":[[{"node":"Get the Third Video URL","type":"main","index":0}]]},"Get the Second Video Generation":{"main":[[{"node":"output2","type":"main","index":0}]]},"Verify the First Video Generation":{"main":[[{"node":"Get the First Video Generation","type":"main","index":0}],[{"node":"Wait for the First Video Generation","type":"main","index":0}]]},"Verify the Third Video Generation":{"main":[[{"node":"Get the Third Video Generation","type":"main","index":0}],[{"node":"Wait for the Third Video Generation","type":"main","index":0}]]},"Verify the Second Video Generation":{"main":[[{"node":"Get the Second Video Generation","type":"main","index":0}],[{"node":"Wait for the Second Video Generation","type":"main","index":0}]]},"Wait for the First Image Generation":{"main":[[{"node":"Get Task of the First Image","type":"main","index":0}]]},"Wait for the First Video Generation":{"main":[[{"node":"Get the First Video Task","type":"main","index":0}]]},"Wait for the Third Image Generation":{"main":[[{"node":"Get Task of the Third Image","type":"main","index":0}]]},"Wait for the Third Video Generation":{"main":[[{"node":"Get the Third Video Task","type":"main","index":0}]]},"Wait for the Second Image Generation":{"main":[[{"node":"Get Task of the Second Image","type":"main","index":0}]]},"Wait for the Second Video Generation":{"main":[[{"node":"Get the Second Video Task","type":"main","index":0}]]},"Get the First Image Generation Status":{"main":[[{"node":"Get the First Image URL","type":"main","index":0}]]},"Get the Third Image Generation Status":{"main":[[{"node":"Get the Third Image URL","type":"main","index":0}]]},"Get the Second Image Generation Status":{"main":[[{"node":"Get the Second Image URL","type":"main","index":0}]]},"Midjourney Generator of the First Image":{"main":[[{"node":"Get Task ID of the First Image","type":"main","index":0}]]},"Midjourney Generator of the Third Image":{"main":[[{"node":"Wait for the Third Image Generation","type":"main","index":0}]]},"Midjourney Generator of the Second Image":{"main":[[{"node":"Wait for the Second Image Generation","type":"main","index":0}]]},"Verify the first image generation status":{"main":[[{"node":"Get the First Image Generation Status","type":"main","index":0}],[{"node":"Wait for the First Image Generation","type":"main","index":0}]]},"Verify the third image generation status":{"main":[[{"node":"Get the Third Image Generation Status","type":"main","index":0}],[{"node":"Wait for the Third Image Generation","type":"main","index":0}]]},"Verify the second image generation status":{"main":[[{"node":"Get the Second Image Generation Status","type":"main","index":0}],[{"node":"Wait for the Second Image Generation","type":"main","index":0}]]},"GPT-4o-mini Generate Image Scenario Prompt":{"main":[[{"node":"Get Prompt","type":"main","index":0}]]},"Wait for Video Generation for at Least 4 min":{"main":[[{"node":"Get the First Video Task","type":"main","index":0}]]}}}


name: AI-Powered Telegram Task Manager with MCP Server
author_name: Francis Njenga
author_username: gatura
categories: []
created_at: 2025-04-22T04:27:33.277Z
updated_at: 2025-04-22T04:27:33.277Z
url: https://n8n.io/workflows/3656
scraped_at: 2025-06-19 22:49:10
description:
  Detailed Description
  The ToDo App workflow is designed to streamline task management through Telegram and Google Tasks integration. This workflow allows users to create, update, and manage tasks via Telegram messages, leveraging AI capabilities to enhance user interaction. The expected outcome is a seamless experience where users can manage their tasks efficiently without needing to switch between applications.

  Who is this for?
  This workflow is intended for:
  Individuals** looking for an efficient way to manage their tasks directly from Telegram.
  Teams** that require a collaborative task management solution integrated with Google Tasks.
  Developers** interested in automating task management processes using n8n and Telegram.

  What problem does this workflow solve?
  Managing tasks can often be cumbersome, especially when switching between different applications. This workflow addresses the following problems:
  Fragmented Task Management**: Users can manage tasks directly from Telegram, reducing the need to switch to Google Tasks.
  Inefficient Communication**: By integrating AI, users can interact with the task management system in a conversational manner, making it more intuitive.
  Task Updates**: Users can easily update task statuses and details through simple messages, enhancing productivity.

  What this workflow does
  The ToDo App workflow performs the following functions:
  Incoming Message Handling: Listens for messages sent to a Telegram bot.
  Task Creation: Allows users to create new tasks based on their messages.
  Task Updates: Users can update existing tasks by sending specific commands.
  Task Retrieval: Retrieves today's and upcoming tasks from Google Tasks.
  Voice Note Transcription: Supports voice messages, converting them into text for task management.
  AI Assistance: Utilizes an AI agent to assist users in managing their tasks effectively.

  Setup
  Prerequisites
  Before setting up the workflow, ensure you have the following:
  n8n Account**: Sign up for an n8n account if you don't have one.
  Telegram Bot**: Create a Telegram bot and obtain the API token.
  Google Tasks API**: Set up Google Tasks API and obtain OAuth2 credentials.
  OpenAI API Key**: Sign up for OpenAI and obtain an API key for AI functionalities.

  Setup Process
  Upload the JSON for this workflow and setup the authentication for the different tools.

  How to customize this workflow
  To adapt the ToDo App workflow to different needs, consider the following customizations:
  Change Task Management Platform**: If you prefer a different task management tool, replace the Google Tasks nodes with your preferred service's API.
  Modify AI Responses**: Adjust the AI agent's system message to change how it interacts with users.
  Add Additional Commands**: Expand the workflow by adding more commands for different task management functionalities (e.g., deleting tasks).
  Integrate Other Messaging Platforms**: If you want to use a different messaging service, replace the Telegram nodes with the appropriate nodes for that service.

  Conclusion
  The ToDo App workflow provides a powerful solution for managing tasks through Telegram, enhancing productivity and user experience. By following the setup instructions and customization options, users can tailor the workflow to meet their specific needs, making task management more efficient and accessible.

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

workflow_json:
  {"meta":{"instanceId":"be27b2af86ae3a5dc19ef2a1947644c0aec45fd8c88f29daa7dea6f0ce537691","templateCredsSetupCompleted":true},"nodes":[{"id":"ca8b122d-1739-4377-ac99-e20dd2341342","name":"Incoming Message","type":"n8n-nodes-base.telegramTrigger","position":[-1020,-320],"webhookId":"75921955-c8ed-4ff6-8de2-e436c6bbe69d","parameters":{"updates":["message"],"additionalFields":{}},"credentials":{"telegramApi":{"id":"ayMpCvQ69GjrbPdP","name":"gatu_pa_bot"}},"typeVersion":1.2},{"id":"68f7568b-e677-454b-a1e8-6c07a05e7570","name":"MCP Server Trigger","type":"@n8n/n8n-nodes-langchain.mcpTrigger","position":[-860,240],"webhookId":"562ffc95-cf8e-4d4d-8f5b-29b3ff22d5ee","parameters":{"path":"562ffc95-cf8e-4d4d-8f5b-29b3ff22d5ee"},"typeVersion":1},{"id":"635b8ecc-0f50-477d-8e19-631f868e30f6","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[340,-320],"parameters":{"options":{"systemMessage":"=You are a helpful assistant. Whenever askes to update a task, call the get_tasks tools first to retrieve the appropriate task ids then use that to update the tasks.\n\nToday's date: {{ $now }}\n"}},"typeVersion":1.8},{"id":"ab7740dc-bac2-4044-8317-40d90252d992","name":"MCP Client","type":"@n8n/n8n-nodes-langchain.mcpClientTool","position":[540,-100],"parameters":{"sseEndpoint":"https://ai.gatuservices.info/mcp/562ffc95-cf8e-4d4d-8f5b-29b3ff22d5ee/sse"},"typeVersion":1},{"id":"5298eee0-747a-496a-a3a2-e395f7c1caa1","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[300,-100],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"lcpI0YZU9bebg3uW","name":"OpenAi account"}},"typeVersion":1.2},{"id":"c5b7e10d-2d7c-403c-bcb5-a10033252f97","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[420,-100],"parameters":{"sessionKey":"={{ $('Incoming Message').item.json.message.from.id }}","sessionIdType":"customKey","contextWindowLength":20},"typeVersion":1.3},{"id":"06d2e8c8-3912-45cd-a074-4eea27c2e5eb","name":"chatInput","type":"n8n-nodes-base.set","position":[80,-220],"parameters":{"options":{},"assignments":{"assignments":[{"id":"ab70dc2d-35d0-4742-988f-ed7077633467","name":"chatInput","type":"string","value":"={{ $json.message.text }}"},{"id":"6439fc2c-dc2d-41fc-b8a3-b33ef80d2878","name":"id","type":"number","value":"={{ $json.message.from.id }}"}]}},"typeVersion":3.4},{"id":"a9309816-8c1d-435c-ad49-2e45053718c1","name":"create_todays_task","type":"n8n-nodes-base.googleTasksTool","position":[-1020,460],"parameters":{"task":"MDg2MzM1OTA5NzI0NzUzNjUwNjc6MDow","title":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Title', `Title summary of the task to be done`, 'string') }}","additionalFields":{"notes":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Notes', `Detailed description of the task`, 'string') }}","dueDate":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Due_Date', `Date the task should be completed`, 'string') }}","completed":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Completion_Date', `Date the task was completed`, 'string') }}"}},"credentials":{"googleTasksOAuth2Api":{"id":"8sBGA2BWJuF6SObU","name":"Connected Account"}},"typeVersion":1},{"id":"ad6cfc1a-7094-434a-98d1-a6f030067091","name":"chatOutput","type":"n8n-nodes-base.set","position":[740,-320],"parameters":{"options":{},"assignments":{"assignments":[{"id":"df6bd510-e63f-41b1-b5b4-d2c612d5b8d0","name":"chatOutput","type":"string","value":"={{ $json.output }}"}]}},"typeVersion":3.4},{"id":"e342066f-3cf8-4926-94df-798e831226be","name":"sendMessage","type":"n8n-nodes-base.telegram","position":[960,-320],"webhookId":"c5eb133f-338f-4918-8e49-83ac339d841b","parameters":{"text":"={{ $json.chatOutput }}","chatId":"={{ $('Incoming Message').item.json.message.chat.id }}","additionalFields":{"appendAttribution":false,"disable_notification":false}},"credentials":{"telegramApi":{"id":"ayMpCvQ69GjrbPdP","name":"gatu_pa_bot"}},"typeVersion":1.2},{"id":"e4a1bc16-549f-46a2-92a8-a06e6023089c","name":"create_upcoming_task","type":"n8n-nodes-base.googleTasksTool","position":[-900,460],"parameters":{"task":"OFVvNlh6ZmhScHVvNll4dw","title":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Title', `Title summary of the task to be done`, 'string') }}","additionalFields":{"notes":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Notes', `Detailed description of the task`, 'string') }}","dueDate":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Due_Date', `Date the task should be completed`, 'string') }}","completed":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Completion_Date', `Date the task was completed`, 'string') }}"}},"credentials":{"googleTasksOAuth2Api":{"id":"8sBGA2BWJuF6SObU","name":"Connected Account"}},"typeVersion":1},{"id":"df71bb02-016d-4d56-b80d-404a60c0e7cf","name":"complete_task","type":"n8n-nodes-base.googleTasksTool","position":[-780,460],"parameters":{"task":"RS1rbkNCS2JsdVFnVl80cg","taskId":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Task_ID', `The task id tom be marked as completed. Get it from the get tasks tool`, 'string') }}","operation":"update","updateFields":{}},"credentials":{"googleTasksOAuth2Api":{"id":"8sBGA2BWJuF6SObU","name":"Connected Account"}},"typeVersion":1},{"id":"a33812bd-986e-4762-87a0-199ff8a7c9aa","name":"get_todays_tasks","type":"n8n-nodes-base.googleTasksTool","position":[-660,460],"parameters":{"task":"MDg2MzM1OTA5NzI0NzUzNjUwNjc6MDow","operation":"getAll","returnAll":true,"additionalFields":{}},"credentials":{"googleTasksOAuth2Api":{"id":"8sBGA2BWJuF6SObU","name":"Connected Account"}},"typeVersion":1},{"id":"dcb3a6c9-5d7c-4fe6-8b52-f07cf74cfa0c","name":"get_upcoming_tasks","type":"n8n-nodes-base.googleTasksTool","position":[-540,460],"parameters":{"task":"OFVvNlh6ZmhScHVvNll4dw","operation":"getAll","returnAll":true,"additionalFields":{}},"credentials":{"googleTasksOAuth2Api":{"id":"8sBGA2BWJuF6SObU","name":"Connected Account"}},"typeVersion":1},{"id":"ce63c24a-ce2f-4e06-8ae5-7de75540d438","name":"Switch","type":"n8n-nodes-base.switch","position":[-800,-320],"parameters":{"rules":{"values":[{"outputKey":"Voice Note","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"8415cc8d-65a2-448e-a106-1ceb54634dfd","operator":{"type":"object","operation":"exists","singleValue":true},"leftValue":"={{ $json.message.voice }}","rightValue":""}]},"renameOutput":true}]},"options":{"fallbackOutput":"extra"}},"typeVersion":3.2},{"id":"a58488c3-38b8-4492-9f13-a900c7697812","name":"audio_id","type":"n8n-nodes-base.set","position":[-580,-420],"parameters":{"options":{},"assignments":{"assignments":[{"id":"eb7f5d62-e4f3-4b4e-9f1b-6c329feafb3e","name":"file_id","type":"string","value":"={{ $json.message.voice.file_id }}"},{"id":"803031b8-6b21-47fa-b339-ad674ccbbb1e","name":"file_unique_id","type":"string","value":"={{ $json.message.voice.file_unique_id }}"}]}},"typeVersion":3.4},{"id":"83c2ecae-b601-4669-b820-b5c35d3f936e","name":"download_audio","type":"n8n-nodes-base.telegram","position":[-360,-420],"webhookId":"c2dbc0eb-0f3a-4f11-9525-804bd5bef4b1","parameters":{"fileId":"={{ $json.file_id }}","resource":"file"},"credentials":{"telegramApi":{"id":"ayMpCvQ69GjrbPdP","name":"gatu_pa_bot"}},"typeVersion":1.2},{"id":"4a496e3a-2e3a-4ce0-9344-192847de1760","name":"transcribeAudio","type":"@n8n/n8n-nodes-langchain.openAi","position":[-140,-420],"parameters":{"options":{},"resource":"audio","operation":"transcribe"},"credentials":{"openAiApi":{"id":"lcpI0YZU9bebg3uW","name":"OpenAi account"}},"typeVersion":1.8},{"id":"38b6aa37-d279-4b1b-be42-7f7cc1bbe688","name":"audioInput","type":"n8n-nodes-base.set","position":[80,-420],"parameters":{"options":{},"assignments":{"assignments":[{"id":"d57b4fc2-10f7-46cd-a89c-0021a92f41d1","name":"chatInput","type":"string","value":"={{ $json.text }}"}]}},"typeVersion":3.4},{"id":"e524f12f-205f-4fc8-b2f0-b308ec4066b7","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-1060,-500],"parameters":{"color":4,"width":2180,"height":540,"content":"## Main Function to Receive and Send Telegram Messages\n"},"typeVersion":1},{"id":"709b252a-b5e8-4c7e-8bcd-a7092d588070","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-1060,140],"parameters":{"color":3,"width":640,"height":480,"content":"## MCP Server to Carry Out Actions"},"typeVersion":1}],"pinData":{"Incoming Message":[{"message":{"chat":{"id":6043747866,"type":"private","first_name":"Gatu"},"date":1745294191,"from":{"id":6043747866,"is_bot":false,"first_name":"Gatu","language_code":"en"},"voice":{"file_id":"AwACAgQAAxkBAAMYaAcTb6Sm3bpJ_8Cc2q1q4vC7MLYAAg8ZAAJAOjlQQhWQOxUBqfU2BA","duration":2,"file_size":9854,"mime_type":"audio/ogg","file_unique_id":"AgADDxkAAkA6OVA"},"message_id":24},"update_id":656804764}]},"connections":{"Switch":{"main":[[{"node":"audio_id","type":"main","index":0}],[{"node":"chatInput","type":"main","index":0}]]},"AI Agent":{"main":[[{"node":"chatOutput","type":"main","index":0}]]},"audio_id":{"main":[[{"node":"download_audio","type":"main","index":0}]]},"chatInput":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"MCP Client":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"audioInput":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"chatOutput":{"main":[[{"node":"sendMessage","type":"main","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"complete_task":{"ai_tool":[[{"node":"MCP Server Trigger","type":"ai_tool","index":0}]]},"download_audio":{"main":[[{"node":"transcribeAudio","type":"main","index":0}]]},"transcribeAudio":{"main":[[{"node":"audioInput","type":"main","index":0}]]},"Incoming Message":{"main":[[{"node":"Switch","type":"main","index":0}]]},"get_todays_tasks":{"ai_tool":[[{"node":"MCP Server Trigger","type":"ai_tool","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"create_todays_task":{"ai_tool":[[{"node":"MCP Server Trigger","type":"ai_tool","index":0}]]},"get_upcoming_tasks":{"ai_tool":[[{"node":"MCP Server Trigger","type":"ai_tool","index":0}]]},"create_upcoming_task":{"ai_tool":[[{"node":"MCP Server Trigger","type":"ai_tool","index":0}]]}}}


name: Build a Chatbot, Voice and Phone Agent with Voiceflow, Google Calendar and RAG
author_name: Davide
author_username: n3witalia
categories: []
created_at: 2025-04-22T06:42:30.604Z
updated_at: 2025-04-22T06:42:30.604Z
url: https://n8n.io/workflows/3657
scraped_at: 2025-06-19 22:49:04
description:
  Voiceflow is a no-code platform that allows you to design, prototype, and deploy conversational assistants across multiple channels—such as chat, voice, and phone—with advanced logic and natural language understanding. It supports integration with APIs, webhooks, and even tools like Twilio for phone agents. It's perfect for building customer support agents, voice bots, or intelligent assistants.

  This workflow connects n8n and Voiceflow with tools like Google Calendar, Qdrant (vector database), OpenAI, and an order tracking API to power a smart, multi-channel conversational agent.



  There are 3 main webhook endpoints in n8n that Voiceflow interacts with:

  n8n_order – receives user input related to order tracking, queries an API, and responds with tracking status.
  n8n_appointment – processes appointment booking, reformats date input using OpenAI, and creates a Google Calendar event.
  n8n_rag – handles general product/service questions using a RAG (Retrieval-Augmented Generation) system backed by:
     Google Drive document ingestion,
     Qdrant vector store for search,
     and OpenAI models for context-based answers.

  Each webhook is connected to a corresponding "Capture" block inside Voiceflow, which sends data to n8n and waits for the response.

  How It Works  
  This n8n workflow integrates Voiceflow for chatbot/voice interactions, Google Calendar for appointment scheduling, and RAG (Retrieval-Augmented Generation) for knowledge-based responses. Here’s the flow:  

  Trigger**:  
    Three webhooks (n8n_order, n8n_appointment, n8n_rag) receive inputs from Voiceflow (chat, voice, or phone calls).  
    Each webhook routes requests to specific functions:  
      Order Tracking: Fetches order status via an external API.  
      Appointment Scheduling: Uses OpenAI to parse dates, creates Google Calendar events, and confirms via WhatsApp.  
      RAG System: Queries a Qdrant vector store (populated with Google Drive documents) to answer customer questions using GPT-4.  

  AI Processing**:  
    OpenAI Chains: Convert natural language dates to Google Calendar formats and generate responses.  
    RAG Pipeline: Embeds documents (via OpenAI), stores them in Qdrant, and retrieves context-aware answers.  
    Voiceflow Integration: Routes responses back to Voiceflow for multi-channel delivery (chat, voice, or phone).  

  Outputs**:  
    Confirmation messages (e.g., "Event created successfully").  
    Dynamic responses for orders, appointments, or product support. 

  Setup Steps  

  Prerequisites:  
  APIs**:  
    Google Calendar & Drive OAuth credentials.  
    Qdrant vector database (hosted or cloud).  
    OpenAI API key (for GPT-4 and embeddings).  

  Configuration:  
  Qdrant Setup:  
     Run the "Create collection" and "Refresh collection" nodes to initialize the vector store.  
     Populate it with documents using the Google Drive → Qdrant pipeline (embeddings generated via OpenAI).  

  Voiceflow Webhooks:  
     Link Voiceflow’s "Captures" to n8n’s webhook URLs (n8n_order, n8n_appointment, n8n_rag).  

  Google Calendar:  
     Authenticate the Google Calendar node and set event templates (e.g., summary, description).  

  RAG System:  
     Configure the Qdrant vector store and OpenAI embeddings nodes.  
     Adjust the Retrieve Agent’s system prompt for domain-specific queries (e.g., electronics store support).   

  Optional:  
  Add Twilio for phone-agent capabilities.  
  Customize OpenAI prompts for tone/accuracy.  




  PS. You can import a Twilio number to assign it to your agent for becoming a Phone Agent

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

nodes_used:
  ["n8n-nodes-base.httpRequest","n8n-nodes-base.googleDrive","n8n-nodes-base.googleCalendar","@n8n/n8n-nodes-langchain.agent","@n8n/n8n-nodes-langchain.chainLlm","@n8n/n8n-nodes-langchain.embeddingsOpenAi","@n8n/n8n-nodes-langchain.lmChatOpenAi","@n8n/n8n-nodes-langchain.outputParserStructured","@n8n/n8n-nodes-langchain.textSplitterTokenSplitter","@n8n/n8n-nodes-langchain.documentDefaultDataLoader","@n8n/n8n-nodes-langchain.vectorStoreQdrant","@n8n/n8n-nodes-langchain.toolVectorStore"]

workflow_json:
  {"id":"MMDt8lGtac2oU8nI","meta":{"instanceId":"a4bfc93e975ca233ac45ed7c9227d84cf5a2329310525917adaf3312e10d5462","templateCredsSetupCompleted":true},"name":"Build a Chatbot, Voice Agent and Phone Agent with Voiceflow, Google Calendar and RAG","tags":[],"nodes":[{"id":"20605948-5277-4fd7-9ba0-63f645bf2dcc","name":"n8n_order","type":"n8n-nodes-base.webhook","position":[-340,-140],"webhookId":"9ff7a394-5b4b-4790-a96b-c41c4ba27fa5","parameters":{"path":"9ff7a394-5b4b-4790-a96b-c41c4ba27fa5","options":{},"responseMode":"responseNode"},"typeVersion":2},{"id":"9ef7971e-f679-4d5e-b347-3238d51a06d6","name":"Google Calendar","type":"n8n-nodes-base.googleCalendar","position":[300,280],"parameters":{"end":"={{ $json.output.end }}","start":"={{ $json.output.start }}","calendar":{"__rl":true,"mode":"list","value":"info@n3w.it","cachedResultName":"info@n3w.it"},"additionalFields":{"summary":"=Event title with {{ $('n8n_appointment').item.json.query.Email }}","description":"Event description"}},"credentials":{"googleCalendarOAuth2Api":{"id":"8RFK3u13g2PJEGa9","name":"Google Calendar account"}},"typeVersion":1.3},{"id":"17b9f162-c4a3-43ec-b640-a68ebc67b0c9","name":"OpenAI Chat Model3","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-120,480],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"4zwP0MSr8zkNvvV9","name":"OpenAi account"}},"typeVersion":1.2},{"id":"5b40db3c-6c98-4fea-9c3b-98ba7e13bc30","name":"Concert start date","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[-80,280],"parameters":{"text":"=Convert this date to a compatible format for Google Calendar APIs for the start date, and for the end date add 1 hour to the start date.\n\nHere is the start date:\n{{ $json.query.Appointment_date }}","promptType":"define","hasOutputParser":true},"typeVersion":1.6},{"id":"8931d21a-7c30-40ae-b0b0-1f5f6868b3a3","name":"n8n_appointment","type":"n8n-nodes-base.webhook","position":[-340,280],"webhookId":"f5edfe92-649b-40da-ab35-f818ccb55ad4","parameters":{"path":"f5edfe92-649b-40da-ab35-f818ccb55ad4","options":{},"responseMode":"responseNode"},"typeVersion":2},{"id":"fa3e66ca-de09-496b-be14-483b33386e07","name":"Retrive Qdrant Vector Store","type":"@n8n/n8n-nodes-langchain.vectorStoreQdrant","position":[20,1280],"parameters":{"options":{},"qdrantCollection":{"__rl":true,"mode":"list","value":"scarperia","cachedResultName":"scarperia"}},"credentials":{"qdrantApi":{"id":"iyQ6MQiVaF3VMBmt","name":"QdrantApi account"}},"typeVersion":1},{"id":"ea7be112-1949-47b7-b68b-ae2f3a7b1b71","name":"Embeddings OpenAI2","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[-20,1460],"parameters":{"options":{}},"credentials":{"openAiApi":{"id":"4zwP0MSr8zkNvvV9","name":"OpenAi account"}},"typeVersion":1.2},{"id":"e61ff57f-a109-41e0-87f3-522b1fa78dd6","name":"RAG","type":"@n8n/n8n-nodes-langchain.toolVectorStore","position":[180,1080],"parameters":{"name":"company_data","description":"Retrive data about company knowledge from vector store"},"typeVersion":1},{"id":"fce158b8-73a3-42c1-baf3-9f2ae979fe15","name":"OpenAI Chat Model2","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-20,1080],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"4zwP0MSr8zkNvvV9","name":"OpenAi account"}},"typeVersion":1.2},{"id":"e2bcfa68-3642-4e49-89cb-e08faade984c","name":"OpenAI Chat Model1","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[340,1300],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"4zwP0MSr8zkNvvV9","name":"OpenAi account"}},"typeVersion":1.2},{"id":"2a79c66c-040b-4ca2-ad91-a0683d0d2996","name":"Retrive Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[60,860],"parameters":{"text":"={{ $json.query.Question }}","agent":"conversationalAgent","options":{"systemMessage":"You are an AI-powered assistant for an electronics store. Your primary goal is to assist customers by providing accurate and helpful information about products, troubleshooting tips, and general support. Use the provided knowledge base (retrieved documents) to answer questions with precision and professionalism.\n\n**Guidelines**:\n1. **Product Information**:\n   - Provide detailed descriptions of products, including specifications, features, and compatibility.\n   - Highlight key selling points and differences between similar products.\n   - Mention availability, pricing, and promotions if applicable.\n\n2. **Technical Support**:\n   - Offer step-by-step troubleshooting guides for common issues.\n   - Suggest solutions for setup, installation, or configuration problems.\n   - If the issue is complex, recommend contacting the store’s support team for further assistance.\n\n3. **Customer Service**:\n   - Respond politely and professionally to all inquiries.\n   - If a question is unclear, ask for clarification to provide the best possible answer.\n   - For order-related questions (e.g., status, returns, or cancellations), guide customers on how to proceed using the store’s systems.\n\n4. **Knowledge Base Usage**:\n   - Always reference the provided knowledge base (retrieved documents) to ensure accuracy.\n   - If the knowledge base does not contain relevant information, inform the customer and suggest alternative resources or actions.\n\n5. **Tone and Style**:\n   - Use a friendly, approachable, and professional tone.\n   - Avoid technical jargon unless the customer demonstrates familiarity with the topic.\n   - Keep responses concise but informative.\n\n**Example Interactions**:\n1. **Product Inquiry**:\n   - Customer: \"What’s the difference between the XYZ Smartwatch and the ABC Smartwatch?\"\n   - AI: \"The XYZ Smartwatch features a longer battery life (up to 7 days) and built-in GPS, while the ABC Smartwatch has a brighter AMOLED display and supports wireless charging. Both are compatible with iOS and Android devices. Would you like more details on either product?\"\n\n2. **Technical Support**:\n   - Customer: \"My wireless router isn’t connecting to the internet.\"\n   - AI: \"Please try the following steps: 1) Restart your router and modem. 2) Ensure all cables are securely connected. 3) Check if the router’s LED indicators show a stable connection. If the issue persists, you may need to reset the router to factory settings. Would you like a detailed guide for resetting your router?\"\n\n3. **Customer Service**:\n   - Customer: \"How do I return a defective product?\"\n   - AI: \"To return a defective product, please visit our Returns Portal on our website and enter your order number. You’ll receive a return label and instructions. If you need further assistance, our support team is available at support@electronicsstore.com.\"\n\n**Limitations**:\n- If the question is outside the scope of the knowledge base or requires human intervention, inform the customer and provide contact details for the appropriate department.\n- Do not provide speculative or unverified information. Always rely on the knowledge base or direct the customer to official resources."},"promptType":"define"},"typeVersion":1.7},{"id":"be516c9c-d2fb-4dea-9a3b-9674be5ea689","name":"n8n_rag","type":"n8n-nodes-base.webhook","position":[-360,860],"webhookId":"edb1e894-1210-4902-a34f-a014bbdad8d8","parameters":{"path":"edb1e894-1210-4902-a34f-a014bbdad8d8","options":{},"responseMode":"responseNode"},"typeVersion":2},{"id":"2412721d-7353-4a27-8068-5c90872c7a51","name":"Tracking response","type":"n8n-nodes-base.set","position":[360,-140],"parameters":{"options":{},"assignments":{"assignments":[{"id":"86f332ff-7b89-4dd4-8df9-06c081625d33","name":"text","type":"string","value":"=Your order status is: {{ $json.status }}"}]}},"typeVersion":3.4},{"id":"4965d781-1452-42c9-8a84-baacb5abe97f","name":"Calendar response","type":"n8n-nodes-base.set","position":[500,280],"parameters":{"options":{},"assignments":{"assignments":[{"id":"0fe6fe50-9263-479a-ab01-ca1d15ce2412","name":"text","type":"string","value":"L'evento è stato creato con successo"}]}},"typeVersion":3.4},{"id":"5311be28-2878-41ce-a70f-4e4aebcea0f9","name":"Webhook tracking response","type":"n8n-nodes-base.respondToWebhook","position":[700,-140],"parameters":{"options":{}},"typeVersion":1.1},{"id":"84d8558f-e6fd-400e-ae2e-0b5fec309561","name":"API URL Tracking","type":"n8n-nodes-base.httpRequest","position":[20,-140],"parameters":{"url":"URL_TRACKING","options":{},"sendBody":true,"bodyParameters":{"parameters":[{"name":"Order number","value":"={{ $json.Order_number }}"},{"name":"Email","value":"={{ $json.Order_number }}"}]}},"typeVersion":4.2},{"id":"32eb8645-c56e-4db4-8870-f28161cba048","name":"Webhook calendar response","type":"n8n-nodes-base.respondToWebhook","position":[700,280],"parameters":{"options":{}},"typeVersion":1.1},{"id":"72e7f085-d1e7-4967-aaa5-161ff0e83c06","name":"Structured Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[140,480],"parameters":{"schemaType":"manual","inputSchema":"{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"start\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"end\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t}\n}"},"typeVersion":1.2},{"id":"3822b875-73f0-4700-8fc4-e4d3285f593a","name":"Webhook RAG response","type":"n8n-nodes-base.respondToWebhook","position":[700,860],"parameters":{"options":{}},"typeVersion":1.1},{"id":"0b43f63b-3c00-4db4-8b28-9938add9fdbe","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[1100,-1320],"parameters":{"width":1140,"height":2200,"content":"# STEP 6 - VOICEFLOW\n\n- Register on [Voiceflow](https://www.voiceflow.com/) \n- Create the workflow as shown in the following image\n![image](https://i.postimg.cc/3rSPwMn2/langflow.png)\n- There are 3 \"Captures\":\n-- n8n_order\n-- n8n_appointment\n-- n8n_rag\n- Add in the created functions the url of the corresponding n8n Webhook trigger node\n- Test your Agent\n- Get your projectID\n- In the Widget section choose Chat or Voice and copy the installation script\n![image](https://i.postimg.cc/855gyTZP/voiceflow-agent.png)\n![image](https://i.postimg.cc/5Nn4Sk43/voiceflow-agent2.png)\n\nPS. You can import a Twilio number to assign it to your agent for becoming a Phone Agent\n![image](https://i.postimg.cc/cLymTTFv/voiceflow-agent3.png)\n\n"},"typeVersion":1},{"id":"589165c8-920d-40e3-8e28-50e94dd37555","name":"When clicking ‘Test workflow’","type":"n8n-nodes-base.manualTrigger","position":[-380,-1120],"parameters":{},"typeVersion":1},{"id":"74c314bb-c445-42f8-8f9d-2ab646486044","name":"Qdrant Vector Store","type":"@n8n/n8n-nodes-langchain.vectorStoreQdrant","position":[600,-1000],"parameters":{"mode":"insert","options":{},"qdrantCollection":{"__rl":true,"mode":"id","value":"="}},"credentials":{"qdrantApi":{"id":"iyQ6MQiVaF3VMBmt","name":"QdrantApi account"}},"typeVersion":1},{"id":"01c05ac3-ac5c-4f1a-a756-db8de4a30e56","name":"Create collection","type":"n8n-nodes-base.httpRequest","position":[-80,-1260],"parameters":{"url":"https://QDRANTURL/collections/COLLECTION","method":"POST","options":{},"jsonBody":"{\n  \"filter\": {}\n}","sendBody":true,"sendHeaders":true,"specifyBody":"json","authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","headerParameters":{"parameters":[{"name":"Content-Type","value":"application/json"}]}},"credentials":{"httpHeaderAuth":{"id":"qhny6r5ql9wwotpn","name":"Qdrant API (Hetzner)"}},"typeVersion":4.2},{"id":"2d7adb45-aae7-4617-b1d1-5a23f3eb3b20","name":"Refresh collection","type":"n8n-nodes-base.httpRequest","position":[-80,-1000],"parameters":{"url":"https://QDRANTURL/collections/COLLECTION/points/delete","method":"POST","options":{},"jsonBody":"{\n  \"filter\": {}\n}","sendBody":true,"sendHeaders":true,"specifyBody":"json","authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","headerParameters":{"parameters":[{"name":"Content-Type","value":"application/json"}]}},"credentials":{"httpHeaderAuth":{"id":"qhny6r5ql9wwotpn","name":"Qdrant API (Hetzner)"}},"typeVersion":4.2},{"id":"5e406bd7-8a93-4db2-8d3d-e92e8c9f4f01","name":"Get folder","type":"n8n-nodes-base.googleDrive","position":[140,-1000],"parameters":{"filter":{"driveId":{"__rl":true,"mode":"list","value":"My Drive","cachedResultUrl":"https://drive.google.com/drive/my-drive","cachedResultName":"My Drive"},"folderId":{"__rl":true,"mode":"id","value":"=test-whatsapp"}},"options":{},"resource":"fileFolder"},"credentials":{"googleDriveOAuth2Api":{"id":"HEy5EuZkgPZVEa9w","name":"Google Drive account (n3w.it)"}},"typeVersion":3},{"id":"f1f883fb-c9d1-42e6-98c2-791ed85e959f","name":"Download Files","type":"n8n-nodes-base.googleDrive","position":[360,-1000],"parameters":{"fileId":{"__rl":true,"mode":"id","value":"={{ $json.id }}"},"options":{"googleFileConversion":{"conversion":{"docsToFormat":"text/plain"}}},"operation":"download"},"credentials":{"googleDriveOAuth2Api":{"id":"HEy5EuZkgPZVEa9w","name":"Google Drive account (n3w.it)"}},"typeVersion":3},{"id":"5fd88e03-3638-4d38-8df4-246e4a5f2bda","name":"Embeddings OpenAI","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[580,-800],"parameters":{"options":{}},"credentials":{"openAiApi":{"id":"4zwP0MSr8zkNvvV9","name":"OpenAi account"}},"typeVersion":1.1},{"id":"3740a841-e272-44f9-b76d-51fb90137fd3","name":"Default Data Loader","type":"@n8n/n8n-nodes-langchain.documentDefaultDataLoader","position":[760,-800],"parameters":{"options":{},"dataType":"binary"},"typeVersion":1},{"id":"075d1038-d1fd-4527-8eda-961f20c7869a","name":"Token Splitter","type":"@n8n/n8n-nodes-langchain.textSplitterTokenSplitter","position":[760,-600],"parameters":{"chunkSize":300,"chunkOverlap":30},"typeVersion":1},{"id":"57cc8eaf-26b3-480f-ab5d-c8646519cfa3","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[120,-1320],"parameters":{"color":6,"width":880,"height":220,"content":"# STEP 1\n\n## Create Qdrant Collection\nChange:\n- QDRANTURL\n- COLLECTION"},"typeVersion":1},{"id":"70bc0676-c0ea-4de8-8659-bfb8b0ea653f","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-100,-1060],"parameters":{"color":4,"width":620,"height":400,"content":"# STEP 2\n\n\n\n\n\n\n\n\n\n\n\n\n## Documents vectorization with Qdrant and Google Drive\nChange:\n- QDRANTURL\n- COLLECTION"},"typeVersion":1},{"id":"411c4f55-ae41-49b5-a821-df1a3d8fefec","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-380,660],"parameters":{"color":5,"width":1220,"content":"# STEP 5\nIf required retrive the informations by RAG system"},"typeVersion":1},{"id":"49d1fe78-4c38-4508-84c3-3a571ad9a2b0","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[-360,-360],"parameters":{"color":5,"width":1220,"content":"# STEP 3\nIf required retrive the informations by Order system\n- Set your API URL Tracking service"},"typeVersion":1},{"id":"23d42754-0126-4b3a-91b0-b489ef83b36c","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[-360,80],"parameters":{"color":5,"width":1220,"content":"# STEP 4\nIf required retrive the informations by Appointment system"},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"20a19983-4edb-4179-a2d2-e2f53d0daf85","connections":{"RAG":{"ai_tool":[[{"node":"Retrive Agent","type":"ai_tool","index":0}]]},"n8n_rag":{"main":[[{"node":"Retrive Agent","type":"main","index":0}]]},"n8n_order":{"main":[[{"node":"API URL Tracking","type":"main","index":0}]]},"Get folder":{"main":[[{"node":"Download Files","type":"main","index":0}]]},"Retrive Agent":{"main":[[{"node":"Webhook RAG response","type":"main","index":0}]]},"Download Files":{"main":[[{"node":"Qdrant Vector Store","type":"main","index":0}]]},"Token Splitter":{"ai_textSplitter":[[{"node":"Default Data Loader","type":"ai_textSplitter","index":0}]]},"Google Calendar":{"main":[[{"node":"Calendar response","type":"main","index":0}]]},"n8n_appointment":{"main":[[{"node":"Concert start date","type":"main","index":0}]]},"API URL Tracking":{"main":[[{"node":"Tracking response","type":"main","index":0}]]},"Calendar response":{"main":[[{"node":"Webhook calendar response","type":"main","index":0}]]},"Embeddings OpenAI":{"ai_embedding":[[{"node":"Qdrant Vector Store","type":"ai_embedding","index":0}]]},"Tracking response":{"main":[[{"node":"Webhook tracking response","type":"main","index":0}]]},"Concert start date":{"main":[[{"node":"Google Calendar","type":"main","index":0}]]},"Embeddings OpenAI2":{"ai_embedding":[[{"node":"Retrive Qdrant Vector Store","type":"ai_embedding","index":0}]]},"OpenAI Chat Model1":{"ai_languageModel":[[{"node":"RAG","type":"ai_languageModel","index":0}]]},"OpenAI Chat Model2":{"ai_languageModel":[[{"node":"Retrive Agent","type":"ai_languageModel","index":0}]]},"OpenAI Chat Model3":{"ai_languageModel":[[{"node":"Concert start date","type":"ai_languageModel","index":0}]]},"Refresh collection":{"main":[[{"node":"Get folder","type":"main","index":0}]]},"Default Data Loader":{"ai_document":[[{"node":"Qdrant Vector Store","type":"ai_document","index":0}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"Concert start date","type":"ai_outputParser","index":0}]]},"Retrive Qdrant Vector Store":{"ai_vectorStore":[[{"node":"RAG","type":"ai_vectorStore","index":0}]]},"When clicking ‘Test workflow’":{"main":[[{"node":"Create collection","type":"main","index":0},{"node":"Refresh collection","type":"main","index":0}]]}}}


name: Real Estate Lead Generation with BatchData Skip Tracing & CRM Integration
author_name: Preston Zeller
author_username: zellerhaus
categories: []
created_at: 2025-04-22T21:27:31.650Z
updated_at: 2025-04-22T21:27:31.650Z
url: https://n8n.io/workflows/3666
scraped_at: 2025-06-19 22:50:38
description:
  How It Works
  This workflow automates the entire property lead generation process in a few simple steps:

  Property Search: Connects to BatchData's Property Search API with customizable parameters (location, property type, value range, equity percentage, etc.)
  Lead Filtering & Scoring: Processes results to identify the most promising leads based on criteria like absentee ownership, years owned, equity percentage, and tax status. Each property receives a lead score to prioritize follow-up.
  Skip Tracing: Automatically retrieves owner contact information (phone, email, mailing address) for each qualified property.
  Data Formatting: Structures all property and owner data into a clean, organized format ready for your systems.
  Multi-Channel Output:
  Generates an Excel spreadsheet with all lead details
  Pushes leads directly to your CRM (configurable for HubSpot, Salesforce, etc.)
  Sends a summary email with the spreadsheet attached



  The workflow can run on a daily schedule or be triggered manually as needed. All parameters are easily configurable through dedicated nodes, requiring no coding knowledge.

  Who's It For
  This workflow is perfect for:

  Real Estate Investors looking to find off-market properties with motivated sellers
  Real Estate Agents who want to generate listing leads from distressed or high-equity properties
  Investment Companies that need regular lead flow for acquisitions
  Real Estate Marketers who run targeted campaigns to property owners
  Wholesalers seeking to build a pipeline of potential deals
  Property Service Providers (roof repair, renovation contractors, etc.) who target specific property types

  Anyone who needs reliable, consistent lead generation for real estate without the manual work of searching, filtering, and organizing property data will benefit from this automation.

  About BatchData
  BatchData is a comprehensive property data provider that offers access to nationwide property information, owner details, and skip tracing services. Key features include:

  Extensive Database: Covers 150+ million properties across all 50 states
  Rich Property Data: Includes ownership information, tax records, sales history, valuation estimates, equity positions, and more
  Skip Tracing Services: Provides owner contact information including phone numbers, email addresses, and mailing addresses
  Distressed Property Indicators: Flags for pre-foreclosure, tax delinquency, vacancy, and other motivation factors
  RESTful API: Professional API for programmatic access to all property data services
  Regular Updates: Continuously refreshed data for accurate information

  BatchData's services are designed for real estate professionals who need reliable property and owner information to power their marketing and acquisition strategies. Their API-first approach makes it ideal for workflow automation tools like N8N.

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

workflow_json:
  {"id":"RGVS0tHJV7Wh6aX4","meta":{"instanceId":"bb9853d4d7d87207561a30bc6fe4ece20b295264f7d27d4a62215de2f3846a56"},"name":"Property Lead Contact Enrichment from CRM","tags":[],"nodes":[{"id":"518b14de-23b9-4821-930c-8fa55eb4cfb4","name":"When clicking \"Execute Workflow\"","type":"n8n-nodes-base.manualTrigger","position":[-340,280],"parameters":{},"typeVersion":1},{"id":"939df2a3-f6dd-40c9-a01a-460923a332a6","name":"Daily Schedule","type":"n8n-nodes-base.scheduleTrigger","position":[-340,100],"parameters":{"rule":{"interval":[{}]}},"typeVersion":1.1},{"id":"3228372f-ac40-4898-8bf5-09a4f37fde85","name":"Search Properties API","type":"n8n-nodes-base.httpRequest","position":[320,260],"parameters":{"url":"https://api.batchdata.com/api/v1/property/search","method":"POST","options":{},"jsonBody":"={\n  \"searchCriteria\": {\n    \"query\": \"{{ $json.city }}, {{ $json.state }}\",\n    \"quickList\": \"{{ $json.quicklist }}\",\n    \"valuation\": {\n      \"estimatedValue\":{\"min\": {{ $json.minValue }}, \"max\": {{ $json.maxValue }}},\n      \"equityPercent\":{\"min\": {{ $json.equityMin }}} \n    },\n    \"general\": {\n      \"propertyTypeDetail\": {\"equals\": \"{{ $json.propertyType }}\"}\n    }\n  },\n  \"options\": {\n    \"skip\": 0,\n    \"take\": {{ $json.propertiesToTake }}\n    }\n}","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"Authorization","value":"=Bearer {{ $json.APIkey }}"}]}},"typeVersion":4.1},{"id":"0aa1fb95-66c8-4b61-81f5-04b37e5c1185","name":"Configure Search Parameters","type":"n8n-nodes-base.set","position":[40,240],"parameters":{"values":{"string":[{"name":"city","value":"=Austin"},{"name":"state","value":"Texas"},{"name":"propertyType","value":"Single Family"},{"name":"minValue","value":"200000"},{"name":"maxValue","value":"500000"},{"name":"quicklist","value":"out-of-state-owner"},{"name":"equityMin","value":"30"},{"name":"propertiesToTake","value":"2"},{"name":"APIkey","value":"REPLACE ME"}]},"options":{}},"typeVersion":2},{"id":"2c183cc1-06a1-4528-82c3-df2585df58eb","name":"Get Owner Contact Info","type":"n8n-nodes-base.httpRequest","position":[800,220],"parameters":{"url":"https://api.batchdata.com/api/v1/property/skip-trace","method":"POST","options":{},"jsonBody":"={\n  \"requests\": [\n    {\n      \"propertyAddress\": {\n        \"street\": \"{{ $json.address.street }}\",\n        \"city\": \"{{ $json.address.city }}\",\n        \"state\": \"{{ $json.address.state }}\"\n      }\n    }\n  ]\n} ","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"Authorization","value":"=Bearer {{ $('Configure Search Parameters').item.json.APIkey }}"}]}},"typeVersion":4.1},{"id":"2fe0aef9-30d2-4c30-9029-571f3b4c8ca9","name":"Format Lead Data","type":"n8n-nodes-base.code","position":[980,300],"parameters":{"jsCode":"const output = [];\n\n$input.all().forEach(item => {\n  const persons = ((item.json.results || {}).persons) || [];\n  persons.forEach(person => {\n    // Owner info\n    const owner_name = `${person.name.first || \"\"} ${person.name.middle || \"\"} ${person.name.last || \"\"}`.trim();\n    const property = person.property || {};\n    const propAddress = person.propertyAddress || {};\n    const mailing = person.mailingAddress || {};\n\n    // Property meta\n    const property_id = property.id || \"\";\n    const address = propAddress.street || \"\";\n    const city = propAddress.city || \"\";\n    const state = propAddress.state || \"\";\n    const zip = propAddress.zip || \"\";\n\n    // Property info\n    const absentee_owner = (property.absenteeOwner === true) ? \"Yes\" : \"No\";\n    const equity = property.equity || \"\";\n    const equity_percent = property.equityPercent || \"\";\n    const owner_mailing_address = mailing.street || \"\";\n    const owner_mailing_city = mailing.city || \"\";\n    const owner_mailing_state = mailing.state || \"\";\n    const owner_mailing_zip = mailing.zip || \"\";\n\n    // Create row object with basic info\n    const row = {\n      owner_name,\n      property_id,\n      address,\n      city,\n      state,\n      zip,\n      absentee_owner,\n      equity,\n      equity_percent,\n      owner_mailing_address,\n      owner_mailing_city,\n      owner_mailing_state,\n      owner_mailing_zip,\n      lead_source: 'BatchData Property Search',\n      date_added: new Date().toISOString().split('T')[0]\n    };\n\n    // Add phones as phone_1, phone_2, etc.\n    (person.phoneNumbers || []).forEach((phone, idx) => {\n      const n = idx + 1;\n      row[`phone_${n}`] = phone.number;\n      row[`phone_${n}_type`] = phone.type;\n      row[`phone_${n}_carrier`] = phone.carrier;\n      row[`phone_${n}_tested`] = phone.tested ? \"Yes\" : \"No\";\n      row[`phone_${n}_reachable`] = phone.reachable ? \"Yes\" : \"No\";\n      row[`phone_${n}_dnc`] = phone.dnc ? \"Yes\" : \"No\";\n      row[`phone_${n}_last_reported`] = phone.lastReportedDate;\n      row[`phone_${n}_score`] = phone.score;\n    });\n\n    // Add emails as email_1, email_2, etc.\n    (person.emails || []).forEach((email, idx) => {\n      const n = idx + 1;\n      row[`email_${n}`] = email.address || email;\n    });\n\n    output.push(row);\n  });\n});\n\nreturn output.map(row => ({ json: row }));\n"},"typeVersion":2},{"id":"013469c2-1e83-44e0-b078-c0b3d052a2c5","name":"Create Excel Spreadsheet","type":"n8n-nodes-base.spreadsheetFile","position":[1320,160],"parameters":{"options":{"fileName":"=Property_Leads_BatchData_{{ $now.format('LL/dd/yyyy') }}.xlsx","headerRow":true},"operation":"toFile","fileFormat":"xlsx"},"typeVersion":2},{"id":"954c492a-7da2-4902-99ab-318d4ea6e333","name":"Push to CRM","type":"n8n-nodes-base.hubspot","position":[1320,540],"parameters":{"email":"=$json[\"email\"]","options":{},"additionalFields":{}},"typeVersion":2},{"id":"61bfd72b-8971-4298-8d2a-09baea403956","name":"Email Notification","type":"n8n-nodes-base.emailSend","position":[1560,360],"webhookId":"e9459278-1cd9-47bb-bffd-88380d297217","parameters":{"options":{},"subject":"Property Lead Report - {{ $now.format('YYYY-MM-DD') }}","toEmail":"your-email@yourdomain.com","fromEmail":"no-reply@yourdomain.com"},"typeVersion":2.1},{"id":"a79a0618-ac63-4aaf-8337-b9ccc5940eef","name":"Summarize Results","type":"n8n-nodes-base.code","position":[1320,360],"parameters":{"jsCode":"// Summarize the results of the property lead search\nconst leads = $input.all();\nconst totalLeads = leads.length;\n\n// Calculate the highest lead score\nlet highestScore = 0;\nif (totalLeads > 0) {\n  highestScore = Math.max(...leads.map(item => item.json.lead_score || 0));\n}\n\n// Return a summary object\nreturn {\n  json: {\n    total_leads: totalLeads,\n    highest_score: highestScore,\n    execution_date: new Date().toISOString(),\n    success: true\n  }\n};"},"typeVersion":2},{"id":"cf6bbc2b-4892-4612-aee9-7f255f627a67","name":"Sticky Note - Workflow Overview","type":"n8n-nodes-base.stickyNote","position":[-420,-520],"parameters":{"width":800,"height":280,"content":"# Property Lead Automation Workflow\n\nThis workflow automatically searches for potential real estate leads based on configured criteria, obtains owner contact information through skip tracing, and pushes the leads to your CRM. It can be run manually or scheduled to run daily.\n\n## Steps: Property Search → Filter Results → Skip Trace → Format Data → Export (Excel & CRM)"},"typeVersion":1},{"id":"ff155460-3f4e-44e8-aac7-4b84dff2dceb","name":"Sticky Note - Triggers","type":"n8n-nodes-base.stickyNote","position":[-420,-160],"parameters":{"color":2,"width":320,"height":620,"content":"## Workflow Triggers\n\nThis workflow can be triggered in two ways:\n\n1. **Scheduled Trigger** - Runs automatically every day at the specified time\n\n2. **Manual Trigger** - Run the workflow on-demand by clicking Execute"},"typeVersion":1},{"id":"8c127497-0dc4-428d-a946-14c10b9572cb","name":"Sticky Note - Property Search","type":"n8n-nodes-base.stickyNote","position":[-80,-180],"parameters":{"color":4,"width":320,"height":650,"content":"## Search Configuration\n\nConfigure your property search criteria including:\n\n- Location (city, state, zip)\n- Property type\n- Value range\n- Equity percentage\n- Owner status\n- And more\n\nEdit the 'search_parameters' in the Set node to customize your search criteria."},"typeVersion":1},{"id":"20ad7c5e-5d73-4b43-b5b0-6c9eaae18400","name":"Sticky Note - Data Processing","type":"n8n-nodes-base.stickyNote","position":[260,-180],"parameters":{"color":5,"width":880,"height":660,"content":"## Property Data Processing\n\n1. **Search Properties API** - Connect to BatchData to search for properties\n\n2. **Filter Property Results** - Apply additional filtering logic and calculate lead scores based on factors like:\n   - Equity percentage\n   - Years of ownership\n   - Owner occupancy status\n   - Tax delinquency\n   - Recent sales activity\n\n3. **Get Owner Contact Info** - Skip trace each property to find owner contact details\n\n4. **Format Lead Data** - Structure the data for CRM and reporting"},"typeVersion":1},{"id":"a0254233-a0af-43b2-8258-0820d8fdd49d","name":"Sticky Note - Output","type":"n8n-nodes-base.stickyNote","position":[1180,-180],"parameters":{"color":6,"width":560,"height":920,"content":"## Lead Output Options\n\n1. **Create Excel Spreadsheet** - Generates an Excel file with all property leads and details\n\n2. **Push to CRM** - Adds leads to your CRM system (HubSpot in this example, but can be changed to Salesforce, Zoho, etc.)\n\n3. **Email Notification** - Sends a summary email with the Excel file attached\n\n4. **Summarize Results** - Provides a summary of the execution results"},"typeVersion":1},{"id":"cd34cafe-5a92-4ac3-b585-77c07862db22","name":"Filter","type":"n8n-nodes-base.filter","position":[480,200],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"cee6d210-4a90-4ad6-bbda-77153c21d3b4","operator":{"type":"dateTime","operation":"before"},"leftValue":"={{ $json.results.properties[0].deedHistory[0].recordingDate }}","rightValue":"2024-06-02T00:00:00"},{"id":"99089667-9c68-48d7-ad09-24a5ce301a70","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.results.properties[0].mls.status }}","rightValue":"Off Market"},{"id":"261c72c7-7208-462c-860d-148f19d3922d","operator":{"type":"number","operation":"lt"},"leftValue":"={{ $json.results.properties[0].openLien.mortgages[0].ltv }}","rightValue":70},{"id":"0a18f08e-86ea-4859-85db-2137c2186d11","operator":{"type":"boolean","operation":"true","singleValue":true},"leftValue":"={{ $json.results.properties[0].quickLists.highEquity }}","rightValue":"true"}]}},"typeVersion":2.2},{"id":"d30c51d7-9f2d-4804-9fec-036b41ebf5a8","name":"Split Out","type":"n8n-nodes-base.splitOut","position":[640,300],"parameters":{"options":{},"fieldToSplitOut":"results.properties"},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"a13b74ed-bc3d-4bed-9f72-4a31de5d9bbc","connections":{"Filter":{"main":[[{"node":"Split Out","type":"main","index":0}]]},"Split Out":{"main":[[{"node":"Get Owner Contact Info","type":"main","index":0}]]},"Daily Schedule":{"main":[[{"node":"Configure Search Parameters","type":"main","index":0}]]},"Format Lead Data":{"main":[[{"node":"Create Excel Spreadsheet","type":"main","index":0},{"node":"Push to CRM","type":"main","index":0},{"node":"Summarize Results","type":"main","index":0}]]},"Summarize Results":{"main":[[{"node":"Email Notification","type":"main","index":0}]]},"Search Properties API":{"main":[[{"node":"Filter","type":"main","index":0}]]},"Get Owner Contact Info":{"main":[[{"node":"Format Lead Data","type":"main","index":0}]]},"Create Excel Spreadsheet":{"main":[[{"node":"Email Notification","type":"main","index":0}]]},"Configure Search Parameters":{"main":[[{"node":"Search Properties API","type":"main","index":0}]]},"When clicking \"Execute Workflow\"":{"main":[[{"node":"Configure Search Parameters","type":"main","index":0}]]}}}


name: Publish image & video to multiple social media (X, Instagram, Facebook and more)
author_name: Davide
author_username: n3witalia
nodes_used: ["n8n-nodes-base.httpRequest"]
categories: []
created_at: 2025-04-23T10:11:00.160Z
updated_at: 2025-04-23T10:11:00.160Z
url: https://n8n.io/workflows/3669
scraped_at: 2025-06-19 22:49:00
description:
  This Workflow streamlines the process of publishing posts (image or video) to multiple social media platforms using a unified form and a third-party API service called Upload-Post.

  The automation starts with a form trigger, allowing users to submit content (text and media) through a simple frontend interface. Users select the platform (Instagram, LinkedIn, Facebook, X, TikTok, Threads), choose the profile name, write a caption, and upload a photo or video.

  How It Works  
  Automates cross-platform social media posting via Upload-Post, handling both images (JPEG) and videos (MP4). Here’s the process:  

  Trigger**:  
    A form submission captures user inputs:  
      Platform (Instagram, LinkedIn, Facebook, X, TikTok, Threads).  
      Account (pre-configured profile name).  
      Caption and file (image/video).  
      Optional Facebook Page ID for targeted posting.  

  Routing**:  
    The "Video or Photo?" Switch node checks the file’s MIME type:  
      Image: Routes to the "Post photo" HTTP node (uploads via upload_photos API).  
      Video: Routes to the "Post video" HTTP node (uploads via upload API).  

  API Integration**:  
    Both nodes send data to Upload-Post.com’s API, including:  
      Caption, account name, platform, and file binary.  
      Facebook ID (if provided).  

  Success/Failure Handling**:  
    The "Result Photo/Video" nodes parse the API response.  

  Setup Steps  

  Prerequisites:  
  Upload-Post.com API Key**:  
    Get it from the API Keys dashboard.  
    Free tier allows 10 uploads/month.  

  Configuration:  
  API Authentication:  
     In the HTTP Request nodes (Post photo/Post video), set the Authorization header:  
       Name: Authorization  
       Value: Apikey YOUR_API_KEY_HERE.  

  Form Customization:  
     Adjust the "On form submission" node to:  
       Add/remove platforms (e.g., YouTube when approved).  
       Modify file type restrictions (default: .jpg, .mp4).  

  Account Mapping:  
     Ensure the "Account" field matches profiles configured in Upload-Post.com (e.g., test1, test2).  

  Facebook Page Integration:  
     Optional: Add a Facebook Page ID field for page-specific posts.  

  Testing:  
     Submit test forms with images/videos.  
     Verify API responses and success/failure messages.  

  Optional Enhancements:  
  Add error logging (e.g., save failed attempts to a database).  
  Extend to YouTube once API support is confirmed.  

  Key Features:  
  Multi-Platform**: Post to 6+ social networks simultaneously.  
  User-Friendly**: Simple form interface for non-technical users.  
  Error Handling**: Clear feedback for success/failure cases.  

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

workflow_json:
  {"id":"r1u4HOJu5j5sP27x","meta":{"instanceId":"a4bfc93e975ca233ac45ed7c9227d84cf5a2329310525917adaf3312e10d5462"},"name":"Social Media Publisher","tags":[],"nodes":[{"id":"f5050652-6170-41c6-b3c3-0f6616c9d575","name":"On form submission","type":"n8n-nodes-base.formTrigger","position":[-380,120],"webhookId":"bb578d47-feaa-4973-96df-659089838de5","parameters":{"options":{},"formTitle":"Post Publisher","formFields":{"values":[{"fieldType":"dropdown","fieldLabel":"Platform","fieldOptions":{"values":[{"option":"instagram"},{"option":"linkedin"},{"option":"facebook"},{"option":"x"},{"option":"tiktok"},{"option":"threads"}]},"requiredField":true},{"fieldLabel":"Account","placeholder":"User Profile name set on Upload-post.com","requiredField":true},{"fieldType":"textarea","fieldLabel":"Caption","requiredField":true},{"fieldType":"file","fieldLabel":"Upload","multipleFiles":false,"requiredField":true,"acceptFileTypes":".jpg,.mp4"},{"fieldLabel":"Facebook Id","placeholder":"Facebook page Id (eg. 00000111122222)"}]}},"typeVersion":2.2},{"id":"e9d8b8c9-3e40-420d-98c3-82c92f1c53c7","name":"Post photo","type":"n8n-nodes-base.httpRequest","position":[220,-180],"parameters":{"url":"https://api.upload-post.com/api/upload_photos","method":"POST","options":{},"sendBody":true,"contentType":"multipart-form-data","authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"title","value":"={{ $json.Caption }}"},{"name":"user","value":"={{ $json.Account }}"},{"name":"platform[]","value":"={{ $json.Platform }}"},{"name":"photos[]","parameterType":"formBinaryData","inputDataFieldName":"=Upload"},{"name":"facebook_id","value":"={{ $('On form submission').item.json['Facebook Id'] }}"}]},"genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"DEE2XGvhGodgbAJh","name":"Upload-post.com API"}},"typeVersion":4.2},{"id":"04103be2-a1d8-4b00-942b-44e13dffa666","name":"Post video","type":"n8n-nodes-base.httpRequest","position":[220,280],"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":"={{ $json.Caption }}"},{"name":"user","value":"={{ $json.Account }}"},{"name":"platform[]","value":"={{ $json.Platform }}"},{"name":"video","parameterType":"formBinaryData","inputDataFieldName":"=Upload"}]},"genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"DEE2XGvhGodgbAJh","name":"Upload-post.com API"}},"typeVersion":4.2},{"id":"e7803375-20b0-4e12-80a4-b102ba48b6ba","name":"KO Video","type":"n8n-nodes-base.form","position":[880,380],"webhookId":"d03e4286-f252-4a35-a65e-ea8ac96222e4","parameters":{"options":{},"operation":"completion","completionTitle":"=Oops","completionMessage":"There was an error"},"typeVersion":1},{"id":"91f2b501-4021-4ecc-9cc3-4e804d020135","name":"OK Video","type":"n8n-nodes-base.form","position":[880,180],"webhookId":"d03e4286-f252-4a35-a65e-ea8ac96222e4","parameters":{"options":{},"operation":"completion","completionTitle":"=Congratulations!","completionMessage":"Your post has been published correctly"},"typeVersion":1},{"id":"b3eead97-f995-42dc-b937-6d05f284f601","name":"KO Photo","type":"n8n-nodes-base.form","position":[880,-80],"webhookId":"d03e4286-f252-4a35-a65e-ea8ac96222e4","parameters":{"options":{},"operation":"completion","completionTitle":"=Oops","completionMessage":"There was an error"},"typeVersion":1},{"id":"8ead4dfa-cb9e-4ab4-b52c-7a681876269f","name":"OK Photo","type":"n8n-nodes-base.form","position":[880,-280],"webhookId":"d03e4286-f252-4a35-a65e-ea8ac96222e4","parameters":{"options":{},"operation":"completion","completionTitle":"=Congratulations!","completionMessage":"Your post has been published correctly"},"typeVersion":1},{"id":"a5fba676-4e7b-42e2-af36-e9d63458870b","name":"Success Photo?","type":"n8n-nodes-base.if","position":[640,-180],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"loose"},"combinator":"and","conditions":[{"id":"47eee8ce-0237-48f2-b67f-04021d3acda2","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.result }}\n","rightValue":"true"}]},"looseTypeValidation":true},"typeVersion":2.2},{"id":"310853de-ab7e-481e-8efa-5a681f08032b","name":"Success Video?","type":"n8n-nodes-base.if","position":[660,280],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"loose"},"combinator":"and","conditions":[{"id":"47eee8ce-0237-48f2-b67f-04021d3acda2","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.result }}\n","rightValue":"true"}]},"looseTypeValidation":true},"typeVersion":2.2},{"id":"81ec87fc-9298-4cd6-8a46-45ee6cb050b3","name":"Result Photo","type":"n8n-nodes-base.set","position":[440,-180],"parameters":{"options":{},"assignments":{"assignments":[{"id":"551c5179-055a-415e-bf17-61f2a5dd2769","name":"=result","type":"string","value":"={{ $json.results[$('Video or Photo?').item.json.Platform].success.toBoolean() }}"}]}},"typeVersion":3.4},{"id":"936ac765-0e7c-411d-b70d-bdfbe8e180a6","name":"Result Video","type":"n8n-nodes-base.set","position":[440,280],"parameters":{"options":{},"assignments":{"assignments":[{"id":"551c5179-055a-415e-bf17-61f2a5dd2769","name":"=result","type":"string","value":"={{ $json.results[$('Video or Photo?').item.json.Platform].success.toBoolean() }}"}]}},"typeVersion":3.4},{"id":"3a3d66ae-7ecd-43aa-a905-10afdab753b3","name":"Video or Photo?","type":"n8n-nodes-base.switch","position":[-120,120],"parameters":{"rules":{"values":[{"outputKey":"Image","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"879af56a-8979-4d9d-9acd-6009d821f6a7","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.Upload.mimetype }}","rightValue":"image/jpeg"}]},"renameOutput":true},{"outputKey":"Video","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"d7ee147d-d775-4b81-b043-0873c535b400","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.Upload.mimetype }}","rightValue":"video/mp4"}]},"renameOutput":true}]},"options":{}},"typeVersion":3.2},{"id":"76d1cc06-8bb5-43cd-8dcc-2da1656b0335","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-400,-1020],"parameters":{"width":1380,"height":680,"content":"## SETTINGS\n\n- Find your API key in your [Upload-Post Manage Api Keys](https://app.upload-post.com/) 10 FREE uploads per month\n- Set the the \"Auth Header\":\n-- Name: Authorization\n-- Value: Apikey YOUR_API_KEY_HERE\n- Create profiles to manage your social media accounts. The \"Profile\" you choose will be used in the field \"Account\" on form submission (eg. test1 or test2).  \n\n![image](https://i.postimg.cc/N0BHdcQ4/uploadpost.png)\n\nApr-2025: YouTube integration is currently being verified by Google, and may not work as expected.\n"},"typeVersion":1},{"id":"e9b40e23-cde9-459d-b490-8adda6b9253f","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-400,-1240],"parameters":{"color":3,"width":1380,"height":180,"content":"## Upload video and photo on TikTok, X, Facebook, Youtube, Instagram, Threads and Linkedin\n\nSimplify your social media workflow with our powerful platform designed for content creators and marketers.\n\nUpload your video once and let Upload-Post distribute it across all your connected social media accounts effortlessly."},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"ac29ff60-2d87-4646-ae63-ab543f3849de","connections":{"Post photo":{"main":[[{"node":"Result Photo","type":"main","index":0}]]},"Post video":{"main":[[{"node":"Result Video","type":"main","index":0}]]},"Result Photo":{"main":[[{"node":"Success Photo?","type":"main","index":0}]]},"Result Video":{"main":[[{"node":"Success Video?","type":"main","index":0}]]},"Success Photo?":{"main":[[{"node":"OK Photo","type":"main","index":0}],[{"node":"KO Photo","type":"main","index":0}]]},"Success Video?":{"main":[[{"node":"OK Video","type":"main","index":0}],[{"node":"KO Video","type":"main","index":0}]]},"Video or Photo?":{"main":[[{"node":"Post photo","type":"main","index":0}],[{"node":"Post video","type":"main","index":0}]]},"On form submission":{"main":[[{"node":"Video or Photo?","type":"main","index":0}]]}}}


