# templates

name: AI YouTube Analytics Agent: Comment Analyzer & Insights Reporter
author_name: Yaron Been
author_username: yaron-nofluff
categories: []
created_at: 2025-05-28T14:26:13.676Z
updated_at: 2025-05-28T14:26:13.676Z
url: https://n8n.io/workflows/4459
scraped_at: 2025-07-06 21:16:30
description:
  Transform YouTube comments into actionable insights with automated AI analysis and professional email reports.

  This intelligent workflow monitors your Google Sheets for YouTube video IDs, fetches comments using YouTube API, performs comprehensive AI sentiment analysis, and delivers formatted email reports with viewer insights - helping content creators understand their audience and improve engagement.

  🚀 What It Does

  Smart Video Monitoring: Watches Google Sheets for new YouTube video IDs marked as "Pending" and triggers automated analysis

  Complete Comment Collection: Fetches up to 100 top comments per video using YouTube API with relevance-based ordering

  AI-Powered Analysis: Uses GPT-4 to analyze comments for sentiment, themes, questions, feedback, and actionable insights

  Professional Email Reports: Generates detailed HTML reports with statistics, sentiment breakdown, and improvement recommendations

  Automated Status Tracking: Updates spreadsheet status to prevent duplicate processing and maintain organized workflow

  🎯 Key Benefits

  ✅ Deep Audience Insights: Understand what viewers really think about your content  
  ✅ Save Hours of Manual Work: Automated comment analysis vs reading hundreds of comments  
  ✅ Improve Content Strategy: Get actionable feedback for better video performance  
  ✅ Track Sentiment Trends: Monitor positive/negative feedback patterns  
  ✅ Professional Reporting: Receive formatted analysis reports via email  
  ✅ Scalable Analysis: Process multiple videos automatically  

  🏢 Perfect For

  Content Creators & YouTubers
  Individual creators tracking audience engagement
  Educational channels analyzing learning feedback
  Entertainment creators understanding viewer preferences
  Business channels monitoring brand sentiment

  Marketing & Business Applications
  Brand Monitoring**: Track sentiment on branded content and partnerships
  Audience Research**: Understand viewer demographics and preferences  
  Content Optimization**: Identify what resonates with your audience
  Competitor Analysis**: Analyze comments on competitor videos (where allowed)

  ⚙️ What's Included

  Complete Analytics Workflow: Ready-to-deploy YouTube comment analysis system
  Google Sheets Integration: Simple spreadsheet-based video management
  YouTube API Integration: Automated comment fetching with proper authentication
  AI Analysis Engine: GPT-4 powered sentiment and insight generation
  Email Reporting System: Professional HTML-formatted reports
  Status Management: Automatic processing tracking and duplicate prevention

  🔧 Setup Requirements

  n8n Platform**: Cloud or self-hosted instance
  YouTube API Credentials**: Google Cloud Console API access
  OpenAI API**: GPT-4 access for comment analysis
  Google Sheets**: Video ID management and status tracking
  Gmail Account**: For receiving analysis reports

  📊 Required Google Sheets Structure

  | ID | Video Title | YouTube Video ID | Status |
  |----|-------------|------------------|---------|
  | 1  | My Tutorial | dQw4w9WgXcQ     | Pending |
  | 2  | Product Demo| abc123def456    | Mail Sent |
  | 3  | Weekly Vlog | xyz789uvw012    | Draft |

  Status Options: Draft → Pending → Mail Sent

  📧 Sample Analysis Report

  📺 YouTube Comments Analysis Report
  Video: "How to Build Your First Website"

  📊 Quick Statistics:
  • Total Comments Analyzed: 87
  • Average Likes per Comment: 3.2
  • Total Replies: 156
  • Sentiment Summary: Positive: 65%, Negative: 10%, Neutral: 25%

  ❓ Common Questions:
  • "What hosting service do you recommend?"
  • "Can I do this without coding experience?"
  • "How much does domain registration cost?"

  💡 Key Feedback Points:
  • Tutorial pace is perfect for beginners
  • More examples of finished websites requested
  • Viewers want follow-up video on advanced features

  🎯 Actionable Insights:
  • Create hosting comparison video
  • Add timestamps for different skill levels
  • Consider beginner-friendly series expansion

  🎨 Customization Options

  Analysis Depth: Adjust AI prompts for different analysis focuses (engagement, education, entertainment)
  Comment Limits: Modify maximum comments processed (default: 100, AI analysis: 50)
  Report Recipients: Send reports to multiple team members or clients
  Custom Metrics: Add specific analysis criteria for your content niche
  Multi-Channel: Process videos from multiple YouTube channels
  Scheduling: Set up regular analysis of your latest videos

  🏷️ Tags & Categories

  #youtube-analytics #comment-analysis #content-creator-tools #ai-sentiment-analysis #video-insights #audience-research #youtube-api #content-optimization #social-media-analytics #creator-economy #video-marketing #engagement-analysis #content-strategy #ai-reporting #youtube-automation

  💡 Use Case Examples

  Educational Channel: Analyze tutorial comments to identify confusing concepts and improve teaching methods
  Product Reviews: Monitor sentiment on review videos to understand customer satisfaction trends  
  Entertainment Creator: Track audience reactions to different content formats and optimize future videos

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

workflow_json:
  {"meta":{"instanceId":"5aaf4236c70e34e423fbdb2c7b754d19253a933bb1476d548f75848a01e473cf","templateCredsSetupCompleted":true},"nodes":[{"id":"e0eae618-d330-4b74-b5a4-528a28ec91c6","name":"Sticky Note12","type":"n8n-nodes-base.stickyNote","position":[-1260,220],"parameters":{"color":4,"width":480,"height":740,"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":"e73f0186-b1a7-4ab9-a23e-94a38d51f8bb","name":"Workflow Overview","type":"n8n-nodes-base.stickyNote","position":[-640,420],"parameters":{"color":2,"width":350,"height":820,"content":"# 📊 YouTube Comment Analyzer Workflow\n\n**Purpose:** Automate YouTube comment collection, sentiment analysis, and email reporting\n\n**Schedule:** Triggers every minute for new/updated rows\n\n**Required Setup:**\n1. Google Sheet with video IDs\n2. YouTube API credentials\n3. OpenAI API key\n4. Gmail account\n\n## Workflow Steps:\n1. **Trigger** - Monitor Google Sheet\n2. **Filter** - Process only 'Pending' videos\n3. **Fetch** - Get video details & comments\n4. **Analyze** - AI sentiment analysis\n5. **Report** - Send email summary\n6. **Update** - Mark as processed"},"typeVersion":1},{"id":"606f8cb5-54a5-4a90-be41-089d7ccae72f","name":"Trigger Documentation","type":"n8n-nodes-base.stickyNote","position":[-260,320],"parameters":{"color":3,"width":380,"height":340,"content":"## 🚀 Trigger Section\n\n**Google Sheets Trigger**\nMonitors the spreadsheet every minute for:\n- New video IDs added\n- Status changes to 'Pending'\n\n**Required Sheet Structure:**\n| ID | Video Title | YouTube Video ID | Status |\n\n⚠️ Set Status to 'Pending' to trigger analysis"},"typeVersion":1},{"id":"f225b68e-272e-4414-82c2-2f79cfbcc381","name":"YouTube API Section","type":"n8n-nodes-base.stickyNote","position":[560,440],"parameters":{"width":280,"height":200,"content":"## 📹 YouTube Data Collection\n\n**This section fetches:**\n- Video metadata (title, channel)\n- Top 100 comments\n- Comment statistics\n\n**API Limits:**\n- Max 100 comments per request\n- Ordered by relevance\n- Top-level comments only"},"typeVersion":1},{"id":"628d65ff-007c-4b7a-862e-64158fa80e7c","name":"AI Analysis Documentation","type":"n8n-nodes-base.stickyNote","position":[1300,420],"parameters":{"color":5,"width":320,"height":250,"content":"## 🤖 AI Analysis Section\n\n**GPT-4o analyzes comments for:**\n1. Sentiment breakdown (positive/negative/neutral)\n2. Main themes & topics\n3. Common viewer questions\n4. Key feedback points\n5. Actionable insights\n\n**Output Format:** Structured JSON with underscore keys\n\n💡 Customize the prompt in AI Agent node for different analysis needs"},"typeVersion":1},{"id":"85b58261-88e1-499a-a082-548713da293e","name":"Email & Status Update","type":"n8n-nodes-base.stickyNote","position":[1820,460],"parameters":{"color":4,"width":300,"height":220,"content":"## 📧 Email & Update Section\n\n**Email Report includes:**\n- Video statistics\n- Sentiment analysis\n- Key insights\n- Formatted HTML\n\n**Final Step:**\nUpdates Google Sheet status to 'Mail Sent' to prevent duplicate processing\n\n⚠️ Update recipient email in Gmail node"},"typeVersion":1},{"id":"e0ba6c37-8b04-406b-9158-aef610274135","name":"Data Processing Note","type":"n8n-nodes-base.stickyNote","position":[1060,900],"parameters":{"color":6,"width":250,"height":180,"content":"⚠️ **Data Preparation**\n\nThis node:\n- Extracts comment texts\n- Calculates statistics\n- Performs basic sentiment analysis\n- Prepares data for AI\n\nLimited to 50 comments for AI analysis to manage token usage"},"typeVersion":1},{"id":"d7edbd68-9213-426b-ae6b-71a13bb23690","name":"Limit","type":"n8n-nodes-base.limit","notes":"Limits processing to 1 item at a time to prevent API overload","position":[220,700],"parameters":{},"typeVersion":1},{"id":"42f0f581-57a0-438d-b1a1-29a89e984554","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","notes":"Uses OpenAI GPT-4o to analyze comments and generate insights. Customize the prompt for different analysis needs.","position":[1320,700],"parameters":{"text":"=Analyze these comments from the video \"{{ $json.videoTitle }}\":\n\nTotal Comments: {{ $json.totalComments }}\nAverage Likes: {{ $json.avgLikes }}\n\nComments to analyze:\n{{ $json.commentTexts }}","options":{"maxIterations":100,"systemMessage":"You are a YouTube comment analyst. Analyze the provided comments and return a structured analysis with:\n1. Overall sentiment breakdown (positive/negative/neutral percentages)\n2. Top 3-5 main themes or topics discussed\n3. Common questions from viewers\n4. Key feedback points and suggestions\n5. Actionable insights for content improvement\n\nFormat your response in clear sections with headers in json key value format and use underscore in the key name. Always use following keys for output json: \n1. overall_sentiment_breakdown\n2. main_themes\n3. common_questions\n4. key_feedback_points\n5. actionable_insights"},"promptType":"define"},"typeVersion":1.9},{"id":"35abbd58-e69a-4d86-963e-0a758aaff7b2","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[1420,920],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{"responseFormat":"json_object"}},"typeVersion":1.2},{"id":"747fb13b-ee39-4dd7-8338-8db07e3b568e","name":"If","type":"n8n-nodes-base.if","notes":"Filters rows to process only videos with 'Pending' status","position":[0,700],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"5f1eae10-5270-4e99-8627-597e3451c82c","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.Status }}","rightValue":"Pending"}]}},"typeVersion":2.2},{"id":"6895d6b4-4ae4-4092-9302-33b1c69167d6","name":"Set Video Details","type":"n8n-nodes-base.set","notes":"Prepares video ID and sets max comments limit (100)","position":[440,700],"parameters":{"options":{},"assignments":{"assignments":[{"id":"219795ef-daa4-4444-9865-c5d3856be63b","name":"videoId","type":"string","value":"={{ $json['Youtube video id'] }}"},{"id":"cd4f519d-4c84-496c-8974-29ef69c890fc","name":"maxComments ","type":"number","value":100}]}},"typeVersion":3.4},{"id":"df200d75-d932-4bb4-9e57-16a940963db3","name":"Get Youtube Video Details","type":"n8n-nodes-base.youTube","notes":"Fetches video metadata including title, channel name, and other details","position":[660,700],"parameters":{"options":{},"videoId":"={{ $json.videoId }}","resource":"video","operation":"get"},"typeVersion":1},{"id":"5346229d-9386-497b-99c7-192e75896bf2","name":"Get Youtube Video Comments","type":"n8n-nodes-base.httpRequest","notes":"Retrieves top 100 comments ordered by relevance using YouTube API","position":[880,700],"parameters":{"url":"https://www.googleapis.com/youtube/v3/commentThreads","options":{},"sendQuery":true,"authentication":"predefinedCredentialType","queryParameters":{"parameters":[{"name":"part","value":"snippet"},{"name":"videoId","value":"={{ $('Set Video Details').item.json.videoId }}"},{"name":"maxResults","value":"100"},{"name":"order","value":"relevance"}]},"nodeCredentialType":"youTubeOAuth2Api"},"typeVersion":4.2},{"id":"ffee99ec-ad6d-4ac9-b0ad-e466a18ad7de","name":"Prepare Comments Data","type":"n8n-nodes-base.code","notes":"Processes raw comments: extracts text, calculates stats, performs basic sentiment analysis, limits to 50 comments for AI","position":[1100,700],"parameters":{"jsCode":"// Get comments from HTTP Request node\nconst comments = $input.first().json.items\n//const comments = response.items || [];\n\n// Get video title from the YouTube node (step 5)\n//const videoData = ;\nconst videoTitle = $('Get Youtube Video Details').first().json.snippet.title;\n\n// Extract comment data\nconst processedComments = comments.map(item => {\n  const comment = item.snippet.topLevelComment.snippet;\n  return {\n    text: comment.textDisplay,\n    author: comment.authorDisplayName,\n    likes: comment.likeCount || 0,\n    publishedAt: comment.publishedAt,\n    replyCount: item.snippet.totalReplyCount || 0\n  };\n});\n\n// Calculate statistics\nconst totalComments = processedComments.length;\nconst totalLikes = processedComments.reduce((sum, c) => sum + c.likes, 0);\nconst avgLikes = totalComments > 0 ? (totalLikes / totalComments).toFixed(2) : 0;\nconst totalReplies = processedComments.reduce((sum, c) => sum + c.replyCount, 0);\n\n// Get top comments by likes\nconst topComments = processedComments\n  .sort((a, b) => b.likes - a.likes)\n  .slice(0, 5);\n\n// Prepare comment texts for AI analysis\nconst commentTexts = processedComments\n  .slice(0, 50) // Limit to 50 comments for AI analysis\n  .map(c => c.text)\n  .join('\\n---\\n');\n\n// Basic sentiment analysis (count positive/negative keywords)\nconst positiveWords = ['love', 'great', 'awesome', 'amazing', 'excellent', 'good', 'fantastic', 'helpful', 'thanks'];\nconst negativeWords = ['hate', 'terrible', 'awful', 'bad', 'worst', 'horrible', 'useless', 'waste'];\n\nlet positiveCount = 0;\nlet negativeCount = 0;\n\nprocessedComments.forEach(comment => {\n  const lowerText = comment.text.toLowerCase();\n  positiveWords.forEach(word => {\n    if (lowerText.includes(word)) positiveCount++;\n  });\n  negativeWords.forEach(word => {\n    if (lowerText.includes(word)) negativeCount++;\n  });\n});\n\nreturn [{\n  json: {\n    videoTitle,\n    totalComments,\n    avgLikes,\n    totalReplies,\n    topComments,\n    commentTexts,\n    processedComments,\n    sentimentCounts: {\n      positive: positiveCount,\n      negative: negativeCount,\n      neutral: totalComments - positiveCount - negativeCount\n    }\n  }\n}];\n\n"},"typeVersion":2},{"id":"7eab55e1-e9e2-4750-a07d-f02941c7a8c6","name":"Prepare HTML for Email","type":"n8n-nodes-base.code","notes":"Converts AI analysis into formatted HTML email with statistics, insights, and professional styling","position":[1700,700],"parameters":{"mode":"runOnceForEachItem","jsCode":"const output = JSON.parse($json.output)\n //return output; \n//return output.overall_sentiment_breakdown.Positive;\n\nlet common_question = \"\";\n  \noutput.common_questions.map(rec => {\n  return common_question += \"<li>\"+rec.trim().replace(new RegExp(\".*,$\"), \"\")+\"</li>\"\n})\n\nlet key_feedback_points_and_suggestions = \"\";\n\noutput.key_feedback_points.map(rec => {\n  return key_feedback_points_and_suggestions += \"<li>\"+rec.trim().replace(new RegExp(\".*,$\"), \"\")+\"</li>\"\n})\n\n\nlet actionable_insights_for_content_improvement = \"\"\n\noutput.actionable_insights.map(rec => {\n  return actionable_insights_for_content_improvement += \"<li>\"+rec.trim().replace(new RegExp(\".*,$\"), \"\")+\"</li>\"\n})\n\n\n// return {common_question};\n\n\n     \n\n//return output; \n// Generate the email HTML\nconst emailHTML = `\n<!DOCTYPE html>\n<html>\n<head>\n  <style>\n    body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }\n    .header { background: #f4f4f4; padding: 20px; border-radius: 5px; }\n    .section { margin: 20px 0; }\n    .stats { background: #e9ecef; padding: 15px; border-radius: 5px; }\n    .analysis { background: #f8f9fa; padding: 20px; border-radius: 5px; }\n    h2 { color: #2c3e50; }\n    h3 { color: #34495e; }\n    h4 { color: #7f8c8d; }\n    .footer { margin-top: 30px; padding-top: 20px; border-top: 1px solid #ddd; color: #666; font-size: 0.9em; }\n  </style>\n</head>\n<body>\n  <div class=\"header\">\n    <h2>YouTube Comments Analysis Report</h2>\n    <h3>Video: ${$(\"Prepare Comments Data\").item.json.videoTitle}</h3>\n  </div>\n\n  <div class=\"section stats\">\n    <h3> Quick Statistics</h3>\n    <ul>\n      <li><strong>Total Comments Analyzed:</strong> ${$('Prepare Comments Data').item.json.totalComments}</li>\n      <li><strong>Average Likes per Comment:</strong> ${$('Prepare Comments Data').item.json.avgLikes}</li>\n      <li><strong>Total Replies:</strong> ${$('Prepare Comments Data').item.json.totalReplies}</li>\n      <li><strong>Sentiment Summary:</strong> \n        Positive: ${output.overall_sentiment_breakdown.positive}, \n        Negative: ${output.overall_sentiment_breakdown.negative}, \n        Neutral: ${output.overall_sentiment_breakdown.neutral}\n      </li>\n    </ul>\n  </div>\n\n  <div class=\"section stats\">\n    <h3>Common Questions</h3>\n    <ul>\n      ${common_question}\n    </ul>\n  </div>\n\n    <div class=\"section stats\">\n    <h3>Key feedback points and suggestions</h3>\n    <ul>\n      ${key_feedback_points_and_suggestions}\n    </ul>\n  </div>\n\n\n  <div class=\"section stats\">\n    <h3>Actionable insights for content improvement</h3>\n    <ul>\n      ${actionable_insights_for_content_improvement}\n    </ul>\n  </div>\n\n\n\n\n  <div class=\"footer\">\n    <p><em>Report generated on ${new Date().toLocaleString()}</em></p>\n    \n  </div>\n</body>\n</html>`;\n\n\n// Return the formatted data\nreturn  {\n  json: {\n    emailHTML,\n    subject: `YouTube Analysis: ${$('Prepare Comments Data').item.json.videoTitle} - ${$('Prepare Comments Data').item.json.totalComments} comments analyzed`,\n    videoTitle: $('Prepare Comments Data').item.json.videoTitle\n  }\n};"},"typeVersion":2},{"id":"f789c4e0-813b-4f6d-9584-86a274fba969","name":"Gmail Account Configuration","type":"n8n-nodes-base.gmail","notes":"Sends formatted analysis report via Gmail. Update SENDER_EMAIL_ADDRESS with actual recipient","position":[1920,700],"webhookId":"90b8f9ad-4226-42a0-971b-7fa9f5f190bd","parameters":{"sendTo":"SENDER_EMAIL_ADDRESS","message":"={{ $json.emailHTML }}","options":{},"subject":"={{ $json.subject }}"},"typeVersion":2.1},{"id":"309d2e7d-2da0-439b-b2ac-87196d9f5733","name":"Update Status on Google Sheet","type":"n8n-nodes-base.googleSheets","notes":"Updates video status to 'Mail Sent' to prevent duplicate processing","position":[2140,700],"parameters":{"columns":{"value":{"Id":"={{ $('Pick Video Ids from Google sheet').item.json.Id }}","Status":"Mail Sent"},"schema":[{"id":"Id","type":"string","display":true,"removed":false,"required":false,"displayName":"Id","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Youtube video id","type":"string","display":true,"required":false,"displayName":"Youtube video id","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Status","type":"string","display":true,"required":false,"displayName":"Status","defaultMatch":false,"canBeUsedToMatch":true},{"id":"row_number","type":"string","display":true,"removed":true,"readOnly":true,"required":false,"displayName":"row_number","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":["Id"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"update","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"GOOGLE_DRIVE_URL","cachedResultName":"Youtube_Video "},"documentId":{"__rl":true,"mode":"list","value":"1qe6Ovp_pfmwZA2k5c7LmmZx-OKqv3hnu8Dg80Pw4KoY","cachedResultUrl":"GOOGLE_DRIVE_URL","cachedResultName":"Youtube_Video"}},"typeVersion":4.5},{"id":"b62a4e3a-c843-4ed2-9ee4-cbfb1a218259","name":"Pick Video Ids from Google sheet","type":"n8n-nodes-base.googleSheetsTrigger","notes":"Triggers on new YouTube videos added to spreadsheet. Polls every minute for changes","position":[-220,700],"parameters":{"options":{},"pollTimes":{"item":[{"mode":"everyMinute"}]},"sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"GOOGLE_DRIVE_URL","cachedResultName":"Youtube_Video "},"documentId":{"__rl":true,"mode":"list","value":"1qe6Ovp_pfmwZA2k5c7LmmZx-OKqv3hnu8Dg80Pw4KoY","cachedResultUrl":"GOOGLE_DRIVE_URL","cachedResultName":"Youtube_Video"}},"typeVersion":1}],"pinData":{},"connections":{"If":{"main":[[{"node":"Limit","type":"main","index":0}]]},"Limit":{"main":[[{"node":"Set Video Details","type":"main","index":0}]]},"AI Agent":{"main":[[{"node":"Prepare HTML for Email","type":"main","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Set Video Details":{"main":[[{"node":"Get Youtube Video Details","type":"main","index":0}]]},"Prepare Comments Data":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Prepare HTML for Email":{"main":[[{"node":"Gmail Account Configuration","type":"main","index":0}]]},"Get Youtube Video Details":{"main":[[{"node":"Get Youtube Video Comments","type":"main","index":0}]]},"Get Youtube Video Comments":{"main":[[{"node":"Prepare Comments Data","type":"main","index":0}]]},"Gmail Account Configuration":{"main":[[{"node":"Update Status on Google Sheet","type":"main","index":0}]]},"Pick Video Ids from Google sheet":{"main":[[{"node":"If","type":"main","index":0}]]}}}


name: Github Webhook-Based n8n Workflow Import Template
author_name: Dave Bernier
author_username: dbern
nodes_used: ["n8n-nodes-base.github"]
categories: []
created_at: 2025-05-28T21:24:41.338Z
updated_at: 2025-05-28T21:24:41.338Z
url: https://n8n.io/workflows/4471
scraped_at: 2025-07-06 21:16:30
description:
  This n8n workflow template uses community nodes and is only compatible with the self-hosted version of n8n. 

  This template aims to ease the process of deploying workflows from github. It has a companion repository that developers might find useful{. See below for more details

  How it works

  Automatically import and deploy n8n workflows from your GitHub repository to your production n8n instance using a secured webhook-based approach. This template enables teams to maintain version control of their workflows while ensuring seamless deployment through a CI/CD pipeline.

  Receives webhook notifications from GitHub when changes are pushed to your repository
  Lists all files in the repository and filters for .json workflow files
  Downloads each workflow file and saves it locally
  Imports all workflows into n8n using the CLI import command
  Cleans up temporary files after successful import

  To trigger the deployment, send a POST request to your webhook with the set up credentials (basic auth) with the following body:
  {
    "owner": "GITHUB_REPO_OWNER_NAME",
    "repository": "GITHUB_REPOSITORY_NAME"
  }

  Set up steps
  Once importing this template in n8n :
  Setup the webhook basic auth credentials
  Setup the github credentials
  Activate the workflow !

  Companion repository
  There is a companion repository located at https://github.com/dynamicNerdsSolutions/n8n-git-flow-template that has a Github action already setup to work with this workflow.

  It provides a complete development environment with:
  Local n8n instance via Docker
  Automated workflow export and commit scripts
  Version control integration
  CI/CD pipeline setup

  This setup allows teams to maintain a clean separation between development and production environments while ensuring reliable workflow deployment.

workflow_json:
  {"nodes":[{"id":"6dcae6fd-9631-4f73-985c-31c08cfba106","name":"Webhook","type":"n8n-nodes-base.webhook","position":[-200,-45],"webhookId":"182bd0f4-bab3-4d3f-8341-773c2af24107","parameters":{"path":"import-workflows","options":{},"httpMethod":"POST","responseMode":"lastNode","authentication":"basicAuth"},"credentials":{"httpBasicAuth":{"id":"0sXvlBjKe1sDOYj0","name":"Github action user"}},"typeVersion":2},{"id":"62de08a4-db11-4602-9e4b-756fdecd2809","name":"No Operation, do nothing","type":"n8n-nodes-base.noOp","position":[900,-20],"parameters":{},"typeVersion":1},{"id":"faff0550-2ddd-4903-a2c2-c6081cf3098e","name":"create workflows sub folder if not exist","type":"n8n-nodes-base.executeCommand","position":[20,-45],"parameters":{"command":"mkdir -p workflows"},"typeVersion":1},{"id":"2b9a3378-f36a-4a25-bcc1-82fa403b85a7","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-740,-300],"parameters":{"color":6,"width":520,"height":500,"content":"# Github import\nThis webhook is secured with a basic authentication credential. Make sure to edit it to values you own.\n\nThe webhook receives the github owner and repository from whitch it should import the workflows.\n\nIt will download all json files into a local directory and call the n8n cli to import them.\n\nThere is a companion developement template on github that complements this flow, including the Github Action that can call this workflow. You can get it from here: https://github.com/dynamicNerdsSolutions/n8n-git-flow-template\n\n## First step :\nCreate the credentials for the webhook authentication and github."},"typeVersion":1},{"id":"9143f124-30b5-4a55-b3b7-03cd3c4fdfe8","name":"List files from specified repo root","type":"n8n-nodes-base.github","position":[240,-45],"webhookId":"b04d7d0c-b721-4d30-b4bd-29ed04f5ac9d","parameters":{"owner":{"__rl":true,"mode":"name","value":"={{ $('Webhook').item.json.body.owner }}"},"resource":"file","operation":"list","repository":{"__rl":true,"mode":"name","value":"={{ $('Webhook').item.json.body.repository }}"}},"credentials":{"githubApi":{"id":"Nx9eJjTiUfwyntOr","name":"GitHub account"}},"typeVersion":1.1},{"id":"f28d4f42-e7a0-4a25-8d1e-44de3a04f11a","name":"Loop Over Files","type":"n8n-nodes-base.splitInBatches","position":[460,-40],"parameters":{"options":{}},"typeVersion":3},{"id":"64d6aeac-bc11-4204-bea5-7f678fddf2b7","name":"If it is a json file","type":"n8n-nodes-base.if","position":[680,-120],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"8ad03c7c-1820-4f9e-998c-a209cc829ea3","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.type }}","rightValue":"file"},{"id":"1a26b68e-91d6-468b-aed5-db0e4cee0f74","operator":{"type":"string","operation":"endsWith"},"leftValue":"={{ $json.name }}","rightValue":".json"}]}},"typeVersion":2.2},{"id":"8c4f7bcc-0c3c-4333-a39e-51d29be43c87","name":"Download file","type":"n8n-nodes-base.github","position":[900,-220],"webhookId":"ec903eb1-d4be-4332-8e28-7f384479336a","parameters":{"owner":{"__rl":true,"mode":"name","value":"={{ $('Webhook').item.json.body.owner }}"},"filePath":"={{ $json.path }}","resource":"file","operation":"get","repository":{"__rl":true,"mode":"name","value":"={{ $('Webhook').item.json.body.repository }}"},"additionalParameters":{}},"credentials":{"githubApi":{"id":"Nx9eJjTiUfwyntOr","name":"GitHub account"}},"typeVersion":1.1},{"id":"27ee1e73-66d5-4c86-a6ea-6be4786bc97e","name":"Store file locally","type":"n8n-nodes-base.readWriteFile","position":[1140,-60],"parameters":{"options":{},"fileName":"=workflows/{{ $json.name }}","operation":"write"},"typeVersion":1},{"id":"3a2a58ae-2f8f-447a-8a95-073d1f5575d6","name":"Call n8n import and cleanup folder","type":"n8n-nodes-base.executeCommand","position":[680,-320],"parameters":{"command":"n8n import:workflow --separate --input=workflows && rm -f ./workflows/*.json"},"typeVersion":1}],"connections":{"Webhook":{"main":[[{"node":"create workflows sub folder if not exist","type":"main","index":0}]]},"Download file":{"main":[[{"node":"Store file locally","type":"main","index":0}]]},"Loop Over Files":{"main":[[{"node":"Call n8n import and cleanup folder","type":"main","index":0}],[{"node":"If it is a json file","type":"main","index":0}]]},"Store file locally":{"main":[[{"node":"Loop Over Files","type":"main","index":0}]]},"If it is a json file":{"main":[[{"node":"Download file","type":"main","index":0}],[{"node":"No Operation, do nothing","type":"main","index":0}]]},"No Operation, do nothing":{"main":[[{"node":"Loop Over Files","type":"main","index":0}]]},"List files from specified repo root":{"main":[[{"node":"Loop Over Files","type":"main","index":0}]]},"create workflows sub folder if not exist":{"main":[[{"node":"List files from specified repo root","type":"main","index":0}]]}}}


name: Automate Multi-Channel Customer Support with Gmail, Telegram, and GPT AI
author_name: RedOne
author_username: redone
categories: []
created_at: 2025-05-29T05:09:06.053Z
updated_at: 2025-05-29T05:09:06.053Z
url: https://n8n.io/workflows/4474
scraped_at: 2025-07-06 21:16:30
description:
  Smart Customer Support AI Agent with Gmail and Telegram

  Who is this for?

  This workflow is perfect for:
  Small to medium businesses** looking to automate customer support
  E-commerce stores** handling order inquiries and customer questions
  SaaS companies** providing technical support to users
  Service providers** managing appointment bookings and general inquiries
  Startups** wanting to provide 24/7 customer service without hiring full-time staff
  Agencies** managing client communications across multiple channels

  What problem is this workflow solving?

  Customer support is essential but resource-intensive. Common challenges include:
  Slow response times** leading to frustrated customers
  Repetitive questions** consuming valuable staff time
  Inconsistent responses** across different support agents
  Limited availability** outside business hours
  Scaling support costs** as business grows
  Context loss** when customers switch between channels

  This workflow eliminates these pain points by providing instant, consistent, and intelligent responses 24/7.

  What this workflow does

  Core Functionality
  Multi-Channel Monitoring: Simultaneously watches Gmail and Telegram for customer inquiries
  Intelligent Processing: Uses AI to understand customer intent and context
  Knowledge Base Integration: Accesses your company's FAQ and support information
  Contextual Responses: Provides personalized, helpful replies maintaining conversation history
  Smart Escalation: Automatically escalates complex issues to human agents
  Comprehensive Logging: Tracks all interactions for analytics and improvement

  AI Agent Capabilities
  Natural Language Understanding**: Comprehends customer questions in plain English
  Context Awareness**: Remembers previous conversations with each customer
  Knowledge Retrieval**: Searches your knowledge base for accurate information
  Response Generation**: Creates professional, brand-appropriate responses
  Escalation Decision**: Identifies when human intervention is needed
  Multi-Channel Support**: Handles Gmail and Telegram with channel-specific formatting

  Automation Features
  Auto-Response**: Replies to customers within seconds
  Email Management**: Marks processed emails as read
  Conversation Threading**: Maintains context in email threads and Telegram chats
  Error Handling**: Gracefully handles failures with admin notifications
  Analytics Tracking**: Logs interactions for performance monitoring

  Setup

  Prerequisites
  Active Google Workspace or Gmail account
  Telegram account for bot creation
  OpenAI API access
  Google Sheets access
  n8n instance (cloud or self-hosted)

  Step 1: Credential Setup

  Gmail OAuth2 Configuration
  Go to Google Cloud Console
  Create new project or select existing one
  Enable Gmail API
  Create OAuth 2.0 credentials
  Add authorized redirect URIs for n8n
  In n8n: Settings → Credentials → Add Gmail OAuth2
  Enter Client ID and Client Secret
  Complete OAuth flow

  Telegram Bot Setup
  Message @BotFather on Telegram
  Create new bot with /newbot command
  Choose bot name and username
  Copy the bot token
  In n8n: Settings → Credentials → Add Telegram
  Enter bot token
  Set webhook URL in bot settings

  OpenAI API Configuration
  Sign up at OpenAI Platform
  Generate API key in API Keys section
  In n8n: Settings → Credentials → Add OpenAI
  Enter API key
  Choose appropriate model (gpt-4o-mini recommended)

  Google Sheets Setup
  Use existing Google account from Gmail setup
  In n8n: Settings → Credentials → Add Google Sheets OAuth2
  Complete authorization flow

  Step 2: Google Sheets Preparation

  Create three Google Sheets in your Google Drive:

  Knowledge Base Sheet
  Sheet Name**: "Knowledge Base"
  Columns**: ID, Category, Question/Topic, Answer/Response, Keywords, Last_Updated
  Import sample data from the Knowledge Base example
  Customize with your company's FAQs and policies

  Escalation Tracker Sheet
  Sheet Name**: "Escalations" 
  Columns**: Timestamp, Customer_Name, Customer_Contact, Inquiry_Summary, Escalation_Reason, Priority, Status, Assigned_To
  This will be auto-populated by the AI agent

  Interaction Log Sheet
  Sheet Name**: "Interaction Log"
  Columns**: Timestamp, Channel, Customer_Name, Customer_Contact, Inquiry_Subject, Customer_Message, AI_Response, Response_Time, Status
  This tracks all customer interactions for analytics

  Step 3: Workflow Configuration

  Import Template
  Copy the workflow JSON from the template
  In n8n: Import workflow from JSON
  Replace placeholder Sheet IDs with your actual Google Sheet IDs

  Update Sheet References
  Open each Google Sheets node
  Select your created sheets from the dropdown
  Verify column mappings match your sheet structure

  Customize AI Prompts
  Edit the "Customer Support AI Agent" node
  Update system message with:
     Your company name and description
     Brand voice and tone guidelines
     Specific policies and procedures
     Escalation criteria

  Configure Error Notifications (Optional)
  Set up Slack webhook or email notifications
  Update error notification node with your webhook URL
  Customize error message format

  Step 4: Testing

  Test Gmail Integration
  Send test email to your support Gmail account
  Check workflow execution in n8n
  Verify response is sent and email marked as read
  Check interaction logging in Google Sheets

  Test Telegram Integration  
  Send message to your Telegram bot
  Verify bot responds appropriately
  Test conversation memory with follow-up messages
  Check escalation functionality with complex request

  Test Knowledge Base
  Ask questions covered in your knowledge base
  Verify AI retrieves and uses correct information
  Test with variations of the same question
  Ensure responses are consistent and helpful

  How to customize this workflow to your needs

  Brand Voice Customization
  Update the AI system prompt to include:
  Your company's tone (formal, casual, friendly)
  Key phrases and terminology you use
  Brand personality traits
  Communication style preferences

  Knowledge Base Expansion
  Add industry-specific FAQs
  Include product documentation
  Add troubleshooting guides
  Create category-specific responses

  Escalation Rules
  Customize when to escalate by modifying the AI agent instructions:
  Billing disputes over $X amount
  Technical issues requiring developer help
  Angry or dissatisfied customers
  Requests outside standard services
  Legal or compliance questions

  Additional Channels
  Extend the workflow to support:
  Slack**: Add Slack triggers and response nodes
  WhatsApp**: Integrate WhatsApp Business API
  Web Chat**: Add webhook triggers for website chat
  Discord**: Connect Discord bot integration

  Analytics Enhancement
  Add sentiment analysis to customer messages
  Implement customer satisfaction scoring
  Create automated reporting dashboards
  Set up alert thresholds for escalation rates

  Integration Opportunities
  CRM Integration**: Connect to HubSpot, Salesforce, or Pipedrive
  Ticketing System**: Link to Zendesk, Freshdesk, or Jira Service Desk
  E-commerce Platform**: Integrate with Shopify, WooCommerce, or Magento
  Calendar Booking**: Connect to Calendly or Acuity for appointment scheduling

  Advanced Features
  Multi-language Support**: Add translation capabilities
  Voice Messages**: Integrate speech-to-text for Telegram voice notes
  Image Recognition**: Process customer screenshots for technical support
  Proactive Outreach**: Send follow-up messages based on customer behavior

  Workflow Maintenance

  Daily Tasks
  Review escalation queue
  Monitor error notifications
  Check response quality in interaction log

  Weekly Reviews
  Analyze customer interaction patterns
  Update knowledge base with new common questions
  Review escalation reasons and optimize AI prompts

  Monthly Optimization
  Export interaction data for detailed analysis
  Calculate key metrics (response time, resolution rate, escalation rate)
  Update AI model parameters based on performance
  Expand knowledge base with seasonal or trending topics

  Key Metrics to Track

  Response Time**: Average time from customer message to AI response
  Resolution Rate**: Percentage of inquiries resolved without escalation  
  Customer Satisfaction**: Based on follow-up surveys or sentiment analysis
  Escalation Rate**: Percentage of conversations requiring human intervention
  Channel Performance**: Effectiveness of Gmail vs Telegram vs other channels
  Knowledge Base Usage**: Which topics are accessed most frequently
  Peak Hours**: When customers contact support most often

  Troubleshooting

  Common Issues
  Gmail not triggering**: Check OAuth permissions and API quotas
  Telegram bot not responding**: Verify bot token and webhook configuration
  AI responses seem off**: Review and update system prompts
  Escalations not logging**: Check Google Sheets permissions and column mapping
  High escalation rate**: Expand knowledge base and refine AI instructions

  Performance Optimization
  Monitor OpenAI API usage and costs
  Adjust AI model temperature for response consistency
  Optimize knowledge base for faster searches
  Set appropriate conversation memory limits

  This workflow provides a solid foundation for automated customer support that can be extensively customized to match your specific business needs and grow with your company.

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

workflow_json:
  {"id":"iYX4vUmfNoVCA86T","meta":{"instanceId":"1037e065dca107c3c15857d49fe150792779e136a3c579aed02192a2b3d2a396","templateCredsSetupCompleted":true},"name":"🤖 Smart Customer Support AI Agent","tags":[],"nodes":[{"id":"696a1b2e-8f22-46ec-8fdd-3c7bb25f8429","name":"📋 Workflow Guide","type":"n8n-nodes-base.stickyNote","position":[1040,660],"parameters":{"color":6,"width":400,"height":1040,"content":"## 🤖 Smart Customer Support AI Agent\n\n**Who is this for?**\nSmall to medium businesses, e-commerce stores, SaaS companies, and service providers who want to automate their customer support while maintaining a personal touch.\n\n**What problem does this solve?**\n- Reduces response time to customer inquiries\n- Handles repetitive questions automatically\n- Provides 24/7 customer support coverage\n- Maintains consistent brand voice across channels\n- Escalates complex issues to human agents\n\n**What this workflow does:**\n1. Monitors Gmail and Telegram for customer messages\n2. Uses AI to understand customer intent and context\n3. Accesses your knowledge base (Google Sheets) for accurate responses\n4. Sends personalized, contextual replies\n5. Escalates complex issues to human agents\n6. Logs all interactions for analysis\n\n**FIXES APPLIED:**\n- Separated Gmail and Telegram processing paths\n- Individual AI agents for each channel\n- Proper conversation memory management\n- Channel-specific response handling\n\n**Setup Instructions:**\n1. Configure Gmail OAuth2 credentials\n2. Set up Telegram bot token\n3. Create your knowledge base in Google Sheets\n4. Add your OpenAI API key\n5. Customize the AI prompts for your business\n6. Test with sample customer inquiries\n\n**Customization Tips:**\n- Update the knowledge base with your FAQs\n- Modify AI prompts to match your brand voice\n- Add more communication channels as needed\n- Set up escalation rules for complex cases"},"typeVersion":1},{"id":"47324b70-8be7-4e92-a739-2ff60f37d14a","name":"💬 Telegram Customer Message Trigger","type":"n8n-nodes-base.telegramTrigger","position":[1500,1220],"webhookId":"customer-support-telegram","parameters":{"updates":["message"],"additionalFields":{}},"credentials":{"telegramApi":{"id":"RIK7bBarkKBJAV5R","name":"Telegram account"}},"typeVersion":1.1},{"id":"23ce0479-3ab0-4150-b893-3e08ed83fd73","name":"📋 Process Telegram Message","type":"n8n-nodes-base.set","position":[1780,1240],"parameters":{"options":{},"assignments":{"assignments":[{"id":"channel","name":"channel","type":"string","value":"telegram"},{"id":"customer_name","name":"customer_name","type":"string","value":"={{ $json.message.from.first_name }} {{ $json.message.from.last_name }}"},{"id":"customer_id","name":"customer_id","type":"string","value":"={{ $json.message.from.id }}"},{"id":"chat_id","name":"chat_id","type":"string","value":"={{ $json.message.chat.id }}"},{"id":"message_content","name":"message_content","type":"string","value":"={{ $json.message.text }}"},{"id":"message_id","name":"message_id","type":"string","value":"={{ $json.message.message_id }}"},{"id":"subject","name":"subject","type":"string","value":"Customer Support Inquiry"}]}},"typeVersion":3.4},{"id":"686affeb-1afb-45cf-b9b0-f3ba6c6ffb94","name":"🤖 Telegram AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[2080,1180],"parameters":{"text":"={{ $json.message_content}}","options":{"systemMessage":"You are a helpful and professional customer support AI assistant for Telegram inquiries. Your role is to:\n\n1. Understand customer inquiries and provide accurate, helpful responses\n2. Use the knowledge base tool to find relevant information\n3. Maintain a friendly, professional tone that matches the company brand\n4. If you cannot fully resolve an issue, escalate it appropriately\n5. Always aim to provide value and resolve customer concerns\n\nImportant guidelines:\n- Be empathetic and understanding\n- Provide clear, actionable responses\n- Use the customer's name when possible\n- If information is not in the knowledge base, say so honestly\n- For complex technical issues, recommend escalation to human support\n\nCompany context: You represent a professional service business focused on customer satisfaction and quality support via Telegram."},"promptType":"define"},"typeVersion":1.7},{"id":"a5e67d73-73c2-4756-9c82-9c05c1dbc36a","name":"🧠 OpenAI Chat Model - Telegram","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[1900,1420],"parameters":{"options":{"maxTokens":100,"temperature":0.3}},"credentials":{"openAiApi":{"id":"IdjfTMR7gLjapSWH","name":"Open Ai"}},"typeVersion":1.1},{"id":"bfa0f8a9-58cc-4c15-8d7e-d633c23e10a6","name":"🧠 Telegram Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[2080,1440],"parameters":{"sessionKey":"telegram_{{ $json.customer_id }}","sessionIdType":"customKey"},"typeVersion":1.3},{"id":"64a05368-29f5-4333-b881-b0ba73e424cb","name":"💬 Send Telegram Reply","type":"n8n-nodes-base.telegram","position":[2460,1120],"parameters":{"text":"={{ $json.output }}","chatId":"={{ $('📋 Process Telegram Message').item.json.chat_id }}","additionalFields":{"parse_mode":"Markdown","reply_to_message_id":"={{ $('📋 Process Telegram Message').item.json.message_id }}"}},"credentials":{"telegramApi":{"id":"RIK7bBarkKBJAV5R","name":"Telegram account"}},"typeVersion":1.2},{"id":"64c36c02-b56d-45dd-b3bf-4f49b3e14b5c","name":"📧 Gmail Customer Inquiry Trigger","type":"n8n-nodes-base.gmailTrigger","position":[1540,720],"parameters":{"filters":{"labelIds":["INBOX","CATEGORY_PERSONAL"],"readStatus":"unread"},"pollTimes":{"item":[{"mode":"everyMinute"}]}},"credentials":{"gmailOAuth2":{"id":"YQWc9jqYGygA6lXT","name":"Gmail account"}},"typeVersion":1},{"id":"baf01d18-d626-4b5c-bbc9-ac45c83b8e0b","name":"📋 Process Gmail Message","type":"n8n-nodes-base.set","position":[1740,720],"parameters":{"options":{},"assignments":{"assignments":[{"id":"channel","name":"channel","type":"string","value":"gmail"},{"id":"customer_email","name":"customer_email","type":"string","value":"={{ $json[\"From\"].match(/<(.*?)>/)?.[1] || $json[\"From\"] }}"},{"id":"customer_name","name":"customer_name","type":"string","value":"={{ $json[\"From\"].split(\" <\")[0] }}"},{"id":"subject","name":"subject","type":"string","value":"={{ $json.Subject }}"},{"id":"message_content","name":"message_content","type":"string","value":"={{ $json.text || $json.snippet }}"},{"id":"message_id","name":"message_id","type":"string","value":"={{ $json.id }}"},{"id":"thread_id","name":"thread_id","type":"string","value":"={{ $json.threadId }}"}]}},"typeVersion":3.4},{"id":"4d1c0b8a-9fed-4977-8ec4-91cb4460c2b6","name":"🤖 Gmail AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[1940,720],"parameters":{"text":"={{ $json.message_content}}","options":{"systemMessage":"You are a helpful and professional customer support AI assistant for Email inquiries. Your role is to:\n\n1. Understand customer inquiries and provide accurate, helpful responses\n2. Use the knowledge base tool to find relevant information\n3. Maintain a friendly, professional tone that matches the company brand\n4. If you cannot fully resolve an issue, escalate it appropriately\n5. Always aim to provide value and resolve customer concerns\n\nImportant guidelines:\n- Be empathetic and understanding\n- Provide clear, actionable responses\n- Use the customer's name when possible\n- If information is not in the knowledge base, say so honestly\n- For complex technical issues, recommend escalation to human support\n- Format responses appropriately for email\n\nCompany context: You represent a professional service business focused on customer satisfaction and quality support via Email."},"promptType":"define"},"typeVersion":1.7},{"id":"8da4c0b1-86b7-436b-8d73-e96d3777be29","name":"🧠 OpenAI Chat Model - Gmail","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[1900,900],"parameters":{"options":{"maxTokens":1000,"temperature":0.3}},"credentials":{"openAiApi":{"id":"IdjfTMR7gLjapSWH","name":"Open Ai"}},"typeVersion":1.1},{"id":"b4cb3e8b-3d5c-49fb-9cc2-f46ffe4cd683","name":"🧠 Gmail Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[2040,980],"parameters":{"sessionKey":"gmail_{{ $json.customer_email }}","sessionIdType":"customKey"},"typeVersion":1.3},{"id":"442e8879-e6c3-4cd6-8f3b-3f64879047c1","name":"📧 Send Gmail Reply","type":"n8n-nodes-base.gmail","position":[2240,720],"webhookId":"c09e3c26-5430-4b47-864d-2344b636fa4e","parameters":{"message":"={{ $json.output }}","options":{"ccList":"","bccList":"","replyToSenderOnly":true},"messageId":"={{ $('📋 Process Gmail Message').item.json.message_id }}","operation":"reply"},"credentials":{"gmailOAuth2":{"id":"YQWc9jqYGygA6lXT","name":"Gmail account"}},"typeVersion":2},{"id":"668afdd0-f68b-45cb-afde-93ebaf7627d3","name":"✅ Mark Gmail as Read","type":"n8n-nodes-base.gmail","position":[2480,620],"webhookId":"3bae576f-ba6e-4ee2-a389-82171a9101d8","parameters":{"messageId":"={{ $('📋 Process Gmail Message').item.json.message_id }}","operation":"markAsRead"},"credentials":{"gmailOAuth2":{"id":"YQWc9jqYGygA6lXT","name":"Gmail account"}},"typeVersion":2},{"id":"2233ac1c-b704-4485-a4dd-3d873fb04538","name":"📊 Log Gmail Interaction","type":"n8n-nodes-base.googleSheets","position":[2540,820],"parameters":{"columns":{"value":{"Status":"Completed","Channel":"Email","Timestamp":"={{ new Date().toISOString() }}","AI_Response":"={{ $('🤖 Gmail AI Agent').item.json.output }}","Customer_Name":"={{ $('📋 Process Gmail Message').item.json.customer_name }}","Response_Time":"={{ new Date().toISOString() }}","Inquiry_Subject":"={{ $json.subject || 'General Inquiry' }}","Customer_Contact":"={{ $('📋 Process Gmail Message').item.json.customer_email }}","Customer_Message":"={{ $('📋 Process Gmail Message').item.json.message_content }}"},"schema":[{"id":"Timestamp","type":"string","display":true,"required":false,"displayName":"Timestamp","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Channel","type":"string","display":true,"required":false,"displayName":"Channel","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Customer_Name","type":"string","display":true,"required":false,"displayName":"Customer_Name","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Customer_Contact","type":"string","display":true,"required":false,"displayName":"Customer_Contact","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Inquiry_Subject","type":"string","display":true,"required":false,"displayName":"Inquiry_Subject","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Customer_Message","type":"string","display":true,"required":false,"displayName":"Customer_Message","defaultMatch":false,"canBeUsedToMatch":true},{"id":"AI_Response","type":"string","display":true,"required":false,"displayName":"AI_Response","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Response_Time","type":"string","display":true,"required":false,"displayName":"Response_Time","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Status","type":"string","display":true,"required":false,"displayName":"Status","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"list","value":1087576053,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8/edit#gid=1087576053","cachedResultName":"AI_Responses"},"documentId":{"__rl":true,"mode":"list","value":"1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8/edit?usp=drivesdk","cachedResultName":"customer_support_knowledge_base"}},"credentials":{"googleSheetsOAuth2Api":{"id":"ubQXdpluCtk0bGFi","name":"Google Sheets account"}},"typeVersion":4.2},{"id":"6e641113-9da3-430c-873d-59fd0c2997fb","name":"📊 Log Telegram Interaction","type":"n8n-nodes-base.googleSheets","position":[2760,960],"parameters":{"columns":{"value":{"Status":"Completed","Channel":"={{ $('📋 Process Telegram Message').item.json.channel }}","Timestamp":"={{ new Date().toISOString() }}","AI_Response":"={{ $json.output }}","Customer_Name":"={{ $('📋 Process Telegram Message').item.json.customer_name }}","Response_Time":"={{ new Date().toISOString() }}","Inquiry_Subject":"={{ $('📋 Process Telegram Message').item.json.subject }}","Customer_Contact":"={{ $('📋 Process Telegram Message').item.json.customer_id }}","Customer_Message":"={{ $('📋 Process Telegram Message').item.json.message_content }}"},"schema":[{"id":"Timestamp","type":"string","display":true,"required":false,"displayName":"Timestamp","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Channel","type":"string","display":true,"required":false,"displayName":"Channel","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Customer_Name","type":"string","display":true,"required":false,"displayName":"Customer_Name","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Customer_Contact","type":"string","display":true,"required":false,"displayName":"Customer_Contact","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Inquiry_Subject","type":"string","display":true,"required":false,"displayName":"Inquiry_Subject","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Customer_Message","type":"string","display":true,"required":false,"displayName":"Customer_Message","defaultMatch":false,"canBeUsedToMatch":true},{"id":"AI_Response","type":"string","display":true,"required":false,"displayName":"AI_Response","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Response_Time","type":"string","display":true,"required":false,"displayName":"Response_Time","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Status","type":"string","display":true,"required":false,"displayName":"Status","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"list","value":1087576053,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8/edit#gid=1087576053","cachedResultName":"AI_Responses"},"documentId":{"__rl":true,"mode":"list","value":"1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8/edit?usp=drivesdk","cachedResultName":"customer_support_knowledge_base"}},"credentials":{"googleSheetsOAuth2Api":{"id":"ubQXdpluCtk0bGFi","name":"Google Sheets account"}},"typeVersion":4.2},{"id":"50ded0f7-2513-4515-8843-e24cb50c89ae","name":"⚠️ Error Handling Info","type":"n8n-nodes-base.stickyNote","position":[3100,980],"parameters":{"width":300,"height":280,"content":"## 🚨 Error Handling\n\nThis section handles any errors that occur during the workflow execution and notifies the admin team.\n\n**Features:**\n- Captures all workflow errors\n- Sends notifications to admin\n- Logs errors for debugging\n- Provides fallback responses"},"typeVersion":1},{"id":"8634105f-1844-4e58-97f3-07697d86ac48","name":"🚨 Error Trigger","type":"n8n-nodes-base.errorTrigger","position":[2760,1300],"parameters":{},"typeVersion":1},{"id":"807781dc-c1ac-4bca-b298-420a3a3d5c2c","name":"📢 Notify Admin of Error","type":"n8n-nodes-base.httpRequest","position":[3020,1300],"parameters":{"url":"https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK","method":"POST","options":{},"sendBody":true,"bodyParameters":{"parameters":[{"name":"text","value":"🚨 Customer Support AI Error Alert\n\nWorkflow: Smart Customer Support AI\nError: {{ $json.error.message }}\nNode: {{ $json.error.node.name }}\nTime: {{ new Date().toISOString() }}\n\nPlease check the workflow execution for details."}]}},"typeVersion":4.2},{"id":"4581974a-7e7c-4b61-b5c7-a6023ef931d0","name":"Gmail Escalation Logger","type":"n8n-nodes-base.googleSheetsTool","position":[2300,920],"parameters":{"options":{},"sheetName":{"__rl":true,"mode":"list","value":1478316494,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8/edit#gid=1478316494","cachedResultName":"Customer_Inquiries"},"documentId":{"__rl":true,"mode":"list","value":"1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8/edit?usp=drivesdk","cachedResultName":"customer_support_knowledge_base"}},"credentials":{"googleSheetsOAuth2Api":{"id":"ubQXdpluCtk0bGFi","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"d9f13fc4-0a68-4bee-a36f-67e779bef7fe","name":"knowledge base","type":"n8n-nodes-base.googleSheetsTool","position":[2180,1000],"parameters":{"options":{},"sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8/edit#gid=0","cachedResultName":"Knowledge_Base"},"documentId":{"__rl":true,"mode":"list","value":"1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8/edit?usp=drivesdk","cachedResultName":"customer_support_knowledge_base"}},"credentials":{"googleSheetsOAuth2Api":{"id":"ubQXdpluCtk0bGFi","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"dfaba1db-fc45-4c09-b83d-2413086f52d8","name":"knowledge base1","type":"n8n-nodes-base.googleSheetsTool","position":[2240,1440],"parameters":{"options":{},"sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8/edit#gid=0","cachedResultName":"Knowledge_Base"},"documentId":{"__rl":true,"mode":"list","value":"1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8/edit?usp=drivesdk","cachedResultName":"customer_support_knowledge_base"}},"credentials":{"googleSheetsOAuth2Api":{"id":"ubQXdpluCtk0bGFi","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"a79e16e6-409a-47b1-a7f9-60de7aac1700","name":"Telegram Escalation Logger","type":"n8n-nodes-base.googleSheetsTool","position":[2420,1400],"parameters":{"options":{},"sheetName":{"__rl":true,"mode":"list","value":1478316494,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8/edit#gid=1478316494","cachedResultName":"Customer_Inquiries"},"documentId":{"__rl":true,"mode":"list","value":"1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1rEZ1A0Gd5ejT_b2F5tcYy9Xk4i0JvTrjss_oolf6WD8/edit?usp=drivesdk","cachedResultName":"customer_support_knowledge_base"}},"credentials":{"googleSheetsOAuth2Api":{"id":"ubQXdpluCtk0bGFi","name":"Google Sheets account"}},"typeVersion":4.5}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"791294ac-b7d5-45f8-951a-7146057b58f7","connections":{"knowledge base":{"ai_tool":[[{"node":"🤖 Gmail AI Agent","type":"ai_tool","index":0}]]},"knowledge base1":{"ai_tool":[[{"node":"🤖 Telegram AI Agent","type":"ai_tool","index":0}]]},"🧠 Gmail Memory":{"ai_memory":[[{"node":"🤖 Gmail AI Agent","type":"ai_memory","index":0}]]},"🚨 Error Trigger":{"main":[[{"node":"📢 Notify Admin of Error","type":"main","index":0}]]},"🤖 Gmail AI Agent":{"main":[[{"node":"📧 Send Gmail Reply","type":"main","index":0}]]},"🧠 Telegram Memory":{"ai_memory":[[{"node":"🤖 Telegram AI Agent","type":"ai_memory","index":0}]]},"📧 Send Gmail Reply":{"main":[[{"node":"✅ Mark Gmail as Read","type":"main","index":0},{"node":"📊 Log Gmail Interaction","type":"main","index":0}]]},"🤖 Telegram AI Agent":{"main":[[{"node":"💬 Send Telegram Reply","type":"main","index":0}]]},"Gmail Escalation Logger":{"ai_tool":[[{"node":"🤖 Gmail AI Agent","type":"ai_tool","index":0}]]},"💬 Send Telegram Reply":{"main":[[{"node":"📊 Log Telegram Interaction","type":"main","index":0}]]},"Telegram Escalation Logger":{"ai_tool":[[{"node":"🤖 Telegram AI Agent","type":"ai_tool","index":0}]]},"📋 Process Gmail Message":{"main":[[{"node":"🤖 Gmail AI Agent","type":"main","index":0}]]},"📋 Process Telegram Message":{"main":[[{"node":"🤖 Telegram AI Agent","type":"main","index":0}]]},"🧠 OpenAI Chat Model - Gmail":{"ai_languageModel":[[{"node":"🤖 Gmail AI Agent","type":"ai_languageModel","index":0}]]},"🧠 OpenAI Chat Model - Telegram":{"ai_languageModel":[[{"node":"🤖 Telegram AI Agent","type":"ai_languageModel","index":0}]]},"📧 Gmail Customer Inquiry Trigger":{"main":[[{"node":"📋 Process Gmail Message","type":"main","index":0}]]},"💬 Telegram Customer Message Trigger":{"main":[[{"node":"📋 Process Telegram Message","type":"main","index":0}]]}}}


name: Auto-Publish YouTube Videos to Facebook & Instagram with AI-Generated Captions
author_name: Yaron Been
author_username: yaron-nofluff
categories: []
created_at: 2025-05-29T07:09:15.501Z
updated_at: 2025-05-29T07:09:15.501Z
url: https://n8n.io/workflows/4478
scraped_at: 2025-07-06 21:16:30
description:
  Automatically turn your YouTube videos into engaging Facebook and Instagram posts with AI-generated captions.

  This powerful workflow monitors your YouTube channel for new uploads, generates engaging social media captions using AI, and automatically publishes to both Facebook pages and Instagram business accounts - maximizing your content reach across all major platforms.

  🚀 What It Does

  YouTube Channel Monitoring: Watches your YouTube RSS feed hourly for new video uploads and triggers cross-platform publishing

  AI Caption Generation: Uses GPT-4 to create engaging, platform-optimized social media captions with emojis and calls-to-action

  Facebook Auto-Publishing: Posts directly to your Facebook page with AI-generated captions and video links

  Instagram Business Posting: Creates Instagram posts using YouTube thumbnails as images with custom captions

  Smart Error Handling: Continues workflow even if one platform fails, ensuring maximum post distribution

  🎯 Key Benefits

  ✅ 3x Content Reach: Automatically distribute YouTube content across major social platforms  
  ✅ Save 5+ Hours Weekly: Eliminate manual cross-posting and caption writing  
  ✅ AI-Optimized Captions: Professional, engaging content tailored for social media  
  ✅ Instant Publishing: New YouTube videos become social posts within 1 hour  
  ✅ Professional Thumbnails: Uses high-quality YouTube thumbnails for Instagram  
  ✅ Set & Forget: Complete automation once configured  

  🏢 Perfect For

  Content Creators & YouTubers
  Individual creators maximizing content distribution
  Educational channels expanding social reach
  Entertainment creators building multi-platform presence
  Business channels driving traffic from social media

  Business Applications
  Brand Awareness**: Increase visibility across all major social platforms
  Traffic Generation**: Drive social media traffic back to YouTube content
  Audience Growth**: Reach different demographics on each platform
  Content Amplification**: Maximize ROI from video content creation

  ⚙️ What's Included

  Complete Cross-Platform Workflow: Ready-to-deploy multi-platform publishing system
  YouTube RSS Integration: Automatic monitoring of your channel for new uploads
  AI Caption Engine: GPT-4 powered social media caption generation
  Facebook Publishing: Direct integration with Facebook Pages API
  Instagram Business Integration: Full Instagram Business account posting capability
  Error-Resistant Design: Robust system continues working even if one platform fails

  🔧 Setup Requirements

  n8n Platform**: Cloud or self-hosted instance
  YouTube Channel**: RSS feed for monitoring new uploads
  Meta Developer Account**: Facebook app with required permissions
  OpenAI API**: GPT-4 access for caption generation
  Long-lived Access Token**: For Facebook and Instagram API access

  📊 Required Meta API Permissions

  Required Permissions:
  ✅ pages_manage_posts
  ✅ pages_read_engagement  
  ✅ pages_show_list
  ✅ instagram_content_publish
  ✅ instagram_basic

  Token Type: Long-lived access token
  API Version: v22.0

  🎨 Sample AI Caption Generation

  YouTube Video: "10 Tips for Better Photography"

  Generated Social Caption:
  📸 Just dropped my latest photography tutorial! 

  Discover 10 game-changing tips that will transform your photos from amateur to professional. Whether you're just starting out or looking to level up your skills, these techniques will make a huge difference! 

  ✨ What you'll learn:
  • Composition secrets the pros use
  • Lighting techniques for any situation  
  • Camera settings that actually matter

  Which tip surprised you the most? Drop a comment below! 👇

  Watch the full tutorial: [YouTube Link]

  #Photography #Tutorial #PhotoTips #ContentCreator #Learn

  🎯 Customization Options

  Caption Personalization: Adjust AI prompts for your brand voice, hashtags, and audience
  Platform-Specific Formatting: Different caption styles for Facebook vs Instagram
  Posting Schedule: Modify monitoring frequency (hourly, daily, custom intervals)
  Multiple Channels: Monitor multiple YouTube channels with different posting strategies
  Content Filtering: Add filters for specific video types or topics
  Brand Integration: Include consistent branding elements and calls-to-action

  🏷️ Tags & Categories

  #youtube-automation #social-media-publishing #cross-platform-marketing #facebook-automation #instagram-business #content-distribution #ai-caption-generation #social-media-management #multi-platform-posting #youtube-marketing #content-amplification #social-media-automation #creator-tools #video-marketing #workflow-automation

  💡 Use Case Examples

  Educational Creator: Automatically share tutorial videos across platforms to reach students on different social networks

  Product Review Channel: Distribute review videos to Facebook and Instagram to drive traffic and affiliate sales

  Business Coach: Share valuable content across platforms to build authority and attract consulting clients

  Entertainment Channel: Maximize viral potential by instantly distributing funny videos across all major platforms

  🛠️ Setup & Support

  Quick Configuration: Complete setup in 45 minutes with Meta Developer account and API tokens
  Template Access Tokens: Instructions for generating long-lived Facebook/Instagram tokens
  Channel Integration: Simple YouTube RSS feed configuration for any channel
  Testing Protocol: Built-in error handling and testing procedures

  📞 Get Help & Resources


  YouTube: https://www.youtube.com/@YaronBeen/videos

  💼 Social Media Automation Support  
  LinkedIn: https://www.linkedin.com/in/yaronbeen/

  📧 Technical Configuration Help  
  Email: Yaron@nofluff.online - Response within 24 hours

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

workflow_json:
  {"id":"kPBvBnjidCFr5v69","meta":{"instanceId":"2c6d3d38af8a4c0f79fb39f43818e6004a0dbcc85be9dad124fc43e13d64847f","templateCredsSetupCompleted":true},"name":"Youtube to Instagram_Facebook","tags":[],"nodes":[{"id":"workflow-overview-social","name":"Workflow Overview","type":"n8n-nodes-base.stickyNote","position":[-1300,-320],"parameters":{"color":2,"width":350,"height":380,"content":"# 📱 YouTube to Social Media Automation\n\n**Purpose:** Auto-publish YouTube videos to Facebook & Instagram\n\n**Schedule:** Checks for new videos every hour\n\n**Required Setup:**\n1. YouTube channel RSS feed\n2. OpenAI API key (GPT-4o-mini)\n3. Meta App with permissions\n4. Long-lived access token\n\n## Workflow Steps:\n1. **Monitor** - RSS feed for new videos\n2. **Generate** - AI creates social caption\n3. **Publish** - Posts to FB & Instagram\n\n💡 Update all `<Access_Token>` and `<Facebook_PageID>` placeholders"},"typeVersion":1},{"id":"rss-trigger-note","name":"RSS Trigger Info","type":"n8n-nodes-base.stickyNote","position":[-1040,-320],"parameters":{"color":3,"width":280,"height":220,"content":"## 🎥 YouTube RSS Trigger\n\n**Monitors your YouTube channel:**\n- Checks every hour for new uploads\n- Uses YouTube RSS feed format\n\n**To find your channel ID:**\n1. Go to your YouTube channel\n2. View page source\n3. Search for \"channelId\"\n\n⚠️ Replace channel_id in RSS URL"},"typeVersion":1},{"id":"ai-caption-note","name":"AI Caption Generation","type":"n8n-nodes-base.stickyNote","position":[-740,-320],"parameters":{"color":5,"width":280,"height":200,"content":"## 🤖 AI Caption Generation\n\n**OpenAI GPT-4o-mini:**\n- Generates engaging social media captions\n- Includes emojis automatically\n- Adds call-to-action\n\n**Customize the prompt to:**\n- Match your brand voice\n- Include specific hashtags\n- Target your audience"},"typeVersion":1},{"id":"facebook-post-note","name":"Facebook Publishing","type":"n8n-nodes-base.stickyNote","position":[-390,-440],"parameters":{"color":4,"width":250,"height":180,"content":"## 📘 Facebook Publishing\n\n**Direct post to Facebook Page**\n\n⚠️ **Required updates:**\n- Replace `<Facebook_PageID>`\n- Replace `<Access_Token>`\n\n**Note:** Uses error handling to continue workflow even if Facebook fails"},"typeVersion":1},{"id":"instagram-flow-note","name":"Instagram Publishing Flow","type":"n8n-nodes-base.stickyNote","position":[-120,-180],"parameters":{"color":6,"width":300,"height":220,"content":"## 📸 Instagram Publishing Flow\n\n**3-step process:**\n1. Get Business Account ID\n2. Create media container with thumbnail\n3. Publish the post\n\n**Automatic thumbnail:**\nPulls YouTube video thumbnail as Instagram image\n\n⚠️ Requires Instagram Business Account linked to Facebook Page"},"typeVersion":1},{"id":"api-requirements-note","name":"API Requirements","type":"n8n-nodes-base.stickyNote","position":[-440,280],"parameters":{"color":1,"width":250,"height":200,"content":"⚠️ **Meta API Requirements**\n\n**Required Permissions:**\n- pages_manage_posts\n- pages_read_engagement\n- pages_show_list\n- instagram_content_publish\n- instagram_basic\n\n**Token Type:** Long-lived access token\n**API Version:** v22.0"},"typeVersion":1},{"id":"cda123c2-21a3-421d-918e-5a6973002aa3","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","notes":"Formats post caption using video metadata. Customize prompt for your brand voice and hashtags","position":[-740,-80],"parameters":{"text":"=Write a short, engaging social media post about this new YouTube video:\n\nTitle: {{ $json.title }}\nURL: {{ $json.link }}\n\nInclude emojis and a call to action.","options":{},"promptType":"define"},"typeVersion":1.9},{"id":"d215f6c3-f9d7-4103-8c26-419f468cf74b","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","notes":"Uses GPT-4o-mini to generate the caption text","position":[-740,160],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"p5RrjC1K9qFbdflM","name":"OpenAi account"}},"typeVersion":1.2},{"id":"fbf6f102-1f8d-4e22-a850-1f5f163b94d5","name":"Post on Facebook","type":"n8n-nodes-base.httpRequest","notes":"Publishes the caption using Facebook Graph API. Replace <Facebook_PageID> and <Access_Token>","onError":"continueErrorOutput","position":[-340,-240],"parameters":{"url":"=https://graph.facebook.com/v22.0/<Facebook_PageID>/feed\n","method":"POST","options":{},"sendBody":true,"contentType":"form-urlencoded","authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"message","value":"={{ $json.output }}"},{"name":"access_token","value":"<Access_Token>"}]},"genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"jfdonlZifjvvr","name":"Header Auth account"}},"typeVersion":4.2},{"id":"000891de-e3e2-4de8-8742-ad45a2a958db","name":"Publish Post On Instagram","type":"n8n-nodes-base.httpRequest","notes":"Publishes post to Instagram feed using the media container ID","position":[180,60],"parameters":{"url":"=https://graph.facebook.com/v22.0/{{ $('Get IG Business Account ID').item.json.instagram_business_account.id }}/media_publish\n","method":"POST","options":{},"sendBody":true,"contentType":"form-urlencoded","bodyParameters":{"parameters":[{"name":"creation_id","value":"={{ $json.id }}"},{"name":"access_token","value":"<Access_Token>"}]}},"typeVersion":4.2},{"id":"2e65dd2e-7f9e-4abd-b6c7-e811b3a86349","name":"Get IG Business Account ID","type":"n8n-nodes-base.httpRequest","notes":"Retrieves Instagram Business account ID linked to Facebook Page","onError":"continueErrorOutput","position":[-340,80],"parameters":{"url":"https://graph.facebook.com/v22.0/<Facebook_PageID>","options":{},"sendQuery":true,"queryParameters":{"parameters":[{"name":"fields","value":"instagram_business_account"},{"name":"access_token","value":"<Access_Token>"}]}},"typeVersion":4.2},{"id":"c2d089b9-754c-49fe-aa4d-976072340a0e","name":"Create Media Container","type":"n8n-nodes-base.httpRequest","notes":"Uploads YouTube thumbnail as Instagram image with AI-generated caption","position":[-80,60],"parameters":{"url":"=https://graph.facebook.com/v22.0/{{ $json.instagram_business_account.id }}/media","method":"POST","options":{},"sendBody":true,"contentType":"form-urlencoded","bodyParameters":{"parameters":[{"name":"image_url","value":"=https://img.youtube.com/vi/{{ $('Pull Youtube Video From Channel').item.json.link.split(\"=\")[1] }}/maxresdefault.jpg"},{"name":"caption","value":"={{ $('AI Agent').item.json.output }}"},{"name":"access_token","value":"<Access_Token>"}]}},"typeVersion":4.2},{"id":"29656ae1-d60e-4f4d-9326-17801ddcbb65","name":"Pull Youtube Video From Channel","type":"n8n-nodes-base.rssFeedReadTrigger","notes":"Monitors new uploads from your YouTube channel. Replace channel_id in RSS URL","position":[-1000,-80],"parameters":{"feedUrl":"https://www.youtube.com/feeds/videos.xml?channel_id=UC2Tf8MGUzFX-GPkuBEBSKMg","pollTimes":{"item":[{"mode":"everyHour"}]}},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"a459b777-6ecf-46d2-9543-061a888393a6","connections":{"AI Agent":{"main":[[{"node":"Get IG Business Account ID","type":"main","index":0},{"node":"Post on Facebook","type":"main","index":0}]]},"Post on Facebook":{"main":[[]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Create Media Container":{"main":[[{"node":"Publish Post On Instagram","type":"main","index":0}]]},"Publish Post On Instagram":{"main":[[]]},"Get IG Business Account ID":{"main":[[{"node":"Create Media Container","type":"main","index":0}]]},"Pull Youtube Video From Channel":{"main":[[{"node":"AI Agent","type":"main","index":0}]]}}}


name: AI-Powered Candidate Screening and Evaluation Workflow using OpenAI and Airtable
author_name: Billy Christi
author_username: billy
categories: []
created_at: 2025-05-29T11:06:09.128Z
updated_at: 2025-05-29T11:06:09.128Z
url: https://n8n.io/workflows/4481
scraped_at: 2025-07-06 21:16:30
description:
  Who is this for?

  This workflow is ideal for:

  HR professionals* and *recruiters** who want to automate and enhance the hiring process
  Organizations** seeking AI-driven, consistent, and data-backed candidate evaluations
  Hiring managers** using Airtable as their recruitment database

  What problem is this workflow solving?

  Screening candidates manually is time-consuming, inconsistent, and difficult to scale. This workflow solves that by:

  Automating resume intake and AI evaluation**
  Matching candidates to job postings dynamically**
  Generating standardized suitability reports**
  Notifying HR only when candidates meet the criteria**
  Storing all applications in a structured Airtable database**

  What this workflow does

  This workflow builds an end-to-end AI-powered hiring pipeline using Airtable, OpenAI, and Google Drive. Here's how it works:

  Accept candidate applications via a public web form, including resume upload (PDF only)
  Extract text from uploaded resumes for processing
  Store resumes in Google Drive and generate shareable links
  Match the application to a job posting stored in Airtable
  Use AI to evaluate candidates (via OpenAI GPT-4) against job descriptions and requirements
  Generate suitability results including:

     Match percentage
     Screening status: Suitable, Not Suitable, Under Review
     Detailed notes
  Combine AI output and files into one data object
  Create a new candidate record in Airtable with all application data
  Automatically notify HR via Gmail if a candidate is marked “Suitable”

  Setup

  View & Copy the Airtable base here:  
  👉 Candidate Screening – Airtable Base Template  
  Set up Google Drive folder
  Connect your OpenAI API key for the AI agent model
  Connect your Gmail account for email notifications
  Deploy the public-facing form to start receiving applications
  Test the workflow using a sample job and resume

  How to customize this workflow to your needs

  Expand file support**: Allow DOC or DOCX uploads by adding format conversion nodes
  Add multi-recipient email alerts**: Extend Gmail node for multiple HR recipients
  Handle “Under Review” differently**: Add additional logic to notify or flag these candidates
  Send rejection emails automatically**: Extend the IF branch for “Not Suitable” candidates
  Schedule interviews**: Integrate with Google Calendar or Calendly APIs
  Add Slack notifications**: Send alerts to team channels for real-time updates

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

workflow_json:
  {"meta":{"instanceId":"d1786ab0d745a7498abf13a9c2cdabb1374c006e889b79eef64ce0386b8f8a41","templateCredsSetupCompleted":true},"nodes":[{"id":"eb5ebae6-b369-4540-93d4-de8bcc2be075","name":"Search Job Posting","type":"n8n-nodes-base.airtable","position":[2040,-80],"parameters":{"base":{"__rl":true,"mode":"list","value":"appgVjZcaRP8BsKf0","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0","cachedResultName":"HR Database"},"limit":1,"table":{"__rl":true,"mode":"list","value":"tblla4rBCW3BhPtRO","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0/tblla4rBCW3BhPtRO","cachedResultName":"Job Posting"},"options":{},"operation":"search","returnAll":false,"filterByFormula":"=FIND(LOWER(\"{{ $('Candidate Application Form').item.json['Position Applied For'] }}\"), LOWER({Job Title})) > 0"},"credentials":{"airtableTokenApi":{"id":"r2IibdsQurA56LDa","name":"Airtable Personal Access Token account"}},"typeVersion":2.1},{"id":"5a39a9d5-ae99-486a-9831-14a0c2945636","name":"Create Candidate","type":"n8n-nodes-base.airtable","position":[3000,140],"parameters":{"base":{"__rl":true,"mode":"list","value":"appgVjZcaRP8BsKf0","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0","cachedResultName":"HR Database"},"table":{"__rl":true,"mode":"list","value":"tblQy83erGR5lQj5c","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0/tblQy83erGR5lQj5c","cachedResultName":"Candidates"},"columns":{"value":{"Resume":"={{ $json.file_array }}","Full Name":"={{ $('Candidate Application Form').item.json['Full Name '] }}","Cover Letter":"={{ $('Candidate Application Form').item.json['Cover Letter'] }}","Date Applied":"={{ $now }}","Email Address":"={{ $('Candidate Application Form').item.json['Email Address'] }}","Relevant Skills":"={{ $('Candidate Application Form').item.json['Relevant Skills'] }}","Screening Notes":"={{ $json.output.screening_notes }}","Match Percentage":"={{ $json.output.match_percentage }}","Position Applied":"={{ $('Candidate Application Form').item.json['Position Applied For'] }}","Screening Status":"={{ $json.output.screening_status }}"},"schema":[{"id":"Candidate ID","type":"string","display":true,"removed":true,"readOnly":true,"required":false,"displayName":"Candidate ID","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Full Name","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Full Name","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Email Address","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Email Address","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Position Applied","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Position Applied","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Relevant Skills","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Relevant Skills","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Cover Letter","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Cover Letter","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Resume","type":"array","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Resume","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Screening Status","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Screening Status","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Match Percentage","type":"number","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Match Percentage","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Screening Notes","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Screening Notes","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Date Applied","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Date Applied","defaultMatch":false,"canBeUsedToMatch":true},{"id":"test","type":"options","display":true,"options":[{"name":"1","value":"1"},{"name":"2","value":"2"},{"name":"3","value":"3"}],"removed":true,"readOnly":false,"required":false,"displayName":"test","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"create"},"credentials":{"airtableTokenApi":{"id":"r2IibdsQurA56LDa","name":"Airtable Personal Access Token account"}},"typeVersion":2.1},{"id":"5604f43d-e7df-404a-b034-f82a667c9871","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[2320,140],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"MGwGMKEkdcjzlYCw","name":"OpenAi account"}},"typeVersion":1.2},{"id":"d2acb00b-9e36-4200-99e8-5a8918f7ddb1","name":"Structured Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[2500,140],"parameters":{"jsonSchemaExample":"{\n  \"screening_status\": \"Suitable\",\n  \"match_percentage\": 88,\n  \"screening_notes\": \"Detailed explanation of the assessment, including relevant skill matches, experience analysis, and justification for the screening status.\"\n}"},"typeVersion":1.2},{"id":"f5071709-8201-40e0-a3dd-ff77376eed11","name":"Candidate Screener AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[2320,-80],"parameters":{"text":"=Candidate Screening Information:\n\n///\nUser Side:\n\nPosition Applied:  \n{{ $('Search Job Posting').item.json['Job Title'] }}\n\nRelevant Skills the Candidate Possesses:\n{{ $('Candidate Application Form').item.json['Relevant Skills'] }}\n\n\nCover Letter:  \n{{ $('Candidate Application Form').item.json['Cover Letter'] }}\n\nResume Content:  \n{{ $('Extract Resume PDF').item.json.text }}\n\n///\n\nEmployer Side:\n\nPosition Description:  \n{{ $('Search Job Posting').item.json['Job Description'] }}\n\nSkills Required:  \n{{ $('Search Job Posting').item.json['Required Skills'] }}\n\n///","options":{"systemMessage":"=You are a Candidate Screening AI Agent responsible for assessing candidate suitability for specific job positions based on the provided information. \n\nObjective:\nEvaluate the candidate’s fit for the applied position by analyzing their relevant skills, cover letter, and resume content. Compare this information with the job description and required skills provided by the employer to determine suitability, a match percentage, and screening notes.\n\nInput Fields:\n\nUser Side:\n- Position applied: The job position the candidate applied for.\n- Relevant skills: A list of key skills the candidate possesses.\n- Cover letter: Candidate’s introduction, work experience, and key achievements.\n- Resume: Parsed text content extracted from the resume in plain text format.\n\nEmployer Side:\n- Position description: Detailed job description including responsibilities and expectations.\n- Skills required: A list of required skills for the position.\n\nOutput Fields:\n- Screening Status: One of the following options: \"Suitable\", \"Not Suitable\", \"Under Review\".\n- Match Percentage: A numerical score indicating the percentage of relevant skills matching the job requirements.\n- Screening Notes: A summary of the assessment, including strengths, areas for improvement, and justification for the screening status.\n\nInstructions:\n1. Extract and analyze relevant skills mentioned in the cover letter and resume content.\n2. Compare the extracted skills with the job requirements and skills required by the employer.\n3. Assign a Match Percentage based on the alignment of skills and experience.\n4. Determine the Screening Status based on the skill match and relevance of the candidate’s experience to the position.\n5. Provide comprehensive Screening Notes to justify the assigned status and percentage, highlighting strengths and areas for improvement."},"promptType":"define","hasOutputParser":true},"typeVersion":1.9},{"id":"9050d69b-8fed-45ea-8b14-0456d88fe056","name":"Set File Array for airtable","type":"n8n-nodes-base.set","position":[2360,580],"parameters":{"mode":"raw","options":{},"jsonOutput":"={\"file_array\":[\n  {\n    \"url\": \"{{ $('Upload File').item.json.webContentLink }}\",\n    \"filename\": \"{{ $('Upload File').item.json.name }}\"\n  }\n]\n}"},"typeVersion":3.4},{"id":"584743e4-ddcd-4744-a01f-493ab6890b24","name":"Merge","type":"n8n-nodes-base.merge","position":[2760,140],"parameters":{"mode":"combine","options":{},"combineBy":"combineAll"},"typeVersion":3.1},{"id":"7ef768ee-58ef-4769-9abc-ff10e2a59fe9","name":"Upload File","type":"n8n-nodes-base.googleDrive","position":[1880,580],"parameters":{"name":"={{ $json.Resume.filename }}","driveId":{"__rl":true,"mode":"list","value":"My Drive"},"options":{},"folderId":{"__rl":true,"mode":"list","value":"13BuRkJofybsBlF77oqoS87A2qq4zD2aP","cachedResultUrl":"https://drive.google.com/drive/folders/13BuRkJofybsBlF77oqoS87A2qq4zD2aP","cachedResultName":"pdf dev"},"inputDataFieldName":"Resume"},"credentials":{"googleDriveOAuth2Api":{"id":"SEUhrgz30NMJS3cH","name":"Google Drive account"}},"typeVersion":3},{"id":"bd096e95-3c2c-450f-9779-e63977f89797","name":"Set File Permission","type":"n8n-nodes-base.googleDrive","position":[2120,580],"parameters":{"fileId":{"__rl":true,"mode":"id","value":"={{ $json.id }}"},"options":{},"operation":"share","permissionsUi":{"permissionsValues":{"role":"reader","type":"anyone"}}},"credentials":{"googleDriveOAuth2Api":{"id":"SEUhrgz30NMJS3cH","name":"Google Drive account"}},"typeVersion":3},{"id":"82bf4fbd-bed1-43be-b1df-be5319069a32","name":"Check if candidate is suitable","type":"n8n-nodes-base.if","position":[3200,140],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"ab5102cf-0952-465e-9340-59ced9f39ce1","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $('Merge').item.json.output.screening_status }}","rightValue":"Suitable"}]}},"typeVersion":2.2},{"id":"e886feba-772f-46a3-b22d-9fb0af1b2250","name":"Send email to HR","type":"n8n-nodes-base.gmail","position":[3480,140],"webhookId":"48fa841c-0312-4829-a80c-85cd37deec25","parameters":{"sendTo":"hr_team_n8n@yopmail.com","message":"=We have successfully completed the candidate screening process, and {{ $('Candidate Application Form').item.json['Full Name '] }} has been identified as a suitable candidate for the {{ $('Search Job Posting').item.json['Job Title'] }} position.  \n\nCandidate Details:  \n- Position Applied: {{ $('Search Job Posting').item.json['Job Title'] }}  \n- Match Percentage: {{ $('Candidate Screener AI Agent').item.json.output.match_percentage }}%  \n- Screening Notes: {{ $('Candidate Screener AI Agent').item.json.output.screening_notes }}\n\nPlease proceed with the next steps in the interview scheduling process. If you need any further information or clarification, feel free to reach out.  \n\nThank you,  \nSuper Awesome HR AI Agent","options":{"appendAttribution":false},"subject":"=Candidate {{ $('Candidate Application Form').item.json['Full Name '] }} - Suitable for {{ $('Search Job Posting').item.json['Job Title'] }}\n","emailType":"text"},"credentials":{"gmailOAuth2":{"id":"sWl7FFMkEUYBj0zM","name":"Gmail account"}},"typeVersion":2.1},{"id":"5d52401f-d9de-425e-88fb-b5bc51e04d78","name":"Candidate Application Form","type":"n8n-nodes-base.formTrigger","position":[1400,-80],"webhookId":"2d4004d0-4c93-49d5-9c3a-4e05264fc772","parameters":{"options":{},"formTitle":"Smart Candidate Screening Form","formFields":{"values":[{"fieldLabel":"Full Name ","requiredField":true},{"fieldType":"email","fieldLabel":"Email Address","requiredField":true},{"fieldLabel":"Position Applied For","requiredField":true},{"fieldType":"textarea","fieldLabel":"Relevant Skills","requiredField":true},{"fieldType":"textarea","fieldLabel":"Cover Letter","requiredField":true},{"fieldType":"file","fieldLabel":"Resume","multipleFiles":false,"acceptFileTypes":".pdf"}]}},"typeVersion":2.2},{"id":"1d3ed59d-4887-467a-977f-8a8f84a6528c","name":"Extract Resume PDF","type":"n8n-nodes-base.extractFromFile","position":[1720,-80],"parameters":{"options":{},"operation":"pdf","binaryPropertyName":"Resume"},"typeVersion":1},{"id":"3f489b80-48a6-4e56-b6b9-8db2ddeb3806","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[2280,-360],"parameters":{"color":4,"width":360,"height":680,"content":"🧠 Candidate Screener AI Agent\nUses OpenAI to analyze:\n- Resume content vs job requirements\n- Skills matching\n- Cover letter quality\n\n📊 OUTPUTS:\n- Screening Status (Suitable/Not Suitable/Under Review)\n- Match Percentage (0-100%)\n- Detailed screening notes\n"},"typeVersion":1},{"id":"335e8f4c-7c80-4cfd-9d7d-f8257d2fbe8c","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[1920,-220],"parameters":{"color":4,"width":340,"height":300,"content":"## Search Job Posting (Job Matching)\nFinds the matching job posting for the applied position"},"typeVersion":1},{"id":"ecb40f1b-2fd5-468e-ac0b-fcf0d82ca110","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[1800,380],"parameters":{"color":4,"width":760,"height":340,"content":"## File Preparation for Airtable Upload\n\n- Upload the file to Google Drive  \n- Set the permission to public  \n- Format the data to match the format required by Airtable for file uploads\n"},"typeVersion":1},{"id":"191f577e-9230-409d-a69e-d7a7dfef3963","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[2720,-20],"parameters":{"color":4,"width":420,"height":380,"content":"## Merge & Create Candidate\n\n- Merge data from both flows (Candidate Screener AI Agent and File Flow)  \n- Use the merged data to create a candidate in Airtable\n"},"typeVersion":1},{"id":"e05d6d9a-75b6-4279-bf1b-10ff9514ad75","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[3180,-60],"parameters":{"color":4,"width":420,"height":420,"content":"## Check Candidate & Send Email to HR\n\n- Check if the candidate is qualified or not  \n- If the candidate is qualified, the system will send an email to HR\n"},"typeVersion":1},{"id":"e8230b23-6e4f-446a-ab10-fc1cd1363713","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[1320,-380],"parameters":{"color":4,"width":560,"height":580,"content":"## Candidate Application Form\n\nWeb form for candidates to submit applications\n\nFields:\n- Full Name (required)\n- Email Address (required, email validation)\n- Position Applied For (required)\n- Relevant Skills (textarea, required)\n- Cover Letter (textarea, required)\n- Resume (PDF file upload only)"},"typeVersion":1},{"id":"e8423226-d858-41c8-8387-2b4a937c84ac","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[1000,-380],"parameters":{"color":4,"width":280,"height":280,"content":"## SETUP REQUIRED\n**Author:** [Billy Christi](https://n8n.io/creators/billy/)\n\nAirtable Base Structure:  \n[Copy this Airtable Base](https://airtable.com/appgVjZcaRP8BsKf0/shrQAqQ2JUW50EEyW/tblGIVbpACRwWzzlp/viwWS2Ohh6oXZLvyY?blocks=hide)\n\nRequired Credentials:  \n• Airtable API Key  \n• OpenAI API Key (GPT-4)  \n• Google Drive Credential\n• Gmail Credential\n"},"typeVersion":1},{"id":"55e89737-4449-4efb-9220-b40e9c1ff1af","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[680,340],"parameters":{"color":5,"width":460,"height":460,"content":"## 🤖 AI-Powered Candidate Screening and Evaluation Workflow using OpenAI and Airtable\n\n**What This Template Does:**\n- Creates a web form for candidates to submit applications with resume uploads\n- Automatically extracts and processes text content from PDF resumes\n- Uses GPT-4 AI to intelligently match candidates against job requirements\n- Calculates compatibility scores and generates detailed screening notes\n- Stores candidate data and resumes in Airtable database and Google Drive\n- Automatically emails HR team when suitable candidates are found\n- Fully automates the entire hiring pipeline from application to notification"},"typeVersion":1},{"id":"9ea639a0-efb8-48f3-9143-e3eeb7a9d641","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[1160,340],"parameters":{"color":5,"width":500,"height":460,"content":"## 📋 WORKFLOW PROCESS OVERVIEW\nStep 1: 📝 Candidate Application Form collects candidate details and PDF resume  \nStep 2: 📄 Extract Resume PDF converts uploaded PDF into readable text  \nStep 3: 📁 Upload File stores resume in Google Drive and sets permissions  \nStep 4: 🔍 Search Job Posting finds matching job in Airtable database  \nStep 5: 🤖 AI Agent (OpenAI) evaluates candidate fit and generates screening results  \nStep 6: 💾 Create Candidate stores complete record in Airtable with AI results  \nStep 7: ✅ Check Suitability determines if candidate meets requirements  \nStep 8: 📧 Send Email to HR notifies team when candidate is suitable"},"typeVersion":1}],"pinData":{},"connections":{"Merge":{"main":[[{"node":"Create Candidate","type":"main","index":0}]]},"Upload File":{"main":[[{"node":"Set File Permission","type":"main","index":0}]]},"Create Candidate":{"main":[[{"node":"Check if candidate is suitable","type":"main","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"Candidate Screener AI Agent","type":"ai_languageModel","index":0}]]},"Extract Resume PDF":{"main":[[{"node":"Search Job Posting","type":"main","index":0}]]},"Search Job Posting":{"main":[[{"node":"Candidate Screener AI Agent","type":"main","index":0}]]},"Set File Permission":{"main":[[{"node":"Set File Array for airtable","type":"main","index":0}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"Candidate Screener AI Agent","type":"ai_outputParser","index":0}]]},"Candidate Application Form":{"main":[[{"node":"Extract Resume PDF","type":"main","index":0},{"node":"Upload File","type":"main","index":0}]]},"Candidate Screener AI Agent":{"main":[[{"node":"Merge","type":"main","index":0}]]},"Set File Array for airtable":{"main":[[{"node":"Merge","type":"main","index":1}]]},"Check if candidate is suitable":{"main":[[{"node":"Send email to HR","type":"main","index":0}]]}}}


name: LinkedIn Post Automation with AI (GPT-4o) Generation & Slack Approval
author_name: Amit Mehta
author_username: amitswba
categories: []
created_at: 2025-05-29T11:20:45.319Z
updated_at: 2025-05-29T11:20:45.319Z
url: https://n8n.io/workflows/4483
scraped_at: 2025-07-06 21:16:30
description:
  LinkedIn Post Automation with AI Generation (Gpt-4o) & Slack Approval

  How it Works

  This workflow automates the creation and publishing of LinkedIn posts with AI-generated content and human approval via Slack, using Google Sheets, OpenAI (GPT-4), Slack Interactive Messages, and the LinkedIn API.

  Whether you're a social media manager, content creator, or marketing professional, this workflow helps you maintain consistent LinkedIn presence and scale content creation while keeping human oversight — all managed from a simple spreadsheet.

  🎯 Use Case

  Ideal for:
  Content Marketers** managing multiple LinkedIn accounts
  Personal Brand Builders** maintaining regular posting schedule  
  Agencies** handling client social media presence
  Teams** requiring content approval workflows

  Setup Instructions

  1. Prepare the Spreadsheet

  File name: Linkedin Post
  Main sheet structure:
  | ID | Linkedin Post Title | Status | Image URL |
  Groups sheet structure:
  | GroupIds |
  Add post topics and set their Status as Pending

  2. Configure Google Sheets Nodes

  Connect your Google account to:
  Linkedin-Post-Topic (Trigger node)
  Update-Status 
  Get-Group-id

  3. Add API Credentials

  OpenAI API Key** → for GPT-4 content generation
  Slack OAuth Token** → for approval messages
  LinkedIn Access Token** → for posting content
  HTTP Header Auth** → Bearer token for LinkedIn API

  4. Configure Webhooks

  Set up Slack Interactive Components webhook
  Point Request URL to your N8N webhook endpoint
  Enable interactive messages in Slack app

  5. Activate the Workflow

  Once live, the workflow will:
  Monitor spreadsheet for new topics every minute
  Generate LinkedIn post using GPT-4
  Send to Slack for approval/editing
  Upload image to LinkedIn
  Publish to profile and groups
  Update spreadsheet status to Posted

  🔁 Workflow Logic

  Trigger: New/updated row with Pending status
  Generate: AI creates engaging LinkedIn post
  Approve: Slack message for review/edit
  Process: Handle approval response
  Upload: Register and upload image
  Publish: Post to LinkedIn profile & groups
  Update: Mark as Posted in sheet

  🧩 Node Descriptions

  | Node Name | Description |
  |-----------|-------------|
  | Linkedin-Post-Topic | Monitors spreadsheet for new post topics |
  | Validate-Status | Filters only 'Pending' items |
  | Limit | Processes one item at a time |
  | Linedin-Post-Creator | Generates post content using GPT-4 |
  | Format-Content | Prepares content for Slack display |
  | Approval-on-Slack | Sends interactive approval message |
  | Webhook | Receives Slack button responses |
  | Format-Response | Extracts edited content from Slack |
  | Set-Final-Message | Prepares approved content |
  | Linkedin-User-Detail | Fetches LinkedIn user info |
  | Register Image | Initiates LinkedIn image upload |
  | Upload Image | Uploads image to LinkedIn |
  | Linkedin-post | Publishes to personal profile |
  | Get-Group-id | Retrieves LinkedIn group IDs |
  | Post-Linkedin-Groups | Posts to multiple groups |
  | Update-Status | Marks as completed in sheet |

  🛠️ Customization Tips

  Adjust AI prompt for brand voice and hashtags
  Change Slack approver or add multiple reviewers
  Modify posting schedule with delay nodes
  Add analytics tracking with additional API calls
  Filter groups based on specific criteria
  Include URL shortening for tracking

  📒 Suggested Sticky Notes for Workflow

  | Node/Section | Sticky Note Content |
  |--------------|---------------------|
  | Linkedin-Post-Topic | "Triggers every minute for new posts in your spreadsheet" |
  | Validate-Status | "Filters to process only 'Pending' items - prevents duplicates" |
  | Linedin-Post-Creator | "Uses GPT-4 to generate LinkedIn content - customize prompt for your brand voice" |
  | Approval-on-Slack | "Sends for human review - edit the Slack user to change approver" |
  | Webhook | "Receives approval responses - ensure URL is configured in Slack app" |
  | Register Image | "Initiates LinkedIn media upload - requires valid image URL from sheet" |
  | Linkedin-post | "Publishes to your profile - update with your LinkedIn credentials" |
  | Post-Linkedin-Groups | "Posts to multiple groups - add group IDs in Groups sheet" |
  | Update-Status | "Marks as 'Posted' to prevent reprocessing" |

  💡 AI Prompt Configuration

  The workflow uses a sophisticated prompt that:
  Creates compelling hooks
  Includes 3-4 informative paragraphs
  Adds engagement questions
  Inserts relevant emojis
  Generates 4-6 hashtags
  Formats with proper spacing

  🔒 Security & Permissions

  LinkedIn App Requirements:
  r_liteprofile - Read profile data
  r_emailaddress - Access email
  w_member_social - Post content
  rw_organization_admin - Group posting

  Slack Bot Permissions:
  chat:write - Send messages
  im:write - Direct messages
  users:read - User information

  📎 Required Components

  | Component | Purpose |
  |-----------|---------|
  | Google Sheet | Store post topics and status |
  | LinkedIn App | API access for posting |
  | Slack App | Interactive approval flow |
  | OpenAI Account | GPT-4 content generation |
  | N8N Instance | Workflow execution |

  🧪 Testing Tips

  Start with one test topic marked as Pending
  Verify Slack message appears correctly
  Test both "Approve" and "Edit" buttons
  Check image upload completes
  Confirm post appears on LinkedIn
  Verify status updates to Posted

  ⚠️ Common Issues & Solutions

  LinkedIn API Errors:
  Token expiration → Refresh access token
  Rate limits → Add delays between posts
  Group restrictions → Check posting permissions

  Slack Integration:
  Missing responses → Verify webhook URL
  Button not working → Check interactive components
  User not found → Confirm Slack user ID

  Image Upload Failures:
  Invalid URL → Validate image accessibility
  Size limits → Compress images under 10MB
  Format issues → Use JPEG or PNG only

  📊 Workflow Benefits

  Time Savings**: 80% reduction in content publishing time
  Consistency**: Regular posting schedule maintained
  Quality Control**: Human review ensures brand standards
  Scalability**: Handle multiple accounts and groups
  Flexibility**: Easy to modify and extend

  📎 Required Files

  | File Name | Purpose |
  |-----------|---------|
  | Linkedin Post | Google Sheet to hold post topics and status |

  🏷 Suggested Tags & Categories

  #LinkedIn
  #AI
  #ContentAutomation
  #SocialMedia
  #Slack
  #GPT4
  #Marketing
  #WorkflowAutomation

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

workflow_json:
  {"id":"YOUR_WORKFLOW_ID","meta":{"instanceId":"YOUR_INSTANCE_ID","templateCredsSetupCompleted":true},"name":"LinkedIn Post Automation with AI & Slack Approval","tags":[],"nodes":[{"id":"workflow-overview-linkedin","name":"Workflow Overview","type":"n8n-nodes-base.stickyNote","position":[-1050,-450],"parameters":{"content":""},"typeVersion":1},{"id":"sheets-trigger-note","name":"Sheets Trigger Info","type":"n8n-nodes-base.stickyNote","position":[-750,-400],"parameters":{"content":""},"typeVersion":1},{"id":"ai-generation-note","name":"AI Generation","type":"n8n-nodes-base.stickyNote","position":[130,-400],"parameters":{"content":""},"typeVersion":1},{"id":"slack-approval-note","name":"Slack Approval","type":"n8n-nodes-base.stickyNote","position":[730,-380],"parameters":{"content":""},"typeVersion":1},{"id":"webhook-handler-note","name":"Webhook Handler","type":"n8n-nodes-base.stickyNote","position":[-750,-800],"parameters":{"content":""},"typeVersion":1},{"id":"image-upload-note","name":"Image Upload Process","type":"n8n-nodes-base.stickyNote","position":[950,-800],"parameters":{"content":""},"typeVersion":1},{"id":"linkedin-publish-note","name":"LinkedIn Publishing","type":"n8n-nodes-base.stickyNote","position":[1450,-780],"parameters":{"content":""},"typeVersion":1},{"id":"status-update-note","name":"Status Update","type":"n8n-nodes-base.stickyNote","position":[2110,-900],"parameters":{"content":""},"typeVersion":1},{"id":"0cd3e628-1720-49f7-9280-a1039d2c2ca9","name":"Limit","type":"n8n-nodes-base.limit","notes":"Processes one item at a time to prevent API overload","position":[-260,-180],"parameters":{},"typeVersion":1},{"id":"c36d36d6-0035-49ac-a757-4598d56e574e","name":"Structured Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[328,40],"parameters":{},"typeVersion":1.2},{"id":"9f521172-07f4-4a17-b358-bd998e9a9d02","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[208,40],"parameters":{},"typeVersion":1.2},{"id":"09b0b22f-eb64-468f-85b0-1c9a0608631e","name":"Webhook","type":"n8n-nodes-base.webhook","notes":"Receives approval responses - ensure URL is configured in Slack app","position":[-700,-590],"webhookId":"YOUR_WEBHOOK_ID","parameters":{},"typeVersion":2},{"id":"4e2954d7-e4de-48bf-a974-5ec80c7b7b0c","name":"Linkedin-Post-Topic","type":"n8n-nodes-base.googleSheetsTrigger","notes":"Triggers every minute for new posts in your spreadsheet","position":[-700,-180],"parameters":{},"typeVersion":1},{"id":"47c4cdd0-48ef-4e41-996b-ed29811b092e","name":"Validate-Status","type":"n8n-nodes-base.if","notes":"Filters to process only 'Pending' items - prevents duplicates","position":[-480,-180],"parameters":{},"typeVersion":2.2},{"id":"908eee31-78eb-482c-b331-2d3467d56b0d","name":"Linedin-Post-Creator","type":"@n8n/n8n-nodes-langchain.agent","notes":"Uses GPT-4 to generate LinkedIn content - customize prompt for your brand voice","position":[180,-180],"parameters":{},"typeVersion":1.9},{"id":"882d6e5c-a7f0-425f-a501-1f7179f8857b","name":"Format-Content","type":"n8n-nodes-base.code","notes":"Formats content for Slack display - handles special characters and newlines","position":[556,-180],"parameters":{},"typeVersion":2},{"id":"31aea874-516c-47c7-9c5f-bde873faae4d","name":"Approval-on-Slack","type":"n8n-nodes-base.slack","notes":"Sends for human review - edit the Slack user to change approver","position":[780,-180],"webhookId":"YOUR_SLACK_WEBHOOK_ID","parameters":{},"notesInFlow":true,"typeVersion":2.3},{"id":"8592224a-0370-48c3-b803-fe3653284545","name":"Format-Response","type":"n8n-nodes-base.code","notes":"Extracts edited content from Slack response","position":[-260,-590],"parameters":{},"typeVersion":2},{"id":"2c503653-e3b6-4229-a733-25fa666ba85a","name":"Validate-Response","type":"n8n-nodes-base.if","notes":"Ensures response contains content before proceeding","position":[-40,-590],"parameters":{},"typeVersion":2.2},{"id":"be68592f-f6a8-4698-8343-58d439eed3ac","name":"Set-Final-Message","type":"n8n-nodes-base.set","notes":"Prepares approved content for publishing","position":[180,-590],"parameters":{},"typeVersion":3.4},{"id":"4ec34acf-1704-4fd7-b14d-680409acbeda","name":"Linkedin-User-Detail","type":"n8n-nodes-base.httpRequest","notes":"Fetches LinkedIn user ID for post attribution","position":[400,-580],"parameters":{},"typeVersion":4.2},{"id":"78293261-7fbd-4757-8353-c2275ba2089a","name":"Linkedin-post","type":"n8n-nodes-base.httpRequest","notes":"Publishes to your profile - update with your LinkedIn credentials","position":[1500,-590],"parameters":{},"typeVersion":4.2},{"id":"54ee84f1-42e2-4f25-96a4-958b27f798f4","name":"Get-Group-id","type":"n8n-nodes-base.googleSheets","notes":"Retrieves LinkedIn group IDs from Groups sheet","position":[1720,-590],"parameters":{},"typeVersion":4.5},{"id":"4e3e1fc5-a0ae-469f-8399-79b9bf98ff41","name":"Pick 1 by 1","type":"n8n-nodes-base.splitInBatches","notes":"Processes groups one at a time to avoid rate limits","position":[1940,-590],"parameters":{},"typeVersion":3},{"id":"7309d6c0-bfec-4d06-b3c3-5b05ccab6df3","name":"Post-Linkedin-Groups","type":"n8n-nodes-base.httpRequest","notes":"Posts to multiple groups - add group IDs in Groups sheet","onError":"continueRegularOutput","position":[2160,-540],"parameters":{},"typeVersion":4.2},{"id":"63b25ac7-e5dc-4836-96cf-5767b57c7784","name":"Update-Status","type":"n8n-nodes-base.googleSheets","notes":"Marks as 'Posted' to prevent reprocessing","position":[2160,-740],"parameters":{},"typeVersion":4.5},{"id":"348ca4b6-fbb0-4a07-9c3d-9a581b95c7fe","name":"Register Image","type":"n8n-nodes-base.httpRequest","notes":"Initiates LinkedIn media upload - requires valid image URL from sheet","position":[620,-580],"parameters":{},"typeVersion":4.2},{"id":"2dfdfc17-78f7-488b-82f2-cb229488062f","name":"Upload-Image-data","type":"n8n-nodes-base.set","notes":"Extracts upload URL and asset ID from LinkedIn response","position":[840,-580],"parameters":{},"typeVersion":3.4},{"id":"a68a5ba8-8913-455f-9893-12013322e9c0","name":"Get Image Binary","type":"n8n-nodes-base.httpRequest","notes":"Downloads image from URL specified in spreadsheet","position":[1060,-590],"parameters":{},"typeVersion":4.2},{"id":"37cfc754-d66f-43f8-b881-4b5f0e927fa2","name":"Upload Image","type":"n8n-nodes-base.httpRequest","notes":"Uploads image binary to LinkedIn servers","position":[1280,-590],"parameters":{},"typeVersion":4.2},{"id":"c67c5ae9-c0c0-4400-a5ed-c2f96842e24d","name":"Edit Fields","type":"n8n-nodes-base.set","notes":"Extracts post ID for tracking through workflow","position":[-40,-180],"parameters":{},"typeVersion":3.4},{"id":"8202c5f6-aa24-44d9-989e-b67d0c481e17","name":"Set Topics and Images for Processing","type":"n8n-nodes-base.code","notes":"Extracts post ID and image URL from Slack approval response","position":[-480,-600],"parameters":{},"typeVersion":2}],"active":false,"pinData":{"Webhook":[{"json":{"body":{"payload":"{'type':'block_actions','user':{'id':'USER_ID','username':'username','name':'user.name','team_id':'TEAM_ID'},'api_app_id':'APP_ID','token':'TOKEN','container':{'type':'message','message_ts':'1234567890.123456','channel_id':'CHANNEL_ID','is_ephemeral':false},'trigger_id':'1234567890123.1234567890123.abcdef1234567890abcdef1234567890','team':{'id':'TEAM_ID','domain':'team-domain'},'enterprise':null,'is_enterprise_install':false,'channel':{'id':'CHANNEL_ID','name':'directmessage'},'message':{'user':'BOT_USER_ID','type':'message','ts':'1234567890.123456','bot_id':'BOT_ID','app_id':'APP_ID','text':'*Content Review Request*\\nPlease review the following content: :mag: Sample LinkedIn post content here...\\n\\n#SampleHashtag #LinkedInPost #Automation','team':'TEAM_ID','blocks':[{'type':'section','block_id':'BLOCK_1','text':{'type':'mrkdwn','text':'*Content Review Request*\\nPlease review the following content:','verbatim':false}},{'type':'section','block_id':'BLOCK_2','text':{'type':'mrkdwn','text':':mag: Sample LinkedIn post content here...\\n\\n#SampleHashtag #LinkedInPost #Automation','verbatim':false}},{'type':'input','block_id':'INPUT_BLOCK','label':{'type':'plain_text','text':'Edit content if needed:','emoji':true},'optional':false,'dispatch_action':false,'element':{'type':'plain_text_input','action_id':'content_input','initial_value':'Sample LinkedIn post content here...\\n\\n#SampleHashtag #LinkedInPost #Automation','multiline':true,'dispatch_action_config':{'trigger_actions_on':['on_enter_pressed']}}},{'type':'actions','block_id':'ACTION_BLOCK','elements':[{'type':'button','action_id':'approve_button','text':{'type':'plain_text','text':'Approve As Is','emoji':true},'style':'primary','value':'approve'},{'type':'button','action_id':'edit_button','text':{'type':'plain_text','text':'Submit Edited Version','emoji':true},'style':'danger','value':'edit'}]},{'type':'section','block_id':'FOOTER_BLOCK','text':{'type':'mrkdwn','text':'_Automated with this n8n workflow_','verbatim':false}}]},'state':{'values':{'INPUT_BLOCK':{'content_input':{'type':'plain_text_input','value':'Sample LinkedIn post content here...\\n\\n#SampleHashtag #LinkedInPost #Automation'}}}},'response_url':'https://hooks.slack.com/actions/TEAM_ID/ACTION_ID/TOKEN','actions':[{'action_id':'approve_button','block_id':'ACTION_BLOCK','text':{'type':'plain_text','text':'Approve As Is','emoji':true},'value':'approve','style':'primary','type':'button','action_ts':'1234567890.123456'}]}"},"query":{},"params":{},"headers":{"host":"YOUR_N8N_HOST","accept":"application/json,*/*","cf-ray":"CF_RAY_ID","cdn-loop":"cloudflare; loops=1; subreqs=1","cf-ew-via":"15","cf-worker":"n8n.cloud","x-real-ip":"REAL_IP","cf-visitor":"{\"scheme\":\"https\"}","user-agent":"Slackbot 1.0 (+https://api.slack.com/robots)","cf-ipcountry":"US","content-type":"application/x-www-form-urlencoded","x-is-trusted":"yes","content-length":"12089","accept-encoding":"gzip, br","x-forwarded-for":"IP_Address_1, IP_Address_2","cf-connecting-ip":"54.224.31.149","x-forwarded-host":"N8N_HOST","x-forwarded-port":"443","x-forwarded-proto":"https","x-slack-signature":"SIGNATURE","x-forwarded-server":"SERVER_NAME","x-slack-request-timestamp":"TIMESTAMP"},"webhookUrl":"WEBHOOK_URL","executionMode":"production"}}]},"settings":{"executionOrder":"v1"},"versionId":"YOUR_VERSION_ID","connections":{"Limit":{"main":[[{"node":"Edit Fields","type":"main","index":0}]]},"Webhook":{"main":[[{"node":"Set Topics and Images for Processing","type":"main","index":0}]]},"Edit Fields":{"main":[[{"node":"Linedin-Post-Creator","type":"main","index":0}]]},"Pick 1 by 1":{"main":[[{"node":"Update-Status","type":"main","index":0}],[{"node":"Post-Linkedin-Groups","type":"main","index":0}]]},"Get-Group-id":{"main":[[{"node":"Pick 1 by 1","type":"main","index":0}]]},"Upload Image":{"main":[[{"node":"Linkedin-post","type":"main","index":0}]]},"Linkedin-post":{"main":[[{"node":"Get-Group-id","type":"main","index":0}]]},"Update-Status":{"main":[[]]},"Format-Content":{"main":[[{"node":"Approval-on-Slack","type":"main","index":0}]]},"Register Image":{"main":[[{"node":"Upload-Image-data","type":"main","index":0}]]},"Format-Response":{"main":[[{"node":"Validate-Response","type":"main","index":0}]]},"Validate-Status":{"main":[[{"node":"Limit","type":"main","index":0}]]},"Get Image Binary":{"main":[[{"node":"Upload Image","type":"main","index":0}]]},"Approval-on-Slack":{"main":[[]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"Linedin-Post-Creator","type":"ai_languageModel","index":0}]]},"Set-Final-Message":{"main":[[{"node":"Linkedin-User-Detail","type":"main","index":0}]]},"Upload-Image-data":{"main":[[{"node":"Get Image Binary","type":"main","index":0}]]},"Validate-Response":{"main":[[{"node":"Set-Final-Message","type":"main","index":0}]]},"Linkedin-Post-Topic":{"main":[[{"node":"Validate-Status","type":"main","index":0}]]},"Linedin-Post-Creator":{"main":[[{"node":"Format-Content","type":"main","index":0}]]},"Linkedin-User-Detail":{"main":[[{"node":"Register Image","type":"main","index":0}]]},"Post-Linkedin-Groups":{"main":[[{"node":"Pick 1 by 1","type":"main","index":0}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"Linedin-Post-Creator","type":"ai_outputParser","index":0}]]},"Set Topics and Images for Processing":{"main":[[{"node":"Format-Response","type":"main","index":0}]]}}}


name: Build a Voice AI Chatbot with ElevenLabs and InfraNodus Knowledge Experts
author_name: InfraNodus
author_username: infranodus
categories: []
created_at: 2025-05-29T11:25:45.230Z
updated_at: 2025-05-29T11:25:45.230Z
url: https://n8n.io/workflows/4484
scraped_at: 2025-07-06 21:16:30
description:
  Set Up ElevenLabs Voice Chat Agent using Graph RAG Knowledge Graphs as Experts

  This workflow creates an AI voice chatbot agent that has access to several knowledge bases at the same time (used as "experts"). 

  These knowledge bases are provided using the InfraNodus GraphRAG using the knowledge graphs and providing high-quality responses without the need to set up complex RAG vector store workflows.

  We use ElevenLabs to set up a voice agent that can be embedded to any website or used via their API.

  The advantages of using GraphRAG instead of the standard vector stores for knowledge are:

  Easy and quick to set up (no complex data import workflows needed) and to update with new knowledge
  A knowledge graph has a holistic overview of your knowledge base
  Better retrieval of relations between the document chunks = higher quality responses
  Ability to reuse in other n8n workflows

  How it works
  This template uses the n8n AI agent node as an orchestrating agent that decides which tool (knowledge graph) to use based on the user's prompt. 

  The user's prompt is received from the ElevenLabs Conversational AI agent via an n8n Webhook, which also takes care of the voice interaction. 

  The response from n8n is then sent to the Webhook, which is polled by the ElevenLabs voice agent. This agent processes the response and provides the final answer.

  Here's a description step by step:

  The user submits a question using ElevenLabs voice interface
  The question is sent via the knowledge_base tool in ElevenLabs to the n8n Webhook with the POST request containing the user's prompt and sessionID for Chat Memory node in n8n.
  The n8n AI agent node checks a list of tools it has access to. Each tool has a description of the knowledge auto-generated by InfraNodus (we call each tool an "expert"). 
  The n8n AI agent decides which tool should be used to generate a response. It may reformulate user's query to be more suitable for the expert. 
  The query is then sent to the InfraNodus HTTP node endpoint, which will query the graph that corresponds to that expert. 
  Each InfraNodus GraphRAG expert provides a rich response that takes the whole context into account and provides a response from each expert (graph) along with a list of relevant statements retrieved using a combination or RAG and GraphRAG. 
  The n8n AI Agent node integrates the responses received from the experts to produce the final answer.
  The final answer is sent back to the Webhook endpoint
  ElevenLabs conversational AI agent picks up the response arriving from the knowledge_base tool via the webhook and then condenses it for conversational format and transforms text into voice.

  How to use

  You need an InfraNodus GraphRAG API account and key to use this workflow. 

  Create an InfraNodus account
  Get the API key at https://infranodus.com/api-access and create a Bearer authorization key for the InfraNodus HTTP nodes.
  Create a separate knowledge graph for each expert (using PDF / content import options) in InfraNodus
  For each graph, go to the workflow, paste the name of the graph into the body name field.
  Keep other settings intact or learn more about them at the InfraNodus access points page. 
  Once you add one or more graphs as experts to your flow, add the LLM key to the OpenAI node and launch the workflow
  You will also need to set up an ElevenLabs account and to set up a conversational AI agent there. See the Post note in the n8n workflow for a complete step-by-step description or our support article on setting up ElevenLabs AI voice agent
  Once the voice AI agent is ready, you might want to combine it with a text AI chatbot workflow so your users have a choice between the text and voice interaction. In that case, you may be interested to use our free open-source website popup chat widget popupchat.dev where you can create an embed code to add to your blog or website and allow the user to choose between the text and voice interaction.

  Requirements

  An InfraNodus account and API key
  An OpenAI (or any other LLM) API key
  An ElevenLabs account

  FAQ

  1. How many "experts" should I aim for?

  We recommend to aim for the number of experts as the optimal number of people in a team, which is usually 2-7. If you add more experts, your AI orchestrating agent will have troubles choosing the most suitable "expert" tool for the user's query. You can mitigate this by specifying in the AI agent description that it can choose maximum 3-7 experts to provide a response.

  2. Why use InfraNodus GraphRAG and not standard vector store for knowledge?

  First, vector stores are complex to set up and to update. You'd need a separate workflow for that, decide on the vector dimensions, add metadata to your knowledge, etc.
  With InfraNodus, you have a complete RAG / GraphRAG solution under the hood that is easy to set up and provides high-quality responses that takes the overall structure and the relations between your ideas into account. 

  3 Why not use ElevenLabs' own knowledge?

  One of the reasons is that you want your knowledge base to be in one place so you can reuse it in other n8n workflows. Another reason is that you will not have such a good separation between the "experts" when you converse with the agent. So the answers you get will be based on top matches from all the books / articles you upload, while with the InfraNodus GraphRAG setup you can better control which graphs are consulted as experts and have an explicit way to display this data.

  Customizing this workflow

  You can use this same workflow with a Telegram bot, so you can interact with it using Telegram. There are many more customizations available on our GitHub repo for n8n workflows.

  Check out the complete setup guide for this workflow at https://support.noduslabs.com/hc/en-us/articles/20318967066396-How-to-Build-a-Text-Voice-AI-Agent-Chatbot-with-n8n-Elevenlabs-and-InfraNodus

  Also check out the video tutorial with a demo:

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

workflow_json:
  {"id":"STzi96JfL52BUuQD","meta":{"instanceId":"2a26454b0172ffcb8d70ba77c235b1209f92cd71bf06c79ba609c7173b416d68","templateCredsSetupCompleted":true},"name":"AI Voice Chat Agent with ElevenLabs and InfraNodus Graph RAG Knowledge","tags":[{"id":"66wgFoDi9Xjl74M3","name":"Support","createdAt":"2025-05-21T17:06:32.355Z","updatedAt":"2025-05-21T17:06:32.355Z"},{"id":"9QurS5Kb1CkCYrnG","name":"Product","createdAt":"2025-05-21T17:06:29.704Z","updatedAt":"2025-05-21T17:06:29.704Z"},{"id":"IzYV3Gv55x1h73cK","name":"Ideation","createdAt":"2025-05-20T14:53:20.662Z","updatedAt":"2025-05-20T14:53:20.662Z"},{"id":"aECLdyckoPZ29skg","name":"Writing","createdAt":"2025-05-20T14:53:23.085Z","updatedAt":"2025-05-20T14:53:23.085Z"},{"id":"ciIq4giMNXaJiyiQ","name":"Thinking Tools","createdAt":"2025-05-20T14:53:17.515Z","updatedAt":"2025-05-20T14:53:17.515Z"},{"id":"hCzs9EJfBuD0RxuX","name":"Other","createdAt":"2025-05-21T17:06:34.674Z","updatedAt":"2025-05-21T17:06:34.674Z"},{"id":"sJk9cUvmMU8FkJXv","name":"AI","createdAt":"2025-05-20T13:16:15.636Z","updatedAt":"2025-05-20T13:16:15.636Z"}],"nodes":[{"id":"b17450bf-5c34-43b9-a7cb-1e8d48a90e5e","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[840,260],"parameters":{"width":200,"height":740,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Expert #1\n\nAdd your InfraNodus graph here via the HTTP node using its name in the `body.name` field.\n\nDescribe what the expert does in the Description of the tool. You can use auto-generated Graph RAG summary from InfraNodus > Graph > Project Notes\n\n![Book Screenshot](https://i.ibb.co/rfxsJ4MV/circadian-special-agents-manual.png)"},"typeVersion":1},{"id":"8d41bb1b-ff2d-43bf-b9aa-be41a824a568","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[1060,260],"parameters":{"width":200,"height":740,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Expert #2\n\nAdd your InfraNodus graph here via the HTTP node using its name in the `body.name` field.\n\nDescribe what the expert does in the Description of the tool. You can use auto-generated Graph RAG summary from InfraNodus > Graph > Project Notes\n\n![waves into patterns screen](https://i.ibb.co/1tDJSgVq/circadian-waves-into-patterns.png)"},"typeVersion":1},{"id":"3092328a-8b99-4086-9be8-20157a48d706","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[1280,260],"parameters":{"width":200,"height":640,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Expert #3\n\nYou can add more experts here. Just make to give them descriptive names, so the agent knows which one to connect to when it has a question. \n\n![flow and notion image](https://i.ibb.co/prLbFG0w/circadian-the-flow-and-notion.png)\n"},"typeVersion":1},{"id":"8165ec0a-ac24-4e3e-8240-162a3ef6e47e","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[620,260],"parameters":{"width":200,"height":540,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Chat Memory\n\nWe use the Simple Memory node to track the conversation's context so that the user can refer to previous messages as they converse with the model."},"typeVersion":1},{"id":"333d860c-615f-441d-a7ab-53e867cd5503","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[420,-360],"parameters":{"width":460,"height":500,"content":"## 2. AI Agent Workflow\n\n### Chooses which tool (expert) to use, depending on the user's message. Then receives the responses and synthesizes the final answer.\n\nMake sure you describe the tools available well both in the Agent's System Prompt and in the tools' descriptions. "},"typeVersion":1},{"id":"9f7a3cc4-99c6-4179-b3ce-7bff999cf77b","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[0,40],"parameters":{"height":580,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## 1. Chat Trigger\n\nThe conversation will be triggered when you send a message via a webhook from your Elevenlabs AI Conversational agent. \n\n### 🚨 SEE THE NOTE AND THE LINK BELOW ON SETTING UP YOUR ELEVENLABS AGENT"},"typeVersion":1},{"id":"c3fd90e8-3451-4c17-92c7-ca6c1e3305c6","name":"OpenAI Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","disabled":true,"position":[400,540],"parameters":{"model":"gpt-4o","options":{}},"credentials":{"openAiApi":{"id":"07wFa8Wa4mMRCHAj","name":"OpenAi account 2"}},"typeVersion":1},{"id":"2e049f32-5d79-4a46-8c99-6a5a9c583c4f","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[680,300],"parameters":{"sessionKey":"={{ $json.body.sessionId }}","sessionIdType":"customKey"},"typeVersion":1.3},{"id":"68137659-df1d-4a23-83f8-42a03189077b","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[980,-360],"parameters":{"width":260,"height":500,"content":"## 3. Respond to the User\n\nOnce the response is generated, send it back to the user's chat in Telegram."},"typeVersion":1},{"id":"e7ffd4c6-d725-4ac0-8aa9-09f52d9a1cb4","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[520,-20],"parameters":{"text":"={{ $json.body.prompt }}","options":{"systemMessage":"You are well-versed on Dmitry Paranyushkin's books through the tools you have access to. When you receive a user's query, assess which tools you have access to, decide on the tools to access (minimum 1, maximum 3), modify the query to better suit each tool's context, and send the request to the tool. \n\nIMPORTANT: Always access at least one of the tools and use the response to get the best possible answer.\n\nWhen you're generating a response, combine perspectives where they fit and point out discrepancies when they exist."},"promptType":"define"},"typeVersion":1.9},{"id":"6b1bff98-cdac-4a80-a5e5-a89def6a767b","name":"Waves into Patterns Book Expert","type":"n8n-nodes-base.httpRequestTool","position":[1120,300],"parameters":{"url":"https://infranodus.com/api/v1/graphAndAdvice?doNotSave=true&addStats=true&optimize=develop&includeGraph=false&includeGraphSummary=true&includeStatements=true","method":"POST","options":{},"sendBody":true,"authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"name","value":"waves_into_patterns"},{"name":"prompt","value":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `User's request adjusted to suit this context`, 'string') }}"},{"name":"requestMode","value":"response"},{"name":"aiTopics","value":"true"}]},"genericAuthType":"httpBearerAuth","toolDescription":"Make a request to The Waves into Patterns book which is well-versed in the questions of natural cycles, variability, fractal states, dynamics, and nonequilibrium stability. Including the following topics:\n\n<MainTopics>: \n1. System Influence: scale influence multiple \n2. Pattern Dynamics: pattern variability fractal \n3. Change Balance: dynamic wave time \n4. Center Transformation: center cycle dominant \n5. Growth Stages: growth exploration period \n6. Long Strategy: term state long \n7. Seasonal Relations: moon summer natural \n8. Flow Connection: exist breaking exploring \n</MainTopics>"},"credentials":{"httpBearerAuth":{"id":"kg0rA5r8siL8LbrU","name":"InfraNodus Circadian API Key"}},"typeVersion":4.2},{"id":"d8df1709-8c55-4336-8dde-5fa8769c3a91","name":"Special Agent's Manual Book Expert","type":"n8n-nodes-base.httpRequestTool","position":[900,300],"parameters":{"url":"https://infranodus.com/api/v1/graphAndAdvice?doNotSave=true&addStats=true&optimize=develop&includeGraph=false&includeGraphSummary=true&includeStatements=true","method":"POST","options":{},"sendBody":true,"authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"name","value":"special_agents_manual"},{"name":"prompt","value":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `User's request adjusted to suit this context`, 'string') }}"},{"name":"requestMode","value":"response"},{"name":"aiTopics","value":"true"}]},"genericAuthType":"httpBearerAuth","toolDescription":"Make a request to The Special Agent's Manual book which is well-versed in the questions of human agency, speciality, infiltration and tension dynamics, strategies, identities, finding the special in you as well as the following topics:\n\n<MainTopics>: \n1. Agent Activation: agent special activation \n2. System Dynamics: system body operating \n3. Order Flow: action time order \n4. Creative Process: create identity entity \n5. Movement Patterns: movement wave breathing \n6. Incoming Impact: incoming impulse impact \n7. Fiction Venture: fiction high risk \n8. Social Framework: preset possibility level \n</MainTopics>"},"credentials":{"httpBearerAuth":{"id":"kg0rA5r8siL8LbrU","name":"InfraNodus Circadian API Key"}},"typeVersion":4.2},{"id":"85a11f6a-c154-43ea-a294-3fe367d13ad0","name":"The Flow and the Notion Book","type":"n8n-nodes-base.httpRequestTool","position":[1340,300],"parameters":{"url":"https://infranodus.com/api/v1/graphAndAdvice?doNotSave=true&addStats=true&optimize=develop&includeGraph=false&includeGraphSummary=true&includeStatements=true","method":"POST","options":{},"sendBody":true,"authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"name","value":"the_flow_and_notion"},{"name":"prompt","value":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `User's request adjusted to suit this context`, 'string') }}"},{"name":"requestMode","value":"response"},{"name":"aiTopics","value":"true"}]},"genericAuthType":"httpBearerAuth","toolDescription":"The Flow and the Notion book which is well-versed in the questions of creating with someone, dreaming, making new shapes, dissipating ideas, art, and life. Including the following topics:\n\n<MainTopics>: \n1. Shape Dynamics: shape outline concentric \n2. Time Alignment: long practice time \n3. Man's Journey: bow man candle \n4. Notion Flow: image flow paranyushkin \n5. Essence Realization: process essence essential \n6. Life Choices: slave thing trace \n7. Wave Patterns: found light movement \n8. Synchrony Mediation: book circadian word \n9. Complete Vision: multiple synchrony mediate \n10. Instruction Guide: full \ninstruction foreword : instruction foreword \n</MainTopics>"},"credentials":{"httpBearerAuth":{"id":"kg0rA5r8siL8LbrU","name":"InfraNodus Circadian API Key"}},"typeVersion":4.2},{"id":"90c32931-3e1c-4c93-8cbb-7c8e7dfa2269","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[1500,260],"parameters":{"width":200,"height":640,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Expert #4\n\nYou can add more experts here. Just make to give them descriptive names, so the agent knows which one to connect to when it has a question. \n\n![infranodus graph](https://i.ibb.co/hRqxn8JN/circadian-conversation-book.png)"},"typeVersion":1},{"id":"d392f193-328d-46b5-bd85-a6db97ca0a58","name":"The Polysingularity Letters Book","type":"n8n-nodes-base.httpRequestTool","position":[1540,300],"parameters":{"url":"https://infranodus.com/api/v1/graphAndAdvice?doNotSave=true&addStats=true&optimize=develop&includeGraph=false&includeGraphSummary=true&includeStatements=true","method":"POST","options":{},"sendBody":true,"authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"name","value":"polysingularity_letters"},{"name":"prompt","value":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `User's request adjusted to suit this context`, 'string') }}"},{"name":"requestMode","value":"response"},{"name":"aiTopics","value":"true"}]},"genericAuthType":"httpBearerAuth","toolDescription":"The Polysingularity Letters book which is well-versed in the questions of polysingularity, multiplicity, networks, networking, art, and creative approach. And also these topics:\n\n<MainTopics>: \n1. Community Dynamics: network community connected \n2. Global Equilibrium: state global change \n3. Polysingular Practice: polysingularity thinking exist \n4. Temporal Relations: time moment thing \n5. Consciousness Source: social cognition view \n6. Meaning Creation: make orthodox meaning \n7. Dmitry Connections: post dmitry minute \n8. Linguistic Variations: wa ë ww \n</MainTopics>"},"credentials":{"httpBearerAuth":{"id":"6lSuuSDajZrvI2GM","name":"InfraNodus API Key"}},"typeVersion":4.2},{"id":"56f27d69-5091-4a0e-abc9-49fea9a863b3","name":"Webhook","type":"n8n-nodes-base.webhook","position":[60,60],"webhookId":"171bf9a6-1390-4195-bd6b-ff3df2e27d1c","parameters":{"path":"171bf9a6-1390-4195-bd6b-ff3df2e27d1c","options":{},"httpMethod":"POST","responseMode":"responseNode"},"typeVersion":2},{"id":"8b7a6506-4220-476e-8d94-fa62315ab807","name":"Respond to Webhook","type":"n8n-nodes-base.respondToWebhook","position":[1060,-20],"parameters":{"options":{}},"typeVersion":1.2},{"id":"0ac0d3d2-75b9-4173-a45a-56a0fe55892d","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-820,680],"parameters":{"color":3,"width":1060,"height":980,"content":"## Setting up ElevenLabs Conversational AI Agent\n\n### You will need to connect the Webhook trigger above to the Conversational AI agent of ElevenLabs. Then you can use their agent (and website widget) to converse with the experts in this workflow. Read the full tutorial at [ElevenLabs AI voice agent setup guide](https://support.noduslabs.com/hc/en-us/articles/20318967066396-How-to-Build-a-Text-Voice-AI-Agent-Chatbot-with-n8n-Elevenlabs-and-InfraNodus)\n\n1. Create an account at [https://elevenlabs.io/](https://elevenlabs.io/)\n\n2. Go to the **Conversational AI** section in the menu\n\n3. Go to **Agent > Create New Agent > Use Blank Template**\n\n4. In the **System Prompt** of the agent put the following text modified to relate to your content:\n\n```\nYou are well-versed on ... through the tools you have access to.\n1) When you receive a user's message, first answer something like \"I am consulting my knowledge and will respond soon\" or \"let me think about it and i'll get back to you\" or any other similar in meaning phrase\n2) Then forward the user's message, without any changes, to the knowledge_base tool.\n3) When you receive a response from the knowledge_base use this answer to respond to the user, use exactly the answer you received to respond.\nIMPORTANT: make the response more suitable for the conversational format making it more succint and shorter but maintaining all the specifics.\n```\n\n5. IMPORTANT: keep the reference to the `knowledge_base` tool above to let the ElevenLabs agent know that it's exactly that tool it needs to be using to access the knowledge. Replace `...` with your content. \n\n6. In the **Tools section** of the Agent's setup, click **Create a new tool**\n\n7. The name of the tool should be: **`knowledge_base`** (as you're referring to it in the system prompt)\n\n8. In the tool's description put in: \"A knowledge base on ....\" (replace ... with your topic)\n\n9. Choose the **POST method** and in the URL put the Webhook link from the n8n workflow you created in the Step 3 above. E.g. https://infranodus.app.n8n.cloud/webhook/your_hook_url\n\n10. Scroll to the **Body Parameters** and add the following parameters that will be submitted with the POST request:\n\na.  Identifier: `prompt`, Value type: LLM prompt, Description: The user's message. \n*You will use this value in the **AI Agent** node.*\n\nb. Identifier: `sessionId`, Value type: Dynamic variable, Variable name: system__conversation_id\n*You will use this in the **Chat Memory** node to keep the history of the interaction.*\n\n10. Save the tool, save the agent\n\n11. Run the test in ElevenLabs\n\n12. Check the n8n workflow logs (from Step 3) to see if the execution went well "},"typeVersion":1},{"id":"2f279f0d-fdd2-493a-b416-6c70ab06b31a","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[-820,-360],"parameters":{"color":5,"width":740,"height":980,"content":"# AI Voice Agent that Chats to Your Experts (e.g. Books, Articles, etc)\n\n## Uses InfraNodus Knowledge Graphs as Experts (AI Agent tools)\n\n## Uses ElevenLabs for voice chat functionality\n\n## Uses an orchestrating AI Agent in n8n to choose the expert based on the query\n\n[Detailed tutorial](https://support.noduslabs.com/hc/en-us/articles/20318967066396-How-to-Build-a-Text-Voice-AI-Agent-Chatbot-with-n8n-Elevenlabs-and-InfraNodus)\n\n[Video Tutorial](https://www.youtube.com/watch?v=07-HZZQs5h0)\n\n\n[![Video tutorial](https://img.youtube.com/vi/07-HZZQs5h0/sddefault.jpg)](https://www.youtube.com/watch?v=07-HZZQs5h0)"},"typeVersion":1},{"id":"49d05baa-50fe-4931-87f8-22726eb868fa","name":"Google Gemini Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[400,340],"parameters":{"options":{},"modelName":"models/gemini-2.5-flash-preview-04-17"},"credentials":{"googlePalmApi":{"id":"ivswOFTY8MYDbj5b","name":"Google Gemini(PaLM) Api account"}},"typeVersion":1},{"id":"3ffc401d-df30-44ad-a3c3-b6b3ee75f59f","name":"Sticky Note10","type":"n8n-nodes-base.stickyNote","position":[340,260],"parameters":{"width":200,"height":660,"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## LLM to Use\n\nGoogle Flash Pro models are much faster than OpenAI. However, OpenAI can be more precise in function (expert) calling."},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"9dd619b8-9071-4d7d-8b5a-fb30b570671f","connections":{"Webhook":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"AI Agent":{"main":[[{"node":"Respond to Webhook","type":"main","index":0}]]},"OpenAI Model":{"ai_languageModel":[[]]},"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Google Gemini Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"The Flow and the Notion Book":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Waves into Patterns Book Expert":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"The Polysingularity Letters Book":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Special Agent's Manual Book Expert":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]}}}


name: Telegram AI Chatbot Agent with InfraNodus GraphRAG Knowledge Base
author_name: InfraNodus
author_username: infranodus
categories: []
created_at: 2025-05-29T11:44:34.562Z
updated_at: 2025-05-29T11:44:34.562Z
url: https://n8n.io/workflows/4485
scraped_at: 2025-07-06 21:16:30
description:
  Using the knowledge graphs instead of RAG vector stores

  This workflow creates a Telegram chatbot agent that has access to several knowledge bases at the same time (used as "experts"). 

  These knowledge bases are provided using the InfraNodus GraphRAG using the knowledge graphs and providing high-quality responses without the need to set up complex RAG vector store workflows.

  The advantages of using GraphRAG instead of the standard vector stores for knowledge are:

  Easy and quick to set up and update (no complex data import workflows or vector stores needed)
  A knowledge graph has a holistic view of your knowledge base and knows what it's about
  Better retrieval of relations between the document chunks = higher quality responses

  How it works
  This template uses the n8n AI agent node as an orchestrating agent that decides which tool (knowledge graph) to use based on the user's prompt. 

  Here's a description step by step:

  The user submits a question using the Telegram bot, which is then received in the n8n workflow via the Telegram trigger node.
  The AI agent node checks a list of tools it has access to. Each tool has a description of the knowledge it has auto-generated by InfraNodus. 
  The AI agent decides which tool should be used to generate a response. It may reformulate user's query to be more suitable for the expert. 
  The query is then sent to the InfraNodus HTTP node endpoint, which will query the graph that corresponds to that expert. 
  Each InfraNodus GraphRAG expert provides a rich response that takes the whole context into account and provides a response from each expert (graph) along with a list of relevant statements retrieved using a combination or RAG and GraphRAG. 
  The n8n AI Agent node integrates the responses received from the experts to produce the final answer.
  The final answer is sent back to the Telegram bot who delivers it back to the private chat or a Telegram group.

  How to use

  You need an InfraNodus GraphRAG API account and key to use this workflow. 

  Create an InfraNodus account
  Get the API key at https://infranodus.com/api-access and create a Bearer authorization key for the InfraNodus HTTP nodes.
  Create a separate knowledge graph for each expert (using PDF / content import options) in InfraNodus
  For each graph, go to the workflow, paste the name of the graph into the body name field.
  Keep other settings intact or learn more about them at the InfraNodus access points page. 
  Once you add one or more graphs as experts to your flow, add the LLM key to the OpenAI node
  Create a Telegram bot (the instructions are in the workflow Post note) — it takes 30 seconds. Get its API key and create the Telegram credentials to use in the Telegram nodes in this workflow.

  Requirements

  An InfraNodus account and API key
  An OpenAI (or any other LLM) API key
  A Telegram account

  Customizing this workflow

  You can use this same workflow with a standard AI chatbot via a URL that can also be embedded to any website. You can also use it with ElevenLabs AI voice agent. There are many more customizations available. 

  Check out the complete guide at https://support.noduslabs.com/hc/en-us/articles/20174217658396-Using-InfraNodus-Knowledge-Graphs-as-Experts-for-AI-Chatbot-Agents-in-n8n

  Also check out the video tutorial with a demo:

  Support

  If you have any questions, contact us via the support portal at https://support.noduslabs.com or via our Discord channel.

  More n8n workflows are available on our support portal: n8n x InfraNodus AI automation workflows.

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

workflow_json:
  {"id":"dHmXMjhXw6tqnf8y","meta":{"instanceId":"2a26454b0172ffcb8d70ba77c235b1209f92cd71bf06c79ba609c7173b416d68","templateCredsSetupCompleted":true},"name":"Telegram AI Chatbot Agent with InfraNodus GraphRAG Knowledge Base","tags":[{"id":"66wgFoDi9Xjl74M3","name":"Support","createdAt":"2025-05-21T17:06:32.355Z","updatedAt":"2025-05-21T17:06:32.355Z"},{"id":"9QurS5Kb1CkCYrnG","name":"Product","createdAt":"2025-05-21T17:06:29.704Z","updatedAt":"2025-05-21T17:06:29.704Z"},{"id":"IzYV3Gv55x1h73cK","name":"Ideation","createdAt":"2025-05-20T14:53:20.662Z","updatedAt":"2025-05-20T14:53:20.662Z"},{"id":"aECLdyckoPZ29skg","name":"Writing","createdAt":"2025-05-20T14:53:23.085Z","updatedAt":"2025-05-20T14:53:23.085Z"},{"id":"ciIq4giMNXaJiyiQ","name":"Thinking Tools","createdAt":"2025-05-20T14:53:17.515Z","updatedAt":"2025-05-20T14:53:17.515Z"},{"id":"hCzs9EJfBuD0RxuX","name":"Other","createdAt":"2025-05-21T17:06:34.674Z","updatedAt":"2025-05-21T17:06:34.674Z"},{"id":"sJk9cUvmMU8FkJXv","name":"AI","createdAt":"2025-05-20T13:16:15.636Z","updatedAt":"2025-05-20T13:16:15.636Z"}],"nodes":[{"id":"736e717e-bad8-4943-9ae2-955cf588112d","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-260,-800],"parameters":{"color":6,"width":540,"height":760,"content":"## AI Chatbot Agent with Experts\n\n### Uses the InfraNodus knowledge graphs and its Graph RAG to retrieve relevant information.\n\nUse your [InfraNodus graph](https://infranodus.com) as the knowledge base for your AI chatbot. \n\nUpload any data to InfraNodus, generate separate knowledge graphs, then connect them as tools to the agent, so it can decide which \"expert\" to use. InfraNodus' Graph RAG will provide high-quality responses that will augment the chatbot's answers.\n\nVideo demo: [https://www.youtube.com/watch?v=kS0QTUvcH6E](https://www.youtube.com/watch?v=kS0QTUvcH6E)\n\nDetailed description: [Nodus Labs support portal](https://support.noduslabs.com/hc/en-us/articles/20174217658396-Using-InfraNodus-Knowledge-Graphs-as-Experts-for-AI-Chatbot-Agents-in-n8n)\n\nInfraNodus API key can be obtained at [InfraNodus.Com](https://infranodus.com/use-case/ai-knowledge-graphs)\n\n\n[![Video tutorial](https://img.youtube.com/vi/kS0QTUvcH6E/sddefault.jpg)](https://www.youtube.com/watch?v=kS0QTUvcH6E)"},"typeVersion":1},{"id":"e966551c-01db-4b3e-a233-632ce1c24d2f","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[620,260],"parameters":{"width":200,"height":540,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Chat Memory\n\nWe use the Simple Memory node to track the conversation's context so that the user can refer to previous messages as they converse with the model."},"typeVersion":1},{"id":"d1507b1d-238f-4ff1-a181-e8120c838714","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[420,-260],"parameters":{"width":460,"height":400,"content":"## 3. AI Agent Workflow\n\n### Chooses which tool (expert) to use, depending on the user's message. Then receives the responses and synthesizes the final answer.\n\nMake sure you describe the tools available well both in the Agent's System Prompt and in the tools' descriptions. "},"typeVersion":1},{"id":"9cd0245e-a848-487a-bca7-22f8cf1ec95f","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[-260,20],"parameters":{"height":500,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## 1. Telegram Trigger\n\nThe conversation will be triggered when you send a message to your Telegram bot. To set up a bot, simply message `/newbot` to `@botfather` in Telegram. It takes 30 seconds. "},"typeVersion":1},{"id":"dc80cc79-24e7-4a43-8869-ba1ef48e2026","name":"OpenAI Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[400,320],"parameters":{"model":"gpt-4o","options":{}},"credentials":{"openAiApi":{"id":"07wFa8Wa4mMRCHAj","name":"OpenAi account 2"}},"typeVersion":1},{"id":"a9000f01-714b-4f85-86f4-29592178eb44","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[680,300],"parameters":{"sessionKey":"={{ $('Receive a Message on Telegram').item.json.message.chat.id }}","sessionIdType":"customKey"},"typeVersion":1.3},{"id":"3ec5c404-69f4-468f-a5cc-9500e207e2ed","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[20,20],"parameters":{"width":260,"height":500,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## 2. Give Feedback to User\n\nThis node gives feedback to the user that the Agent is working."},"typeVersion":1},{"id":"c4edb9b5-7293-490d-a718-ebaf0bb3aeb0","name":"Receive a Message on Telegram","type":"n8n-nodes-base.telegramTrigger","position":[-200,40],"webhookId":"aa8d195c-01c2-435b-9d88-87b38306a6a6","parameters":{"updates":["message"],"additionalFields":{}},"credentials":{"telegramApi":{"id":"RoCnmnDFLL2S3f81","name":"Dmitry's Books Bot"}},"typeVersion":1.2},{"id":"3023c0bc-f219-4b24-b889-726112808b70","name":"Send \"Typing...\" message to User","type":"n8n-nodes-base.telegram","position":[100,40],"webhookId":"845f29dd-9da3-4ac9-86d1-22280acbb46a","parameters":{"chatId":"={{ $json.message.chat.id }}","operation":"sendChatAction"},"credentials":{"telegramApi":{"id":"RoCnmnDFLL2S3f81","name":"Dmitry's Books Bot"}},"typeVersion":1.2},{"id":"a698860d-e2dd-4679-be0a-d8c36d12f9ba","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[1080,-260],"parameters":{"width":260,"height":380,"content":"## 4. Respond to the User\n\nOnce the response is generated, send it back to the user's chat in Telegram."},"typeVersion":1},{"id":"879d4e7a-c2c7-47eb-aaca-4847e61d6886","name":"Send Telegram Message to User","type":"n8n-nodes-base.telegram","position":[1160,-40],"webhookId":"a6b9e331-2b1a-4056-a9fc-5d10b7196c54","parameters":{"text":"={{ $json.output }}","chatId":"={{ $('Receive a Message on Telegram').item.json.message.chat.id }}","additionalFields":{"appendAttribution":false}},"credentials":{"telegramApi":{"id":"RoCnmnDFLL2S3f81","name":"Dmitry's Books Bot"}},"typeVersion":1.2},{"id":"1bc915c9-8494-4c74-b508-80484e9bc290","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[540,0],"parameters":{"text":"={{ $('Receive a Message on Telegram').item.json.message.text }}","options":{"systemMessage":"You are well-versed on Dmitry Paranyushkin's books through the tools you have access to. When you receive a user's query, you can modify it to suit better each tool's context. Always access at least one of the tools and deliver an augmented response.\n\nWhen you're generating a response, attempt to combine perspectives where they fit and point out discrepancies when they exist."},"promptType":"define"},"typeVersion":1.9},{"id":"75db20b3-7a82-49db-a574-66b0ce0a9560","name":"Waves into Patterns Book Expert","type":"n8n-nodes-base.httpRequestTool","position":[1120,300],"parameters":{"url":"https://infranodus.com/api/v1/graphAndAdvice?doNotSave=true&addStats=true&optimize=develop&includeGraph=false&includeGraphSummary=true&includeStatements=true","method":"POST","options":{},"sendBody":true,"authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"name","value":"special_agents_manual"},{"name":"prompt","value":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `User's request adjusted to suit this context`, 'string') }}"},{"name":"requestMode","value":"response"},{"name":"aiTopics","value":"true"}]},"genericAuthType":"httpBearerAuth","toolDescription":"Make a request to The Waves into Patterns book which is well-versed in the questions of natural cycles, variability, fractal states, dynamics, and nonequilibrium stability. Including the following topics:\n\n<MainTopics>: \n1. System Influence: scale influence multiple \n2. Pattern Dynamics: pattern variability fractal \n3. Change Balance: dynamic wave time \n4. Center Transformation: center cycle dominant \n5. Growth Stages: growth exploration period \n6. Long Strategy: term state long \n7. Seasonal Relations: moon summer natural \n8. Flow Connection: exist breaking exploring \n</MainTopics>"},"credentials":{"httpBearerAuth":{"id":"kg0rA5r8siL8LbrU","name":"InfraNodus Circadian API Key"}},"typeVersion":4.2},{"id":"791b109a-f7f4-4391-86ce-4db6315fcd95","name":"Special Agent's Manual Book Expert","type":"n8n-nodes-base.httpRequestTool","position":[900,300],"parameters":{"url":"https://infranodus.com/api/v1/graphAndAdvice?doNotSave=true&addStats=true&optimize=develop&includeGraph=false&includeGraphSummary=true&includeStatements=true","method":"POST","options":{},"sendBody":true,"authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"name","value":"special_agents_manual"},{"name":"prompt","value":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `User's request adjusted to suit this context`, 'string') }}"},{"name":"requestMode","value":"response"},{"name":"aiTopics","value":"true"}]},"genericAuthType":"httpBearerAuth","toolDescription":"Make a request to The Special Agent's Manual book which is well-versed in the questions of human agency, speciality, infiltration and tension dynamics, strategies, identities, finding the special in you as well as the following topics:\n\n<MainTopics>: \n1. Agent Activation: agent special activation \n2. System Dynamics: system body operating \n3. Order Flow: action time order \n4. Creative Process: create identity entity \n5. Movement Patterns: movement wave breathing \n6. Incoming Impact: incoming impulse impact \n7. Fiction Venture: fiction high risk \n8. Social Framework: preset possibility level \n</MainTopics>"},"credentials":{"httpBearerAuth":{"id":"kg0rA5r8siL8LbrU","name":"InfraNodus Circadian API Key"}},"typeVersion":4.2},{"id":"c1a5628c-aa40-451b-b9ac-0cd9ba98dce1","name":"The Flow and the Notion Book","type":"n8n-nodes-base.httpRequestTool","position":[1340,300],"parameters":{"url":"https://infranodus.com/api/v1/graphAndAdvice?doNotSave=true&addStats=true&optimize=develop&includeGraph=false&includeGraphSummary=true&includeStatements=true","method":"POST","options":{},"sendBody":true,"authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"name","value":"the_flow_and_notion"},{"name":"prompt","value":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `User's request adjusted to suit this context`, 'string') }}"},{"name":"requestMode","value":"response"},{"name":"aiTopics","value":"true"}]},"genericAuthType":"httpBearerAuth","toolDescription":"The Flow and the Notion book which is well-versed in the questions of creating with someone, dreaming, making new shapes, dissipating ideas, art, and life. Including the following topics:\n\n<MainTopics>: \n1. Shape Dynamics: shape outline concentric \n2. Time Alignment: long practice time \n3. Man's Journey: bow man candle \n4. Notion Flow: image flow paranyushkin \n5. Essence Realization: process essence essential \n6. Life Choices: slave thing trace \n7. Wave Patterns: found light movement \n8. Synchrony Mediation: book circadian word \n9. Complete Vision: multiple synchrony mediate \n10. Instruction Guide: full \ninstruction foreword : instruction foreword \n</MainTopics>"},"credentials":{"httpBearerAuth":{"id":"kg0rA5r8siL8LbrU","name":"InfraNodus Circadian API Key"}},"typeVersion":4.2},{"id":"e7cc5883-e814-4ed8-95fb-8c7294466e31","name":"The Polysingularity Letters Book","type":"n8n-nodes-base.httpRequestTool","position":[1540,300],"parameters":{"url":"https://infranodus.com/api/v1/graphAndAdvice?doNotSave=true&addStats=true&optimize=develop&includeGraph=false&includeGraphSummary=true&includeStatements=true","method":"POST","options":{},"sendBody":true,"authentication":"genericCredentialType","bodyParameters":{"parameters":[{"name":"name","value":"polysingularity_letters"},{"name":"prompt","value":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `User's request adjusted to suit this context`, 'string') }}"},{"name":"requestMode","value":"response"},{"name":"aiTopics","value":"true"}]},"genericAuthType":"httpBearerAuth","toolDescription":"The Polysingularity Letters book which is well-versed in the questions of polysingularity, multiplicity, networks, networking, art, and creative approach. And also these topics:\n\n<MainTopics>: \n1. Community Dynamics: network community connected \n2. Global Equilibrium: state global change \n3. Polysingular Practice: polysingularity thinking exist \n4. Temporal Relations: time moment thing \n5. Consciousness Source: social cognition view \n6. Meaning Creation: make orthodox meaning \n7. Dmitry Connections: post dmitry minute \n8. Linguistic Variations: wa ë ww \n</MainTopics>"},"credentials":{"httpBearerAuth":{"id":"6lSuuSDajZrvI2GM","name":"InfraNodus API Key"}},"typeVersion":4.2},{"id":"e9b348cc-d6ea-4a46-99cf-cf395a50ab6e","name":"Sticky Note10","type":"n8n-nodes-base.stickyNote","position":[-260,560],"parameters":{"color":3,"width":540,"height":820,"content":"## Setting up a Telegram bot \n\n### It takes only 30 seconds to set up a Telegram bot. Once set up, create a Telegram credential with its access token and use it in all the Telegram nodes above. \n\n1. Create a new chat in Telegram with the [@botfather](https://t.me/botfather) user at [https://t.me/botfather](https://t.me/botfather). \n\n2. Type in `/newbot`\n\n3. Give it a name (that's not the username)\n\n4. Give it a username (e.g. @my_new_bot)\n\n5. You will receive an **API token**. Copy that token and use it to set up the Telegram credentials for the Telegram nodes above. \n\n\nOPTIONAL SETTINGS FOR TELEGRAM GROUPS USE:\n\n6. Note, that if you want to make it possible to add your Telegram bots to groups, you will need to give them permissions to access groups and to read groups' messages. To do that, type in `/mybots`, and list your bots, then choose the bot you created. \n\n7. Then click on Bot Settings > Allow Groups > Yes (the bot will be allowed to join groups)\n\n8. Then choose Settings > Group Privacy > Turn Off (to allow the bot to read groups' messages)\n\n9. Note that your bots won't be able to respond to each other (that's Telegram limitation to avoid spamming and infinite loops), but they will be able to participate in your group's conversations. In that case, you might want to set up an additional filter in the workflow above where the bot will only respond if addressed directly using its username (so that it doesn't respond to every message in the group but only when asked directly)."},"typeVersion":1},{"id":"75e639fa-33dc-4fbc-a34d-dee9e5550969","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[840,260],"parameters":{"width":200,"height":740,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Expert #1\n\nAdd your InfraNodus graph here via the HTTP node using its name in the `body.name` field.\n\nDescribe what the expert does in the Description of the tool. You can use auto-generated Graph RAG summary from InfraNodus > Graph > Project Notes\n\n![Book Screenshot](https://i.ibb.co/rfxsJ4MV/circadian-special-agents-manual.png)"},"typeVersion":1},{"id":"8bb5f9fd-3a31-4c67-8684-b7190a342b2a","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[1060,260],"parameters":{"width":200,"height":740,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Expert #2\n\nAdd your InfraNodus graph here via the HTTP node using its name in the `body.name` field.\n\nDescribe what the expert does in the Description of the tool. You can use auto-generated Graph RAG summary from InfraNodus > Graph > Project Notes\n\n![waves into patterns screen](https://i.ibb.co/1tDJSgVq/circadian-waves-into-patterns.png)"},"typeVersion":1},{"id":"e2e4dd57-fdb2-4ed3-940f-085e4b1a0934","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[1280,260],"parameters":{"width":200,"height":640,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Expert #3\n\nYou can add more experts here. Just make to give them descriptive names, so the agent knows which one to connect to when it has a question. \n\n![flow and notion image](https://i.ibb.co/prLbFG0w/circadian-the-flow-and-notion.png)\n"},"typeVersion":1},{"id":"af7c969d-e48d-4d36-8e71-a7c70b79763d","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[1500,260],"parameters":{"width":200,"height":640,"content":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Expert #4\n\nYou can add more experts here. Just make to give them descriptive names, so the agent knows which one to connect to when it has a question. \n\n![infranodus graph](https://i.ibb.co/hRqxn8JN/circadian-conversation-book.png)"},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"5ad178b3-764a-40eb-a074-e768b615960f","connections":{"AI Agent":{"main":[[{"node":"Send Telegram Message to User","type":"main","index":0}]]},"OpenAI Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"The Flow and the Notion Book":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Receive a Message on Telegram":{"main":[[{"node":"Send \"Typing...\" message to User","type":"main","index":0}]]},"Waves into Patterns Book Expert":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Send \"Typing...\" message to User":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"The Polysingularity Letters Book":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Special Agent's Manual Book Expert":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]}}}


name: Airbnb Telegram Agent - AI-powered accommodation search with voice support
author_name: Friedemann Schuetz
author_username: freddy-schuetz
categories: []
created_at: 2025-05-29T16:00:00.652Z
updated_at: 2025-05-29T16:00:00.652Z
url: https://n8n.io/workflows/4494
scraped_at: 2025-07-06 21:16:30
description:
  Welcome to my Airbnb Telegram Agent Workflow!
  This workflow creates an intelligent Telegram bot that helps users search and find Airbnb accommodations using natural language queries and voice messages.

  DISCLAIMER: This workflow only works with self-hosted n8n instances! You have to install the n8n-nodes-mcp-client Community Node!

  What this workflow does
  This workflow processes incoming Telegram messages (text or voice) and provides personalized Airbnb accommodation recommendations. The AI agent understands natural language queries, searches through Airbnb data using MCP tools, and returns mobile-optimized results with clickable links, prices, and key details.

  Key Features:
  Voice message support (speech-to-text and text-to-speech)
  Conversation memory for context-aware responses
  Mobile-optimized formatting for Telegram
  Real-time Airbnb data access via MCP integration

  This workflow has the following sequence:
  Telegram Trigger - Receives incoming messages from users
  Text or Voice Switch - Routes based on message type
  Voice Processing (if applicable) - Downloads and transcribes voice messages
  Text Preparation - Formats text input for the AI agent
  Airbnb AI Agent - Core logic that:
     Lists available MCP tools for Airbnb data
     Executes searches with parsed parameters
     Formats results for mobile display
  Response Generation - Sends formatted text response
  Voice Response (optional) - Creates and sends audio summary

  Requirements:
  Telegram Bot API**: Documentation 
    Create a bot via @BotFather on Telegram
    Get bot token and configure webhook
  OpenAI API**: Documentation
    Used for speech transcription (Whisper)
    Used for chat completion (GPT-4)
    Used for text-to-speech generation
  MCP Community Client Node**: Documentation
    Custom integration for Airbnb data
    Requires MCP server setup with Airbnb/Airtable connection
    Provides tools for accommodation search and details

  Important: You need to set up an MCP server with Airbnb data access. The workflow uses MCP tools to retrieve real accommodation data, so ensure your MCP server is properly configured with the Airtable/Airbnb integration.

  Configuration Notes:
  Update the Telegram chat ID in the trigger for your specific bot
  Modify the system prompt in the Airbnb Agent for different use cases
  The workflow supports both individual users and can be extended for group chats

  Feel free to contact me via LinkedIn, if you have any questions!

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

workflow_json:
  {"id":"9ElwM3xJyiw4my1L","meta":{"instanceId":"558d88703fb65b2d0e44613bc35916258b0f0bf983c5d4730c00c424b77ca36a","templateCredsSetupCompleted":true},"name":"Airbnb Telegram Agent - Template","tags":[],"nodes":[{"id":"380df1f8-7d7a-4c50-abd3-cf31b09084e1","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[-540,320],"parameters":{"sessionKey":"={{ $('Telegram Trigger').item.json.message.chat.id }}","sessionIdType":"customKey"},"typeVersion":1.3},{"id":"209d3ae6-19c5-455a-88fd-72ebd2ee0807","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-660,320],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4.1","cachedResultName":"gpt-4.1"},"options":{}},"credentials":{"openAiApi":{"id":"niikB3HA4fT5WAqt","name":"OpenAi account"}},"typeVersion":1.2},{"id":"c04d2f36-b275-45de-850e-35046a0e21f0","name":"Airbnb MCP Client - List Tools","type":"n8n-nodes-mcp.mcpClientTool","position":[-420,320],"parameters":{},"credentials":{"mcpClientApi":{"id":"miKKxgV86msS3iHq","name":"MCP Airtable"}},"typeVersion":1},{"id":"6d71b756-431e-4970-a7bf-b5f7f190cc5f","name":"Airbnb MCP Client - Execute Tools","type":"n8n-nodes-mcp.mcpClientTool","position":[-300,320],"parameters":{"toolName":"={{ $fromAI(\"tool\", \"Das ausgewählte Tool\") }}","operation":"executeTool","toolParameters":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Tool_Parameters', `Die Parameter für das Tool`, 'json') }}"},"credentials":{"mcpClientApi":{"id":"miKKxgV86msS3iHq","name":"MCP Airtable"}},"typeVersion":1},{"id":"3103776d-b39e-431e-a72d-cbaf5dc70ef7","name":"Airbnb Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[-568,100],"parameters":{"text":"={{ $json.text }}","options":{"systemMessage":"=<system_prompt>\nYOU ARE A HIGHLY SPECIALIZED **AIRBNB EXPERT AGENT** INTEGRATED INTO **n8n**. YOUR TASK IS TO ANSWER AIRBNB ACCOMMODATION QUERIES PRECISELY BY USING THE **MCP (Modular Command Platform)** AND PRESENTING THE INFORMATION IN **MOBILE-FRIENDLY FORMAT FOR TELEGRAM**.\n\nCURRENT DATE AND TIME: {{ $now }}\n\n---\n\n###TOOL USAGE###\n\nYOU HAVE ACCESS TO TWO MCP TOOLS:\n\n- `Airbnb MCP Client - List Tools` → SHOWS ALL AVAILABLE MCP FUNCTIONS\n- `Airbnb MCP Client - Execute Tools` → EXECUTES THE SELECTED TOOL WITH PARAMETERS\n\n⚠️ **IMPORTANT**: ALWAYS RUN `LIST TOOLS` FIRST → THEN `EXECUTE TOOLS` WITH THE APPROPRIATE TOOL!\n\n---\n\n###CHAIN OF THOUGHTS – WORK STEPS###\n\n1. **UNDERSTAND**: ANALYZE THE QUERY (e.g., location, time period, price limit, special requirements)\n2. **BASICS**: CLARIFY WHETHER IT'S ABOUT A LIST, DETAILS, OR COMPARISON\n3. **BREAK DOWN**: PARSE RELEVANT PARAMETERS FROM THE QUERY\n4. **ANALYZE**: CALL `LIST TOOLS` TO GET ALL AVAILABLE OPTIONS\n5. **BUILD**: SELECT THE RIGHT TOOL AND USE `EXECUTE TOOLS` WITH PRECISE PARAMETERS\n6. **FORMAT**: FORMAT THE OUTPUT FOR **MOBILE/TELEGRAM** – NO TABLES!\n7. **FINAL OUTPUT**: FOR EACH ACCOMMODATION, USE THIS FORMAT:\n\n🏡 {Accommodation Name}\n🛏️ {Beds, Bedrooms}\n💶 {Price/Night} – Total: {Total Price}\n✨ {Special Feature, if available}\n🔗 [View]({URL to accommodation})\n\n📌 *IMPORTANT: THE URL MUST BE WITHIN THE BRACKETS, OTHERWISE THE LINK WON'T BE CLICKABLE ON TELEGRAM!*\n\n---\n\n###EXAMPLE OUTPUT FOR TELEGRAM###\n\nHere are accommodations in Allgäu for 2 people from May 28-30, 2025:\n\n🏡 Sandra's apartment in the countryside\n🛏️ 2 beds\n💶 €82/night – Total: €164\n✨ Guest favorite\n🔗 View\n\n🏡 Villa Kunterbunt in Allgäu\n🛏️ 2 single beds\n💶 €137/night – Total: €274\n✨ Guest favorite\n🔗 View\n\n🔎 More results & filters:\n→ All accommodations for 2 people in Allgäu (May 28-30, 2025)\n\n👉 Let me know if you want details about any accommodation like amenities, photos, or cancellation policies!\n</system_prompt>"},"promptType":"define"},"typeVersion":1.9},{"id":"3860e787-78a7-4211-a7c3-f4b3fcf4fb60","name":"Telegram Trigger","type":"n8n-nodes-base.telegramTrigger","position":[-1540,100],"webhookId":"6596b191-7b90-41ed-ad04-b84340d8d3d6","parameters":{"updates":["message"],"additionalFields":{}},"credentials":{"telegramApi":{"id":"8FPdItv7hTnpO77J","name":"Airtable Agent Bot"}},"typeVersion":1.1},{"id":"442e9229-5576-4193-a629-b7343eb62f1b","name":"Text or Voice","type":"n8n-nodes-base.switch","position":[-1320,100],"parameters":{"rules":{"values":[{"outputKey":"Text","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"7c629699-9dd6-4a75-9b76-d796875f9ac9","operator":{"type":"string","operation":"notEmpty","singleValue":true},"leftValue":"={{ $json.message.text }}","rightValue":""}]},"renameOutput":true},{"outputKey":"Voice","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"0e56bc7f-c754-4f5e-9ddd-7124e1f5d998","operator":{"type":"object","operation":"exists","singleValue":true},"leftValue":"={{ $json.message.voice }}","rightValue":""}]},"renameOutput":true}]},"options":{}},"typeVersion":3.2},{"id":"6ecbc049-1c0d-4e93-886a-6a99f584dfd3","name":"Get Voice Message","type":"n8n-nodes-base.telegram","position":[-1100,200],"webhookId":"b77489ac-fd9d-4ed6-94eb-f646d292bfb2","parameters":{"fileId":"={{ $json.message.voice.file_id }}","resource":"file"},"credentials":{"telegramApi":{"id":"8FPdItv7hTnpO77J","name":"Airtable Agent Bot"}},"typeVersion":1.2},{"id":"c88de1a5-d775-467d-99ba-ee2bba985109","name":"Prepare Text Message for AI Agent","type":"n8n-nodes-base.set","position":[-880,0],"parameters":{"options":{},"assignments":{"assignments":[{"id":"a5bcf087-7580-4904-88d3-ca29614fc923","name":"text","type":"string","value":"={{ $json.message.text }}"}]}},"typeVersion":3.4},{"id":"ffb9dfef-5b76-446f-9b4f-cb6ea1766375","name":"Send Text Response","type":"n8n-nodes-base.telegram","position":[-22,0],"webhookId":"2b263d0d-6a0e-4319-8c5b-5916faba83a8","parameters":{"text":"={{ $json.output }}","chatId":"={{ $('Telegram Trigger').item.json.message.chat.id }}","additionalFields":{"appendAttribution":false}},"credentials":{"telegramApi":{"id":"8FPdItv7hTnpO77J","name":"Airtable Agent Bot"}},"typeVersion":1.2},{"id":"afbe65f9-8576-4217-8eea-4413a8aa8657","name":"Send Voice Response","type":"n8n-nodes-base.telegram","position":[496,200],"webhookId":"17ddaf92-7e24-4ca9-a4e0-74aabea37e20","parameters":{"chatId":"={{ $('Telegram Trigger').item.json.message.chat.id }}","operation":"sendAudio","binaryData":true,"additionalFields":{}},"credentials":{"telegramApi":{"id":"8FPdItv7hTnpO77J","name":"Airtable Agent Bot"}},"typeVersion":1.2},{"id":"e1171f41-47e0-4821-80fa-d1350c6b6d99","name":"Create Voice Response","type":"@n8n/n8n-nodes-langchain.openAi","position":[276,200],"parameters":{"input":"={{ $json.text }}","options":{},"resource":"audio"},"credentials":{"openAiApi":{"id":"niikB3HA4fT5WAqt","name":"OpenAi account"}},"typeVersion":1.8},{"id":"c31a642c-068f-4b63-ac89-4530377f8a52","name":"Summarize Response for Voice","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[-100,200],"parameters":{"text":"=Summarize the given input briefly and clearly for voice output. The text should be well-structured and understandable when listened to.\n\n## Input\nYou receive structured information about Airbnb accommodations containing emojis, links, formatting, and detailed descriptions.\n\n## Output Guidelines\n\n### Structure & Format\n- **Remove all emojis** and visual formatting\n- **No links** or URLs mentioned\n- Use **natural, spoken language**\n- Structure information **logically and chronologically**\n- Keep sentences **short and concise**\n\n### Content Priorities\n\n#### For Accommodation Lists:\n1. **Mention number of found accommodations**\n2. **Price range** (cheapest to most expensive option)\n3. **2-3 most interesting options** with name, price, and key feature\n4. Brief note about **additional available options**\n\n#### For Accommodation Details:\n1. **Name and basic data** (guest count, room type)\n2. **Price per night**\n3. **3-4 most important amenities**\n4. **Key house rules** (check-in/out, guest limit)\n5. **Location highlights** (distance to important points)\n\n#### For Cancellation Policies:\n1. **Type of cancellation policy** (flexible/moderate/strict)\n2. **Deadlines for free cancellation**\n3. **Refund rates** after cancellation deadlines\n4. **Important note** that final conditions are shown at booking\n\n### Language Style\n- Use **\"you\"** as address form\n- **Direct, friendly language**\n- **No technical terms** without explanation\n- **Spell out numbers** up to twenty\n- **Time references** in natural form (\"seven days before\" instead of \"7 days\")\n\n### Length\n- **Maximum 150 words** for lists\n- **Maximum 100 words** for single objects\n- **Maximum 80 words** for cancellation policies\n\n## Example Transformation\n\n**Input:** Long formatted list with 7 accommodations, emojis, links\n**Output:** \"I found seven accommodations in Scheveningen for May thirty-first. Prices range from seventy-three to two hundred nine euros per night. Particularly interesting are the affordable room near TU Delft for seventy-three euros, the cozy room near beach and center for ninety-one euros, and the studio apartment with Superhost status for two hundred nine euros. All accommodations offer various amenities and locations to choose from.\"\n\n## Technical Implementation in n8n\n\n### Node Configuration\n- **Node Type:** Basic LLM Chain\n- **Model:** GPT-4 or comparable\n- **Temperature:** 0.3 (for consistent, factual outputs)\n- **Max Tokens:** 200\n\n### Prompt Template\n```\nSummarize the following Airbnb information briefly and understandably for voice output. \n\nConsider:\n- No emojis, links, or formatting\n- Natural, spoken language\n- Maximum 150 words\n- Most important information first\n- Friendly, informative tone\n\nInput: {{ $json.output }}\n\nSummary:\n```\n\n### Input Mapping\n- Connect the output of the previous node with the `input` parameter\n- Use the `output` property of the JSON array as input\n\n### Output Processing\n- The summarized text can be passed directly to Text-to-Speech services\n- Or for further processing in downstream nodes","batching":{},"promptType":"define"},"typeVersion":1.7},{"id":"598891da-ece9-4ef1-a3a7-bcc11ab31d19","name":"Transcribe Voice Message","type":"@n8n/n8n-nodes-langchain.openAi","position":[-880,200],"parameters":{"options":{},"resource":"audio","operation":"transcribe"},"credentials":{"openAiApi":{"id":"niikB3HA4fT5WAqt","name":"OpenAi account"}},"typeVersion":1.8},{"id":"5b9a2516-4b8e-42c2-869d-1f8d85d279ba","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-2620,-480],"parameters":{"width":1040,"height":1280,"content":"# Welcome to my Airbnb Telegram Agent Workflow!\n\n## This workflow has the following sequence:\n\n1. **Telegram Trigger** - Receives incoming messages (text or voice) from Telegram users\n2. **Text or Voice Switch** - Routes the workflow based on message type (text vs. voice)\n3. **Voice Processing Path** (if voice message):\n   - Get Voice Message - Downloads the voice file from Telegram\n   - Transcribe Voice Message - Converts speech to text using OpenAI Whisper\n4. **Text Processing Path** - Prepares text messages for the AI agent\n5. **Airbnb Agent (Core Logic)** - LangChain agent that:\n   - Uses conversation memory to maintain context\n   - Lists available MCP tools for Airbnb data access\n   - Executes appropriate tools with parsed parameters\n   - Formats results for mobile/Telegram display\n6. **Response Generation**:\n   - Send Text Response - Sends formatted text back to Telegram\n   - Summarize Response for Voice - Creates voice-friendly summary\n   - Create Voice Response - Converts summary to speech using OpenAI TTS\n   - Send Voice Response - Sends audio message back to Telegram\n\n## The following accesses are required for the workflow:\n\n- **Telegram Bot API**: [Documentation](https://docs.n8n.io/integrations/builtin/credentials/telegram/) \n  - Create a bot via @BotFather on Telegram\n  - Get bot token and configure webhook\n- **OpenAI API**: [Documentation](https://docs.n8n.io/integrations/builtin/credentials/openai/)\n  - Used for speech transcription (Whisper)\n  - Used for chat completion (GPT-4)\n  - Used for text-to-speech generation\n- **MCP Community Client Node**: [Documentation](https://github.com/nerding-io/n8n-nodes-mcp)\n  - Custom integration for Airbnb data\n  - Requires MCP server setup with Airbnb/Airtable connection\n  - Provides tools for accommodation search and details\n\n## Key Features:\n\n- **Multimodal Support**: Handles both text and voice messages\n- **Conversation Memory**: Maintains context across multiple messages\n- **Mobile-Optimized Output**: Formats results specifically for Telegram mobile viewing\n- **Tool Integration**: Uses MCP platform to access real Airbnb data\n- **Voice Capabilities**: Full speech-to-text and text-to-speech support\n\n## Configuration Notes:\n\n- Uses GPT-4.1 model for enhanced reasoning capabilities\n- Includes comprehensive system prompts for Airbnb-specific responses\n- Voice responses are automatically summarized for better audio experience\n\nYou can contact me via LinkedIn, if you have any questions: https://www.linkedin.com/in/friedemann-schuetz"},"typeVersion":1}],"active":false,"pinData":{"Airbnb Agent":[{"json":{"output":"Hier sind Unterkünfte in Scheveningen für 1 Person vom 31. Mai (Samstag) bis 1. Juni 2025 (Sonntag):\n\n🏡 Comfort double room | Hotel Corel\n🛏️ 1 Doppelbett\n💶 €156/Nacht – Total: €156\n🔗 [View](https://www.airbnb.com/rooms/810809021737050160)\n\n🏡 Cozy room near the city center and the beach!\n🛏️ Einzelzimmer\n💶 €91/Nacht – Total: €91\n🔗 [View](https://www.airbnb.com/rooms/1148459085653934403)\n\n🏡 Go see Peace Palace – an easy 15-min walk\n🛏️ 2 Einzelbetten\n💶 €164/Nacht – Total: €164\n🔗 [View](https://www.airbnb.com/rooms/1257252023824017600)\n\n🏡 Peaceful room, King size bed, Big Balcony, Centre\n🛏️ King-Size-Bett\n💶 €123/Nacht – Total: €123\n🔗 [View](https://www.airbnb.com/rooms/3874587)\n\n🏡 Studio Apartment at Cove Centrum\n🛏️ 1 Doppelbett\n💶 €209/Nacht – Total: €209\n✨ Superhost\n🔗 [View](https://www.airbnb.com/rooms/559146820973459936)\n\n🏡 The Hague City Center Studio Appartement Brand New\n🛏️ 2 Betten\n💶 €146/Nacht – Total: €146\n✨ Guest favorite\n🔗 [View](https://www.airbnb.com/rooms/34312629)\n\n🔎 Mehr Ergebnisse & weitere Filter:\n→ [Alle Unterkünfte für 1 Person in Scheveningen (31.05.–01.06.2025)](https://www.airbnb.com/s/Scheveningen/homes?checkin=2025-05-31&checkout=2025-06-01&adults=1&children=0&infants=0&pets=0)\n\n👉 Sag Bescheid, wenn du Infos zu Ausstattung, Fotos oder Stornierung brauchst!"}}]},"settings":{"executionOrder":"v1"},"versionId":"b2664114-a335-4dbb-a47b-0feebed5807d","connections":{"Airbnb Agent":{"main":[[{"node":"Send Text Response","type":"main","index":0},{"node":"Summarize Response for Voice","type":"main","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"Airbnb Agent","type":"ai_memory","index":0}]]},"Text or Voice":{"main":[[{"node":"Prepare Text Message for AI Agent","type":"main","index":0}],[{"node":"Get Voice Message","type":"main","index":0}]]},"Telegram Trigger":{"main":[[{"node":"Text or Voice","type":"main","index":0}]]},"Get Voice Message":{"main":[[{"node":"Transcribe Voice Message","type":"main","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"Airbnb Agent","type":"ai_languageModel","index":0},{"node":"Summarize Response for Voice","type":"ai_languageModel","index":0}]]},"Create Voice Response":{"main":[[{"node":"Send Voice Response","type":"main","index":0}]]},"Transcribe Voice Message":{"main":[[{"node":"Airbnb Agent","type":"main","index":0}]]},"Summarize Response for Voice":{"main":[[{"node":"Create Voice Response","type":"main","index":0}]]},"Airbnb MCP Client - List Tools":{"ai_tool":[[{"node":"Airbnb Agent","type":"ai_tool","index":0}]]},"Airbnb MCP Client - Execute Tools":{"ai_tool":[[{"node":"Airbnb Agent","type":"ai_tool","index":0}]]},"Prepare Text Message for AI Agent":{"main":[[{"node":"Airbnb Agent","type":"main","index":0}]]}}}


name: Schedule & Publish All Instagram Content Types with Facebook Graph API
author_name: Lakshit Ukani
author_username: lakshit1996
nodes_used: ["n8n-nodes-base.httpRequest","n8n-nodes-base.facebookGraphApi"]
categories: []
created_at: 2025-05-29T18:35:10.370Z
updated_at: 2025-05-29T18:35:10.370Z
url: https://n8n.io/workflows/4498
scraped_at: 2025-07-06 21:16:30
description:
  Automated Instagram posting with Facebook Graph API and content routing

  Who is this for?

  This workflow is perfect for social media managers, content creators, digital marketing agencies, and small business owners who need to automate their Instagram posting process. Whether you're managing multiple client accounts or maintaining consistent personal branding, this template streamlines your social media operations.

  What problem is this workflow solving?

  Manual Instagram posting is time-inconsistent and prone to inconsistency. Content creators struggle with:
  Remembering to post at optimal times
  Managing different content types (images, videos, reels, stories, carousels)
  Maintaining posting schedules across multiple accounts
  Ensuring content is properly formatted for each post type

  This workflow eliminates manual posting, reduces human error, and ensures consistent content delivery across all Instagram format types.

  What this workflow does

  The workflow automatically publishes content to Instagram using Facebook's Graph API with intelligent routing based on content type. It handles image posts, video stories, Instagram reels, carousel posts, and story content. The system creates media containers, monitors processing status, and publishes content when ready. It supports both HTTP requests and Facebook SDK methods for maximum reliability and includes automatic retry mechanisms for failed uploads.

  Setup

  Connect Instagram Business Account to a Facebook Page
  Configure Facebook Graph API credentials with instagram_basic permissions  
  Update the "Configure Post Settings" node with your Instagram Business Account ID
  Set media URLs and captions in the configuration section
  Choose post type (http_image, fb_reel, http_carousel, etc.)
  Test workflow with sample content before going live

  How to customize this workflow to your needs

  Modify the post_type variable to control content routing:
  Use http_* prefixes for direct API calls 
  Use fb_* prefixes for Facebook SDK calls
  Use both HTTP and Facebook SDK nodes as fallback mechanisms** - if one method fails, automatically try the other for maximum success rate
  Add scheduling by connecting a Cron node trigger
  Integrate with Google Sheets or Airtable for content management
  Connect webhook triggers for automated posting from external systems
  Customize wait times based on your content file sizes
  Set up error handling** to switch between HTTP and Facebook SDK methods when API limits are reached

workflow_json:
  {"meta":{"instanceId":"353ac65d120d2007b8a1503e85a96651a9b2cbb94b0334693ebac2129fa6a7ee","templateCredsSetupCompleted":true},"nodes":[{"id":"b4438922-5dfd-44a7-838b-1d91be3dd032","name":"Container HTTP Image","type":"n8n-nodes-base.httpRequest","position":[-4220,240],"parameters":{"url":"=https://graph.facebook.com/v22.0/{{ $json.node }}/media","method":"POST","options":{},"sendQuery":true,"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","queryParameters":{"parameters":[{"name":"image_url","value":"={{ $json.image_url }}"},{"name":"caption","value":"={{ $json.caption }}"}]}},"credentials":{"httpHeaderAuth":{"id":"hWVD8Wl5GEMhDj4z","name":"lakshitukani IG Account"}},"typeVersion":4.2},{"id":"9350ff43-ae98-4165-98cc-2781937ca2af","name":"Container HTTP Reels","type":"n8n-nodes-base.httpRequest","position":[-4220,1500],"parameters":{"url":"=https://graph.facebook.com/v22.0/{{ $json.node }}/media","method":"POST","options":{},"sendQuery":true,"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","queryParameters":{"parameters":[{"name":"media_type","value":"=REELS"},{"name":"video_url","value":"={{ $json.video_url }}"},{"name":"caption","value":"={{ $json.caption }}"},{"name":"cover_url","value":"={{ $json.cover_image }}"},{"name":"audio_name","value":"Monody (feat. Laura Brehm)"}]}},"credentials":{"httpHeaderAuth":{"id":"hWVD8Wl5GEMhDj4z","name":"lakshitukani IG Account"}},"typeVersion":4.2},{"id":"4706d54a-b294-46af-b6af-ee4b751af246","name":"Container FB Image","type":"n8n-nodes-base.facebookGraphApi","position":[-4220,440],"parameters":{"edge":"media","node":"={{ $json.node }}","options":{"queryParameters":{"parameter":[{"name":"caption","value":"={{ $json.caption }}"},{"name":"image_url","value":"={{ $json.image_url }}"}]}},"graphApiVersion":"v22.0","httpRequestMethod":"POST"},"credentials":{"facebookGraphApi":{"id":"YeGWCZ0amouHAnaI","name":"IG lakshitukani Login (n8n Integration 2)"}},"typeVersion":1},{"id":"bc067bab-2652-4667-a0bc-afe1bc009af0","name":"Container FB Story Image","type":"n8n-nodes-base.facebookGraphApi","position":[-4220,840],"parameters":{"edge":"media","node":"={{ $json.node }}","options":{"queryParameters":{"parameter":[{"name":"caption","value":"={{ $json.caption }}"},{"name":"image_url","value":"={{ $json.image_url }}"},{"name":"media_type","value":"STORIES"}]}},"graphApiVersion":"v22.0","httpRequestMethod":"POST"},"credentials":{"facebookGraphApi":{"id":"YeGWCZ0amouHAnaI","name":"IG lakshitukani Login (n8n Integration 2)"}},"typeVersion":1},{"id":"0781252a-0145-4659-9c53-7ad130842711","name":"Container HTTP Story Image","type":"n8n-nodes-base.httpRequest","position":[-4220,680],"parameters":{"url":"=https://graph.facebook.com/v22.0/{{ $json.node }}/media","method":"POST","options":{},"sendQuery":true,"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","queryParameters":{"parameters":[{"name":"media_type","value":"=STORIES"},{"name":"image_url","value":"={{ $json.image_url }}"}]}},"credentials":{"httpHeaderAuth":{"id":"hWVD8Wl5GEMhDj4z","name":"lakshitukani IG Account"}},"typeVersion":4.2},{"id":"f47c2dcc-e0d1-457e-8741-c5952cf61606","name":"Container FB Reels","type":"n8n-nodes-base.facebookGraphApi","position":[-4220,1640],"parameters":{"edge":"media","node":"=17841456545908024","options":{"queryParameters":{"parameter":[{"name":"caption","value":"={{ $json.caption }}"},{"name":"video_url","value":"={{ $json.video_url }}"},{"name":"media_type","value":"REELS"},{"name":"cover_url","value":"={{ $json.cover_image }}"}]}},"graphApiVersion":"v22.0","httpRequestMethod":"POST"},"credentials":{"facebookGraphApi":{"id":"YeGWCZ0amouHAnaI","name":"IG lakshitukani Login (n8n Integration 2)"}},"typeVersion":1},{"id":"fa81d7f3-d5c0-402d-8741-70b09656a5fc","name":"Container HTTP Story Video","type":"n8n-nodes-base.httpRequest","position":[-4220,1080],"parameters":{"url":"=https://graph.facebook.com/v22.0/{{ $json.node }}/media","method":"POST","options":{},"sendQuery":true,"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","queryParameters":{"parameters":[{"name":"media_type","value":"=STORIES"},{"name":"video_url","value":"={{ $json.video_url }}"}]}},"credentials":{"httpHeaderAuth":{"id":"hWVD8Wl5GEMhDj4z","name":"lakshitukani IG Account"}},"typeVersion":4.2},{"id":"f6a8ec74-68f2-4b9e-a5dc-b3f0d7ecf5d2","name":"Container FB Story Video","type":"n8n-nodes-base.facebookGraphApi","position":[-4220,1240],"parameters":{"edge":"media","node":"={{ $json.node }}","options":{"queryParameters":{"parameter":[{"name":"video_url","value":"={{ $json.video_url }}"},{"name":"media_type","value":"STORIES"}]}},"graphApiVersion":"v22.0","httpRequestMethod":"POST"},"credentials":{"facebookGraphApi":{"id":"YeGWCZ0amouHAnaI","name":"IG lakshitukani Login (n8n Integration 2)"}},"typeVersion":1},{"id":"43cc35cd-6f96-4db1-9b6d-11e1fa7d529b","name":"Container Carousel Image 1","type":"n8n-nodes-base.httpRequest","position":[-4660,1880],"parameters":{"url":"=https://graph.facebook.com/v22.0/{{ $json.node }}/media","method":"POST","options":{},"sendQuery":true,"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","queryParameters":{"parameters":[{"name":"image_url","value":"={{ $json.image_url }}"},{"name":"caption","value":"={{ $json.caption }}"}]}},"credentials":{"httpHeaderAuth":{"id":"hWVD8Wl5GEMhDj4z","name":"lakshitukani IG Account"}},"typeVersion":4.2},{"id":"fa54a3d6-2e93-445f-9c6c-6643eb181d07","name":"Container Carousel Image 2","type":"n8n-nodes-base.httpRequest","position":[-4440,1880],"parameters":{"url":"=https://graph.facebook.com/v22.0/{{ $('🔀 Smart Content Router').item.json.node }}/media","method":"POST","options":{},"sendQuery":true,"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","queryParameters":{"parameters":[{"name":"image_url","value":"=https://4.img-dpreview.com/files/p/TC190x190S190x190~sample_galleries/0890568360/4504013564.jpg"},{"name":"caption","value":"={{ $('🔀 Smart Content Router').item.json.caption }}"}]}},"credentials":{"httpHeaderAuth":{"id":"hWVD8Wl5GEMhDj4z","name":"lakshitukani IG Account"}},"typeVersion":4.2},{"id":"7f1a40cb-79b9-4af1-b41c-5eb26e19ebc7","name":"Container HTTP Carousel","type":"n8n-nodes-base.httpRequest","position":[-4220,1880],"parameters":{"url":"=https://graph.facebook.com/v22.0/{{ $('🔀 Smart Content Router').item.json.node }}/media","method":"POST","options":{},"sendQuery":true,"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","queryParameters":{"parameters":[{"name":"children","value":"={{ $('Container Carousel Image 1').item.json.id }}, {{ $json.id }}"},{"name":"caption","value":"={{ $('🔀 Smart Content Router').item.json.caption }}"},{"name":"media_type","value":"CAROUSEL"}]}},"credentials":{"httpHeaderAuth":{"id":"hWVD8Wl5GEMhDj4z","name":"lakshitukani IG Account"}},"typeVersion":4.2},{"id":"0472b36a-76c6-4f1d-840b-1cc6d44aaeef","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-4360,180],"parameters":{"width":400,"height":420,"content":"## 📸 Image Post Creation"},"typeVersion":1},{"id":"9bd43a33-0ce2-4b70-a6e8-82b770388bfd","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-4360,620],"parameters":{"width":400,"height":380,"content":"## 📱 Story Image Upload"},"typeVersion":1},{"id":"1fe2c077-d86b-4ce9-b04e-b33c5f515d98","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-4360,1020],"parameters":{"width":400,"height":380,"content":"## 🎬 Story Video Upload"},"typeVersion":1},{"id":"72c5e2d9-c8a1-45ed-9856-99cef03ee29c","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-4360,1420],"parameters":{"width":400,"height":380,"content":"## 🎵 Instagram Reels Upload"},"typeVersion":1},{"id":"0fb7ead7-7eec-40af-9242-59e514c31e3d","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-4820,1820],"parameters":{"width":860,"height":220,"content":"## 🖼️ Carousel Post (Multiple Images)"},"typeVersion":1},{"id":"9284f2a3-f2a2-4f0d-bc3a-9affaf54b871","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-5380,760],"parameters":{"color":3,"width":840,"height":640,"content":"## Variable and Routing Setup"},"typeVersion":1},{"id":"f6c099a8-bc27-4636-b857-c380d0f99766","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[-3700,840],"parameters":{"color":6,"width":1140,"height":540,"content":"## 🔄 Container Processing Pipeline\n1. **Create Container** → After Getting Container ID\n2. **Wait & Poll** → Check if container processing is complete  \n3. **Status Check** → Verify FINISHED status before publishing\n4. **Auto-Retry** → If not ready, wait and check again"},"typeVersion":1},{"id":"db361414-e90c-4a71-b353-f837a76f4b6f","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[-2520,840],"parameters":{"color":4,"width":580,"height":540,"content":"## 📤 Smart Publishing System\nRoute automatically selected based on post_type prefix:\n- http_* → Uses HTTP Request nodes\n- fb_* → Uses Facebook Graph API nodes"},"typeVersion":1},{"id":"a27e2ffc-b8e2-4501-a9ba-bc8f31efd92e","name":"✅ Is Container Ready?","type":"n8n-nodes-base.if","position":[-2960,960],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"682def4c-2cda-4417-9329-682a8a60feed","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.status_code }}","rightValue":"FINISHED"}]}},"typeVersion":2.2},{"id":"a42df401-c1e9-4194-9c76-a03c26b1c09c","name":"🔀 HTTP vs FB API Router","type":"n8n-nodes-base.if","position":[-2460,1040],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"da6bcb63-632a-443a-b5b3-a8b6e1c62871","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $('🔀 Smart Content Router').item.json.post_type.split(\"_\")[0] }}","rightValue":"http"}]}},"typeVersion":2.2},{"id":"10905c0b-ff3c-4aed-b741-652dd1847fac","name":"📤 Publish via HTTP API","type":"n8n-nodes-base.httpRequest","position":[-2240,940],"parameters":{"url":"=https://graph.facebook.com/v22.0/{{ $('🔀 Smart Content Router').item.json.node }}/media_publish","method":"POST","options":{},"sendQuery":true,"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","queryParameters":{"parameters":[{"name":"creation_id","value":"={{ $json.id }}"}]}},"credentials":{"httpHeaderAuth":{"id":"hWVD8Wl5GEMhDj4z","name":"lakshitukani IG Account"}},"typeVersion":4.2},{"id":"24948258-f1b0-4e47-92b1-4282b88dbf14","name":"📤 Publish via Facebook SDK","type":"n8n-nodes-base.facebookGraphApi","position":[-2240,1140],"parameters":{"edge":"media_publish","node":"={{ $('🔀 Smart Content Router').item.json.node }}","options":{"queryParameters":{"parameter":[{"name":"creation_id","value":"={{ $json.id }}"}]}},"graphApiVersion":"v22.0","httpRequestMethod":"POST"},"credentials":{"facebookGraphApi":{"id":"YeGWCZ0amouHAnaI","name":"IG lakshitukani Login (n8n Integration 2)"}},"typeVersion":1},{"id":"90e80bc1-81ab-43dc-b764-2850284ec9e9","name":"⏰ Initial Processing Wait","type":"n8n-nodes-base.wait","position":[-3440,1040],"webhookId":"443f84eb-1e9d-4c77-9a9a-c70290333dca","parameters":{},"typeVersion":1.1},{"id":"9db2f610-29ba-46ad-858d-80f909b8ecf7","name":"⏰ Retry Wait Loop","type":"n8n-nodes-base.wait","position":[-2740,1140],"webhookId":"e9ac0c1d-b415-4160-a6b1-908d2310cb23","parameters":{},"typeVersion":1.1},{"id":"6aa81fe8-430c-4a06-a9a7-863c568390f2","name":"🔍 Check Processing Status","type":"n8n-nodes-base.set","position":[-3660,1040],"parameters":{"options":{},"assignments":{"assignments":[{"id":"37f96da8-a8b6-417b-b5cf-7a4df5b4610c","name":"container_id","type":"string","value":"={{ $json.id }}"}]}},"typeVersion":3.4},{"id":"4327071b-4646-4044-8003-b16720a759be","name":"🔀 Smart Content Router","type":"n8n-nodes-base.switch","position":[-4880,900],"parameters":{"rules":{"values":[{"outputKey":"HTTP - Image","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"ab388a77-1660-4a64-ba58-bc405444dbd5","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.post_type }}","rightValue":"http_image"}]},"renameOutput":true},{"outputKey":"FB - Image","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"be8816f5-ae68-48c3-869e-bc67078298d8","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.post_type }}","rightValue":"fb_image"}]},"renameOutput":true},{"outputKey":"HTTP - Story Img","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"663bacc8-ceeb-4f81-b058-c379eaf6e717","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.post_type }}","rightValue":"http_story_image"}]},"renameOutput":true},{"outputKey":"FB - Story Image","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"99441a51-906e-469a-b98e-64aa43c996ba","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.post_type }}","rightValue":"fb_story_image"}]},"renameOutput":true},{"outputKey":"HTTP = Story Video","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"29cfc5f8-e1ae-4c10-8961-2356d7c13195","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.post_type }}","rightValue":"http_story_video"}]},"renameOutput":true},{"outputKey":"FB - Story Video","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"578f5df3-23ef-4ef3-9a48-7528c826ea46","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.post_type }}","rightValue":"fb_story_video"}]},"renameOutput":true},{"outputKey":"HTTP - Reels","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"25e31619-4116-46e0-bfcb-a8d8a030fa68","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.post_type }}","rightValue":"http_reel"}]},"renameOutput":true},{"outputKey":"FB - Reels","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"cf34e931-f798-4c70-af29-9aec7aab8f6c","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.post_type }}","rightValue":"fb_reel"}]},"renameOutput":true},{"outputKey":"HTTP - Carousel","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"02944863-db4b-445f-9c03-382abd9525b9","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.post_type }}","rightValue":"http_carousel"}]},"renameOutput":true},{"outputKey":"FB - Carousel","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"0a17aaa0-8520-442f-9c3f-b4112339a08c","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.post_type }}","rightValue":"fb_carousel"}]},"renameOutput":true}]},"options":{}},"typeVersion":3.2},{"id":"f27ef907-cdab-401d-b8ec-e244f63aada0","name":"🚀 Manual Trigger - Start Workflow","type":"n8n-nodes-base.manualTrigger","position":[-5320,1040],"parameters":{},"typeVersion":1},{"id":"cb1562d5-2e46-4299-a93d-d9a283c720d3","name":"⚙️ Configure Post Settings","type":"n8n-nodes-base.set","position":[-5100,1040],"parameters":{"options":{},"assignments":{"assignments":[{"id":"217b69e3-98ec-49a2-8fde-372dd1bc1848","name":"node","type":"string","value":"17841456545908024"},{"id":"2caebe7c-a2d3-428e-b129-fcfbe66854e5","name":"post_type","type":"string","value":"http_reel"},{"id":"a17a5c94-d9ae-44f8-9d56-fb55d17efe5a","name":"image_url","type":"string","value":"https://media.licdn.com/dms/image/v2/D4D03AQHf-K7ergkUwQ/profile-displayphoto-shrink_800_800/B4DZbdtDouHQAg-/0/1747476298728?e=1753920000&v=beta&t=Js1KDjpDYOgzYW4YlhwT1_ZmbggoSIxjcq3IA0rRJs0"},{"id":"6e2c9c54-ce2c-4ea5-8bb2-ae2ae4712427","name":"caption","type":"string","value":"Automated Post"},{"id":"32aa1561-458c-4f64-a854-eab65f9ad1dd","name":"video_url","type":"string","value":"https://videos.pexels.com/video-files/4434242/4434242-sd_360_640_24fps.mp4"},{"id":"c6485101-488b-43db-8708-1a1136292956","name":"cover_image","type":"string","value":"https://cdn.pixabay.com/photo/2023/11/07/22/59/building-8373618_1280.jpg"}]}},"typeVersion":3.4},{"id":"38e0d117-e4b0-429d-b263-41ee141c71a2","name":"🔍 Check Processing Status1","type":"n8n-nodes-base.httpRequest","position":[-3180,1040],"parameters":{"url":"=https://graph.facebook.com/v22.0/{{ $('🔍 Check Processing Status').item.json.container_id }}","options":{},"sendQuery":true,"authentication":"genericCredentialType","genericAuthType":"httpQueryAuth","queryParameters":{"parameters":[{"name":"fields","value":"status_code"}]}},"credentials":{"httpQueryAuth":{"id":"teNjcIVMpXV90H7T","name":"IG lakshitukani (n8n integration)"}},"typeVersion":4.2},{"id":"7cfc1f61-8318-479e-b763-6d218d04be6c","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[-5260,160],"parameters":{"color":2,"width":460,"height":380,"content":"## 👨‍💻 Creator Information\n\n**Created by:** Lakshit Ukani  \n🔗 **LinkedIn:** [Connect with me](https://www.linkedin.com/in/lakshit-ukani/)\n🔗 **Youtube:** [Subscribe to my Channel](https://www.youtube.com/@lakshit-ukani?sub_confirmation=1)\n\n### 🤝 Community & Support\n💬 **Join Community:** [Skool Community Link](https://www.skool.com/ai-automation-club-7843)   \n📚 **Documentation:** [Full Guide & FAQ](https://developers.facebook.com/docs/instagram-platform/instagram-graph-api/reference/ig-user/media#creating)  \n\n### 📞 Need Help?\n- **Quick Questions:** Comment on the YouTube video\n- **Workflow Issues:** Post in our community  \n- **Business Inquiries:** Connect via LinkedIn"},"typeVersion":1}],"pinData":{},"connections":{"Container FB Image":{"main":[[{"node":"🔍 Check Processing Status","type":"main","index":0}]]},"Container FB Reels":{"main":[[{"node":"🔍 Check Processing Status","type":"main","index":0}]]},"⏰ Retry Wait Loop":{"main":[[{"node":"🔍 Check Processing Status1","type":"main","index":0}]]},"Container HTTP Image":{"main":[[{"node":"🔍 Check Processing Status","type":"main","index":0}]]},"Container HTTP Reels":{"main":[[{"node":"🔍 Check Processing Status","type":"main","index":0}]]},"Container HTTP Carousel":{"main":[[{"node":"🔍 Check Processing Status","type":"main","index":0}]]},"✅ Is Container Ready?":{"main":[[{"node":"🔀 HTTP vs FB API Router","type":"main","index":0}],[{"node":"⏰ Retry Wait Loop","type":"main","index":0}]]},"Container FB Story Image":{"main":[[{"node":"🔍 Check Processing Status","type":"main","index":0}]]},"Container FB Story Video":{"main":[[{"node":"🔍 Check Processing Status","type":"main","index":0}]]},"🔀 Smart Content Router":{"main":[[{"node":"Container HTTP Image","type":"main","index":0}],[{"node":"Container FB Image","type":"main","index":0}],[{"node":"Container HTTP Story Image","type":"main","index":0}],[{"node":"Container FB Story Image","type":"main","index":0}],[{"node":"Container HTTP Story Video","type":"main","index":0}],[{"node":"Container FB Story Video","type":"main","index":0}],[{"node":"Container HTTP Reels","type":"main","index":0}],[{"node":"Container FB Reels","type":"main","index":0}],[{"node":"Container Carousel Image 1","type":"main","index":0}],[]]},"Container Carousel Image 1":{"main":[[{"node":"Container Carousel Image 2","type":"main","index":0}]]},"Container Carousel Image 2":{"main":[[{"node":"Container HTTP Carousel","type":"main","index":0}]]},"Container HTTP Story Image":{"main":[[{"node":"🔍 Check Processing Status","type":"main","index":0}]]},"Container HTTP Story Video":{"main":[[{"node":"🔍 Check Processing Status","type":"main","index":0}]]},"🔀 HTTP vs FB API Router":{"main":[[{"node":"📤 Publish via HTTP API","type":"main","index":0}],[{"node":"📤 Publish via Facebook SDK","type":"main","index":0}]]},"⏰ Initial Processing Wait":{"main":[[{"node":"🔍 Check Processing Status1","type":"main","index":0}]]},"🔍 Check Processing Status":{"main":[[{"node":"⏰ Initial Processing Wait","type":"main","index":0}]]},"🔍 Check Processing Status1":{"main":[[{"node":"✅ Is Container Ready?","type":"main","index":0}]]},"⚙️ Configure Post Settings":{"main":[[{"node":"🔀 Smart Content Router","type":"main","index":0}]]},"🚀 Manual Trigger - Start Workflow":{"main":[[{"node":"⚙️ Configure Post Settings","type":"main","index":0}]]}}}


name: Build & Query RAG System with Google Drive, OpenAI GPT-4o-mini, and Pinecone
author_name: David Olusola
author_username: dae221
categories: []
created_at: 2025-05-30T01:35:59.082Z
updated_at: 2025-05-30T01:35:59.082Z
url: https://n8n.io/workflows/4501
scraped_at: 2025-07-06 21:16:30
description:
  🔍 What This Workflow Does

  This RAG Pipeline in n8n automates document ingestion from Google Drive, vectorizes it using OpenAI embeddings, stores it in Pinecone, and enables chat-based retrieval using LangChain agents.

  Main Functions:

  📂 Auto-detects new files uploaded to a specific Google Drive folder.
  🧠 Converts the file into embeddings using OpenAI.
  📦 Stores them in a Pinecone vector database.
  💬 Allows a user to query the knowledge base through a chat interface.
  🤖 Uses a GPT-4o-mini model with LangChain to generate intelligent responses using retrieved context.
  ⚙️ Setup Instructions

  Connect Accounts
  Ensure these services are connected in n8n:

  ✅ Google Drive (OAuth2)
  ✅ OpenAI
  ✅ Pinecone
  You can do this in n8n &gt; Credentials &gt; New and use the matching names from the file:

  Google Drive: "Google Drive account 2"
  OpenAI: "OpenAi success"
  Pinecone: "PineconeApi account 2"
  Folder Setup
  Upload your documents to this folder in Google Drive:

  📁 Power Folder

  The workflow is triggered every minute when a new file is uploaded.

  Workflow Overview
  A. File Ingestion Path

  Google Drive Trigger — detects new file.
  Google Drive (Download) — downloads the new file.
  Recursive Text Splitter — splits text into chunks.
  Default Data Loader — loads content as LangChain documents.
  OpenAI Embeddings — converts text chunks into embeddings.
  Pinecone Vector Store — stores them in "ragfile" index.
  B. Chat Retrieval Path

  When chat message received — 
  AI Agent — LangChain agent managing tools.
  OpenAI Chat Model (GPT-4o-mini) — generates replies.
  Pinecone Vector Store (retrieval) — retrieves matching content.
  Embeddings OpenAI1 — helps match queries to document chunks.

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

workflow_json:
  {"id":"xOFhKr29kjrBDnlw","meta":{"instanceId":"2000c64071c20843606b95c63795bb0797c41036047055a6586498e855b96efc","templateCredsSetupCompleted":true},"name":"Instant RaG Builder","tags":[],"nodes":[{"id":"71812204-ccca-4757-a52f-0cd30c7ef393","name":"Google Drive Trigger","type":"n8n-nodes-base.googleDriveTrigger","position":[-440,-80],"parameters":{"event":"fileCreated","options":{},"pollTimes":{"item":[{"mode":"everyMinute"}]},"triggerOn":"specificFolder","folderToWatch":{"__rl":true,"mode":"list","value":"1uf6zZN51rgAuQgid4-Oi314f6mJIQdiB","cachedResultUrl":"https://drive.google.com/drive/folders/1uf6zZN51rgAuQgid4-Oi314f6mJIQdiB","cachedResultName":"ETOO power"}},"credentials":{"googleDriveOAuth2Api":{"id":"IPz4dCJVFC8uaoHw","name":"Google Drive account 2"}},"typeVersion":1},{"id":"e4302b23-c964-421e-a8fd-3e84935a1fea","name":"Google Drive","type":"n8n-nodes-base.googleDrive","position":[-220,-80],"parameters":{"fileId":{"__rl":true,"mode":"id","value":"={{ $json.id }}"},"options":{},"operation":"download"},"credentials":{"googleDriveOAuth2Api":{"id":"IPz4dCJVFC8uaoHw","name":"Google Drive account 2"}},"typeVersion":3},{"id":"9990d9d8-3c56-49af-beb9-d9a335ed7874","name":"Pinecone Vector Store","type":"@n8n/n8n-nodes-langchain.vectorStorePinecone","position":[40,-80],"parameters":{"mode":"insert","options":{},"pineconeIndex":{"__rl":true,"mode":"list","value":"ragfile","cachedResultName":"ragfile"}},"credentials":{"pineconeApi":{"id":"Q5ey0Vpj2rWRrb7p","name":"PineconeApi account 2"}},"typeVersion":1.1},{"id":"ee09de71-4146-4f51-a036-5eeb0d72044a","name":"Embeddings OpenAI","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[-40,140],"parameters":{"options":{}},"credentials":{"openAiApi":{"id":"AAQM78g30SkuHYxB","name":"OpenAi success"}},"typeVersion":1.2},{"id":"b1edcf2c-4b19-43dc-9985-dad03a0e6df2","name":"Default Data Loader","type":"@n8n/n8n-nodes-langchain.documentDefaultDataLoader","position":[180,140],"parameters":{"options":{},"dataType":"binary"},"typeVersion":1},{"id":"1db4c053-9953-4a63-91cc-676fc59d434d","name":"Recursive Character Text Splitter","type":"@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter","position":[200,260],"parameters":{"options":{}},"typeVersion":1},{"id":"80e69d74-18ca-4d47-8900-9fa070fd2b22","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[-440,440],"parameters":{"options":{}},"typeVersion":2},{"id":"9679f79a-cbee-4d6e-9633-76c96e5c7ffc","name":"When chat message received","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[-720,440],"webhookId":"fa37c7db-d78c-4a86-9de3-7cb6805de74f","parameters":{"options":{}},"typeVersion":1.1},{"id":"3ea509ac-f5dd-410f-b310-587382770773","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-440,620],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"AAQM78g30SkuHYxB","name":"OpenAi success"}},"typeVersion":1.2},{"id":"6bbee514-a4c6-4ea9-97fb-02d0343c93a9","name":"Pinecone Vector Store1","type":"@n8n/n8n-nodes-langchain.vectorStorePinecone","position":[-140,600],"parameters":{"mode":"retrieve-as-tool","options":{},"toolName":"knowledge_base","pineconeIndex":{"__rl":true,"mode":"list","value":"ragfile","cachedResultName":"ragfile"},"toolDescription":"call this tool to access the database"},"credentials":{"pineconeApi":{"id":"Q5ey0Vpj2rWRrb7p","name":"PineconeApi account 2"}},"typeVersion":1.2},{"id":"37fd9772-35c6-4310-b449-f1b07b729f6d","name":"Embeddings OpenAI1","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[60,760],"parameters":{"options":{}},"credentials":{"openAiApi":{"id":"AAQM78g30SkuHYxB","name":"OpenAi success"}},"typeVersion":1.2},{"id":"51c6804d-6b49-4a5f-a475-26abef7925b0","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-1220,80],"parameters":{"width":460,"height":620,"content":"## Instant RaG Builder: Drive to Pinecone\n\n**Author** **David Olusola**\n\n**Set Up** :✅ Connect credentials:\n    Google Drive, OpenAI, Pinecone\n\n📁 Upload file to:\n    Google Drive folder (auto-watched)\n\n🔄 Workflow does the rest:\n    - Downloads file\n    - Splits text\n    - Creates embeddings\n    - Stores in Pinecone\n\n💬 Send a chat message to the Agent\n    → Query stored knowledge instantly!"},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"f8ed5291-ab8f-428a-9728-8db5b3c04122","connections":{"Google Drive":{"main":[[{"node":"Pinecone Vector Store","type":"main","index":0}]]},"Embeddings OpenAI":{"ai_embedding":[[{"node":"Pinecone Vector Store","type":"ai_embedding","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Embeddings OpenAI1":{"ai_embedding":[[{"node":"Pinecone Vector Store1","type":"ai_embedding","index":0}]]},"Default Data Loader":{"ai_document":[[{"node":"Pinecone Vector Store","type":"ai_document","index":0}]]},"Google Drive Trigger":{"main":[[{"node":"Google Drive","type":"main","index":0}]]},"Pinecone Vector Store1":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"When chat message received":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Recursive Character Text Splitter":{"ai_textSplitter":[[{"node":"Default Data Loader","type":"ai_textSplitter","index":0}]]}}}


name: Generate Youtube Video Metadata (Timestamps, Tags, Description, ...)
author_name: Nasser
author_username: nasser
categories: []
created_at: 2025-05-30T08:59:44.727Z
updated_at: 2025-05-30T08:59:44.727Z
url: https://n8n.io/workflows/4506
scraped_at: 2025-07-06 21:16:30
description:
  For Who?

  Content Creators
  Youtube Automation
  Marketing Team

  How it works?

  1 - Enter the ID of the YTB channel to trigger the workflow when a new video is posted
  2 - Apify scrape the last YTB video of the channel
  3 - Wait until the dataset is completed in Apify and get it
  4 - Verify if Metadata are not already generated and generate them with LLM
  5 - Format all the data created and update YTB Video

  📺 YouTube Video Tutorial: 

  SETUP

  Setup Input YTB Chanel : Go to the channel's page on YouTube, and look at the URL of the page. The channel ID is the value that comes after channel/ in the URL. Add it after "?channel_id=" You can also use free tools available to retrieve channel ID.

  Setup Output YTB Video Update : Connect your YTB account to your n8n instance thanks to the Google Cloud Console. You can find tutorials by typing "youtube api Oauth" on Google.

  APIs : For the following third-party integrations, replace ==[YOUR_API_TOKEN]== with your API Token or connect your account via Client ID / Secret to your n8n instance : 
  Apify : https://docs.apify.com/api/v2/getting-started
  Youtube : https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.youtube/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.youTube#templates-and-examples

  👨‍💻 More Workflows : https://n8n.io/creators/nasser/

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

workflow_json:
  {"id":"","meta":{"instanceId":"","templateCredsSetupCompleted":true},"name":"YTB Metadata Generator","tags":[],"nodes":[{"id":"","name":"Mistral Cloud Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatMistralCloud","position":[700,-40],"parameters":{"model":"mistral-large-latest","options":{}},"credentials":{"mistralCloudApi":{"id":"","name":"Mistral Cloud account"}},"typeVersion":1},{"id":"","name":"No Operation, do nothing","type":"n8n-nodes-base.noOp","position":[-440,120],"parameters":{},"typeVersion":1},{"id":"","name":"Structured Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[860,-40],"parameters":{"jsonSchemaExample":"[\n  {\n    \"name\": \"preview\",\n    \"type\": \"string\",\n    \"description\": \"Short preview (100–200 characters, no hashtags)\"\n  },\n  {\n    \"name\": \"timestamps\",\n    \"type\": \"string\",\n    \"description\": \"YouTube-style timestamps, each on a new line, starts with 00:00\"\n  },\n  {\n    \"name\": \"tags\",\n    \"type\": \"string\",\n    \"description\": \"Comma-separated keywords (no hashtags)\"\n  }\n]\n"},"typeVersion":1.2},{"id":"","name":"No Operation, do nothing1","type":"n8n-nodes-base.noOp","position":[700,100],"parameters":{},"typeVersion":1},{"id":"","name":"Check IF Finished","type":"n8n-nodes-base.httpRequest","position":[-160,-80],"parameters":{"url":"https://api.apify.com/v2/acts/streamers~youtube-scraper/runs/last?token=[YOUR_API_TOKEN]","options":{}},"typeVersion":4.2},{"id":"","name":"Get DataSet","type":"n8n-nodes-base.httpRequest","position":[240,-100],"parameters":{"url":"https://api.apify.com/v2/acts/streamers~youtube-scraper/runs/last/dataset/items?token=[YOUR_API_TOKEN]","options":{}},"typeVersion":4.2},{"id":"","name":"Scrape Video","type":"n8n-nodes-base.httpRequest","position":[-440,-80],"parameters":{"url":"https://api.apify.com/v2/acts/streamers~youtube-scraper/runs?token=[YOUR_API_TOKEN]","method":"POST","options":{},"jsonBody":"={\n    \"downloadSubtitles\": true,\n    \"preferAutoGeneratedSubtitles\": false,\n    \"startUrls\": [\n        {\n            \"url\": \"{{ $('Trigger New Video Posted').item.json.link }}\",\n            \"method\": \"GET\"\n        }\n    ],\n    \"subtitlesLanguage\": \"en\"\n}","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"Content-Type","value":"application/json"}]}},"typeVersion":4.2},{"id":"","name":"If Finished","type":"n8n-nodes-base.if","position":[20,-80],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.data.status }}","rightValue":"SUCCEEDED"}]}},"typeVersion":2.2},{"id":"","name":"Wait","type":"n8n-nodes-base.wait","position":[180,120],"webhookId":"","parameters":{},"typeVersion":1.1},{"id":"","name":"If Recent","type":"n8n-nodes-base.if","position":[-660,20],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"","operator":{"type":"number","operation":"gt"},"leftValue":"={{ new Date($json[\"pubDate\"]).getTime() }}","rightValue":"={{ new Date().getTime() - 10 * 60 * 1000 }}"}]}},"typeVersion":2.2},{"id":"","name":"If Not Generated","type":"n8n-nodes-base.if","position":[460,-100],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"","operator":{"type":"string","operation":"notContains"},"leftValue":"={{ $json.text }}","rightValue":"00:00"}]}},"typeVersion":2.2},{"id":"","name":"Generate Description","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[700,-200],"parameters":{"text":"You are given the full script of a YouTube video. Your task is to extract metadata in a structured format to be used in a YouTube upload.","messages":{"messageValues":[{"type":"HumanMessagePromptTemplate","message":"=Script Input:\n{{ $json.subtitles[0].srt }}\n\nFinal Output Format:\n\nPreview:\n[short preview description]\n\nTimestamps:\n00:00 [Title]\n00:30 [Title]\n...\n\nTags:\ntag1,tag2,tag3,...\n\nFollow these instructions strictly:\n\n1. Short Preview Description\nWrite a short preview (100–200 characters max) of the video.\nUse engaging language, and include relevant keywords from the topic of the video.\nThis should be a single sentence or two, no hashtags, no line breaks.\n\n2. Timestamps\nFormat: MM:SS Timestamp Title (each on a new line)\nMust start with 00:00\nEach timestamp section must be at least 30 seconds apart\nOnly 3 to 7 total timestamps\nEach timestamp title should be maximum 3 words, summarize the section clearly\nExample format:\n\"00:00 Intro  \n00:47 Key Concept  \n02:12 Real Example\"\n\n3. Tags\nProvide 5 to 10 relevant SEO-friendly keywords separated by commas\nNo hashtags\nFormat like this:\n\"automation,n8n,ai workflows,youtube growth,openai\"\n"}]},"promptType":"define","hasOutputParser":true},"typeVersion":1.5},{"id":"","name":"Format ","type":"n8n-nodes-base.code","position":[1100,-200],"parameters":{"jsCode":"// Assuming input data contains preview, timestamps, tags\nconst preview = $input.first().json.output[0].description;\nconst timestamps = $input.first().json.output[1].description;\n\n// Hardcoded links section (edit as needed)\nconst links = `\nLinks:\n- Website: https://example.com\n- Twitter: https://twitter.com/example\n- GitHub: https://github.com/example\n`;\n\n// Format description string\nconst description = preview + \"\\n\" +links + \"\\n\" +timestamps \n\n// Return the formatted description\nreturn [\n  {\n    json: {\n      description: description.trim(),\n    },\n  },\n];\n"},"typeVersion":2},{"id":"","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-940,-100],"parameters":{"color":7,"width":420,"height":340,"content":"## 1- Input\nEnter the ID of the YTB channel to trigger the workflow when a new video is posted"},"typeVersion":1},{"id":"","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-500,-180],"parameters":{"color":7,"height":480,"content":"## 2- Create DataSet\nApify scrape the last YTB video of the channel"},"typeVersion":1},{"id":"","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[420,-280],"parameters":{"color":7,"width":600,"height":580,"content":"## 4- Check and Generate Metadata\nVerify if Metadata are not already generated and generate them with LLM\n"},"typeVersion":1},{"id":"","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[1040,-280],"parameters":{"color":7,"width":460,"height":240,"content":"## 5- Output\nFormat all the data created and update YTB Video"},"typeVersion":1},{"id":"","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-240,-180],"parameters":{"color":7,"width":640,"height":500,"content":"## 3- Wait for Completion & Get DataSet\nWait until the dataset is completed in Apify and get it"},"typeVersion":1},{"id":"","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-940,-800],"parameters":{"color":7,"width":780,"height":240,"content":"## How it works?\n**1 -** Enter the ID of the YTB channel to trigger the workflow when a new video is posted\n**2 -** Apify scrape the last YTB video of the channel\n**3 -** Wait until the dataset is completed in Apify and get it\n**4 -** Verify if Metadata are not already generated and generate them with LLM\n**5 -** Format all the data created and update YTB Video\n\n**📺 Youtube Video Tutorial : https://youtu.be/HaQPAa6l5bU**\n**🛠️ Need Help with Your Workflows ? https://tally.so/r/wayeqB**\n**👨‍💻 More Workflows : https://n8n.io/creators/nasser/**"},"typeVersion":1},{"id":"","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[-940,-540],"parameters":{"color":7,"width":780,"height":340,"content":"## SETUP\n\n**Setup Input YTB Chanel :** Go to the channel's page on YouTube, and look at the URL of the page. The channel ID is the value that comes after channel/ in the URL. Add it after \"?channel_id=\" You can also use free tools available to retrieve channel ID.\n\n**Setup Output YTB Video Update :** Connect your YTB account to your n8n instance thanks to the Google Cloud Console. You can find tutorials by typing \"youtube api Oauth\" on Google.\n\n**APIs :** For the following third-party integrations, replace [YOUR_API_TOKEN] with your API Token or connect your account via Client ID / Secret to your n8n instance : \n- Apify : https://docs.apify.com/api/v2/getting-started\n- Youtube : https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.youtube/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.youTube#templates-and-examples"},"typeVersion":1},{"id":"","name":"Trigger New Video Posted","type":"n8n-nodes-base.rssFeedReadTrigger","position":[-880,20],"parameters":{"feedUrl":"https://www.youtube.com/feeds/videos.xml?channel_id=[YOUR_CHANNEL_ID]","pollTimes":{"item":[{"mode":"everyX","unit":"minutes","value":10}]}},"typeVersion":1},{"id":"","name":"Update YTB Video","type":"n8n-nodes-base.youTube","position":[1280,-200],"parameters":{"title":"={{ $('Get DataSet').item.json.title }}","videoId":"={{ $('Get DataSet').item.json.id }}","resource":"video","operation":"update","regionCode":"US","updateFields":{"tags":"={{ $('Generate Description').item.json.output[2].description }}","description":"={{ $json.description }}"}},"credentials":{"youTubeOAuth2Api":{"id":"","name":"YouTube account"}},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"","connections":{"Wait":{"main":[[{"node":"Check IF Finished","type":"main","index":0}]]},"Format ":{"main":[[{"node":"Update YTB Video","type":"main","index":0}]]},"If Recent":{"main":[[{"node":"Scrape Video","type":"main","index":0}],[{"node":"No Operation, do nothing","type":"main","index":0}]]},"Get DataSet":{"main":[[{"node":"If Not Generated","type":"main","index":0}]]},"If Finished":{"main":[[{"node":"Get DataSet","type":"main","index":0}],[{"node":"Wait","type":"main","index":0}]]},"Scrape Video":{"main":[[{"node":"Check IF Finished","type":"main","index":0}]]},"If Not Generated":{"main":[[{"node":"Generate Description","type":"main","index":0}],[{"node":"No Operation, do nothing1","type":"main","index":0}]]},"Check IF Finished":{"main":[[{"node":"If Finished","type":"main","index":0}]]},"Generate Description":{"main":[[{"node":"Format ","type":"main","index":0}]]},"Mistral Cloud Chat Model":{"ai_languageModel":[[{"node":"Generate Description","type":"ai_languageModel","index":0}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"Generate Description","type":"ai_outputParser","index":0}]]},"Trigger New Video Posted":{"main":[[{"node":"If Recent","type":"main","index":0}]]}}}


name: Multi-Platform AI Sales Agent with RAG, CRM, Calendar & Stripe
author_name: Vansh Arora
author_username: v4nsh
categories: []
created_at: 2025-05-30T09:29:25.335Z
updated_at: 2025-05-30T09:29:25.335Z
url: https://n8n.io/workflows/4508
scraped_at: 2025-07-06 21:16:30
description:
  Turn More Website and Social Media Leads into Sales, Automatically. 
  This AI workflow instantly connects with new leads from your website, WhatsApp, Instagram, and Facebook to boost your sales.

  Who is it for?
  This solution is designed for:
  Product and service-based businesses committed to maximizing lead conversion and sales.
  Sales Teams aiming to automate lead engagement, qualification, and accelerate sales generation.
  Companies seeking to provide immediate, personalized, and consistent responses to inquiries across multiple channels.
  Use Case: Turn Conversations into Conversions, 24/7
  Imagine a potential customer fills out a form on your website or interact with your website chatbot or directly messages your business on WhatsApp, Instagram, or Facebook. Instantly, our intelligent workflow springs into action:
  Personalized Welcome: If they filled out a form, they receive a personalized WhatsApp message referencing the key details they provided. If they messaged directly on social media or your website chat, they receive an immediate, welcoming response.
  Human-like Engagement: The AI sales agent initiates a natural, human-like conversation to understand their specific goals and needs.
  Intelligent Product Matching: Leveraging your product database, the agent intelligently suggests the most suitable products or services.
  Expert Consultation & Meeting Booking: For complex needs requiring expert advice, the agent seamlessly books a meeting in your calendar.
  Seamless CRM Integration: All interactions, customer details, and meeting information are automatically saved and updated in your CRM.
  Overcoming Hesitation (Optional): If a lead shows pricing concerns, the agent can be configured to offer pre-approved discounts or alternative solutions.
  Facilitating Transactions (Optional): The workflow can even send payment links to close deals directly within the conversation.
  This automated yet personalized approach ensures every lead is nurtured effectively, regardless of where the conversation starts.
  How This Workflow Works:
  This intelligent system streamlines your sales process through a series of automated yet highly personalized steps:
  Lead Capture: A prospect either fills out a form embedded on your website or initiates a conversation directly via your business's WhatsApp, Instagram, Facebook page, or the n8n Chat embedded on your website.
  Instant & Personalized Outreach:
  Form Submissions: An instant, personalized WhatsApp message is dispatched, incorporating details from their form submission.
  Direct Messages (WhatsApp, Instagram, Facebook, n8n Chat): The AI sales agent immediately greets the user and begins a human-like conversation.
  AI-Powered Engagement & Qualification: The AI agent engages the lead with relevant questions to understand their needs and qualify them based on predefined criteria. It accesses your product information (from a vector database) to provide accurate and relevant suggestions.
  Tailored Call to Action: Based on the conversation and qualification:
  Product/Service Recommendation: Offers the most suitable product or service with a clear call to action (e.g., view product, learn more).
  Consultation Booking: If expert advice is needed or requested, the agent can schedule a meeting directly into your calendar.
  CRM Update: All lead details, conversation history, and scheduled meetings are automatically logged in your CRM.
  Handling Objections & Closing (Optional):
  Payment Links: Can send direct payment links for purchases.
  Discount Offers: If a lead expresses hesitation about pricing, the agent can be programmed to offer a predefined discount to encourage conversion.
  Multi-Channel Communication: The entire interaction can seamlessly occur on WhatsApp, Instagram, Facebook, or your website's embedded n8n Chat, providing flexibility for your leads.
  How to Set It Up:
  Modular Agent Creation: Design distinct workflows for your CRM Agent (managing customer data), Calendar Agent (handling meeting bookings), and Billing Agent (managing payments and discounts).
  Connect AI Agent Tools: Integrate each workflow with its specific AI agent communication tool (e.g., call workflow tool).
  Multi-Platform App Configuration: Create an application on https://developers.facebook.com and set up WhatsApp, Instagram, and Facebook messaging capabilities, linking them to your app.
  Knowledge Base Creation: Develop a vector document (e.g., in PostgreSQL) containing comprehensive details about your products, services, sales techniques, FAQs, and other relevant information for the AI to draw upon.
  Credential Integration: Securely connect all necessary credentials for your CRM, calendar, payment gateways, and messaging platforms.
  AI Agent Personalization: Edit the system prompt of your AI agent, filling in your specific business details, brand voice, and operational guidelines to ensure responses are accurate, relevant, and on-brand.
  Website Form Integration (Recommended): Customize your lead capture form and embed it on your website to directly feed leads into the workflow.
  Embeddable Web Chat (Recommended): Integrate the n8n Chat widget onto your website, allowing visitors to directly communicate with your AI sales agent.

  DEMO DATABASE - https://airtable.com/appFUS6RjSdbJhtR0/shrIEUJf9egBqDl8q

nodes_used:
  ["n8n-nodes-base.httpRequest","n8n-nodes-base.postgres","n8n-nodes-base.facebookGraphApi","n8n-nodes-base.whatsApp","@n8n/n8n-nodes-langchain.agent","@n8n/n8n-nodes-langchain.memoryBufferWindow","@n8n/n8n-nodes-langchain.toolWorkflow","@n8n/n8n-nodes-langchain.openAi","@n8n/n8n-nodes-langchain.embeddingsGoogleGemini","@n8n/n8n-nodes-langchain.lmChatGoogleGemini","@n8n/n8n-nodes-langchain.memoryPostgresChat","@n8n/n8n-nodes-langchain.toolVectorStore","@n8n/n8n-nodes-langchain.vectorStorePGVector"]

workflow_json:
  {"meta":{"instanceId":"28099d2544433ae0f39c65315a4d4c531947fcb0f060a94d6047d7be5df31063","templateCredsSetupCompleted":true},"nodes":[{"id":"58641566-634e-4618-971c-18f2f3710186","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[-1340,2560],"parameters":{},"typeVersion":1.7},{"id":"1873beed-8d42-497a-a1fa-8423c8378e45","name":"No Operation, do nothing","type":"n8n-nodes-base.noOp","position":[-1760,2540],"parameters":{},"typeVersion":1},{"id":"13a17f82-4d0b-410a-9fa8-2d23c3c47ee2","name":"Calendar Agent","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[-1300,2780],"parameters":{},"typeVersion":2},{"id":"60a12daa-0df9-4459-921f-5d7b70ba17e2","name":"CRM Agent","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[-1180,2780],"parameters":{},"typeVersion":2},{"id":"d5745cc5-de7d-4178-a2ba-0297e70a7301","name":"Postgres Chat Memory","type":"@n8n/n8n-nodes-langchain.memoryPostgresChat","position":[-1420,2780],"parameters":{},"typeVersion":1.3},{"id":"d27aba8b-432c-4270-b10b-ee58a76466cc","name":"Handle Message Types","type":"n8n-nodes-base.switch","position":[-2860,2540],"parameters":{},"typeVersion":3.2},{"id":"a50148d4-91bb-44e1-9fe3-ec008aa68b34","name":"Reply To User1","type":"n8n-nodes-base.whatsApp","position":[-2640,2740],"webhookId":"0e86d9ab-6130-44f5-a7f1-4930bfcad48b","parameters":{},"typeVersion":1},{"id":"e379eb19-a275-41e6-b157-fc4f2320c9fc","name":"Edit Fields - chat1","type":"n8n-nodes-base.set","position":[-1980,2340],"parameters":{},"typeVersion":3.4},{"id":"e9cd46c1-9265-4545-938e-9f8be97af0c4","name":"Reply To  User","type":"n8n-nodes-base.whatsApp","position":[-340,2440],"webhookId":"3b2ca5bf-7b1d-4012-b68e-ef06653a3c18","parameters":{},"typeVersion":1},{"id":"cd8701e9-22ad-44db-b0ff-8067b1fd5226","name":"WhatsApp","type":"n8n-nodes-base.whatsAppTrigger","position":[-3300,2540],"webhookId":"aaf6d81e-dbdd-47e2-a2d4-c496ff92933b","parameters":{},"typeVersion":1},{"id":"be1a15ac-020d-4f2c-ab2c-016c44263943","name":"WhatsApp Business Cloud","type":"n8n-nodes-base.whatsApp","position":[-2640,2540],"webhookId":"5cbf4730-3963-45f9-8457-6f41e648d4fe","parameters":{},"typeVersion":1},{"id":"c7fd035e-49f3-4a36-b042-3da9782d7044","name":"HTTP Request","type":"n8n-nodes-base.httpRequest","position":[-2420,2540],"parameters":{},"typeVersion":4.2},{"id":"ea0e0a79-4c67-4160-a84a-265420ef612f","name":"OpenAI","type":"@n8n/n8n-nodes-langchain.openAi","position":[-2200,2540],"parameters":{},"typeVersion":1.8},{"id":"bc53e0c7-ca12-4383-bef1-7cc3d5a26c0d","name":"Edit Fields - chat2","type":"n8n-nodes-base.set","position":[-1980,2540],"parameters":{},"typeVersion":3.4},{"id":"3c682d04-7d3f-4b39-9891-dcc904b7f1dc","name":"Output - chat","type":"n8n-nodes-base.set","position":[-340,3020],"parameters":{},"typeVersion":3.4},{"id":"0dfac069-95ce-4886-95d7-572323cbe3b0","name":"Postgres PGVector Store","type":"@n8n/n8n-nodes-langchain.vectorStorePGVector","position":[-1240,3160],"parameters":{},"typeVersion":1.1},{"id":"9228bbe6-8451-4882-bb60-aea6718e0b8d","name":"Get Lead","type":"n8n-nodes-base.postgres","position":[-3080,2540],"parameters":{},"typeVersion":2.6},{"id":"8499737b-71c5-403f-b603-5abcc909f066","name":"When chat message received","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[-2220,3560],"webhookId":"0e63503d-ab21-4a3d-8d29-19c5d94c24d4","parameters":{},"typeVersion":1.1},{"id":"8898ee54-6d90-4bab-baa0-8868862c19bb","name":"Google Gemini Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[-1540,2780],"parameters":{},"typeVersion":1},{"id":"96ca0d02-ce10-4d8f-8713-d667257020df","name":"Google Gemini Chat Model1","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[-1440,3100],"parameters":{},"typeVersion":1},{"id":"ed512f2e-e731-49bf-b40e-1ca3a0c7e3d3","name":"Embeddings Google Gemini1","type":"@n8n/n8n-nodes-langchain.embeddingsGoogleGemini","position":[-1220,3300],"parameters":{},"typeVersion":1},{"id":"59d6fe5e-0737-4937-a511-b6736faf94a6","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-3420,2300],"parameters":{"content":""},"typeVersion":1},{"id":"15ad6a6f-6656-4bc0-86b0-093c3d262af1","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[-4380,3540],"parameters":{},"typeVersion":1.3},{"id":"40433c21-a918-4edc-94ec-77d79e24e2bc","name":"Create Charge","type":"n8n-nodes-base.stripeTool","position":[-4260,3540],"parameters":{},"typeVersion":1},{"id":"0eb2c1b7-d7df-4b7d-9582-fefbbdb70f28","name":"Create Discount Coupon","type":"n8n-nodes-base.stripeTool","position":[-4140,3540],"parameters":{},"typeVersion":1},{"id":"2dd8cb76-1435-4a4a-9873-e482b67e4814","name":"Get Customer Card","type":"n8n-nodes-base.stripeTool","position":[-4020,3540],"parameters":{},"typeVersion":1},{"id":"a80893fb-3fc2-4115-b42a-e2746e48cd96","name":"Get Customer","type":"n8n-nodes-base.stripeTool","position":[-3900,3540],"parameters":{},"typeVersion":1},{"id":"8fba2cfc-1999-4ce4-9141-52b2a17f2b49","name":"Create Customer","type":"n8n-nodes-base.stripeTool","position":[-3780,3540],"parameters":{},"typeVersion":1},{"id":"a9f53b19-ed50-478b-b56b-ed4d226fd0e2","name":"Update Customer","type":"n8n-nodes-base.stripeTool","position":[-3660,3540],"parameters":{},"typeVersion":1},{"id":"c3622cc6-260f-4add-8dc3-d791d5f652e9","name":"Delete Customer","type":"n8n-nodes-base.stripeTool","position":[-3540,3540],"parameters":{},"typeVersion":1},{"id":"f15d4a72-7a00-495e-bee5-f53131b12f93","name":"Google Gemini Chat Model4","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[-4500,3540],"parameters":{},"typeVersion":1},{"id":"2ded9423-c4a9-4652-a31b-0e6120dcb2b0","name":"Response1","type":"n8n-nodes-base.set","position":[-3660,3140],"parameters":{},"typeVersion":3.4},{"id":"d34db7c1-a2a3-48ce-888f-46486a921abe","name":"Try Again2","type":"n8n-nodes-base.set","position":[-3640,3340],"parameters":{},"typeVersion":3.4},{"id":"0215f430-64ca-41dd-8940-76cd7d2bd271","name":"Billing Agent","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[-1060,2780],"parameters":{},"typeVersion":2.1},{"id":"7da4747e-d01e-4b96-97f1-15df1b2d1685","name":"Billing Agent1","type":"@n8n/n8n-nodes-langchain.agent","position":[-4100,3320],"parameters":{},"typeVersion":1.9},{"id":"47b76f97-6326-4361-9a2b-fd5e3c2e47aa","name":"technical_and_sales_knowledge","type":"@n8n/n8n-nodes-langchain.toolVectorStore","position":[-1540,2940],"parameters":{},"typeVersion":1,"alwaysOutputData":true},{"id":"08a31dfb-8f53-4e27-89a0-417fe59ed17e","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-4560,3120],"parameters":{"content":""},"typeVersion":1},{"id":"cb7da763-6728-41c7-ac66-21980c06b761","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-4560,1860],"parameters":{"content":""},"typeVersion":1},{"id":"79b14ad4-f810-4cb6-b46b-46a91baaa965","name":"Facebook Trigger","type":"n8n-nodes-base.webhook","position":[-3100,3080],"webhookId":"b7e461f0-9a0d-4e27-9e86-f74a3e684e3a","parameters":{},"typeVersion":2},{"id":"85539ceb-9fe7-4ad3-855a-609e7610443b","name":"Edit Fields - facebook","type":"n8n-nodes-base.set","position":[-2440,3080],"parameters":{},"typeVersion":3.4},{"id":"f9ce8bcd-f09d-4fd0-888b-ebccff222fd2","name":"Respond to Webhook - facebook post","type":"n8n-nodes-base.respondToWebhook","position":[-2880,2980],"parameters":{},"typeVersion":1.1},{"id":"01374a59-8f58-4b00-859c-7411f9da5834","name":"Respond to Webhook - facebook get","type":"n8n-nodes-base.respondToWebhook","position":[-2880,3180],"parameters":{},"typeVersion":1.1},{"id":"13d88b7f-4785-4b99-aaf3-acf549ef1c96","name":"Instagram Trigger","type":"n8n-nodes-base.webhook","position":[-2780,3440],"webhookId":"cc6546da-6f16-4546-ada3-e2c83b208997","parameters":{},"typeVersion":2},{"id":"7f37a4b7-8aed-4983-bc0a-5fe62b33c72d","name":"Respond to Webhook - instagram get","type":"n8n-nodes-base.respondToWebhook","position":[-2560,3540],"parameters":{},"typeVersion":1.1},{"id":"0f69802c-875d-4628-9889-47a8bf1194f2","name":"Respond to Webhook - instagram post","type":"n8n-nodes-base.respondToWebhook","position":[-2560,3340],"parameters":{},"typeVersion":1.1},{"id":"d607f6d6-3194-496c-bbb0-d28bd44d8b51","name":"Edit Fields - instagram","type":"n8n-nodes-base.set","position":[-2120,3340],"parameters":{},"typeVersion":3.4},{"id":"fcd3d650-85e3-4e8d-959b-9e655c50de4d","name":"If is not echo - facebook","type":"n8n-nodes-base.if","position":[-2660,2980],"parameters":{},"typeVersion":2.2},{"id":"40a5199a-11aa-4302-9f90-5bc4a89438e6","name":"If is not echo - instagram","type":"n8n-nodes-base.if","position":[-2340,3340],"parameters":{},"typeVersion":2.2},{"id":"b82f327f-0e26-497d-af2c-feb333ca88b6","name":"Sales Agent Demo - typing_on","type":"n8n-nodes-base.facebookGraphApi","position":[-2440,2880],"parameters":{},"typeVersion":1},{"id":"43e05526-4201-488b-8435-6bd9368ffde0","name":"Edit Fields - chat","type":"n8n-nodes-base.set","position":[-2020,3560],"parameters":{},"typeVersion":3.4},{"id":"27fc17eb-41e8-4d60-a4a0-34407d9e4356","name":"Facebook Graph API - Sales Agent Demo","type":"n8n-nodes-base.facebookGraphApi","position":[-340,2620],"parameters":{},"typeVersion":1},{"id":"981988f2-3bf7-4c7b-885f-0e30967f57e3","name":"Instagram Graph API - smb.sales.agent.demo","type":"n8n-nodes-base.httpRequest","position":[-340,2800],"parameters":{},"typeVersion":4.2},{"id":"4f334ed1-5f35-4b83-a2fc-83fe94bd0480","name":"Switch1","type":"n8n-nodes-base.switch","position":[-780,2700],"parameters":{},"typeVersion":3.2},{"id":"0432619e-4c59-43ed-880d-020bbdb6b485","name":"Send First Message","type":"n8n-nodes-base.whatsApp","position":[-1340,2020],"webhookId":"89b0633a-88c4-4fe8-82f4-4e3ae20a075a","parameters":{},"typeVersion":1},{"id":"90a43e82-6a80-40a5-976b-bc77050b9705","name":"Personalised First Message","type":"@n8n/n8n-nodes-langchain.agent","position":[-1680,1920],"parameters":{},"typeVersion":1.8},{"id":"4fbf5472-24b2-4d89-86dd-a6f2acc4d26b","name":"Gemini","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[-1640,2140],"parameters":{},"typeVersion":1},{"id":"e6e0ad95-d46d-4c67-99e6-821d34899459","name":"Contact Form","type":"n8n-nodes-base.formTrigger","position":[-2100,2020],"webhookId":"a34f7372-b42d-4176-ac9b-2518d85c125d","parameters":{},"typeVersion":2.2},{"id":"541c12e5-342c-4e32-b51a-958ce49ea605","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-2160,1860],"parameters":{"content":""},"typeVersion":1},{"id":"75ffc72b-3390-413e-a594-898f747e6eb7","name":"Response","type":"n8n-nodes-base.set","position":[-2400,1880],"parameters":{},"typeVersion":3.4},{"id":"cb413086-2eae-46f6-9378-34f846a41b3b","name":"Try Again","type":"n8n-nodes-base.set","position":[-2560,1980],"parameters":{},"typeVersion":3.4},{"id":"cdcc9bd3-a79b-4486-98bb-99ff34f8803c","name":"When Executed by Another Workflow","type":"n8n-nodes-base.executeWorkflowTrigger","position":[-3320,1920],"parameters":{},"typeVersion":1.1},{"id":"913f677a-4d63-44d1-8ce2-3f032fbbdee1","name":"Window Buffer Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[-3200,2140],"parameters":{},"typeVersion":1.3},{"id":"b8f62932-e65f-413e-bcf9-951958f52f20","name":"Success","type":"n8n-nodes-base.set","position":[-420,1920],"parameters":{},"typeVersion":3.4},{"id":"1be27ba7-c5f2-4ef0-9d44-e93055459897","name":"Create Event with Attendee","type":"n8n-nodes-base.googleCalendarTool","position":[-900,2140],"parameters":{},"typeVersion":1.3},{"id":"60f9b8d9-c34b-426f-a9e2-1f67155ab23b","name":"Create Event","type":"n8n-nodes-base.googleCalendarTool","position":[-780,2140],"parameters":{},"typeVersion":1.3},{"id":"a82f6be5-b5a8-43a9-8453-5c38d6ef1d51","name":"Get Events","type":"n8n-nodes-base.googleCalendarTool","position":[-660,2140],"parameters":{},"typeVersion":1.3},{"id":"23016d49-01d5-423e-9737-59420e6e7086","name":"Delete Event","type":"n8n-nodes-base.googleCalendarTool","position":[-540,2140],"parameters":{},"typeVersion":1.3},{"id":"62150a9c-eba7-47b5-81fc-0b449129d70f","name":"Update Event","type":"n8n-nodes-base.googleCalendarTool","position":[-420,2140],"parameters":{},"typeVersion":1.3},{"id":"89e46cfc-63bf-4f9a-9569-2b2f6cdd151d","name":"Try Again1","type":"n8n-nodes-base.set","position":[-300,2080],"parameters":{},"typeVersion":3.4},{"id":"99d178bd-89da-410a-92dd-d918412193d6","name":"Calendar Agent1","type":"@n8n/n8n-nodes-langchain.agent","onError":"continueErrorOutput","position":[-880,1920],"parameters":{},"typeVersion":1.6},{"id":"796d0dce-af71-450e-8d8e-5c57a1394f75","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-1100,1860],"parameters":{"content":""},"typeVersion":1},{"id":"37e75ce6-89bc-4606-acc2-bf6885cda264","name":"Google Gemini Chat Model2","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[-3320,2140],"parameters":{},"typeVersion":1},{"id":"76472fe3-39b5-48d5-b810-292db6ad9b0c","name":"Create Opportunity","type":"n8n-nodes-base.postgresTool","position":[-3080,2140],"parameters":{},"typeVersion":2.6},{"id":"328576a9-e5c9-4139-a09a-8c5f4e269e56","name":"List Records","type":"n8n-nodes-base.postgresTool","position":[-2960,2140],"parameters":{},"typeVersion":2.6},{"id":"885bf1c2-b626-45e0-ba2c-664fead335bc","name":"Update Contact","type":"n8n-nodes-base.postgresTool","position":[-2840,2140],"parameters":{},"typeVersion":2.6},{"id":"e4b6d14f-4683-4d87-b2c2-788e546bec2d","name":"Delete Contact","type":"n8n-nodes-base.postgresTool","position":[-2600,2140],"parameters":{},"typeVersion":2.6},{"id":"cbd27b5f-0338-4b4b-99a8-7952e16333fa","name":"Delete Opportunity","type":"n8n-nodes-base.postgresTool","position":[-2480,2140],"parameters":{},"typeVersion":2.6},{"id":"5c02a07b-c055-4af7-a18f-654fc9020ed4","name":"Update Opportunity","type":"n8n-nodes-base.postgresTool","position":[-2360,2140],"parameters":{},"typeVersion":2.6},{"id":"be1d5ad5-0a6d-4583-b44d-840877c43021","name":"Google Gemini Chat Model3","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[-1020,2140],"parameters":{},"typeVersion":1},{"id":"76b932ac-aa1e-4bde-bc00-af493985431b","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-3420,1860],"parameters":{"content":""},"typeVersion":1},{"id":"14111c3e-b71b-409b-835e-5af861b3ed7f","name":"Create Contact","type":"n8n-nodes-base.postgresTool","position":[-2720,2140],"parameters":{},"typeVersion":2.6},{"id":"84a834dc-a8e6-408d-8a5a-03ab5000f932","name":"CRM Agent2","type":"@n8n/n8n-nodes-langchain.agent","onError":"continueErrorOutput","position":[-3060,1920],"parameters":{},"typeVersion":1.7},{"id":"a3a711aa-c7ca-449d-b9c2-ce12f2e1e504","name":"Create Contact1","type":"n8n-nodes-base.postgres","position":[-1900,2020],"parameters":{},"typeVersion":2.6}],"pinData":{"When Executed by Another Workflow":[{"query":"Create or update contact for Ben with email Ben@Ben.com and record interest in Ceramic Coating for appearance enhancement."}]},"connections":{"Gemini":{"ai_languageModel":[[{"node":"Personalised First Message","type":"ai_languageModel","index":0}]]},"OpenAI":{"main":[[{"node":"Edit Fields - chat2","type":"main","index":0}]]},"Switch1":{"main":[[{"node":"Reply To  User","type":"main","index":0}],[{"node":"Facebook Graph API - Sales Agent Demo","type":"main","index":0}],[{"node":"Instagram Graph API - smb.sales.agent.demo","type":"main","index":0}],[{"node":"Output - chat","type":"main","index":0}]]},"AI Agent":{"main":[[{"node":"Switch1","type":"main","index":0}]]},"Get Lead":{"main":[[{"node":"Handle Message Types","type":"main","index":0}]]},"WhatsApp":{"main":[[{"node":"Get Lead","type":"main","index":0}]]},"CRM Agent":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"CRM Agent2":{"main":[[{"node":"Response","type":"main","index":0}],[{"node":"Try Again","type":"main","index":0}]]},"Get Events":{"ai_tool":[[{"node":"Calendar Agent1","type":"ai_tool","index":0}]]},"Contact Form":{"main":[[{"node":"Create Contact1","type":"main","index":0}]]},"Create Event":{"ai_tool":[[{"node":"Calendar Agent1","type":"ai_tool","index":0}]]},"Delete Event":{"ai_tool":[[{"node":"Calendar Agent1","type":"ai_tool","index":0}]]},"Get Customer":{"ai_tool":[[{"node":"Billing Agent1","type":"ai_tool","index":0}]]},"HTTP Request":{"main":[[{"node":"OpenAI","type":"main","index":0}]]},"List Records":{"ai_tool":[[{"node":"CRM Agent2","type":"ai_tool","index":0}]]},"Update Event":{"ai_tool":[[{"node":"Calendar Agent1","type":"ai_tool","index":0}]]},"Billing Agent":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Create Charge":{"ai_tool":[[{"node":"Billing Agent1","type":"ai_tool","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"Billing Agent1","type":"ai_memory","index":0}]]},"Billing Agent1":{"main":[[{"node":"Response1","type":"main","index":0},{"node":"Try Again2","type":"main","index":0}]]},"Calendar Agent":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Create Contact":{"ai_tool":[[{"node":"CRM Agent2","type":"ai_tool","index":0}]]},"Delete Contact":{"ai_tool":[[{"node":"CRM Agent2","type":"ai_tool","index":0}]]},"Update Contact":{"ai_tool":[[{"node":"CRM Agent2","type":"ai_tool","index":0}]]},"Calendar Agent1":{"main":[[{"node":"Success","type":"main","index":0}],[{"node":"Try Again1","type":"main","index":0}]]},"Create Contact1":{"main":[[{"node":"Personalised First Message","type":"main","index":0}]]},"Create Customer":{"ai_tool":[[{"node":"Billing Agent1","type":"ai_tool","index":0}]]},"Delete Customer":{"ai_tool":[[{"node":"Billing Agent1","type":"ai_tool","index":0}]]},"Update Customer":{"ai_tool":[[{"node":"Billing Agent1","type":"ai_tool","index":0}]]},"Facebook Trigger":{"main":[[{"node":"Respond to Webhook - facebook post","type":"main","index":0}],[{"node":"Respond to Webhook - facebook get","type":"main","index":0}]]},"Get Customer Card":{"ai_tool":[[{"node":"Billing Agent1","type":"ai_tool","index":0}]]},"Instagram Trigger":{"main":[[{"node":"Respond to Webhook - instagram post","type":"main","index":0}],[{"node":"Respond to Webhook - instagram get","type":"main","index":0}]]},"Create Opportunity":{"ai_tool":[[{"node":"CRM Agent2","type":"ai_tool","index":0}]]},"Delete Opportunity":{"ai_tool":[[{"node":"CRM Agent2","type":"ai_tool","index":0}]]},"Edit Fields - chat":{"main":[[{"node":"No Operation, do nothing","type":"main","index":0}]]},"Update Opportunity":{"ai_tool":[[{"node":"CRM Agent2","type":"ai_tool","index":0}]]},"Edit Fields - chat1":{"main":[[{"node":"No Operation, do nothing","type":"main","index":0}]]},"Edit Fields - chat2":{"main":[[{"node":"No Operation, do nothing","type":"main","index":0}]]},"Handle Message Types":{"main":[[{"node":"Edit Fields - chat1","type":"main","index":0}],[{"node":"WhatsApp Business Cloud","type":"main","index":0}],[{"node":"Reply To User1","type":"main","index":0}]]},"Postgres Chat Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Window Buffer Memory":{"ai_memory":[[{"node":"CRM Agent2","type":"ai_memory","index":0}]]},"Create Discount Coupon":{"ai_tool":[[{"node":"Billing Agent1","type":"ai_tool","index":0}]]},"Edit Fields - facebook":{"main":[[{"node":"No Operation, do nothing","type":"main","index":0}]]},"Edit Fields - instagram":{"main":[[{"node":"No Operation, do nothing","type":"main","index":0}]]},"Postgres PGVector Store":{"ai_vectorStore":[[{"node":"technical_and_sales_knowledge","type":"ai_vectorStore","index":0}]]},"WhatsApp Business Cloud":{"main":[[{"node":"HTTP Request","type":"main","index":0}]]},"Google Gemini Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"No Operation, do nothing":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Embeddings Google Gemini1":{"ai_embedding":[[{"node":"Postgres PGVector Store","type":"ai_embedding","index":0}]]},"Google Gemini Chat Model1":{"ai_languageModel":[[{"node":"technical_and_sales_knowledge","type":"ai_languageModel","index":0}]]},"Google Gemini Chat Model2":{"ai_languageModel":[[{"node":"CRM Agent2","type":"ai_languageModel","index":0}]]},"Google Gemini Chat Model3":{"ai_languageModel":[[{"node":"Calendar Agent1","type":"ai_languageModel","index":0}]]},"Google Gemini Chat Model4":{"ai_languageModel":[[{"node":"Billing Agent1","type":"ai_languageModel","index":0}]]},"If is not echo - facebook":{"main":[[{"node":"Edit Fields - facebook","type":"main","index":0},{"node":"Sales Agent Demo - typing_on","type":"main","index":0}]]},"Create Event with Attendee":{"ai_tool":[[{"node":"Calendar Agent1","type":"ai_tool","index":0}]]},"If is not echo - instagram":{"main":[[{"node":"Edit Fields - instagram","type":"main","index":0}]]},"Personalised First Message":{"main":[[{"node":"Send First Message","type":"main","index":0}]]},"When chat message received":{"main":[[{"node":"Edit Fields - chat","type":"main","index":0}]]},"Sales Agent Demo - typing_on":{"main":[[{"node":"No Operation, do nothing","type":"main","index":0}]]},"technical_and_sales_knowledge":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"When Executed by Another Workflow":{"main":[[{"node":"CRM Agent2","type":"main","index":0}]]},"Respond to Webhook - facebook post":{"main":[[{"node":"If is not echo - facebook","type":"main","index":0}]]},"Respond to Webhook - instagram post":{"main":[[{"node":"If is not echo - instagram","type":"main","index":0}]]}}}


name: AI-Powered HR Interview System with BeyondPresence
author_name: M Shehroz Sajjad
author_username: mshehrozsajjad
nodes_used: ["n8n-nodes-base.googleSheets","n8n-nodes-base.code","@n8n/n8n-nodes-langchain.openAi"]
categories: []
created_at: 2025-05-30T13:55:23.666Z
updated_at: 2025-05-30T13:55:23.666Z
url: https://n8n.io/workflows/4514
scraped_at: 2025-07-06 21:16:30
description:
  What problem does it solve?

  Manual candidate screening is time-consuming and inconsistent. This workflow automates initial interviews, providing 24/7 availability, consistent questioning, and objective assessments for every candidate.

  Who is it for?

  HR teams handling high-volume recruiting
  Small businesses without dedicated recruiters
  Companies scaling their hiring process
  Remote-first organizations needing asynchronous screening

  What this workflow does

  Creates AI interviewers from job descriptions that conduct natural conversations with candidates via BeyondPresence Agents. Automatically analyzes interviews and saves structured assessments to Google Sheets.

  Setup
  Copy template sheet: BeyondPresence HR Interview System Template
  Add credentials:
     BeyondPresence API Key
     OpenAI API
     Google Sheets
  Configure webhook in BeyondPresence dashboard:
     https://[your-n8n-instance]/webhook/beyondpresence-hr-interviews
  Paste job description and run setup
  Share generated link with candidates

  How it works
  Agent Creation: Converts job description into conversational AI interviewer
  Interview Conduct: Candidates chat naturally with AI via shared link
  Webhook Trigger: Completed interviews sent to n8n
  AI Analysis: OpenAI evaluates responses against job requirements
  Results Storage: Assessments saved to Google Sheets with scores and recommendations

  Resources
  Google Sheets Template
  BeyondPresence Documentation
  Webhook Setup Guide

  Example Use Case
  Tech startup screens 200 applicants for engineering role. Creates AI interviewer in 2 minutes, sends link to all candidates. Receives structured assessments within 24 hours, identifying top 20 candidates for human interviews. Reduces initial screening time from 2 weeks to 2 days.

workflow_json:
  {"id":"dOaiA0eoSCdxkOv0","meta":{"instanceId":"eb3d53320c110bef9b66cf21b0da1ce60c7b6876e22315eca1be511a26fd726c","templateCredsSetupCompleted":true},"name":"BeyondPresence Agent HR Interview System","tags":[],"nodes":[{"id":"f934aa49-faee-4413-b1b9-6a4c2b9f45b2","name":"Job Description Instructions","type":"n8n-nodes-base.stickyNote","position":[-1240,-680],"parameters":{"color":5,"width":400,"height":520,"content":"## 📝 Step 1: Add Your Job Description\n\n**Simply paste your complete job posting in the yellow box below**\n\nInclude:\n- Job title\n- Company name\n- Responsibilities\n- Requirements\n- Any other relevant details\n\nThe AI will understand everything from your text!"},"typeVersion":1},{"id":"81fa81d2-1b16-4e15-a84c-4677bcbc4ad8","name":"📝 Your Job Description","type":"n8n-nodes-base.code","position":[-1000,-320],"parameters":{"jsCode":"// ========== PASTE YOUR JOB DESCRIPTION HERE ==========\n// Simply paste your entire job posting between the quotes below\n// Include everything: job title, company name, requirements, etc.\n\nconst jobDescription = `\nProduct Marketing Manager – BeyondPresence.ai\n\nBeyondPresence.ai is redefining human-computer interaction with hyper-realistic, emotionally intelligent digital avatars and Conversational Video Agents that deliver human-like, real-time conversations at scale. Our proprietary AI technology powers next-generation customer support, sales, HR, and training experiences for leading brands worldwide. We are seeking a dynamic Product Marketing Manager to drive the go-to-market strategy and accelerate adoption of our cutting-edge platform.\n\nResponsibilities\nDevelop and execute go-to-market strategies for new and existing BeyondPresence.ai products, with a focus on driving demand, adoption, and customer engagement.\n\nCraft compelling product positioning and messaging that differentiates our conversational avatars and platform in the market.\n\nConduct market, competitor, and user research to identify trends, customer needs, and growth opportunities.\n\nBuild and maintain detailed buyer personas to guide targeted marketing and sales initiatives.\n\nCollaborate closely with product, engineering, and sales teams to align on product vision, roadmap, and feature launches.\n\nLead cross-functional product launches, including launch planning, sales enablement, and campaign execution.\n\nCreate and manage marketing collateral, demos, website content, case studies, and sales tools that clearly communicate product value.\n\nGather and analyze customer feedback and campaign performance data to optimize messaging and marketing programs.\n\nSupport the sales team with training, product presentations, and competitive insights to drive conversions and upsells.\n\nRepresent BeyondPresence.ai at industry events, webinars, and customer meetings as a product evangelist.\n\nRequirements\n4+ years of experience in product marketing, preferably in B2B SaaS, AI, or related technology sectors.\n\nProven track record of launching and scaling innovative technology products, ideally in AI, conversational platforms, or digital avatars.\n\nDeep understanding of go-to-market strategies, product positioning, and value-based messaging.\n\nExceptional written and verbal communication skills, including copywriting and storytelling.\n\nStrong analytical skills with experience in market research, data analysis, and campaign optimization.\n\nDemonstrated ability to influence and collaborate with cross-functional teams without direct authority.\n\nExperience supporting sales teams with enablement materials and training.\n\nBachelor’s degree in marketing, business, or a related field; advanced degree a plus.\n\nPassion for emerging technologies, AI, and shaping the future of human-computer interaction.\n\nWhy BeyondPresence.ai?\nJoin a visionary, fast-growing team with deep expertise in AI, avatars, and conversational technology.\n\nShape the future of digital communication and help global brands deliver human-like experiences at scale.\n\nWork with a collaborative, mission-driven team backed by proven founders and industry leaders.\n\nCompetitive compensation, flexible work environment, and opportunities for rapid career growth.\n\nReady to help define the future of human-AI interaction? Apply now and join BeyondPresence.ai!\n`;\n\n// Don't change anything below this line\nreturn [{\n  json: {\n    jobDescription: jobDescription.trim(),\n    timestamp: new Date().toISOString()\n  }\n}];"},"typeVersion":2},{"id":"3b076ed7-a31d-4ce5-af14-c79fe425ce41","name":"Setup Instructions","type":"n8n-nodes-base.stickyNote","position":[-820,-680],"parameters":{"color":7,"width":430,"height":520,"content":"## 🚀 Step 2: Create Your Interview Agent\n\n**Click the button below to:**\n1. Create your AI interviewer\n2. Get your interview link\n\nThis only needs to be done ONCE!"},"typeVersion":1},{"id":"aecf3f6e-bd63-4af5-b8f1-d18c05c1c661","name":"▶️ Click to Start Setup","type":"n8n-nodes-base.manualTrigger","position":[-1200,-320],"parameters":{},"typeVersion":1},{"id":"2ce3a3f3-05cc-49f6-b52e-4e2491848452","name":"Prepare Interview Agent","type":"n8n-nodes-base.code","position":[-780,-320],"parameters":{"jsCode":"// Generate the interview system prompt\nconst jobDescription = $input.first().json.jobDescription;\n\nconst systemPrompt = `You are a professional HR interviewer conducting job interviews. Your goal is to assess candidates thoroughly while making them feel comfortable and valued.\n\nJob Description:\n${jobDescription}\n\nInterview Approach:\n- Start with a warm welcome and brief introduction\n- Ask about their interest in the role and company\n- Explore their relevant experience with specific examples\n- Assess technical skills and cultural fit\n- Allow time for their questions\n- Close professionally with next steps\n\nBe conversational, ask follow-up questions, and show genuine interest in their responses. If they seem nervous, help them feel at ease. Always maintain a professional yet friendly tone.`;\n\nconst welcomeMessage = `Hello! Welcome to our interview. I'm excited to learn about your background and discuss this opportunity with you. \n\nLet's start with you telling me a bit about yourself and what interests you about this position.`;\n\nreturn [{\n  json: {\n    jobDescription,\n    systemPrompt,\n    welcomeMessage,\n    agentName: `HR Interview Bot - ${new Date().toLocaleDateString()}`\n  }\n}];"},"typeVersion":2},{"id":"f05b2cd3-1550-4c5b-ab27-9313b46b75ef","name":"Create Interview Agent","type":"n8n-nodes-beyondpresence.beyondPresence","position":[-560,-320],"parameters":{"name":"={{ $json.agentName }}","greeting":"={{ $json.welcomeMessage }}","systemPrompt":"={{ $json.systemPrompt }}","requestOptions":{}},"typeVersion":1},{"id":"9ccd8a67-fbae-4ac8-b763-f43b1cf38a48","name":"Save Agent Info","type":"n8n-nodes-base.code","position":[-220,-320],"parameters":{"jsCode":"const workflowStaticData = $getWorkflowStaticData('global');\n\n\n\nconst agentId = $input.first().json.id;\nconst interviewLink = $input.first().json.call_link;\nconst jobDescription = $('Prepare Interview Agent').first().json.jobDescription;\n\nworkflowStaticData.agentId = agentId;\nworkflowStaticData.jobDescription = jobDescription;\nworkflowStaticData.interviewLink = interviewLink;\n\n\n\nreturn [{\n  json: {\n    \"Agent ID\": workflowStaticData.agentId,\n    \"Agent Name\":$('Prepare Interview Agent').first().json.agentName,\n    \"Interview Link\": interviewLink,\n    \"Job Description\": workflowStaticData.jobDescription,\n    \"System Prompt\": $('Prepare Interview Agent').first().json.systemPrompt,\n    \"Welcome Message\": $('Prepare Interview Agent').first().json.welcomeMessage\n    \n  }\n}];"},"typeVersion":2},{"id":"25c02197-28b9-415f-8e83-1b0700fe1ae7","name":"Success!","type":"n8n-nodes-base.stickyNote","position":[-340,-680],"parameters":{"color":2,"width":330,"height":520,"content":"## ✅ Setup Complete!\n\n**Your interview link:**\n`https://bey.chat/[agent-id]`\n\n** This step will now setup our agent id and job description which is now automatically passed and used by our webhook."},"typeVersion":1},{"id":"ac2610af-10e0-42ef-83f8-5aa3ee48dbdf","name":"Automated Analysis","type":"n8n-nodes-base.stickyNote","position":[-1240,-140],"parameters":{"color":6,"width":390,"height":540,"content":"## 🤖 Step 3: Automated Interview Analysis\n\n**This section runs automatically to:**\n- Receive completed interviews\n- Analyze candidate responses\n- Save results to Google Sheets\n\n**Before activating:** \nMake sure to configure the webhook URL in your BeyondPresence dashboard under Settings → Webhooks"},"typeVersion":1},{"id":"99af0fae-f69a-4172-8864-2e4a94347ecf","name":"Receive Interview Data","type":"n8n-nodes-base.webhook","position":[-1200,300],"webhookId":"beyondpresence-hr-interviews","parameters":{"path":"beyondpresence-hr-interviews","options":{},"httpMethod":"POST","responseMode":"responseNode"},"typeVersion":2},{"id":"94289ea4-518a-4b37-9ece-6d1bf1d4a4a8","name":"Confirm Receipt","type":"n8n-nodes-base.respondToWebhook","position":[-1000,300],"parameters":{"options":{},"respondWith":"json","responseBody":"{\n  \"status\": \"success\",\n  \"message\": \"Interview received and being analyzed\"\n}"},"typeVersion":1.2},{"id":"c0b156a3-99a4-437d-b116-e8fe94ac5ead","name":"Is Our Interview?","type":"n8n-nodes-base.if","position":[-520,280],"parameters":{"options":{},"conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"931e1a97-c22c-48be-9728-73989cf00f41","operator":{"type":"boolean","operation":"true"},"leftValue":"={{ $json.process }}","rightValue":true}]}},"typeVersion":2.1},{"id":"09cf419c-3a1a-4c08-b27f-08c35fbd1b1a","name":"Analyze Interview","type":"@n8n/n8n-nodes-langchain.openAi","position":[-220,300],"parameters":{"modelId":{"__rl":true,"mode":"id","value":"gpt-4o-mini"},"options":{"temperature":0.3},"messages":{"values":[{"role":"system","content":"=Analyze this job interview and provide a hiring assessment.\n\nJob Description:\n{{ $getWorkflowStaticData('global').jobDescription }}\n\n\nCandidate: {{ $json.webhookData.call_data.userName }}\nInterview Date:  {{ $now }}\nDuration: {{ $json.webhookData.evaluation.duration_minutes }} minutes\n\nCandidate Transcript:\n{{ $json.webhookData.messages.map(m => `[${m.sent_at}] ${m.sender.toUpperCase()}: ${m.message}`).join('\\n') }}\n\nProvide a comprehensive assessment including:\n1. Overall fit score (0-100)\n2. Key strengths\n3. Any concerns or gaps\n4. Hiring recommendation\n5. Suggested next steps\n\nFormat your response as JSON:\n```json\n{\n  \"fitScore\": 85,\n  \"recommendation\": \"recommend\",\n  \"strengths\": [\"strength 1\", \"strength 2\", \"strength 3\"],\n  \"concerns\": [\"concern 1\", \"concern 2\"],\n  \"summary\": \"Brief 2-3 sentence overall assessment\",\n  \"nextSteps\": [\"suggested action 1\", \"suggested action 2\"]\n}\n```"}]}},"typeVersion":1},{"id":"0dea6278-69e2-485f-a213-90d6a8aeb26f","name":"Format for Sheets","type":"n8n-nodes-base.code","position":[280,300],"parameters":{"jsCode":"// Parse AI analysis\nconst analysisText = $input.first().json.message.content;\nconst analysis = JSON.parse(analysisText.match(/```json\\n([\\s\\S]*?)\\n```/)[1]);\nconst interviewData = $input.first().json;\n\n// Format for Google Sheets\nreturn [{\n  json: {\n    \"Candidate Name\": $('Is Our Interview?').first().json.webhookData.call_data.userName,\n    \"Interview Date\":  $now,\n    \"Duration (minutes)\": $('Is Our Interview?').first().json.webhookData.evaluation.duration_minutes,\n    \"Fit Score\": analysis.fitScore,\n    \"Recommendation\": analysis.recommendation,\n    \"Strengths\": analysis.strengths.join(\"; \"),\n    \"Concerns\": analysis.concerns.join(\"; \") || \"None\",\n    \"Summary\": analysis.summary,\n    \"Next Steps\": analysis.nextSteps.join(\"; \"),\n    \"Call ID\": $('Is Our Interview?').first().json.webhookData.call_id,\n    \"Analyzed On\": $now,\n  }\n}];"},"typeVersion":2},{"id":"74a0fe09-9c5e-4181-a38b-e15404d256e3","name":"Save to Google Sheets","type":"n8n-nodes-base.googleSheets","position":[640,280],"parameters":{"columns":{"value":{"Fit Score":"={{ $json['Fit Score'] }}","Candidate Name":"={{ $json['Candidate Name'] }}","Interview Date":"={{ $json['Interview Date'] }}","Duration (minutes)":"={{ $json['Duration (minutes)'] }}"},"schema":[{"id":"Candidate Name","type":"string","display":true,"required":false,"displayName":"Candidate Name","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Interview Date","type":"string","display":true,"required":false,"displayName":"Interview Date","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Duration (minutes)","type":"string","display":true,"required":false,"displayName":"Duration (minutes)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Fit Score","type":"string","display":true,"required":false,"displayName":"Fit Score","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Recommendation","type":"string","display":true,"required":false,"displayName":"Recommendation","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Strengths","type":"string","display":true,"required":false,"displayName":"Strengths","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Concerns","type":"string","display":true,"required":false,"displayName":"Concerns","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Summary","type":"string","display":true,"required":false,"displayName":"Summary","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Next Steps","type":"string","display":true,"required":false,"displayName":"Next Steps","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Call ID","type":"string","display":true,"required":false,"displayName":"Call ID","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Analyzed On","type":"string","display":true,"required":false,"displayName":"Analyzed On","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"autoMapInputData","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1dXLpP5bRRirBsln4YIQtFgb1MiP-0yR8IDRzse5k7X0/edit#gid=0","cachedResultName":"Interview Results"},"documentId":{"__rl":true,"mode":"list","value":"1dXLpP5bRRirBsln4YIQtFgb1MiP-0yR8IDRzse5k7X0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1dXLpP5bRRirBsln4YIQtFgb1MiP-0yR8IDRzse5k7X0/edit?usp=drivesdk","cachedResultName":"BeyondPresence HR Interview System Template"}},"typeVersion":4.6},{"id":"eebced68-6690-4a91-a165-0ec99aadd268","name":"Sheet Headers","type":"n8n-nodes-base.stickyNote","position":[480,-140],"parameters":{"color":3,"width":480,"height":540,"content":"## 📊 Google Sheets Connection\n\n**Quick Start**:\n1. Use the same document but select **'Interview Results'**  sheet this time, the template includes all required columns!\n\n**Connect your Google Sheets here →**"},"typeVersion":1},{"id":"375ff0d6-e540-46cb-a20a-baf42969cc08","name":"Important!","type":"n8n-nodes-base.stickyNote","position":[-820,-80],"parameters":{"width":500,"height":100,"content":"⚠️ **MUST DO BEFORE ACTIVATING:**\n\n1. Run Step 2 first it will automatically setup required values\n"},"typeVersion":1},{"id":"f3b219c1-6888-4e2d-9ea6-a65b72200770","name":"Processing Steps","type":"n8n-nodes-base.stickyNote","position":[-280,-140],"parameters":{"color":4,"width":700,"height":540,"content":"## 🔍 Interview Processing & AI Assessment\n\n1. Extract Interview Data: Captures candidate responses and metadata from completed interviews\n2. AI Interview Analysis: Uses OpenAI to evaluate candidate fit against job requirements\n3. Format Assessment Results: Structures AI insights for easy review and decision-making\n\nThe AI analyzes:\n- Overall fit score (0-100)\n- Key strengths demonstrated\n- Potential concerns or skill gaps\n- Hiring recommendation level\n- Suggested next steps\n- Summary of candidate suitability\n\nThis comprehensive analysis helps HR teams make data-driven hiring decisions by providing consistent, objective assessments of each candidate's interview performance."},"typeVersion":1},{"id":"6929cd46-bfcb-435b-8e9b-7a2c1c20ccde","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-820,120],"parameters":{"color":3,"width":500,"height":320,"content":"## Data Checks\n\n- Only pass webhooks related to our agent\n- Only pass completed calls and discard realtime messages."},"typeVersion":1},{"id":"5a62069a-d4a7-427d-ba2e-84ea9ab81954","name":"Data checks","type":"n8n-nodes-base.code","position":[-740,280],"parameters":{"jsCode":"const workflowStaticData = $getWorkflowStaticData('global');\nconst MY_AGENT_ID = workflowStaticData.agentId;\n\nconst jobDescription = workflowStaticData.jobDescription;\n\nconst webhookData = $input.first().json.body;\nconst receivedAgentId = webhookData.agent_id || webhookData.agentId || \n                        (webhookData.call_data && webhookData.call_data.agent_id);\n\n// Only process if it's our agent and the call ended\nif (receivedAgentId === MY_AGENT_ID && webhookData.event_type === \"call_ended\") {\n  return [{\n    json: {\n      process: true,\n      jobDescription,\n      webhookData\n    }\n  }];\n} else {\n  return [{\n    json: {\n      process: false,\n      reason: receivedAgentId !== MY_AGENT_ID ? \n        \"Interview from different agent\" : \n        \"Call not finished yet\"\n    }\n  }];\n}"},"typeVersion":2},{"id":"003bd0dc-e828-475a-aa7b-130c11cd2991","name":"Sheet Headers1","type":"n8n-nodes-base.stickyNote","position":[80,-680],"parameters":{"color":3,"width":380,"height":520,"content":"## 📊 Google Sheets Setup\n\n**Quick Start**:\n1. Copy our template sheet:  https://docs.google.com/spreadsheets/d/1dXLpP5bRRirBsln4YIQtFgb1MiP-0yR8IDRzse5k7X0/copy\n2. Connect your account credential in the node.\n3. Update the Google Sheets node with your new document and select **'Interview Agents'**  sheet\n (if not automatically set)\n3. You will get interview link in this sheet which you can share with candidates and start interviewing\n\n**Connect your Google Sheets here →**"},"typeVersion":1},{"id":"60847f4e-5e0d-41a6-bee1-96e6bb733fce","name":"Save to Google Sheets1","type":"n8n-nodes-base.googleSheets","position":[180,-320],"parameters":{"columns":{"value":{},"schema":[{"id":"Agent ID","type":"string","display":true,"required":false,"displayName":"Agent ID","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Agent Name","type":"string","display":true,"required":false,"displayName":"Agent Name","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Interview Link","type":"string","display":true,"required":false,"displayName":"Interview Link","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Job Description","type":"string","display":true,"required":false,"displayName":"Job Description","defaultMatch":false,"canBeUsedToMatch":true},{"id":"System Prompt","type":"string","display":true,"required":false,"displayName":"System Prompt","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Welcome Message","type":"string","display":true,"required":false,"displayName":"Welcome Message","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"autoMapInputData","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"list","value":1902016160,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1dXLpP5bRRirBsln4YIQtFgb1MiP-0yR8IDRzse5k7X0/edit#gid=1902016160","cachedResultName":"Interview Agents"},"documentId":{"__rl":true,"mode":"list","value":"1dXLpP5bRRirBsln4YIQtFgb1MiP-0yR8IDRzse5k7X0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1dXLpP5bRRirBsln4YIQtFgb1MiP-0yR8IDRzse5k7X0/edit?usp=drivesdk","cachedResultName":"BeyondPresence HR Interview System Template"}},"typeVersion":4.6}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"7bc4a98e-afe5-4924-849e-a75f74bfdc69","connections":{"Data checks":{"main":[[{"node":"Is Our Interview?","type":"main","index":0}]]},"Confirm Receipt":{"main":[[{"node":"Data checks","type":"main","index":0}]]},"Save Agent Info":{"main":[[{"node":"Save to Google Sheets1","type":"main","index":0}]]},"Analyze Interview":{"main":[[{"node":"Format for Sheets","type":"main","index":0}]]},"Format for Sheets":{"main":[[{"node":"Save to Google Sheets","type":"main","index":0}]]},"Is Our Interview?":{"main":[[{"node":"Analyze Interview","type":"main","index":0}]]},"Create Interview Agent":{"main":[[{"node":"Save Agent Info","type":"main","index":0}]]},"Receive Interview Data":{"main":[[{"node":"Confirm Receipt","type":"main","index":0}]]},"Prepare Interview Agent":{"main":[[{"node":"Create Interview Agent","type":"main","index":0}]]},"📝 Your Job Description":{"main":[[{"node":"Prepare Interview Agent","type":"main","index":0}]]},"▶️ Click to Start Setup":{"main":[[{"node":"📝 Your Job Description","type":"main","index":0}]]}}}


name: Build a Knowledge Base Chatbot with OpenAI, RAG and MongoDB Vector Embeddings
author_name: NovaNode
author_username: thomasgpt
categories: []
created_at: 2025-05-30T23:12:00.516Z
updated_at: 2025-05-30T23:12:00.516Z
url: https://n8n.io/workflows/4526
scraped_at: 2025-07-06 21:16:30
description:
  Who is this for?

  This template is designed for internal support teams, product specialists, and knowledge managers in technology companies who want to automate ingestion of product documentation and enable AI-driven, retrieval-augmented question answering.

  What problem is this workflow solving?
  Support agents often spend too much time manually searching through lengthy documentation, leading to inconsistent or delayed answers. This solution automates importing, chunking, and indexing product manuals, then uses retrieval-augmented generation (RAG) to answer user queries accurately and quickly with AI.

  What these workflows do
  Workflow 1: Document Ingestion & Indexing
  Manually triggered to import product documentation from Google Docs.

  Automatically splits large documents into chunks for efficient searching.

  Generates vector embeddings for each chunk using OpenAI embeddings.

  Inserts the embedded chunks and metadata into a MongoDB Atlas vector store, enabling fast semantic search.

  Workflow 2: AI-Powered Query & Response
  Listens for incoming user questions (can be extended to webhook).

  Converts questions to vector embeddings and performs similarity search on MongoDB vector store.

  Uses OpenAI’s GPT-4o-mini model with retrieval-augmented generation to produce direct, context-aware answers.

  Maintains short-term conversation context using a memory buffer node.

  Setup
  Setting up vector embeddings
  Authenticate Google Docs and connect your Google Docs URL containing the product documentation you want to index.

  Authenticate MongoDB Atlas and connect the collection where you want to store the vector embeddings. Create a search index on this collection to support vector similarity queries.

  Ensure the index name matches the one configured in n8n (data_index).

  See the example MongoDB search index template below for reference.

  Setting up chat
  Configure the AI system prompt in the “Knowledge Base Agent” node to reflect your company’s tone, answering style, and any business rules.

  Update the workflow description and instructions to help users understand the chat’s purpose and capabilities.

  Connect the MongoDB collection used for vector search in the chat workflow and update the vector search index if needed to match your setup.

  Make sure
  Both MongoDB nodes (in ingestion and chat workflows) are connected to the same collection, with:

  An embedding field storing vector data,

  Relevant metadata fields (e.g., document ID, source), and

  The same vector index name configured (e.g., data_index).



  Search Index Example:
  {
    "mappings": {
      "dynamic": false,
      "fields": {
        "_id": {
          "type": "string"
        },
        "text": {
          "type": "string"
        },
        "embedding": {
          "type": "knnVector",
          "dimensions": 1536,
          "similarity": "cosine"
        },
        "source": {
          "type": "string"
        },
        "doc_id": {
          "type": "string"
        }
      }
    }
  }

nodes_used:
  ["n8n-nodes-base.googleDocs","@n8n/n8n-nodes-langchain.agent","@n8n/n8n-nodes-langchain.embeddingsOpenAi","@n8n/n8n-nodes-langchain.lmChatOpenAi","@n8n/n8n-nodes-langchain.memoryBufferWindow","@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter","@n8n/n8n-nodes-langchain.documentDefaultDataLoader","@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas"]

workflow_json:
  {"meta":{"instanceId":"074f90e2bb5206c5f405a8aac6551497c72005283a5405fb08207b1b3a78c2b8","templateCredsSetupCompleted":true},"nodes":[{"id":"5cb0a836-f9a1-4f92-9326-cd82a392d0da","name":"Knowledge Base Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[220,0],"parameters":{"text":"={{ $json.chatInput }}","options":{"systemMessage":"You are the AI assistant for an internal support team at a technology company specializing in advanced software solutions. Your task is to assist internal users by consulting the official product documentation stored in the company’s knowledge base.\n\nAvailable references:\n\nproductDocs: Step-by-step guides, technical configurations, and official manuals extracted from the product’s documentation.\n\nBehavior rules for answering questions:\nAlways consult the official product documentation first using the productDocs tool.\n\nRespond clearly and directly, explaining how to do what is requested.\n\nDo not filter by category unless explicitly asked by the user.\n\nDetect the language of each incoming message individually and respond in that language. Do not use prior conversation language or history to decide the response language.\n\nNever provide links, even if requested. If a user asks for a link, reply:\n“I cannot provide links. If you need specific information, please let me know and I will help with the details.”\n\nUse a professional, direct, and human tone.\n\nKeep answers between 2 and 4 lines unless the user requests more detail.\n\nDo not invent information that is not in the knowledge base.\n\nIf you give numbered steps or lists, number them sequentially (1, 2, 3...) without skipping or repeating numbers, even if the source content uses different numbering."},"promptType":"define"},"typeVersion":1.9},{"id":"56e6fb75-6a97-4466-9e7f-70710c2740d7","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[60,240],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"cJRah9hGPQ7eX4jd","name":"OpenAi account"}},"typeVersion":1.2},{"id":"e352c32e-7108-4a0d-b081-b2532d96d092","name":"Embeddings OpenAI","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[680,380],"parameters":{"options":{}},"credentials":{"openAiApi":{"id":"cJRah9hGPQ7eX4jd","name":"OpenAi account"}},"typeVersion":1.2},{"id":"74bbfb00-1a00-4131-a291-bce5b79628b4","name":"When clicking \"Execute Workflow\"","type":"n8n-nodes-base.manualTrigger","position":[-60,-420],"parameters":{},"typeVersion":1},{"id":"f720a4b0-6239-4a0b-bb61-1e43f78f8e40","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[320,220],"parameters":{},"typeVersion":1.3},{"id":"94561d61-4a01-48b6-b114-dc4d47546ff3","name":"MongoDB Vector Search","type":"@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas","position":[560,220],"parameters":{"mode":"retrieve-as-tool","options":{},"toolName":"productDocs","mongoCollection":{"__rl":true,"mode":"list","value":"n8n-template","cachedResultName":"n8n-template"},"toolDescription":"retreive documentation","vectorIndexName":"data_index"},"credentials":{"mongoDb":{"id":"7riubYENUDZsmjyK","name":"MongoDB account 2"}},"typeVersion":1.1},{"id":"c473c33d-5681-4f3a-ac36-0d3012e7251f","name":"Document Section Loader","type":"@n8n/n8n-nodes-langchain.documentDefaultDataLoader","position":[740,-260],"parameters":{"options":{"metadata":{"metadataValues":[{"name":"doc_id","value":"={{ $json.documentId }}"}]}},"jsonData":"={{ $json.content }}","jsonMode":"expressionData"},"typeVersion":1},{"id":"321222cb-1daf-4be2-a6ca-1a03d24f670f","name":"Document Chunker","type":"@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter","position":[860,-100],"parameters":{"options":{"splitCode":"markdown"},"chunkSize":3000,"chunkOverlap":200},"typeVersion":1},{"id":"716519f5-cec1-4bfe-afbe-614fc23e74b5","name":"MongoDB Vector Store Inserter","type":"@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas","position":[540,-420],"parameters":{"mode":"insert","options":{},"mongoCollection":{"__rl":true,"mode":"list","value":"n8n-template","cachedResultName":"n8n-template"},"vectorIndexName":"data_index"},"credentials":{"mongoDb":{"id":"7riubYENUDZsmjyK","name":"MongoDB account 2"}},"typeVersion":1.1},{"id":"a49c19fc-f5f5-4381-b6ba-1bfc12b96135","name":"OpenAI Embeddings Generator","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[480,-180],"parameters":{"options":{}},"credentials":{"openAiApi":{"id":"cJRah9hGPQ7eX4jd","name":"OpenAi account"}},"typeVersion":1.2},{"id":"6de724d5-2941-4e72-af8b-302ca2cf2ca0","name":"Google Docs Importer","type":"n8n-nodes-base.googleDocs","position":[200,-420],"parameters":{"operation":"get","documentURL":"https://docs.google.com/document/d/1gvgp71e9edob8WLqFIYCdzC7kUq3pLO37VKb-a-vVW4/edit?tab=t.0"},"credentials":{"googleDocsOAuth2Api":{"id":"FNXMwqMf7vl1WUFj","name":"Google Docs account"}},"typeVersion":2},{"id":"4f30bb21-72f0-4d13-b610-2ec218ad31b1","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-420,-440],"parameters":{"color":5,"content":"Run this workflow manually to import and index Google Docs product documentation into MongoDB with vector embeddings for fast search."},"typeVersion":1},{"id":"25fd33d5-041b-4f01-a46b-1bacabd88376","name":"When chat message received","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[40,0],"webhookId":"427ead97-647d-49c7-82d7-e76b40664fd1","parameters":{"options":{}},"typeVersion":1.1},{"id":"f1f3fadd-d5e6-45df-b810-1616531dffcb","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-420,40],"parameters":{"color":4,"content":"This workflow uses retrieval-augmented generation (RAG) to answer user questions by searching the MongoDB vector store and generating AI responses with context."},"typeVersion":1},{"id":"39eee95c-b332-4ae4-bde9-aaf0fe5e0546","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[1060,-380],"parameters":{"height":520,"content":"Search Index Example \n\n{\n  \"mappings\": {\n    \"dynamic\": false,\n    \"fields\": {\n      \"_id\": {\n        \"type\": \"string\"\n      },\n      \"text\": {\n        \"type\": \"string\"\n      },\n      \"embedding\": {\n        \"type\": \"knnVector\",\n        \"dimensions\": 1536,\n        \"similarity\": \"cosine\"\n      },\n      \"source\": {\n        \"type\": \"string\"\n      },\n      \"doc_id\": {\n        \"type\": \"string\"\n      }\n    }\n  }\n}\n"},"typeVersion":1}],"pinData":{},"connections":{"Simple Memory":{"ai_memory":[[{"node":"Knowledge Base Agent","type":"ai_memory","index":0}]]},"Document Chunker":{"ai_textSplitter":[[{"node":"Document Section Loader","type":"ai_textSplitter","index":0}]]},"Embeddings OpenAI":{"ai_embedding":[[{"node":"MongoDB Vector Search","type":"ai_embedding","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"Knowledge Base Agent","type":"ai_languageModel","index":0}]]},"Google Docs Importer":{"main":[[{"node":"MongoDB Vector Store Inserter","type":"main","index":0}]]},"Knowledge Base Agent":{"main":[[]]},"MongoDB Vector Search":{"ai_tool":[[{"node":"Knowledge Base Agent","type":"ai_tool","index":0}]]},"Document Section Loader":{"ai_document":[[{"node":"MongoDB Vector Store Inserter","type":"ai_document","index":0}]]},"When chat message received":{"main":[[{"node":"Knowledge Base Agent","type":"main","index":0}]]},"OpenAI Embeddings Generator":{"ai_embedding":[[{"node":"MongoDB Vector Store Inserter","type":"ai_embedding","index":0}]]},"When clicking \"Execute Workflow\"":{"main":[[{"node":"Google Docs Importer","type":"main","index":0}]]}}}


name: Automate B2B Lead Generation with Apollo, GPT-4o Scoring, and Brevo Email Outreach
author_name: Luka Zivkovic
author_username: zivkovic58
categories: []
created_at: 2025-05-31T17:18:03.659Z
updated_at: 2025-05-31T17:18:03.659Z
url: https://n8n.io/workflows/4539
scraped_at: 2025-07-06 21:16:30
description:
  Lead Generation, AI Scoring, Personalized Email Creation and Outreach

  Overview

  This comprehensive automation flow helps you scale your outreach to potential customers through intelligent lead generation and personalized email campaigns. The system combines web scraping, AI-powered lead scoring, and automated email sequences to maximize your conversion rates.

  Key Features
  Bulk Lead Scraping** from Apollo.io
  Intelligent Website Analysis** with automated scraping
  AI-Powered Lead Scoring** for prioritization
  Personalized Email Generation** using AI
  Automated Email Outreach** with tracking
  Real-time Event Monitoring** via Brevo webhooks
  Centralized Data Management** with NocoDB

  System Architecture
  The workflow integrates multiple platforms to create a seamless lead generation pipeline:
  NocoDB** - Central database and CRM
  Apollo.io** - Lead data source
  Crawl4AI** - Website content analysis
  OpenAI** - Lead scoring and email personalization
  Brevo** - Email delivery and tracking

  Setup Requirements

  Prerequisites
  Before starting, ensure you have accounts for the following services:
  NocoDB (Database & CRM)
  Apify (Web scraping platform)
  OpenAI (AI processing)
  Brevo (Email delivery service)

  &gt; 💡 Pro Tip: For advanced users, consider self-hosting NocoDB and Crawl4AI to significantly reduce operational costs.

  Step-by-Step Setup

  1. NocoDB Database Configuration

  Create Your NocoDB Account
  Sign up at nocodb.com
  Create a new workspace
  Set up your first base (database)

  Database Schema Setup
  Create a new table with the following field structure:

  | Field Name | Field Type | Configuration |
  |------------|------------|---------------|
  | first_name | Single Line Text | - |
  | last_name | Single Line Text | - |
  | email | Email | - |
  | headline | Single Line Text | - |
  | linkedin_url | URL | - |
  | industry | Single Line Text | - |
  | organization_name | Single Line Text | - |
  | organization_website | URL | - |
  | organization_size | Number | - |
  | organization_linkedin_url | URL | - |
  | organization_facebook_url | URL | - |
  | market_cap | Single Line Text | - |
  | job_title | Single Line Text | - |
  | country | Single Line Text | - |
  | city | Single Line Text | - |
  | lead_status | Single Select | Options: entered, processed, email_created, contacted, trash, failed_to_process, opened_email, warm | Default Value: entered
  | website_summary | Long Text | - |
  | score | Number | Default: 0 |
  | organization_description | Long Text | - |
  | primary_phone | Phone Number | - |
  | keywords | Single Line Text | - |
  | email_subject | Single Line Text | - |
  | email_body | Long Text | - |
  | email_opened_times | Number | Default: 0 |
  | personal_email | Single Line Text | - |

  2. External Service Setup

  Apify Configuration
  Create account at apify.com
  Navigate to Settings → API tokens
  Generate new API token
  Save token securely for automation setup

  OpenAI API Setup
  Visit platform.openai.com
  Go to API Keys section
  Create new secret key
  Store API key securely
  Ensure billing is configured for API usage

  Brevo Email Service
  Sign up at brevo.com
  Complete account verification
  Navigate to SMTP & API settings
  Generate API key for integration
  Configure sender authentication (SPF/DKIM)

  Workflow Process

  Phase 1: Lead Discovery & Data Collection
  Apollo Scraping - Extract lead data based on target criteria
  Data Import - Populate NocoDB with lead information
  Status Update - Mark leads as entered

  Phase 2: Website Analysis & Lead Scoring
  Website Scraping - Analyze company websites using Crawl4AI
  Content Processing - Extract key business information
  AI Scoring - Evaluate lead quality using OpenAI
  Database Update - Store analysis results and scores

  Phase 3: Email Personalization & Outreach
  Content Generation - Create personalized email content
  Email Preparation - Format messages for delivery
  Automated Sending - Deploy via Brevo
  Status Tracking - Monitor delivery and engagement

  Phase 4: Performance Monitoring
  Webhook Processing - Capture Brevo email events
  Engagement Tracking - Update open/click metrics
  Lead Qualification - Adjust lead status based on engagement
  Pipeline Management - Maintain lead progression

  Lead Status Workflow

  entered → processed → email_created → contacted → opened_email → warm
      ↓
  failed_to_process / trash (for low-quality leads)

  Status Definitions
  entered**: Initial lead data captured
  processed**: Website analyzed and scored
  email_created**: Personalized email generated
  contacted**: Email successfully sent
  opened_email**: Recipient opened the email
  warm**: High engagement, ready for follow-up
  failed_to_process**: Technical issues during processing
  trash**: Low-quality lead, removed from active pipeline

  Best Practices

  Data Quality
  Regularly clean and deduplicate your lead database
  Monitor lead scores to refine your targeting criteria
  Archive or remove inactive leads to maintain performance

  Email Deliverability
  Warm up your sending domain before high-volume campaigns
  Monitor bounce rates and adjust list quality
  Implement proper SPF, DKIM, and DMARC records

  Compliance
  Ensure GDPR/CAN-SPAM compliance in all communications
  Provide clear unsubscribe mechanisms
  Respect recipient preferences and opt-outs

  Performance Optimization
  A/B test email subject lines and content
  Analyze open rates and adjust sending times
  Segment leads based on engagement levels for targeted follow-up

  Next Steps

  Once your setup is complete, you'll have a powerful, automated lead generation system that can:
  Process hundreds of leads simultaneously
  Provide intelligent lead prioritization
  Generate personalized outreach at scale
  Track and optimize campaign performance

  Ready to transform your lead generation process? Start with the NocoDB setup and work through each integration step by step.

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

workflow_json:
  {"id":"BVxFpIBewfg8Jwjx","meta":{"instanceId":"6c0a09a47d94a1a73da5dfac616caeedf0377a325eabc675382bec3037bf1127","templateId":"3435","templateCredsSetupCompleted":true},"name":"Lead Gen From Apollo To NocoDB","tags":[],"nodes":[{"id":"03eabaeb-ad13-4764-98de-183325e32cbd","name":"When clicking ‘Test workflow’","type":"n8n-nodes-base.manualTrigger","position":[-40,-40],"parameters":{},"typeVersion":1},{"id":"e7df072c-fba8-4dc2-94ce-ae20a135a633","name":"Edit Fields","type":"n8n-nodes-base.set","position":[840,-60],"parameters":{},"typeVersion":3.4},{"id":"3aaa9ea7-0c5d-4ea3-aa10-6cd0125ea91a","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[240,-320],"parameters":{"content":""},"typeVersion":1},{"id":"0915cea5-746a-4dde-9208-885e08644ae2","name":"Filter leads without email","type":"n8n-nodes-base.if","position":[560,-40],"parameters":{},"typeVersion":2.2},{"id":"79c0d44d-461c-47c4-a2c3-bc48819424f5","name":"NocoDB","type":"n8n-nodes-base.nocoDb","position":[1100,-60],"parameters":{},"typeVersion":3},{"id":"2ae8597b-c3cc-4094-ac10-876286a767fd","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[1340,-540],"parameters":{"content":""},"typeVersion":1},{"id":"65f90ea8-fead-4d3a-af5a-087711bd7c89","name":"Fetch data to prepare for scoring","type":"n8n-nodes-base.nocoDb","position":[3080,680],"parameters":{},"executeOnce":true,"typeVersion":3},{"id":"039c6258-d5da-45f1-8bce-5db46535bb19","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[3000,340],"parameters":{"content":""},"typeVersion":1},{"id":"cada3220-ba44-40a2-a376-6c4b085b52ff","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[3000,-240],"parameters":{"content":""},"typeVersion":1},{"id":"3f290863-d49b-4bda-8a9e-d60f1acd3431","name":"If not scored","type":"n8n-nodes-base.if","onError":"continueRegularOutput","position":[3580,440],"parameters":{},"typeVersion":2.2},{"id":"0f157716-a181-45f9-a003-c99fd8fdb7a1","name":"Add a score","type":"n8n-nodes-base.nocoDb","position":[4220,480],"parameters":{},"typeVersion":3},{"id":"61917624-c471-49db-b94e-b3af95d54932","name":"Crawl4AI","type":"n8n-nodes-base.httpRequest","onError":"continueRegularOutput","position":[1800,-500],"parameters":{},"typeVersion":4.2},{"id":"aeaca1d7-47b8-4949-8431-470b9173444c","name":"Crawl4AI resolve","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[2080,-500],"parameters":{},"typeVersion":4.2},{"id":"9b6e2ab7-11c2-4f50-87de-e7c3d1e0d1d2","name":"Wait","type":"n8n-nodes-base.wait","position":[1940,-240],"webhookId":"7b0d36c1-b26b-448b-a9a9-6bff0c03293c","parameters":{},"typeVersion":1.1},{"id":"a7a0226d-de96-4fde-93d6-26861c27ed4c","name":"If mail not created","type":"n8n-nodes-base.if","position":[3520,-80],"parameters":{},"typeVersion":2.2},{"id":"fbf38182-6201-47e9-a144-db168947bdf3","name":"Add Personalized mail","type":"n8n-nodes-base.nocoDb","onError":"continueRegularOutput","position":[4200,20],"parameters":{},"typeVersion":3},{"id":"0ef74fde-b88c-417c-850d-9c18a48f2840","name":"Ai Scoring","type":"@n8n/n8n-nodes-langchain.openAi","onError":"continueRegularOutput","position":[3840,400],"parameters":{},"typeVersion":1.8},{"id":"f9d4f2c5-2ab7-4393-b697-2e5a72aeb840","name":"Email Personalization","type":"@n8n/n8n-nodes-langchain.openAi","onError":"continueErrorOutput","position":[3800,-40],"parameters":{},"typeVersion":1.8},{"id":"904fc571-1d57-4281-915e-ba0ab05b6bb5","name":"Personalized Mail Loop","type":"n8n-nodes-base.splitInBatches","onError":"continueRegularOutput","position":[4700,-160],"parameters":{},"executeOnce":false,"typeVersion":3},{"id":"01e6de3a-77df-4ef7-aa14-6c75c8e7bc8d","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[4440,-240],"parameters":{"content":""},"typeVersion":1},{"id":"38732d31-45d9-4446-8c5e-83a753ab9d7a","name":"Mark as contacted","type":"n8n-nodes-base.nocoDb","onError":"continueRegularOutput","position":[5980,60],"parameters":{},"typeVersion":3},{"id":"0b8ef68a-b4c5-4e6b-969f-a2e18172dae1","name":"Email Exists -> Mark as Contacted","type":"n8n-nodes-base.nocoDb","onError":"continueRegularOutput","position":[5380,-80],"parameters":{},"typeVersion":3},{"id":"6622c17f-4372-4dfa-bb6d-f4d5bdd5732d","name":"Email Send","type":"n8n-nodes-base.sendInBlue","onError":"continueErrorOutput","position":[5700,-220],"parameters":{},"typeVersion":1},{"id":"ad99aea5-e1d7-42ab-8feb-d31dbb1c131d","name":"Create Contact","type":"n8n-nodes-base.sendInBlue","onError":"continueErrorOutput","position":[5240,-200],"parameters":{},"typeVersion":1},{"id":"a93dbfed-c320-4775-907f-b14528440a72","name":"If not contacted and email created","type":"n8n-nodes-base.if","position":[4960,-140],"parameters":{},"typeVersion":2.2},{"id":"f366ff2c-91c7-4c66-bd38-d767aed98cdd","name":"If pending","type":"n8n-nodes-base.if","position":[2220,-240],"parameters":{},"typeVersion":2.2},{"id":"c8ac0133-0d38-4b51-9b7d-4da170128d99","name":"Mark as Trash","type":"n8n-nodes-base.nocoDb","position":[5700,0],"parameters":{},"typeVersion":3},{"id":"8e0e6f67-edcf-408e-b5f8-3af76151ad57","name":"If not success","type":"n8n-nodes-base.if","position":[2440,-220],"parameters":{},"typeVersion":2.2},{"id":"42e3f6de-4ec4-46a7-a7f9-c028d27a677b","name":"Scrape Leads From Apollo","type":"n8n-nodes-base.httpRequest","position":[300,-40],"parameters":{},"typeVersion":4.2},{"id":"9d3e9f4b-faac-4712-8b3a-7455acf15049","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-1140,-680],"parameters":{"content":""},"typeVersion":1},{"id":"54e6e348-94da-4468-9c7b-c841b9b970d7","name":"Get by email","type":"n8n-nodes-base.nocoDb","position":[5160,-560],"parameters":{},"typeVersion":3,"alwaysOutputData":false},{"id":"1aa6ab44-929d-48f0-b82d-b5cd7900f7ee","name":"Lead Status -> Trash","type":"n8n-nodes-base.nocoDb","position":[5600,-560],"parameters":{},"typeVersion":3},{"id":"06d7157e-c32d-4301-bdae-6e1363bf9280","name":"Delete Contact In Brevo","type":"n8n-nodes-base.sendInBlue","onError":"continueRegularOutput","position":[4940,-560],"parameters":{},"typeVersion":1},{"id":"9e9d2e18-7f07-4779-8add-5bab43c23ce9","name":"Email Opened","type":"n8n-nodes-base.sendInBlueTrigger","disabled":true,"position":[4720,-820],"webhookId":"10d24686-a8b9-4a61-b8f7-88c7aebec134","parameters":{},"typeVersion":1},{"id":"f49e831b-c958-4f7c-a42f-06570f9e589f","name":"Lead Status -> Email Opened","type":"n8n-nodes-base.nocoDb","position":[5160,-820],"parameters":{},"typeVersion":3},{"id":"3499fc86-5edc-4c28-9e95-dc08b00745d9","name":"If Email Opened More Than Once","type":"n8n-nodes-base.if","position":[5380,-820],"parameters":{},"typeVersion":2.2},{"id":"f1c092fe-ab2b-4af3-acab-c16eaeea1794","name":"Lead Status -> Warm","type":"n8n-nodes-base.nocoDb","position":[5600,-820],"parameters":{},"typeVersion":3},{"id":"18a47bc2-c7d0-4164-ba12-7b057358343f","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[4620,-600],"parameters":{"content":""},"typeVersion":1},{"id":"47e16200-8710-405f-baf0-7078d147649f","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[4620,-900],"parameters":{"content":""},"typeVersion":1},{"id":"b81accf5-26f3-4e5b-8f27-81462cb20bd2","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[5320,-900],"parameters":{"content":""},"typeVersion":1},{"id":"d6fed6ec-a5fb-4e46-8cc7-90e9e75220d9","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[1340,20],"parameters":{"content":""},"typeVersion":1},{"id":"45189b23-8fa7-4993-907a-2475dcdb2d6e","name":"Apify Crawl Request","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[2240,100],"parameters":{},"typeVersion":4.2},{"id":"dd026984-588b-4cb0-a59e-81a8b78e26d9","name":"Process Apify Crawl","type":"n8n-nodes-base.nocoDb","onError":"continueRegularOutput","position":[2700,260],"parameters":{},"typeVersion":3},{"id":"7ca5e49d-6e9c-4717-a276-906079b69b62","name":"Mark as failed_to_process","type":"n8n-nodes-base.nocoDb","onError":"continueRegularOutput","position":[2400,220],"parameters":{},"typeVersion":3},{"id":"c7dd8f36-a045-45d2-9378-264556c1b71f","name":"Sticky Note10","type":"n8n-nodes-base.stickyNote","position":[240,-680],"parameters":{"content":""},"typeVersion":1},{"id":"46191283-6f1b-4f80-943c-a70a3a7e40d5","name":"Sticky Note11","type":"n8n-nodes-base.stickyNote","position":[780,-680],"parameters":{"content":""},"typeVersion":1},{"id":"fdbe2dd5-9f58-49fa-a583-461f6d2a2131","name":"Sticky Note12","type":"n8n-nodes-base.stickyNote","position":[880,220],"parameters":{"content":""},"typeVersion":1},{"id":"6997b63c-b4a4-4c5e-a60e-4f94b7d0c50c","name":"Sticky Note13","type":"n8n-nodes-base.stickyNote","position":[240,220],"parameters":{"content":""},"typeVersion":1},{"id":"c619c476-d1db-4274-9f69-a7721a69989a","name":"Sticky Note14","type":"n8n-nodes-base.stickyNote","position":[-1140,840],"parameters":{"content":""},"typeVersion":1},{"id":"e6834cb7-8def-419c-9b4a-955225b4a6cd","name":"Sticky Note15","type":"n8n-nodes-base.stickyNote","position":[-1140,960],"parameters":{"content":""},"typeVersion":1},{"id":"e4e4d68a-4b82-4814-84aa-93507ec03b71","name":"Sticky Note16","type":"n8n-nodes-base.stickyNote","position":[-160,-480],"parameters":{"content":""},"typeVersion":1},{"id":"086dadba-e5aa-4878-8db5-db31f133e16d","name":"Get Entered Leads From Crawl4AI","type":"n8n-nodes-base.nocoDb","position":[1400,-480],"parameters":{},"executeOnce":true,"typeVersion":3},{"id":"17deb25e-ad8e-46d7-aa96-461e0fa68147","name":"Get 'Entered' Leads From Apify","type":"n8n-nodes-base.nocoDb","position":[1380,80],"parameters":{},"executeOnce":true,"typeVersion":3},{"id":"13d17853-a3f8-4090-9092-e0f5ca3947bf","name":"Set Lead Status -> 'processed'","type":"n8n-nodes-base.nocoDb","onError":"continueRegularOutput","position":[2680,-220],"parameters":{},"typeVersion":3},{"id":"0e52decf-7492-46c2-9c93-6f3118da7f87","name":"Set Lead Status -> 'failed_to_process'","type":"n8n-nodes-base.nocoDb","onError":"continueRegularOutput","position":[2680,-500],"parameters":{},"typeVersion":3},{"id":"be068a81-5255-4c60-9de1-2c2f2f4e775b","name":"Loop over entered leads","type":"n8n-nodes-base.splitInBatches","onError":"continueRegularOutput","position":[1640,80],"parameters":{},"executeOnce":false,"typeVersion":3},{"id":"2c3351fc-e75f-4ca7-ae85-1d245ba1b127","name":"Loop Over Entered Leads Crawl4AI","type":"n8n-nodes-base.splitInBatches","onError":"continueRegularOutput","position":[1400,-260],"parameters":{},"executeOnce":false,"typeVersion":3},{"id":"fb062cba-8e2c-457f-98b8-8cb2365cfab6","name":"Fetch processed leads","type":"n8n-nodes-base.nocoDb","position":[3060,-60],"parameters":{},"executeOnce":true,"typeVersion":3},{"id":"6a665ba4-9613-48f3-b268-2cca0233c891","name":"Loop Over Processed Leads","type":"n8n-nodes-base.splitInBatches","onError":"continueRegularOutput","position":[3340,-200],"parameters":{},"executeOnce":false,"typeVersion":3},{"id":"7e71cf7a-46c4-44c7-a573-245af9fb6072","name":"Loop Over Leads For Scoring","type":"n8n-nodes-base.splitInBatches","position":[3280,400],"parameters":{},"retryOnFail":true,"typeVersion":3},{"id":"9000cd35-dc89-4a03-a3b8-d5691d89454e","name":"Fetch Leads With Created Emails","type":"n8n-nodes-base.nocoDb","position":[4500,-160],"parameters":{},"executeOnce":true,"typeVersion":3},{"id":"97ad2f49-dab9-4761-a43a-df21f75885d3","name":"Get by user email","type":"n8n-nodes-base.nocoDb","position":[4940,-820],"parameters":{},"typeVersion":3,"alwaysOutputData":false},{"id":"1f259b81-fbfe-4e51-9a84-18d5ee7158d5","name":"Sticky Note17","type":"n8n-nodes-base.stickyNote","position":[1340,-800],"parameters":{"content":""},"typeVersion":1},{"id":"da386568-de62-4de7-9499-8bf476b2d5c3","name":"Sticky Note18","type":"n8n-nodes-base.stickyNote","position":[1340,580],"parameters":{"content":""},"typeVersion":1},{"id":"ddd9a21a-bb09-44d2-8df5-8104a41c2e50","name":"If organization website exists Crawl4AI","type":"n8n-nodes-base.if","position":[1640,-260],"parameters":{},"typeVersion":2.2},{"id":"4acc6b9c-7767-4f45-8212-404b8a4a845b","name":"If organization website exists","type":"n8n-nodes-base.if","position":[1880,140],"parameters":{},"typeVersion":2.2},{"id":"0b33cb3d-ca9f-445a-8337-7d6ba7a70834","name":"Sticky Note19","type":"n8n-nodes-base.stickyNote","position":[3720,660],"parameters":{"content":""},"typeVersion":1},{"id":"7cd52266-8c9e-48dd-8fbe-6a9718d4a730","name":"Sticky Note20","type":"n8n-nodes-base.stickyNote","position":[3000,-540],"parameters":{"content":""},"typeVersion":1},{"id":"1a67fa60-a90c-4509-a34a-835dbf11f26d","name":"Sticky Note21","type":"n8n-nodes-base.stickyNote","position":[4420,340],"parameters":{"content":""},"typeVersion":1},{"id":"ee6dda9b-2598-468d-9806-318841e51b6b","name":"Sticky Note22","type":"n8n-nodes-base.stickyNote","position":[4620,-1100],"parameters":{"content":""},"typeVersion":1},{"id":"57d82b63-51c5-45c2-9352-cd7863f39506","name":"Email Unwanted","type":"n8n-nodes-base.sendInBlueTrigger","disabled":true,"position":[4720,-560],"webhookId":"f71be43b-84bd-40cb-bfc0-49253bd58a5e","parameters":{},"typeVersion":1},{"id":"266ac693-20a2-4681-bc9f-9afebbc20cb6","name":"Sticky Note23","type":"n8n-nodes-base.stickyNote","position":[-160,140],"parameters":{"content":""},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"c02ac938-5c46-4bc7-9ee9-d5d774ba8fa3","connections":{"Wait":{"main":[[{"node":"Crawl4AI resolve","type":"main","index":0}]]},"NocoDB":{"main":[[{"node":"Get 'Entered' Leads From Apify","type":"main","index":0}]]},"Crawl4AI":{"main":[[{"node":"Wait","type":"main","index":0}]]},"Ai Scoring":{"main":[[{"node":"Add a score","type":"main","index":0}]]},"Email Send":{"main":[[{"node":"Mark as contacted","type":"main","index":0}],[{"node":"Mark as Trash","type":"main","index":0}]]},"If pending":{"main":[[{"node":"Wait","type":"main","index":0}],[{"node":"If not success","type":"main","index":0}]]},"Add a score":{"main":[[{"node":"Loop Over Leads For Scoring","type":"main","index":0}]]},"Edit Fields":{"main":[[{"node":"NocoDB","type":"main","index":0}]]},"Email Opened":{"main":[[{"node":"Get by user email","type":"main","index":0}]]},"Get by email":{"main":[[{"node":"Lead Status -> Trash","type":"main","index":0}]]},"If not scored":{"main":[[{"node":"Loop Over Leads For Scoring","type":"main","index":0}],[{"node":"Ai Scoring","type":"main","index":0}]]},"Mark as Trash":{"main":[[{"node":"Personalized Mail Loop","type":"main","index":0}]]},"Create Contact":{"main":[[{"node":"Email Send","type":"main","index":0}],[{"node":"Email Exists -> Mark as Contacted","type":"main","index":0}]]},"Email Unwanted":{"main":[[{"node":"Delete Contact In Brevo","type":"main","index":0}]]},"If not success":{"main":[[{"node":"Set Lead Status -> 'failed_to_process'","type":"main","index":0}],[{"node":"Set Lead Status -> 'processed'","type":"main","index":0}]]},"Crawl4AI resolve":{"main":[[{"node":"If pending","type":"main","index":0}],[{"node":"Set Lead Status -> 'failed_to_process'","type":"main","index":0}]]},"Get by user email":{"main":[[{"node":"Lead Status -> Email Opened","type":"main","index":0}]]},"Mark as contacted":{"main":[[{"node":"Personalized Mail Loop","type":"main","index":0}]]},"Apify Crawl Request":{"main":[[{"node":"Process Apify Crawl","type":"main","index":0}],[{"node":"Mark as failed_to_process","type":"main","index":0}]]},"If mail not created":{"main":[[{"node":"Email Personalization","type":"main","index":0}],[{"node":"Loop Over Processed Leads","type":"main","index":0}]]},"Process Apify Crawl":{"main":[[{"node":"Loop over entered leads","type":"main","index":0}]]},"Add Personalized mail":{"main":[[{"node":"Loop Over Processed Leads","type":"main","index":0}]]},"Email Personalization":{"main":[[{"node":"Add Personalized mail","type":"main","index":0}],[{"node":"Loop Over Processed Leads","type":"main","index":0}]]},"Fetch processed leads":{"main":[[{"node":"Loop Over Processed Leads","type":"main","index":0}]]},"Personalized Mail Loop":{"main":[[],[{"node":"If not contacted and email created","type":"main","index":0}]]},"Delete Contact In Brevo":{"main":[[{"node":"Get by email","type":"main","index":0}]]},"Loop over entered leads":{"main":[[{"node":"Fetch data to prepare for scoring","type":"main","index":0}],[{"node":"If organization website exists","type":"main","index":0}]]},"Scrape Leads From Apollo":{"main":[[{"node":"Filter leads without email","type":"main","index":0}]]},"Loop Over Processed Leads":{"main":[[{"node":"Fetch Leads With Created Emails","type":"main","index":0}],[{"node":"If mail not created","type":"main","index":0}]]},"Mark as failed_to_process":{"main":[[{"node":"Loop over entered leads","type":"main","index":0}]]},"Filter leads without email":{"main":[[{"node":"Edit Fields","type":"main","index":0}],[]]},"Lead Status -> Email Opened":{"main":[[{"node":"If Email Opened More Than Once","type":"main","index":0}]]},"Loop Over Leads For Scoring":{"main":[[{"node":"Fetch processed leads","type":"main","index":0}],[{"node":"If not scored","type":"main","index":0}]]},"Get 'Entered' Leads From Apify":{"main":[[{"node":"Loop over entered leads","type":"main","index":0}]]},"If Email Opened More Than Once":{"main":[[{"node":"Lead Status -> Warm","type":"main","index":0}]]},"If organization website exists":{"main":[[{"node":"Apify Crawl Request","type":"main","index":0}],[{"node":"Mark as failed_to_process","type":"main","index":0}]]},"Set Lead Status -> 'processed'":{"main":[[{"node":"Loop Over Entered Leads Crawl4AI","type":"main","index":0}],[]]},"Fetch Leads With Created Emails":{"main":[[{"node":"Personalized Mail Loop","type":"main","index":0}]]},"Get Entered Leads From Crawl4AI":{"main":[[{"node":"Loop Over Entered Leads Crawl4AI","type":"main","index":0}]]},"Loop Over Entered Leads Crawl4AI":{"main":[[],[{"node":"If organization website exists Crawl4AI","type":"main","index":0}]]},"Email Exists -> Mark as Contacted":{"main":[[{"node":"Personalized Mail Loop","type":"main","index":0}]]},"Fetch data to prepare for scoring":{"main":[[{"node":"Loop Over Leads For Scoring","type":"main","index":0}]]},"When clicking ‘Test workflow’":{"main":[[{"node":"Scrape Leads From Apollo","type":"main","index":0}]]},"If not contacted and email created":{"main":[[{"node":"Create Contact","type":"main","index":0}],[{"node":"Personalized Mail Loop","type":"main","index":0}]]},"Set Lead Status -> 'failed_to_process'":{"main":[[{"node":"Loop Over Entered Leads Crawl4AI","type":"main","index":0}],[]]},"If organization website exists Crawl4AI":{"main":[[{"node":"Crawl4AI","type":"main","index":0}],[{"node":"Loop Over Entered Leads Crawl4AI","type":"main","index":0}]]}}}


name: AI-Powered Employee Database Management via Telegram using OpenAI and Airtable
author_name: Billy Christi
author_username: billy
categories: []
created_at: 2025-06-01T02:01:03.787Z
updated_at: 2025-06-01T02:01:03.787Z
url: https://n8n.io/workflows/4545
scraped_at: 2025-07-06 21:16:30
description:
  Who is this for?

  This workflow is perfect for:

  HR professionals** seeking to automate employee and department management
  Startups and SMBs** that want an AI-powered HR assistant on Telegram
  Internal operations teams** that want to simplify onboarding and employee data tracking

  What problem is this workflow solving?

  Managing employee databases manually is error-prone and inefficient—especially for growing teams. This workflow solves that by:

  Enabling natural language-based HR operations directly through Telegram
  Automating the creation, retrieval, and deletion of employee records in Airtable
  Dynamically managing related data such as departments and job titles
  Handling data consistency and linking across relational tables automatically
  Providing a conversational interface backed by OpenAI for smart decision-making

  What this workflow does

  Using Telegram as the interface and Airtable as the backend database, this intelligent HR workflow allows users to:

  Chat in natural language (e.g. “Show me all employees” or “Create employee: Sarah, Marketing…”)
  Interpret and route requests via an AI Agent that acts as the orchestrator
  Query employee, department, and job title data from Airtable
  Create or update records as needed:

     Add new departments and job titles automatically if they don’t exist
     Create new employees and link them to the correct department and job title
  Delete employees based on ID
  Respond directly in Telegram, providing user-friendly feedback

  Setup
  View & Copy the Airtable base here:
     👉 Employee Database Management – Airtable Base Template

  Telegram Bot: Set up a Telegram bot and connect it to the Telegram Trigger node

  Airtable: Prepare three Airtable tables:

     Employees with links to Departments and Job Titles
     Departments with Name & Description
     Job Titles with Title & Description

  Connect your Airtable API key and base/table IDs into the appropriate Airtable nodes

  Add your OpenAI API key to the AI Agent nodes

  Deploy both workflows: the main chatbot workflow and the employee creation sub-workflow

  Test with sample messages like:

     “Create employee: John Doe, john@company.com, Engineering, Software Engineer”
     “Remove employee ID rec123xyz”

  How to customize this workflow to your needs

  Switch databases**: Replace Airtable with Notion, PostgreSQL, or Google Sheets if desired
  Enhance security**: Add authentication and validation before allowing deletion
  Add approval flows**: Integrate Telegram button-based approvals for sensitive actions
  Multi-language support**: Expand system prompts to support multiple languages
  Add logging**: Store every user action in a log table for auditability
  Expand capabilities**: Integrate payroll, time tracking, or Slack notifications

  Extra Tips

  This is a two-workflow setup. Make sure the sub-workflow is deployed and accessible from the main agent.
  Use Simple Memory per chat ID to preserve context across user queries.
  You can expand the orchestration logic by adding more tools to the main agent—such as “Get active employees only” or “List employees by job title.”

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

workflow_json:
  {"meta":{"instanceId":"d1786ab0d745a7498abf13a9c2cdabb1374c006e889b79eef64ce0386b8f8a41","templateCredsSetupCompleted":true},"nodes":[{"id":"da4fe281-3ee8-4fdf-a779-6bea354b4e57","name":"Telegram Trigger","type":"n8n-nodes-base.telegramTrigger","position":[2560,-140],"webhookId":"5971294c-ab28-481a-83b5-efa64d93554f","parameters":{"updates":["message"],"additionalFields":{}},"credentials":{"telegramApi":{"id":"HtvibSVWl4VexYu9","name":"Employee Database Management"}},"typeVersion":1.2},{"id":"a18dec81-5bfa-496b-a06a-f150fa4c1fd8","name":"Create Employee AI Agent tool","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[2220,460],"parameters":{"workflowId":{"__rl":true,"mode":"list","value":"uOrbNX2DcYJ0iAyv","cachedResultName":"employee database management"},"description":"Create Employee AI Agent tool\nCall this tool if user requested to create new employee","workflowInputs":{"value":{"query":"={{ $json.message.text }}","action":"=create"},"schema":[{"id":"query","type":"string","display":true,"removed":false,"required":false,"displayName":"query","defaultMatch":false,"canBeUsedToMatch":true},{"id":"action","type":"string","display":true,"removed":false,"required":false,"displayName":"action","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":["query"],"attemptToConvertTypes":false,"convertFieldsToString":false}},"typeVersion":2.2},{"id":"c7c6e0c7-204f-497b-95d7-662789a5b9d2","name":"Get departments data from airtable tool","type":"n8n-nodes-base.airtableTool","position":[2700,460],"parameters":{"base":{"__rl":true,"mode":"list","value":"appgVjZcaRP8BsKf0","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0","cachedResultName":"HR Database"},"table":{"__rl":true,"mode":"list","value":"tblB0xec7TL36pDgC","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0/tblB0xec7TL36pDgC","cachedResultName":"Departments"},"options":{"fields":["Department Name","Department Description"]},"operation":"search","descriptionType":"manual","filterByFormula":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Filter_By_Formula', ``, 'string') }}","toolDescription":"Get departments data from airtable tool"},"credentials":{"airtableTokenApi":{"id":"r2IibdsQurA56LDa","name":"Airtable Personal Access Token account"}},"typeVersion":2.1},{"id":"5640ff19-445a-479a-b3ed-94e5227f2d6c","name":"Get job titles data from airtable tool","type":"n8n-nodes-base.airtableTool","position":[2860,460],"parameters":{"base":{"__rl":true,"mode":"list","value":"appgVjZcaRP8BsKf0","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0","cachedResultName":"HR Database"},"table":{"__rl":true,"mode":"list","value":"tblnyWkG6BTpxjMzo","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0/tblnyWkG6BTpxjMzo","cachedResultName":"Job Titles"},"options":{"fields":["Job Title","Job Description"]},"operation":"search","descriptionType":"manual","filterByFormula":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Filter_By_Formula', ``, 'string') }}","toolDescription":"Get job titles data from airtable tool"},"credentials":{"airtableTokenApi":{"id":"r2IibdsQurA56LDa","name":"Airtable Personal Access Token account"}},"typeVersion":2.1},{"id":"c07f0aff-6088-44ad-bc64-a95e8b373355","name":"Get employees data from airtable tool","type":"n8n-nodes-base.airtableTool","position":[3020,460],"parameters":{"base":{"__rl":true,"mode":"list","value":"appgVjZcaRP8BsKf0","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0","cachedResultName":"HR Database"},"table":{"__rl":true,"mode":"list","value":"tblGIVbpACRwWzzlp","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0/tblGIVbpACRwWzzlp","cachedResultName":"Employees"},"options":{"fields":["Full Name","Email","Phone Number","Job Title (from Job Titles)","Reports To (from Employees)","Department Name (from Department)","Employee Status"]},"operation":"search","descriptionType":"manual","filterByFormula":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Filter_By_Formula', ``, 'string') }}","toolDescription":"Get employees data from airtable tool"},"credentials":{"airtableTokenApi":{"id":"r2IibdsQurA56LDa","name":"Airtable Personal Access Token account"}},"typeVersion":2.1},{"id":"7963abbb-c1f6-43a6-94d3-4329c172aa54","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[2200,100],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"MGwGMKEkdcjzlYCw","name":"OpenAi account"}},"typeVersion":1.2},{"id":"67eb142c-b53f-4449-b0b3-3af300f3f546","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[2240,240],"parameters":{"sessionKey":"={{ $json.message.chat.id }}","sessionIdType":"customKey"},"typeVersion":1.3},{"id":"7d9a4fdd-09a9-4a87-b661-26a87287ce5e","name":"Send Message to User","type":"n8n-nodes-base.telegram","position":[2860,120],"webhookId":"507c9446-fd78-4695-8dd2-7c348390a4db","parameters":{"text":"={{ $json.output }}","chatId":"={{ $('Telegram Trigger').item.json.message.chat.id }}","additionalFields":{"appendAttribution":false}},"credentials":{"telegramApi":{"id":"HtvibSVWl4VexYu9","name":"Employee Database Management"}},"typeVersion":1.2},{"id":"4e9b295d-8fc4-4e8c-8f07-47301dd8d42a","name":"Create Department Tool","type":"n8n-nodes-base.airtableTool","position":[2380,460],"parameters":{"base":{"__rl":true,"mode":"list","value":"appgVjZcaRP8BsKf0","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0","cachedResultName":"HR Database"},"table":{"__rl":true,"mode":"list","value":"tblB0xec7TL36pDgC","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0/tblB0xec7TL36pDgC","cachedResultName":"Departments"},"columns":{"value":{"Department Name":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Department_Name', ``, 'string') }}","Department Description":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Department_Description', ``, 'string') }}"},"schema":[{"id":"Department Name","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Department Name","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Department Description","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Department Description","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Department Head","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Department Head","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Job Titles","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Job Titles","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Employees","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Employees","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":["Department Name"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{"typecast":true},"operation":"create","descriptionType":"manual","toolDescription":"Create department tool"},"credentials":{"airtableTokenApi":{"id":"r2IibdsQurA56LDa","name":"Airtable Personal Access Token account"}},"typeVersion":2.1},{"id":"b8f74f5f-74ad-4bd6-9f96-309184331a2b","name":"Create Job Title Tool","type":"n8n-nodes-base.airtableTool","position":[2540,460],"parameters":{"base":{"__rl":true,"mode":"list","value":"appgVjZcaRP8BsKf0","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0","cachedResultName":"HR Database"},"table":{"__rl":true,"mode":"list","value":"tblnyWkG6BTpxjMzo","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0/tblnyWkG6BTpxjMzo","cachedResultName":"Job Titles"},"columns":{"value":{"Job Title":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Job_Title', ``, 'string') }}","Job Description":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Job_Description', ``, 'string') }}"},"schema":[{"id":"Job Title","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Job Title","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Job Description","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Job Description","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Department associated with the job title","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Department associated with the job title","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Employees","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Employees","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":["Job Title"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{"typecast":true},"operation":"create","descriptionType":"manual","toolDescription":"Create job title tool"},"credentials":{"airtableTokenApi":{"id":"r2IibdsQurA56LDa","name":"Airtable Personal Access Token account"}},"typeVersion":2.1},{"id":"d9ad68a2-67ac-4a5a-96bd-3ae41965b888","name":"Delete employee tool","type":"n8n-nodes-base.airtableTool","position":[3200,460],"parameters":{"id":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Record_ID', ``, 'string') }}","base":{"__rl":true,"mode":"list","value":"appgVjZcaRP8BsKf0","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0","cachedResultName":"HR Database"},"table":{"__rl":true,"mode":"list","value":"tblGIVbpACRwWzzlp","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0/tblGIVbpACRwWzzlp","cachedResultName":"Employees"},"operation":"deleteRecord","descriptionType":"manual","toolDescription":"Delete employee tool"},"credentials":{"airtableTokenApi":{"id":"r2IibdsQurA56LDa","name":"Airtable Personal Access Token account"}},"typeVersion":2.1},{"id":"c53da289-17e0-4699-9465-a9aaebc84d8a","name":"Employee Management AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[2460,120],"parameters":{"text":"=User Request:\n{{ $json.message.text }}","options":{"systemMessage":"=You are employee database management specialist\n\nCall the right tools based on the request:\n\n//\nUser wants to create new employee:\ncall Create Employee AI Agent tool\n//\n\n//\nUser wants to delete:\nPass the employee id to Delete employee tool\nrun Delete employee tool\n//\n\n//\nUser wants to create department data:\ncall \"Create department tool\"\n//\n\n//\nUser wants to create job title data:\ncall \"Create Job Title tool\"\n//\n\n//\nUser wants get department data:\ncall Get departments data from airtable tool\n//\n\n//\nUser wants get employee data:\ncall Get employees data from airtable tool\n//\n\nImportant notes:\nOnly call 1 tool max, choose the most suitable tool\nFor getting data, no need to output the airtable id, example for getting department data => show only name and description (without id)"},"promptType":"define"},"typeVersion":1.9},{"id":"8a1d71c3-b9b8-4d73-b96d-962d569fc97f","name":"Get departments data from airtable","type":"n8n-nodes-base.airtableTool","position":[2480,1020],"parameters":{"base":{"__rl":true,"mode":"list","value":"appgVjZcaRP8BsKf0","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0","cachedResultName":"HR Database"},"limit":1,"table":{"__rl":true,"mode":"list","value":"tblB0xec7TL36pDgC","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0/tblB0xec7TL36pDgC","cachedResultName":"Departments"},"options":{},"operation":"search","returnAll":false,"descriptionType":"manual","filterByFormula":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Filter_By_Formula', ``, 'string') }}","toolDescription":"Get departments data from airtable"},"credentials":{"airtableTokenApi":{"id":"r2IibdsQurA56LDa","name":"Airtable Personal Access Token account"}},"typeVersion":2.1},{"id":"c6f20c6b-56c0-43e9-81ec-ae62d40791ed","name":"Get job titles data from airtable","type":"n8n-nodes-base.airtableTool","position":[2640,1020],"parameters":{"base":{"__rl":true,"mode":"list","value":"appgVjZcaRP8BsKf0","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0","cachedResultName":"HR Database"},"limit":1,"table":{"__rl":true,"mode":"list","value":"tblnyWkG6BTpxjMzo","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0/tblnyWkG6BTpxjMzo","cachedResultName":"Job Titles"},"options":{},"operation":"search","returnAll":false,"descriptionType":"manual","filterByFormula":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Filter_By_Formula', ``, 'string') }}","toolDescription":"Get job titles data from airtable"},"credentials":{"airtableTokenApi":{"id":"r2IibdsQurA56LDa","name":"Airtable Personal Access Token account"}},"typeVersion":2.1},{"id":"a8e4f533-aa7a-4bd9-bb25-d7f8f1c2c0a2","name":"Create Employee AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[2540,660],"parameters":{"text":"=User message:\n{{ $json.query }}","options":{"systemMessage":"=```\nYou are an airtable database management agent\n\nthe exact column name on airtable is:\nDepartment name\nJob title\n\ndont use any other name combination like underscore\n\nfirst check if {Department name} and {job title} exist\n\nif department name and job title doesnt exist:\ncreate new department and job title then output the airtable id\nif end\n\nif department name and job title exist:\noutput the department and job title existing airtable id\nif end\n\nCall the create employee tools and pass the job_title_id and department_id\n\nOutput in json format:\n{\n  \"department_id\":\"recxxxxxxx\",\n  \"job_title_id\":\"recxxxxxxx\",\n  \"new_employee_id\": \"recxxxxxxx\"\n}\n\n\n```\n"},"promptType":"define","hasOutputParser":true},"typeVersion":1.9},{"id":"3ce2ac45-4b98-44df-89e1-428aab71aaef","name":"When Executed by Another Workflow","type":"n8n-nodes-base.executeWorkflowTrigger","position":[2300,660],"parameters":{"inputSource":"jsonExample","jsonExample":"{\n  \"query\":\"test\",\n  \"action\":\"create\"\n}"},"typeVersion":1.1},{"id":"e842e97e-82e6-451e-af41-b93b3cff9076","name":"Structured Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[3280,1020],"parameters":{"jsonSchemaExample":"{\n  \"department_id\":\"recxxxxxxx\",\n  \"job_title_id\":\"recxxxxxxx\",\n  \"new_employee_id\": \"recxxxxxxx\"\n}"},"typeVersion":1.2},{"id":"1ce2b5e1-2abf-4a19-9439-2972386300e5","name":"Create Department","type":"n8n-nodes-base.airtableTool","position":[2800,1020],"parameters":{"base":{"__rl":true,"mode":"list","value":"appgVjZcaRP8BsKf0","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0","cachedResultName":"HR Database"},"table":{"__rl":true,"mode":"list","value":"tblB0xec7TL36pDgC","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0/tblB0xec7TL36pDgC","cachedResultName":"Departments"},"columns":{"value":{"Department Name":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Department_Name', ``, 'string') }}","Department Description":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Department_Description', ``, 'string') }}"},"schema":[{"id":"Department Name","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Department Name","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Department Description","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Department Description","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Department Head","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Department Head","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Job Titles","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Job Titles","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Employees","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Employees","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{"typecast":true},"operation":"create","descriptionType":"manual","toolDescription":"Create department"},"credentials":{"airtableTokenApi":{"id":"r2IibdsQurA56LDa","name":"Airtable Personal Access Token account"}},"typeVersion":2.1},{"id":"03f4d2f2-2746-4c5c-ab4c-91a5293022d3","name":"Create Job Title","type":"n8n-nodes-base.airtableTool","position":[2960,1020],"parameters":{"base":{"__rl":true,"mode":"list","value":"appgVjZcaRP8BsKf0","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0","cachedResultName":"HR Database"},"table":{"__rl":true,"mode":"list","value":"tblnyWkG6BTpxjMzo","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0/tblnyWkG6BTpxjMzo","cachedResultName":"Job Titles"},"columns":{"value":{"Job Title":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Job_Title', ``, 'string') }}","Job Description":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Job_Description', ``, 'string') }}"},"schema":[{"id":"Job Title","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Job Title","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Job Description","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Job Description","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Department associated with the job title","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Department associated with the job title","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Employees","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Employees","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{"typecast":true},"operation":"create","descriptionType":"manual","toolDescription":"Create job title"},"credentials":{"airtableTokenApi":{"id":"r2IibdsQurA56LDa","name":"Airtable Personal Access Token account"}},"typeVersion":2.1},{"id":"cba162ce-c8b2-4e75-bff2-f663248b6147","name":"Create employee","type":"n8n-nodes-base.airtableTool","position":[3120,1020],"parameters":{"base":{"__rl":true,"mode":"list","value":"appgVjZcaRP8BsKf0","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0","cachedResultName":"HR Database"},"table":{"__rl":true,"mode":"list","value":"tblGIVbpACRwWzzlp","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0/tblGIVbpACRwWzzlp","cachedResultName":"Employees"},"columns":{"value":{"Email":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Email', ``, 'string') }}","Full Name":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Full_Name', ``, 'string') }}","Phone Number":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Phone_Number', ``, 'string') }}","job_title_id":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('job_title_id', ``, 'string') }}","department_id":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('department_id', ``, 'string') }}","Employee Status":"Active"},"schema":[{"id":"Full Name","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Full Name","defaultMatch":false,"canBeUsedToMatch":true},{"id":"id","type":"string","display":true,"removed":false,"readOnly":true,"required":false,"displayName":"id","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Email","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Email","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Phone Number","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Phone Number","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Job Title","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Job Title","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Employee Type","type":"options","display":true,"options":[{"name":"Employee","value":"Employee"},{"name":"Manager","value":"Manager"}],"removed":true,"readOnly":false,"required":false,"displayName":"Employee Type","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Reports To","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Reports To","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Job Title (from Job Titles)","type":"string","display":true,"removed":true,"readOnly":true,"required":false,"displayName":"Job Title (from Job Titles)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Reports To (from Employees)","type":"string","display":true,"removed":true,"readOnly":true,"required":false,"displayName":"Reports To (from Employees)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Department","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Department","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Department Name (from Department)","type":"string","display":true,"removed":true,"readOnly":true,"required":false,"displayName":"Department Name (from Department)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Employee Type Text","type":"string","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Employee Type Text","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Employee Status","type":"options","display":true,"options":[{"name":"Active","value":"Active"},{"name":"On Leave","value":"On Leave"},{"name":"Inactive","value":"Inactive"}],"removed":false,"readOnly":false,"required":false,"displayName":"Employee Status","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_title_id","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"job_title_id","defaultMatch":false,"canBeUsedToMatch":true},{"id":"department_id","type":"string","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"department_id","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Head of Department","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Head of Department","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{"typecast":true},"operation":"create","descriptionType":"manual","toolDescription":"Create employee"},"credentials":{"airtableTokenApi":{"id":"r2IibdsQurA56LDa","name":"Airtable Personal Access Token account"}},"typeVersion":2.1},{"id":"0539ead3-9b8b-49be-aab9-b8c2e256fd83","name":"Update Employee Data","type":"n8n-nodes-base.airtable","position":[2920,660],"parameters":{"base":{"__rl":true,"mode":"list","value":"appgVjZcaRP8BsKf0","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0","cachedResultName":"HR Database"},"table":{"__rl":true,"mode":"list","value":"tblGIVbpACRwWzzlp","cachedResultUrl":"https://airtable.com/appgVjZcaRP8BsKf0/tblGIVbpACRwWzzlp","cachedResultName":"Employees"},"columns":{"value":{"id":"={{ $json.output.new_employee_id }}","Job Title":"=[\"{{ $json.output.job_title_id }}\"]","Department":"=[\"{{ $json.output.department_id }}\"]"},"schema":[{"id":"id","type":"string","display":true,"removed":false,"readOnly":true,"required":false,"displayName":"id","defaultMatch":true},{"id":"Full Name","type":"string","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Full Name","defaultMatch":false,"canBeUsedToMatch":true},{"id":"id","type":"string","display":true,"removed":false,"readOnly":true,"required":false,"displayName":"id","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Email","type":"string","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Email","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Phone Number","type":"string","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Phone Number","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Job Title","type":"array","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Job Title","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Employee Type","type":"options","display":true,"options":[{"name":"Employee","value":"Employee"},{"name":"Manager","value":"Manager"}],"removed":true,"readOnly":false,"required":false,"displayName":"Employee Type","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Reports To","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Reports To","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Job Title (from Job Titles)","type":"string","display":true,"removed":true,"readOnly":true,"required":false,"displayName":"Job Title (from Job Titles)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Reports To (from Employees)","type":"string","display":true,"removed":true,"readOnly":true,"required":false,"displayName":"Reports To (from Employees)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Department","type":"array","display":true,"removed":false,"readOnly":false,"required":false,"displayName":"Department","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Department Name (from Department)","type":"string","display":true,"removed":true,"readOnly":true,"required":false,"displayName":"Department Name (from Department)","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Employee Type Text","type":"string","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Employee Type Text","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Employee Status","type":"options","display":true,"options":[{"name":"Active","value":"Active"},{"name":"On Leave","value":"On Leave"},{"name":"Inactive","value":"Inactive"}],"removed":true,"readOnly":false,"required":false,"displayName":"Employee Status","defaultMatch":false,"canBeUsedToMatch":true},{"id":"job_title_id","type":"string","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"job_title_id","defaultMatch":false,"canBeUsedToMatch":true},{"id":"department_id","type":"string","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"department_id","defaultMatch":false,"canBeUsedToMatch":true},{"id":"Head of Department","type":"array","display":true,"removed":true,"readOnly":false,"required":false,"displayName":"Head of Department","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":["id"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"update"},"credentials":{"airtableTokenApi":{"id":"r2IibdsQurA56LDa","name":"Airtable Personal Access Token account"}},"typeVersion":2.1},{"id":"0ad8d7cc-7fd7-4aef-a91c-434dc467fa8e","name":"OpenAI Chat Model1","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[2320,1020],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"MGwGMKEkdcjzlYCw","name":"OpenAi account"}},"typeVersion":1.2},{"id":"4131e553-62e8-457f-b04c-45182b0bd7b2","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[1960,-500],"parameters":{"color":5,"width":460,"height":460,"content":"## 🤖 AI-Powered Employee Database Management via Telegram using OpenAI and Airtable\n\n**What This Template Does:**\n- Provides an HR assistant chatbot interface through Telegram\n- Uses GPT-4 to interpret natural language requests (e.g., “Show me all employees” or “Create employee Sarah…”)\n- Performs Airtable operations to manage Employees, Departments, and Job Titles\n- Supports dynamic record creation and linking (e.g., if department doesn't exist, it will be created)\n- Maintains conversation memory per Telegram chat for smooth back-and-forth interaction\n- Splits logic into a main router workflow and a sub-workflow for employee creation"},"typeVersion":1},{"id":"f61c6914-98ea-481e-a189-f43ab0e03734","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[2800,-500],"parameters":{"color":5,"width":500,"height":460,"content":"## 📋 WORKFLOW PROCESS OVERVIEW  \nStep 1: 💬 Telegram Trigger receives natural language command from HR user  \nStep 2: 🧠 AI Agent (OpenA) interprets intent (view, create, delete, etc.)  \nStep 3: 🔀 Router decides workflow path based on user intent  \nStep 4: 📄 Get Employees fetches employee records from Airtable (if viewing)  \nStep 5: 🛠️ Create Employee Tool triggers sub-workflow for new employee creation  \nStep 6: 🏢 Create/Find Department checks Airtable for department or creates it  \nStep 7: 👔 Create/Find Job Title checks Airtable for job title or creates it  \nStep 8: 💾 Create Employee saves employee record in Airtable with linked fields  \nStep 9: 🗑️ Delete Employee removes employee record by ID (if requested)  \nStep 10: 🔁 Return Response sends formatted reply back to Telegram user\n"},"typeVersion":1},{"id":"48e9996d-ff56-410f-9957-68805ccd677f","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[2480,-500],"parameters":{"color":4,"width":280,"height":320,"content":"## SETUP REQUIRED  \n**Author:** [Billy Christi](https://n8n.io/creators/billy/)\n\nAirtable Base Structure:  \n[Copy this Airtable Base](https://airtable.com/appgVjZcaRP8BsKf0/shrQAqQ2JUW50EEyW)\n\nRequired Credentials:  \n• Airtable API Key  \n• OpenAI API Key\n• Telegram Bot Token\n"},"typeVersion":1}],"pinData":{"When Executed by Another Workflow":[{"query":"Create employee records using this data:\n- Full name: Jack123 new 123\n- Email: jackbower@gmail.com\n- Phone: +12125551212\n- Department: Engineering\n- Job Title: AI Automation Developer","action":"create"}]},"connections":{"Simple Memory":{"ai_memory":[[{"node":"Employee Management AI Agent","type":"ai_memory","index":0}]]},"Create employee":{"ai_tool":[[{"node":"Create Employee AI Agent","type":"ai_tool","index":0}]]},"Create Job Title":{"ai_tool":[[{"node":"Create Employee AI Agent","type":"ai_tool","index":0}]]},"Telegram Trigger":{"main":[[{"node":"Employee Management AI Agent","type":"main","index":0}]]},"Create Department":{"ai_tool":[[{"node":"Create Employee AI Agent","type":"ai_tool","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"Employee Management AI Agent","type":"ai_languageModel","index":0}]]},"OpenAI Chat Model1":{"ai_languageModel":[[{"node":"Create Employee AI Agent","type":"ai_languageModel","index":0}]]},"Delete employee tool":{"ai_tool":[[{"node":"Employee Management AI Agent","type":"ai_tool","index":0}]]},"Create Job Title Tool":{"ai_tool":[[{"node":"Employee Management AI Agent","type":"ai_tool","index":0}]]},"Create Department Tool":{"ai_tool":[[{"node":"Employee Management AI Agent","type":"ai_tool","index":0}]]},"Create Employee AI Agent":{"main":[[{"node":"Update Employee Data","type":"main","index":0}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"Create Employee AI Agent","type":"ai_outputParser","index":0}]]},"Employee Management AI Agent":{"main":[[{"node":"Send Message to User","type":"main","index":0}]]},"Create Employee AI Agent tool":{"ai_tool":[[{"node":"Employee Management AI Agent","type":"ai_tool","index":0}]]},"Get job titles data from airtable":{"ai_tool":[[{"node":"Create Employee AI Agent","type":"ai_tool","index":0}]]},"When Executed by Another Workflow":{"main":[[{"node":"Create Employee AI Agent","type":"main","index":0}]]},"Get departments data from airtable":{"ai_tool":[[{"node":"Create Employee AI Agent","type":"ai_tool","index":0}]]},"Get employees data from airtable tool":{"ai_tool":[[{"node":"Employee Management AI Agent","type":"ai_tool","index":0}]]},"Get job titles data from airtable tool":{"ai_tool":[[{"node":"Employee Management AI Agent","type":"ai_tool","index":0}]]},"Get departments data from airtable tool":{"ai_tool":[[{"node":"Employee Management AI Agent","type":"ai_tool","index":0}]]}}}


name: AI-Powered RAG Document Processing & Chatbot with Google Drive, Supabase, OpenAI
author_name: Billy Christi
author_username: billy
categories: []
created_at: 2025-06-01T06:44:01.484Z
updated_at: 2025-06-01T06:44:01.484Z
url: https://n8n.io/workflows/4551
scraped_at: 2025-07-06 21:16:30
description:
  Who is this for?

  This workflow is perfect for:

  Businesses and teams who need an automated solution to organize, analyze, and retrieve insights from their internal documents.
  Researchers who want to quickly analyze and query large collections of research papers, reports, or datasets.
  Customer support teams looking to streamline access to product documentation and support resources.
  Legal and compliance professionals needing to reference and query legal documents with confidence.
  AI enthusiasts and developers wanting to implement Retrieval-Augmented Generation (RAG) systems without starting from scratch.

  What problem is this workflow solving?

  Manually organizing, processing, and searching through documents can be time-consuming, error-prone, and inefficient. This workflow solves that by:

  Automating document processing** from Google Drive, supporting multiple formats like PDFs, CSVs, and Google Docs.
  Extracting, chunking, and enhancing document text**, preserving context and improving AI comprehension.
  Storing vector embeddings** in a secure, scalable Supabase vector database, enabling semantic search and retrieval.
  Providing an interactive AI chat interface** that allows users to ask natural language questions and get precise, document-based answers.

  This means teams can quickly access relevant insights from their document repositories—boosting productivity and ensuring accurate information retrieval.

  Key Features

  🚀 End-to-End Document Processing: From Google Drive upload detection to vector embedding and storage.
  🔍 Semantic Search & Retrieval: Users can ask complex, natural-language questions and receive contextually relevant answers.
  🤖 AI-Powered Summaries & Metadata: Automatically generates document titles and summaries using Google Gemini AI.
  📝 Smart Chunking & Contextual Enhancement: Breaks documents into smart chunks with overlap, preserving context and table integrity.
  🔐 Secure & Scalable Vector Database: Stores and retrieves embeddings in a Supabase vector store for fast, reliable searches.
  💬 Conversational AI Interface: Uses OpenAI to power natural, accurate, and cost-effective AI chat interactions.

  How does this workflow work?

  Monitors Google Drive for new files
  Extracts text from PDFs and CSVs (or Google Docs auto-converted)
  Splits text into context-preserving chunks
  Enhances chunk quality and stores embeddings in Supabase
  Enables natural language search and AI-powered chat interactions with the stored documents

  Typical Use Cases

  📚 Corporate Knowledge Base
  🔬 Research Paper Analysis
  📞 Customer Support Document Query
  ⚖️ Legal Document Review and Analysis
  🔍 Internal Team Documentation Search

  Why You’ll Love It

  This workflow lets you build a scalable, searchable, and AI-powered document system—without needing to write complex code or manage multiple systems. With this, you can:

  Stay organized with automated document processing.
  Deliver faster, more accurate answers to user queries.
  Reduce manual work and improve productivity.
  Gain a competitive edge with cutting-edge AI search capabilities.

  Setup Requirements

  An n8n instance with Google Drive, Supabase, OpenAI, and Gemini credentials configured.
  Access to a Supabase vector store for storing document embeddings.
  Configurable chunk size, overlap, and processing limits (default: 1000 characters per chunk, 20 chunks max).

nodes_used:
  ["n8n-nodes-base.googleDrive","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.memoryBufferWindow","@n8n/n8n-nodes-langchain.outputParserStructured","@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter","@n8n/n8n-nodes-langchain.vectorStoreSupabase","@n8n/n8n-nodes-langchain.documentDefaultDataLoader","@n8n/n8n-nodes-langchain.lmChatGoogleGemini"]

workflow_json:
  {"meta":{"instanceId":"d1786ab0d745a7498abf13a9c2cdabb1374c006e889b79eef64ce0386b8f8a41","templateCredsSetupCompleted":true},"nodes":[{"id":"f13af0a4-02e8-41b4-9ad8-55443604f031","name":"Loop Over Items","type":"n8n-nodes-base.splitInBatches","position":[540,-80],"parameters":{"options":{}},"typeVersion":3},{"id":"3a3a9bee-fd2c-48fb-a946-850bdd574b21","name":"Extract from PDF","type":"n8n-nodes-base.extractFromFile","position":[1720,-120],"parameters":{"options":{},"operation":"pdf"},"typeVersion":1},{"id":"42a44446-4cd9-4b8f-bcc8-dc912954e515","name":"Extract from CSV","type":"n8n-nodes-base.extractFromFile","position":[1720,80],"parameters":{"options":{}},"typeVersion":1},{"id":"2141dbdd-4fce-4306-a852-581b138864e4","name":"Default Data Loader","type":"@n8n/n8n-nodes-langchain.documentDefaultDataLoader","position":[3800,80],"parameters":{"options":{"metadata":{"metadataValues":[{"name":"file_id","value":"={{ $('Set File ID').first().json.file_id}}"},{"name":"title","value":"={{ $('Create Metadata Title & Description').item.json.output.title }}"},{"name":"description","value":"={{ $('Create Metadata Title & Description').item.json.output.description }}"}]}},"jsonData":"={{ $json.concatenated_text }}","jsonMode":"expressionData"},"typeVersion":1},{"id":"af8b85b1-1cfa-4b76-b94e-48213ae232d8","name":"Google Drive Trigger File Created","type":"n8n-nodes-base.googleDriveTrigger","position":[280,-80],"parameters":{"event":"fileCreated","options":{},"pollTimes":{"item":[{"mode":"everyMinute"}]},"triggerOn":"specificFolder","folderToWatch":{"__rl":true,"mode":"url","value":"https://drive.google.com/drive/u/0/folders/1B-Wl-ktVFbTmX685DB978jNvs9Ihnxiv"}},"credentials":{"googleDriveOAuth2Api":{"id":"SEUhrgz30NMJS3cH","name":"Google Drive account"}},"typeVersion":1},{"id":"97304af3-3a09-4724-8e87-7fff0ece6eca","name":"Character Text Splitter","type":"@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter","position":[3900,260],"parameters":{"separator":"###SPLIT###"},"typeVersion":1},{"id":"af31206c-94e6-48fe-895e-f8a000486457","name":"Set File ID","type":"n8n-nodes-base.set","position":[800,-60],"parameters":{"options":{},"assignments":{"assignments":[{"id":"0144a9a7-6e73-46c4-979f-838ad5c62b89","name":"file_id","type":"string","value":"={{ $json.id }}"}]}},"typeVersion":3.4},{"id":"580b1192-be67-46f1-aea4-ae1aaeab10ea","name":"Download FIle","type":"n8n-nodes-base.googleDrive","position":[1040,-60],"parameters":{"fileId":{"__rl":true,"mode":"id","value":"={{ $('Set File ID').item.json.file_id }}"},"options":{"googleFileConversion":{"conversion":{"docsToFormat":"application/pdf"}}},"operation":"download"},"credentials":{"googleDriveOAuth2Api":{"id":"SEUhrgz30NMJS3cH","name":"Google Drive account"}},"typeVersion":3},{"id":"af92c035-f1f0-47e4-b542-c13a7386892b","name":"Switch","type":"n8n-nodes-base.switch","position":[1320,-60],"parameters":{"rules":{"values":[{"outputKey":"application/pdf","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"e959d5a8-d311-4a29-b400-7c07468a72fe","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $binary.data.mimeType }}","rightValue":"application/pdf"}]},"renameOutput":true},{"outputKey":"text/csv","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"d5ae6f2d-e62d-4e08-aa06-629e6dfa7ee8","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $binary.data.mimeType }}","rightValue":"text/csv"}]},"renameOutput":true}]},"options":{}},"typeVersion":3.2},{"id":"1a2575ef-8792-4389-84ea-a016c5ba535e","name":"Structured Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[2540,160],"parameters":{"jsonSchemaExample":"{\n\t\"title\": \"Test Title (Replace it with real title\",\n    \"description\":\"Test Description (Replace it with real description)\"\n}"},"typeVersion":1.2},{"id":"0c8ba080-daab-493d-8c7d-4f1c7e9fb1e7","name":"Google Gemini Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[3320,40],"parameters":{"options":{},"modelName":"models/gemini-1.5-flash"},"credentials":{"googlePalmApi":{"id":"gdaO8lU3HwsldifM","name":"Google Gemini(PaLM) Api account"}},"typeVersion":1},{"id":"e12a0a90-a1d7-4de0-901a-58ce35b95675","name":"Process Context","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[3160,-120],"parameters":{"text":"=<document> \n{{ $('Document Data').first().json.data }}\n</document> \n\nHere is the chunk we want to situate within the overall document:\n\n<chunk> \n{{ $json.chunk }}\n</chunk> \n\nPlease:\n- Provide a short and succinct **context** to situate this chunk within the document for improved search retrieval.\n- Return the **original chunk** exactly as provided unless a correction is necessary.\n- If the chunk contains an **incomplete number, percentage, or entity**, correct it using the full document.\n- If part of a **sentence is cut off**, reconstruct the missing words only if necessary for clarity.\n- If the chunk is part of a table, include the complete table entry to maintain data integrity\n- Do not add any additional explanations or formatting beyond the required output.\n\nFill in the following format:\n[succinct context] : [original chunk or corrected version if necessary]\n\nYour response should contain only the text that replaces these placeholders, without including the placeholder labels themselves.","promptType":"define"},"typeVersion":1.6},{"id":"d6f500ba-c0f3-4cc8-af60-e2c38307582c","name":"Document Data","type":"n8n-nodes-base.set","position":[1980,-120],"parameters":{"mode":"raw","options":{},"jsonOutput":"={\n  \"data\":  {{ JSON.stringify($json.text) }}\n} "},"typeVersion":3.4},{"id":"de223e76-1d95-41a9-b1ff-961d8b744044","name":"Split Out","type":"n8n-nodes-base.splitOut","position":[2780,-120],"parameters":{"options":{"destinationFieldName":"chunk"},"fieldToSplitOut":"chunks"},"typeVersion":1},{"id":"7d2eb334-a73c-4777-b4a9-757356201311","name":"Limit","type":"n8n-nodes-base.limit","position":[2960,-120],"parameters":{"maxItems":20},"typeVersion":1},{"id":"d8f88a96-bed6-461a-ae5f-6924c655ba84","name":"Summarize","type":"n8n-nodes-base.summarize","position":[3480,-120],"parameters":{"options":{},"fieldsToSummarize":{"values":[{"field":"text","separateBy":"other","aggregation":"concatenate","customSeparator":"###SPLIT###"}]}},"typeVersion":1.1},{"id":"820dda10-a369-4415-a739-16f197d0b1ad","name":"Embeddings OpenAI","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[3680,80],"parameters":{"options":{}},"credentials":{"openAiApi":{"id":"MGwGMKEkdcjzlYCw","name":"OpenAi account"}},"typeVersion":1.2},{"id":"1a622d78-d5f1-498d-8882-1cbc9166e4b4","name":"Add Data to Supabase Vector Store","type":"@n8n/n8n-nodes-langchain.vectorStoreSupabase","position":[3680,-120],"parameters":{"mode":"insert","options":{},"tableName":{"__rl":true,"mode":"list","value":"documents","cachedResultName":"documents"}},"credentials":{"supabaseApi":{"id":"XijKo1j1EsG3XUhz","name":"Supabase account"}},"typeVersion":1.1},{"id":"51d8e196-8752-4fe7-a182-c4a00d3caefa","name":"Google Gemini Chat Model1","type":"@n8n/n8n-nodes-langchain.lmChatGoogleGemini","position":[2340,180],"parameters":{"options":{},"modelName":"models/gemini-1.5-flash"},"credentials":{"googlePalmApi":{"id":"gdaO8lU3HwsldifM","name":"Google Gemini(PaLM) Api account"}},"typeVersion":1},{"id":"23b491e1-3732-46eb-a62b-c86b975df894","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[200,-260],"parameters":{"color":4,"width":1960,"height":560,"content":"## 📁 Data Processing from Google Drive\nAutomatically monitors your Google Drive folder and processes new files. When you upload a PDF, CSV, or Google Doc, this section downloads the file, extracts all the text content, and prepares it for AI analysis. Think of it as your automatic document reader that never sleeps."},"typeVersion":1},{"id":"5d95cc1c-5dec-4238-8ecc-d47d5c107e53","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[2220,-260],"parameters":{"color":4,"width":1940,"height":700,"content":"## 🧠 RAG Data Upload Pipeline\nTakes your extracted document text and makes it AI-ready. It creates smart summaries, breaks documents into digestible chunks, adds context to each piece, and stores everything in a searchable database. This is where your documents become \"AI-searchable\" knowledge that can answer questions."},"typeVersion":1},{"id":"d5ab29ee-d9a6-48c6-a2d5-20374cda6296","name":"Create Metadata Title & Description","type":"@n8n/n8n-nodes-langchain.chainLlm","position":[2280,-120],"parameters":{"text":"=Create metadata title and metadata description based on the document specified below (below ##Document). Metadata title and metadata description will be used to seperate data in vector DB that will be used for RAG.\n\n##Document\n{{ $('Document Data').item.json.data }}","promptType":"define","hasOutputParser":true},"typeVersion":1.6},{"id":"8eddba99-f77b-4b85-b2ef-0aa68762b851","name":"Split into chunks","type":"n8n-nodes-base.code","position":[2620,-120],"parameters":{"jsCode":"const chunkSize = 1000;\nconst chunkOverlap = 200;\n//const text = $node[\"ABC\"].json.data.replace(/\\n/, '');\nconst text = $items(\"Document Data\")[0].json.data.replace(/\\n/, '');\n\nconst chunks = [];\nlet remainingText = text;\n\nwhile (remainingText.length > 0) {\n    let splitPoint;\n\n    // Try splitting at paragraph level first\n    splitPoint = remainingText.lastIndexOf(\"\\n\\n\", chunkSize);\n    \n    // If no paragraph split, try splitting at sentence level\n    if (splitPoint === -1) {\n        splitPoint = remainingText.lastIndexOf(\". \", chunkSize);\n    }\n\n    // If no sentence split, try splitting at word level\n    if (splitPoint === -1) {\n        splitPoint = remainingText.lastIndexOf(\" \", chunkSize);\n    }\n\n    // If still no split point, force cut at chunkSize\n    if (splitPoint === -1 || splitPoint < chunkSize * 0.5) {  \n        splitPoint = chunkSize; // Hard split if no good split point\n    }\n\n    // Extract chunk and adjust remaining text with overlap\n    let chunk = remainingText.substring(0, splitPoint).trim();\n    chunks.push(chunk);\n\n    // Move the pointer forward while keeping the overlap\n    remainingText = remainingText.substring(Math.max(0, splitPoint - chunkOverlap)).trim();\n\n    // Break if remaining text is too small to form another chunk\n    if (remainingText.length < chunkSize * 0.2) {\n        chunks.push(remainingText);\n        break;\n    }\n}\n\nreturn { chunks };"},"typeVersion":2},{"id":"2cd80097-3f90-441a-b0ef-08b43c30981b","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[1900,-740],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"MGwGMKEkdcjzlYCw","name":"OpenAi account"}},"typeVersion":1.2},{"id":"03ae06b7-c804-4e35-bac5-17836123771a","name":"Supabase Vector Store","type":"@n8n/n8n-nodes-langchain.vectorStoreSupabase","position":[2200,-700],"parameters":{"mode":"retrieve-as-tool","topK":20,"options":{},"toolName":"documents","tableName":{"__rl":true,"mode":"list","value":"documents","cachedResultName":"documents"},"toolDescription":"Work with your data in Supabase Vector Store"},"credentials":{"supabaseApi":{"id":"XijKo1j1EsG3XUhz","name":"Supabase account"}},"typeVersion":1.1},{"id":"c22f1100-86b0-4d49-b0b5-baa3f997c0a0","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[1940,-960],"parameters":{"text":"=User Input:\n{{ $json.chatInput }}","options":{"systemMessage":"=You're an internal company knowledge assistants. Your job is to answer questions using the files in the Vector Database. Here's how to do it:\n\nCheck Vector Database First\n- Search for similar test chunks using RAG.\n- If you find matches, use them to answer the question. \n- If you find relevant matches and need additional context to support the answer, prioritize retrieving it from documents that share the same metadata \"file_id\" & \"title\" before exploring other sources.\"\n\nNo Answer Found?\n- Clearly say: \"I couldn't find this in the databases\"\n- Never guess or invent answers.\n\nExample Response:\n\"Netflix grew revenue in Streaming services by 20% in 2024.\""},"promptType":"define"},"typeVersion":1.8},{"id":"8ff3b246-2078-4c69-934a-fde989c5dbda","name":"Embeddings OpenAI1","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[2280,-520],"parameters":{"options":{}},"credentials":{"openAiApi":{"id":"MGwGMKEkdcjzlYCw","name":"OpenAi account"}},"typeVersion":1.2},{"id":"4fc4edb9-b5a1-4d4b-b571-cf665cf4eae1","name":"When chat message received","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[1700,-960],"webhookId":"2d4c41cb-c8b7-49c7-a8eb-ebd3dd9ff46d","parameters":{"options":{}},"typeVersion":1.1},{"id":"3fc29837-d177-4af0-a842-57705ef8b97d","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[2060,-700],"parameters":{"contextWindowLength":10},"typeVersion":1.3},{"id":"27ca3852-baac-41fa-a8bc-620dd36fac2d","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[1520,-1080],"parameters":{"color":4,"width":1180,"height":760,"content":"## AI Chat Agent - Chat with your documents stored in Supabase Vector Store\nour personal AI assistant that can answer questions about all your uploaded documents. Ask anything in plain English - it searches through your document database, finds relevant information, and gives you accurate answers with source references. It remembers your conversation and never makes up information."},"typeVersion":1},{"id":"ee2b6e9d-a49b-435e-bc38-7d3a4e989ca5","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[340,-1080],"parameters":{"color":5,"width":460,"height":320,"content":"## 📄 AI-Powered RAG Document Processing & Chatbot with Google Drive, Supabase, OpenAI\n\n**What This Workflow Does:**\n- Watches a Google Drive folder for new documents\n- Extracts text from PDF/CSV files\n- Enhances the text using AI (Google Gemini)\n- Chunks and embeds the text using OpenAI\n- Stores vector data in Supabase for semantic search\n- Enables users to chat with documents using OpenAI"},"typeVersion":1},{"id":"f533c790-36d0-4f7e-a004-1ab64fdbd046","name":"Sticky Note8","type":"n8n-nodes-base.stickyNote","position":[-480,-260],"parameters":{"color":5,"width":660,"height":1500,"content":"## 📋 Data Processing & RAG Workflow\n\n### 📁 Step 1: Google Drive Trigger  \nWatches a specific Google Drive folder for new file uploads. Triggers every minute.\n\n### 🔁 Step 2: Loop Over Uploaded Files  \nEnsures each uploaded file is processed one-by-one to avoid bulk processing issues.\n\n### 🆔 Step 3: Set File ID  \nExtracts and stores the Google Drive file ID for reference in later steps.\n\n### 📥 Step 4: Download File  \nDownloads the file (PDF, CSV, or Google Docs). Google Docs are auto-converted to PDF.\n\n### 🧭 Step 5: File Type Switch  \nRoutes file based on type:\n- PDF → Go to PDF Text Extractor\n- CSV → Go to CSV Extractor\n\n### 📄 Step 6A: Extract Text from PDF  \nExtracts raw text content from the PDF file.\n\n### 📊 Step 6B: Extract Text from CSV  \nExtracts and formats CSV data into a readable string.\n\n### 📦 Step 7: Format Document Data  \nWraps extracted text into JSON: `{\"data\": \"text content\"}`.\n\n### 🧠 Step 8: Generate Metadata (Gemini)  \nUses Gemini AI to create a document title and description.\n\n### ✂️ Step 9: Split into Chunks  \nSplits the document text into 1000-character chunks with 200-character overlap, intelligently at paragraph/sentence/word level.\n\n### 🔄 Step 10: Split Out Chunks  \nConverts array of chunks into individual workflow items.\n\n### 🚫 Step 11: Limit to 20 Chunks  \nLimits processing to first 20 chunks to control API and processing load.\n\n### 🧠 Step 12: Enhance Chunk Context (Gemini)  \nEach chunk is enhanced for better clarity, continuity, and context using Gemini.\n\n### 🧩 Step 13: Summarize  \nCombines enhanced chunks using `###SPLIT###` separator for further processing.\n\n### 🧷 Step 14: Re-Split Enhanced Chunks  \nSplits combined text back into chunks using `###SPLIT###` separator.\n\n### 🧬 Step 15: Generate Embeddings (OpenAI)  \nConverts text chunks into vector embeddings for semantic search.\n\n### 🗂️ Step 16: Add Metadata  \nEach chunk is wrapped with metadata (file ID, title, description) for vector DB.\n\n### 🧠 Step 17: Store in Supabase Vector DB  \nStores embeddings in Supabase vector store for later semantic retrieval.\n\n"},"typeVersion":1},{"id":"2090caca-8fff-461b-a9b5-5460b8978c3c","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[1520,-1640],"parameters":{"color":5,"width":1160,"height":520,"content":"\n## SETUP REQUIRED  \n**Author:** [Billy Christi](https://n8n.io/creators/billy/)\n\n---\n\n### 📚 Database: Supabase Table `documents`\n\nTo manage and store embeddings and metadata, we use a Supabase table with the following schema:\n\n```sql\nCREATE TABLE public.documents (\n  id bigserial PRIMARY KEY,         -- Unique identifier\n  content text,                     -- Textual content of the document\n  metadata jsonb,                   -- Additional metadata (e.g., title, source)\n  embedding vector                  -- Vector embeddings (for similarity search, etc.)\n);\n````\n### 🔐 Required Credentials & Keys\n✅ **Google Drive Credential** \n✅ **Supabase API Key & Project URL** \n✅ **OpenAI API Key**\n✅ **Google Gemini API Key**\n\n\n"},"typeVersion":1},{"id":"989d4cef-fae3-4163-a51e-58cf9aafac61","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[820,-1080],"parameters":{"color":5,"width":660,"height":760,"content":"\n## 🤖 CHAT INTERFACE WORKFLOW\n\n### 💬 Step 1: Chat Trigger  \nListens for user chat input (e.g., question about a document).\n\n### 🧠 Step 2: Simple Memory  \nStores last 10 messages to maintain conversation context.\n\n### 🔍 Step 3: Vector Search (Supabase)  \nSearches Supabase vector DB for relevant chunks related to the user's question.\n\n### 🧬 Step 4: Convert Question to Embedding  \nUses OpenAI to embed the question text for similarity search.\n\n### 🗨️ Step 5: Generate Response (OpenAI GPT-4o-mini)  \nUses context + question to generate a natural language answer.\n\n### 🧠 Step 6: AI Agent  \nFinal agent logic:\n- Searches vector DB first\n- Answers based on found chunks\n- Attributes response to correct document\n- Admits if answer not found (no hallucination)"},"typeVersion":1},{"id":"8d2661d4-3bdc-456e-bba0-766d89ab3ece","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[2860,20],"parameters":{"color":5,"width":340,"height":300,"content":"📌 **Understanding the Limit Node**\nThe **Limit Node** restricts the number of records or items processed in your workflow. This is especially useful for:\n✅ **Testing** your setup with a smaller dataset\n✅ **Controlling resource usage** during processing\n\n💡 **You can**:\n* **Adjust the limit value** to suit your workflow's needs\n* **Remove the Limit Node** altogether to process all available data"},"typeVersion":1}],"pinData":{},"connections":{"Limit":{"main":[[{"node":"Process Context","type":"main","index":0}]]},"Switch":{"main":[[{"node":"Extract from PDF","type":"main","index":0}],[{"node":"Extract from CSV","type":"main","index":0}]]},"AI Agent":{"main":[[]]},"Split Out":{"main":[[{"node":"Limit","type":"main","index":0}]]},"Summarize":{"main":[[{"node":"Add Data to Supabase Vector Store","type":"main","index":0}]]},"Set File ID":{"main":[[{"node":"Download FIle","type":"main","index":0}]]},"Document Data":{"main":[[{"node":"Create Metadata Title & Description","type":"main","index":0}]]},"Download FIle":{"main":[[{"node":"Switch","type":"main","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Loop Over Items":{"main":[[],[{"node":"Set File ID","type":"main","index":0}]]},"Process Context":{"main":[[{"node":"Summarize","type":"main","index":0}]]},"Extract from CSV":{"main":[[{"node":"Document Data","type":"main","index":0}]]},"Extract from PDF":{"main":[[{"node":"Document Data","type":"main","index":0}]]},"Embeddings OpenAI":{"ai_embedding":[[{"node":"Add Data to Supabase Vector Store","type":"ai_embedding","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Split into chunks":{"main":[[{"node":"Split Out","type":"main","index":0}]]},"Embeddings OpenAI1":{"ai_embedding":[[{"node":"Supabase Vector Store","type":"ai_embedding","index":0}]]},"Default Data Loader":{"ai_document":[[{"node":"Add Data to Supabase Vector Store","type":"ai_document","index":0}]]},"Supabase Vector Store":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Character Text Splitter":{"ai_textSplitter":[[{"node":"Default Data Loader","type":"ai_textSplitter","index":0}]]},"Google Gemini Chat Model":{"ai_languageModel":[[{"node":"Process Context","type":"ai_languageModel","index":0}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"Create Metadata Title & Description","type":"ai_outputParser","index":0}]]},"Google Gemini Chat Model1":{"ai_languageModel":[[{"node":"Create Metadata Title & Description","type":"ai_languageModel","index":0}]]},"When chat message received":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Google Drive Trigger File Created":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Create Metadata Title & Description":{"main":[[{"node":"Split into chunks","type":"main","index":0}]]}}}


name: Index Documents from Google Drive to Pinecone with OpenAI Embeddings for RAG
author_name: Automate With Marc
author_username: marconi
categories: []
created_at: 2025-06-01T07:53:00.731Z
updated_at: 2025-06-01T07:53:00.731Z
url: https://n8n.io/workflows/4552
scraped_at: 2025-07-06 21:16:30
description:
  🧠 Google Drive Upload Trigger → Pinecone Vector Upsert for Document Indexing
  Category: AI & LLM / Document Indexing
  Level: Intermediate
  Tags: Google Drive, Pinecone, OpenAI, Embeddings, Vector Store, LangChain, RAG

  📄 What This Workflow Does
  This workflow watches a specific Google Drive folder and automatically uploads any newly added document to a Pinecone vector database — complete with OpenAI-generated embeddings.

  Perfect for setting up retrieval-augmented generation (RAG) pipelines, semantic search, or document Q&A systems. Once configured, your knowledge base stays up-to-date with zero manual effort.

  Watch Full Step By Stey Tutorial Video Here:
  https://www.youtube.com/@Automatewithmarc

  🔧 How It Works
  📁 Google Drive Trigger
  Watches a specific folder and triggers when new documents are uploaded.

  🔍 Google Drive File Search & Download
  Finds and fetches all files in the folder.

  🔄 Loop Over Each File
  Handles batch processing for multiple files.

  📃 Document Loader
  Parses each file as binary and applies custom metadata like document type.

  ✂️ Text Splitter
  Breaks content into manageable chunks for embedding (e.g., 600 characters, 60 overlap).

  🧠 OpenAI Embeddings
  Generates vector embeddings using OpenAI.

  📦 Pinecone Vector Store
  Inserts/upserts documents into a specific Pinecone namespace for search-ready indexing.

  🧠 Why This is Useful
  This is a production-grade setup for:

  Building vector search tools over internal docs

  Feeding up-to-date data into RAG agents or chatbots

  Auto-tagging and chunking files for scalable AI workflows

  Whether you’re indexing course outlines, SOPs, or technical docs — this automation keeps your vector store fresh and organized.

  🪜 Setup Instructions
  Connect your Google Drive, OpenAI, and Pinecone accounts.

  Specify the Google Drive folder to monitor.

  Customize metadata, chunk size, or vector namespace as needed.

  Activate the workflow and drop a file into the folder — magic happens behind the scenes.

  📌 Notes
  Works best with PDFs or text-based documents.

  You can swap out OpenAI with other embedding models if needed.

  Consider adding notifications or logging (e.g., via Slack or email) for better observability.

nodes_used:
  ["n8n-nodes-base.googleDrive","@n8n/n8n-nodes-langchain.embeddingsOpenAi","@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter","@n8n/n8n-nodes-langchain.vectorStorePinecone","@n8n/n8n-nodes-langchain.documentDefaultDataLoader"]

workflow_json:
  {"id":"OceYxCmiuf5W2X4y","meta":{"instanceId":"16d5a69b6a4f4733c8f669903729902650204c895b060993271b9227d7b0b3e8","templateCredsSetupCompleted":true},"name":"Bundle RAG Upload","tags":[],"nodes":[{"id":"e72ec6be-08f3-4195-b429-34c0870ee1bc","name":"Google Drive","type":"n8n-nodes-base.googleDrive","position":[180,0],"parameters":{"filter":{"folderId":{"__rl":true,"mode":"list","value":"17cefWWyf-yKZVpCLHFVOlpfuqQpLl8QW","cachedResultUrl":"https://drive.google.com/drive/folders/17cefWWyf-yKZVpCLHFVOlpfuqQpLl8QW","cachedResultName":"Folder for n8n"}},"options":{},"resource":"fileFolder","returnAll":true},"credentials":{"googleDriveOAuth2Api":{}},"typeVersion":3},{"id":"82a0bcb2-35e0-4897-b2a5-2e8d22fdec43","name":"Get Docs","type":"n8n-nodes-base.googleDrive","position":[440,0],"parameters":{"fileId":{"__rl":true,"mode":"id","value":"={{ $json.id }}"},"options":{},"operation":"download"},"credentials":{"googleDriveOAuth2Api":{}},"typeVersion":3},{"id":"61fc1b10-4a5e-4f12-82c1-c1c7d64c7901","name":"Loop Over Items","type":"n8n-nodes-base.splitInBatches","position":[660,0],"parameters":{"options":{}},"typeVersion":3},{"id":"95a8e03c-bd70-4742-b4ad-6bf3a9b484a2","name":"Pinecone Vector Store","type":"@n8n/n8n-nodes-langchain.vectorStorePinecone","position":[900,20],"parameters":{"mode":"insert","options":{"pineconeNamespace":"Redacted"},"pineconeIndex":{"__rl":true,"mode":"list","value":"Redacted","cachedResultName":"Redacted"}},"credentials":{"pineconeApi":{}},"typeVersion":1},{"id":"8d762bd6-d64f-4e01-bf9d-8183b7cd7555","name":"Embeddings OpenAI","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[920,160],"parameters":{"options":{}},"credentials":{"openAiApi":{}},"typeVersion":1.2},{"id":"80c20301-9fdd-455a-85eb-f0f5b12091be","name":"Default Data Loader","type":"@n8n/n8n-nodes-langchain.documentDefaultDataLoader","position":[1060,240],"parameters":{"options":{"metadata":{"metadataValues":[{"name":"Type","value":"Redacted"}]}},"dataType":"binary"},"typeVersion":1},{"id":"9b849c85-fa99-4f2d-bdd5-02fababbc361","name":"Recursive Character Text Splitter","type":"@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter","position":[1140,380],"parameters":{"options":{},"chunkSize":600,"chunkOverlap":60},"typeVersion":1},{"id":"a18e5576-6e16-487f-9347-2de39ecd7708","name":"Google Drive Trigger","type":"n8n-nodes-base.googleDriveTrigger","position":[-60,0],"parameters":{"event":"fileCreated","options":{},"pollTimes":{"item":[{"mode":"everyMinute"}]},"triggerOn":"specificFolder","folderToWatch":""},"credentials":{"googleDriveOAuth2Api":{}},"typeVersion":1},{"id":"b82cc00a-56f9-41e9-9257-9a054c971db7","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-140,-120],"parameters":{"color":4,"width":260,"height":400,"content":"Google Folder Upload Trigger"},"typeVersion":1},{"id":"aca97112-2f76-44ab-b5ae-aa232bd1242c","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[140,-120],"parameters":{"color":6,"width":220,"height":400,"content":"Google Search File from Folder"},"typeVersion":1},{"id":"7cf71e7a-db76-43b5-a8fd-c377ac4187aa","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[380,-120],"parameters":{"color":2,"width":220,"height":400,"content":"Get File"},"typeVersion":1},{"id":"ee27b02f-4d74-49f7-a3fd-5d0e928ac556","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[860,-120],"parameters":{"color":3,"width":500,"height":680,"content":"Upload to Pinecone Vector"},"typeVersion":1},{"id":"ec38ac32-c4a8-47fb-9312-c8804590a891","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[620,-120],"parameters":{"color":7,"width":220,"height":400,"content":"Loop for multiple files"},"typeVersion":1},{"id":"4db0ce4b-77d2-4875-963c-10f61438128e","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-740,-120],"parameters":{"color":3,"width":580,"height":1300,"content":"🧠 Google Drive Upload Trigger → Pinecone Vector Upsert for Document Indexing\n\n📄 What This Workflow Does\nThis workflow watches a specific Google Drive folder and automatically uploads any newly added document to a Pinecone vector database — complete with OpenAI-generated embeddings.\n\nPerfect for setting up retrieval-augmented generation (RAG) pipelines, semantic search, or document Q&A systems. Once configured, your knowledge base stays up-to-date with zero manual effort.\n\nWatch Full Video Step-by-step guide here:\nhttps://www.youtube.com/@Automatewithmarc\n\n🔧 How It Works\n📁 Google Drive Trigger\nWatches a specific folder and triggers when new documents are uploaded.\n\n🔍 Google Drive File Search & Download\nFinds and fetches all files in the folder.\n\n🔄 Loop Over Each File\nHandles batch processing for multiple files.\n\n📃 Document Loader\nParses each file as binary and applies custom metadata like document type.\n\n✂️ Text Splitter\nBreaks content into manageable chunks for embedding (e.g., 600 characters, 60 overlap).\n\n🧠 OpenAI Embeddings\nGenerates vector embeddings using OpenAI.\n\n📦 Pinecone Vector Store\nInserts/upserts documents into a specific Pinecone namespace for search-ready indexing.\n\n🧠 Why This is Useful\nThis is a production-grade setup for:\n\nBuilding vector search tools over internal docs\n\nFeeding up-to-date data into RAG agents or chatbots\n\nAuto-tagging and chunking files for scalable AI workflows\n\nWhether you’re indexing document outlines, SOPs, or technical docs — this automation keeps your vector store fresh and organized.\n\n🪜 Setup Instructions\nConnect your Google Drive, OpenAI, and Pinecone accounts.\n\nSpecify the Google Drive folder to monitor.\n\nCustomize metadata, chunk size, or vector namespace as needed.\n\nActivate the workflow and drop a file into the folder — magic happens behind the scenes.\n\n📌 Notes\nWorks best with PDFs or text-based documents.\n\nYou can swap out OpenAI with other embedding models if needed.\n\nConsider adding notifications or logging (e.g., via Slack or email) for better observability."},"typeVersion":1}],"active":true,"pinData":{"Default Data Loader":[{"json":{"isArtificialRecoveredEventItem":true}}],"Recursive Character Text Splitter":[{"json":{"isArtificialRecoveredEventItem":true}}]},"settings":{"executionOrder":"v1"},"versionId":"f3a17075-083e-42bc-acfb-c4480b2fe716","connections":{"Get Docs":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Google Drive":{"main":[[{"node":"Get Docs","type":"main","index":0}]]},"Loop Over Items":{"main":[[],[{"node":"Pinecone Vector Store","type":"main","index":0}]]},"Embeddings OpenAI":{"ai_embedding":[[{"node":"Pinecone Vector Store","type":"ai_embedding","index":0}]]},"Default Data Loader":{"ai_document":[[{"node":"Pinecone Vector Store","type":"ai_document","index":0}]]},"Google Drive Trigger":{"main":[[{"node":"Google Drive","type":"main","index":0}]]},"Pinecone Vector Store":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Recursive Character Text Splitter":{"ai_textSplitter":[[{"node":"Default Data Loader","type":"ai_textSplitter","index":0}]]}}}


name: Generate Guerrilla Marketing Campaign Plans with AI Swarm Intelligence
author_name: Sina
author_username: sina2266
categories: []
created_at: 2025-06-01T11:31:39.415Z
updated_at: 2025-06-01T11:31:39.415Z
url: https://n8n.io/workflows/4553
scraped_at: 2025-07-06 21:16:30
description:
  🧠 Who is this for?
  Startup founders designing creative growth strategies  
  Marketing teams seeking low-cost, high-impact campaigns  
  Consultants and agencies needing fast guerrilla plans  
  Creators exploring AI-powered content and campaigns  

  ❓ What problem does this workflow solve?
  Building a full guerrilla marketing strategy usually takes hours of brainstorming, validation, and formatting. This template does all of that in minutes using a swarm of AI agents, from idea generation to KPIs, and even kills bad ideas before you waste time on them.

  ⚙️ What this workflow does
  Starts with a chat input where you describe your business or idea  
  A “Swarm Intelligence” loop:  
    One AI agent generates guerrilla ideas  
    Another agent critically validates the idea and gives honest feedback  
    If the idea is weak, it asks for a new one  
  If accepted, the swarm continues with 16 AI specialists generating:  
    🎯 Objectives  
    🧍‍♂️ Personas  
    🎤 Messaging  
    🧨 Tactics  
    📢 Channels  
    🧮 Budget  
    📊 KPIs  
    📋 Risk plan and more  
  Merges all chapters into a final Markdown file  
  Lets you download the campaign in seconds  

  🛠️ Setup
  Import the workflow to your n8n instance  
  (Optional) Configure your LLM (OpenAI or Ollama) in the “OpenAI Chat Model” node   
  Type your business idea (e.g., “Luxury dog collar brand for Instagram dads”)  
  Wait for flow completion
  Download the final marketing plan file  

  🤖 LLM Flexibility (Choose Your Model)
  Supports any LLM via LangChain:  
    Ollama (LLaMA 3.1, Mistral, DeepSeek)  
    OpenAI (GPT-4, GPT-3.5)  
  To switch models, just replace the “Language Model” node, no other logic needs updating  



  📌 Notes
  Output is professional and ready-to-pitch  
  Built-in pessimistic validator filters out bad ideas before wasting time  

  📩 Need help?
  Email: sinamirshafiee@gmail.com  
  Happy to support setup or customization!

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

workflow_json:
  {"id":"w78LbTzNOGbofCGA","meta":{"instanceId":"7dad74485e3e05b018ebcb1de30d0069d50b5085ff62446e7e84ef96b35d0508","templateCredsSetupCompleted":true},"name":"Guerrilla Marketing Campaign Plan Generator (using Swarm Intelligence)","tags":[],"nodes":[{"id":"f4c7bc5e-9584-4d75-924d-cfccd70f1551","name":"When chat message received","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[-5800,2040],"webhookId":"65b565d7-5beb-4818-b920-1ad9e9308695","parameters":{"options":{}},"typeVersion":1.1},{"id":"cb7217af-5f82-4ade-a1ac-89d02ab4e12d","name":"Introduction Writer","type":"@n8n/n8n-nodes-langchain.agent","position":[-1560,220],"parameters":{"text":"=Here is the project description: \n{{ $json.output }}","options":{"systemMessage":"You are an elite marketing strategist with decades of global experience. Your task is to create the \"Introduction\" section of a guerrilla marketing campaign master document.\n\nInstructions:\n- Explain the purpose of having a detailed plan in guerrilla marketing.\n- Highlight the strategic importance of creativity, precision, and adaptability.\n- Set an inspiring, motivational, and professional tone.\n- Your writing must reflect deep expertise, as if coaching a world-class marketing team.\n- Analyze the emotional and practical importance of structured preparation.\n\nBe sure to:\n- Research the core reasons why guerrilla marketing needs planning.\n- Think about successful examples globally and summarize underlying principles.\n- Avoid generic advice; write sharp, specific, and high-level insight.\n- Maintain logical structure without deviation.\n\nFormat:\n- Output must be clear and simple paragraphs.\n\n- Only output the main paragraph ready for direct copy-paste.\n- If specific information is not available, leave blank without guessing.\n\n\nthe output should only contain the result, not any pre or post result note"},"promptType":"define"},"typeVersion":1.8},{"id":"73a42030-3fa6-47ce-b8c1-cb471d45e9c4","name":"Campaign Definition Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[-1560,480],"parameters":{"text":"=You are a creative campaign architect with vast global experience. Your task is to create the \"Campaign Definition\" section for a guerrilla marketing strategy.\n\nInstructions:\n- Define the name of the campaign clearly and creatively.\n- Write a precise mission statement (maximum 2 lines).\n- Describe the core problem or opportunity the campaign addresses.\n- Ensure the tone is innovative yet clear.\n\nYou must:\n- Analyze the target market briefly before writing.\n- Ensure that the name and mission resonate with guerrilla marketing spirit.\n- Validate that the problem statement is realistic and solvable.\n- Stay tightly focused on practicality and creativity.\n\nFormat:\n- Output must be clear and simple paragraphs.\n- Only the paragraph content.\n- Leave blank any section that cannot be precisely completed based on available data.\n\nHere is the project description: \n{{ $json.output }}","options":{},"promptType":"define"},"typeVersion":1.8},{"id":"986dd87c-8c95-40e7-a95b-c3804900164b","name":"Campaign Objectives Specialist","type":"@n8n/n8n-nodes-langchain.agent","position":[-1560,740],"parameters":{"text":"=You are a goal-setting expert and strategic planner. Your task is to create the \"Campaign Objectives\" section for a guerrilla marketing strategy.\n\nInstructions:\n- Define 2-3 short-term objectives that are measurable and concrete.\n- Define 2-3 long-term strategic objectives aligned with brand growth.\n- Ensure that objectives are written following the SMART criteria.\n- Focus on achievable, logical, and highly strategic goals.\n\nYou must:\n- Carefully assess the project description.\n- Ensure the objectives can realistically be measured and achieved.\n- Avoid vague language or generic goal setting.\n- Maintain a strategic yet inspiring tone.\n\nFormat:\n- Output must be clear and simple paragraphs.\n- Leave blank sections where information is insufficient without guessing.\n\nthe output should only contain the result, not any pre or post result note\n\nHere is the project description: \n{{ $json.output }}","options":{},"promptType":"define"},"typeVersion":1.8},{"id":"da84d2d6-48d5-4dd3-ab09-b335ee026773","name":"Current Situation Analyst","type":"@n8n/n8n-nodes-langchain.agent","position":[-1560,1000],"parameters":{"text":"=You are an advanced market and competition analyst. Your task is to build the \"Current Situation Analysis\" section.\n\nInstructions:\n- Perform a SWOT analysis (Strengths, Weaknesses, Opportunities, Threats).\n- Summarize the current competitor landscape (main competitors, market dynamics).\n- Identify key consumer trends relevant to the campaign.\n\nYou must:\n- Research thoroughly based on the project context.\n- Cross-reference assumptions to ensure practical validity.\n- Critically assess possible gaps or challenges.\n- Maintain a strategic, executive-level analytical tone.\n\nFormat:\n- Output must be clear and simple paragraphs.\n- If data is missing, leave blank without fabricating information.\n\nthe output should only contain the result, not any pre or post result note\n\nHere is the project description: \n{{ $json.output }}","options":{},"promptType":"define"},"typeVersion":1.8},{"id":"5233dc8b-7910-4418-98c5-0d66652b63fe","name":"Target Persona Researcher","type":"@n8n/n8n-nodes-langchain.agent","position":[-1560,1260],"parameters":{"text":"=Here is the project description: \n{{ $json.output }}","options":{"systemMessage":"You are a deep customer insight researcher with specialization in behavioral psychology. Your task is to create the \"Target Audience Persona\" section create 5 different persona with detailed info as described below,and name them depend on the persona to a famous character (celebrity, movie, game, someone who has been famous) that has those persona (or similar).\n\nInstructions:\n- Describe the demographic profile: age, gender, occupation, income level.\n- Describe the psychographic profile: values, motivations, fears, lifestyles.\n- Explain expected buying behaviors and key emotional triggers.\n\nYou must:\n- Research potential customer segments carefully.\n- Prioritize accuracy, depth, and practical segmentation.\n- Validate assumptions against realistic market behaviors.\n- Ensure persona matches guerrilla marketing style (open to surprise, risk-YOUR_OPENAI_KEY_HERE_OPENAI_KEY_HERE_OPENAI_KEY_HERE_OPENAI_KEY_HERE_OPENAI_KEY_HERE_OPENAI_KEY_HERE_OPENAI_KEY_HERE_OPENAI_KEY_HERE, trend adopters).\n\nFormat:\n- Output must be clear and simple paragraphs.\n- If some details cannot be inferred reasonably, leave blank.\n\nthe output should only contain the result, not any pre or post result note\n"},"promptType":"define"},"typeVersion":1.8},{"id":"13b9e9a5-4691-4e05-b422-2e6a04795a16","name":"Key Messaging Specialist","type":"@n8n/n8n-nodes-langchain.agent","position":[-1560,1520],"parameters":{"text":"=You are a brand messaging expert specializing in guerrilla marketing campaigns. Your task is to create the \"Key Messaging\" section.\n\nInstructions:\n- Define the primary message the campaign must deliver.\n- Write a memorable slogan or core phrase.\n- Define the tone of voice (e.g., bold, rebellious, humorous).\n- Ensure the message is aligned with the emotions of the target audience.\n\nYou must:\n- Research psychological triggers related to guerrilla marketing success.\n- Focus on clear, emotional, and provocative messaging.\n- Validate that the messaging style fits guerrilla marketing culture (unexpected, unforgettable, shareable).\n\nFormat:\n- Output must be clear and simple paragraphs.\n- Leave blank if information cannot be completed without strong basis.\n\nthe output should only contain the result, not any pre or post result note\n\nHere is the project description: \n{{ $json.output }}","options":{},"promptType":"define"},"typeVersion":1.8},{"id":"d8ec0c1e-ffaa-4c92-8f1d-4c2a1641844d","name":"Main Strategy Architect","type":"@n8n/n8n-nodes-langchain.agent","position":[-1560,1780],"parameters":{"text":"=You are a chief strategy architect for disruptive marketing campaigns. Your task is to write the \"Main Marketing Strategy\" section.\n\nInstructions:\n- Define the strategic direction (penetration, emotional stimulation, interaction-driven).\n- Outline how to leverage guerrilla tactics for maximum impact.\n- Ensure the plan is realistic, creative, and shock-driven.\n\nYou must:\n- Analyze competitive patterns.\n- Validate the feasibility of tactics.\n- Emphasize high surprise factor, emotional involvement, and viral potential.\n- Ensure strategy feels bold but executable.\n\nFormat:\n- Output must be clear and simple paragraphs.\n- Leave blank parts if strong information is missing.\n\nthe output should only contain the result, not any pre or post result note\n\nHere is the project description: \n{{ $json.output }}","options":{},"promptType":"define"},"typeVersion":1.8},{"id":"f12c7d75-238f-4b15-b517-57de140c5aef","name":"guerrilla Tactics Designer","type":"@n8n/n8n-nodes-langchain.agent","position":[-1560,2040],"parameters":{"text":"=You are a guerrilla marketing tactics designer with expertise in low-cost, high-impact strategies. Your task is to develop the \"guerrilla Marketing Tactics\" section.\n\nInstructions:\n- Propose specific unconventional tactics: street marketing, ambient marketing, flash mobs, PR stunts.\n- Each tactic must be realistic, cost-effective, and viral-friendly.\n- Prioritize tactics that maximize shock, surprise, and memorability.\n\nYou must:\n- Evaluate feasibility and ease of execution.\n- Ensure tactics have natural potential for virality.\n- Only propose ideas that could realistically be implemented with limited budget.\n- Maintain creativity at the highest level.\n\nFormat:\n- Output must be paragraphs.\n- Leave blank if insufficient information.\n\nthe output should only contain the result, not any pre or post result note\n\nHere is the project description: \n{{ $json.output }}","options":{},"promptType":"define"},"typeVersion":1.8},{"id":"6b6c1448-fe5f-4f92-a702-54a1cb80ac94","name":"Channel Strategy Expert","type":"@n8n/n8n-nodes-langchain.agent","position":[-1560,2300],"parameters":{"text":"=You are a distribution and media strategist. Your task is to complete the \"Channels & Distribution\" section.\n\nInstructions:\n- Identify the best channels for campaign exposure (social media, public places, PR, collaborations).\n- Explain briefly how each channel would maximize visibility.\n- Ensure chosen channels fit guerrilla marketing principles: unexpectedness, low cost, mass attention.\n\nYou must:\n- Research effectiveness of each potential channel for guerrilla marketing.\n- Validate reach potential against campaign goals.\n- Focus on creativity and strategic leverage.\n\nFormat:\n- Output must be clean paragraphs.\n- If necessary information is missing, leave the area blank.\n\nthe output should only contain the result, not any pre or post result note\n\nHere is the project description: \n{{ $json.output }}","options":{},"promptType":"define"},"typeVersion":1.8},{"id":"d26d1002-65e9-4c28-acfe-1753f9c5c112","name":"Execution Planner","type":"@n8n/n8n-nodes-langchain.agent","position":[-1560,2560],"parameters":{"text":"=You are an operational execution master. Your task is to complete the \"Execution Plan\" section.\n\nInstructions:\n- Define clear phases of the campaign.\n- Specify timelines, responsibilities, and resources needed.\n- Ensure the plan is step-by-step and execution-ready.\n- Plan should reflect maximum agility and quick reaction options.\n\nYou must:\n- Validate feasibility at each step.\n- Ensure no unnecessary dependency between steps.\n- Maintain practical, fast-paced planning style suited for guerrilla marketing.\n\nFormat:\n- Output must be clean paragraphs.\n- If strong data missing, leave blank without assuming.\n\nthe output should only contain the result, not any pre or post result note\n\nHere is the project description: \n{{ $json.output }}","options":{},"promptType":"define"},"typeVersion":1.8},{"id":"1fc40cd2-5dbc-4689-b40f-bef05f821546","name":"Budget Planning Specialist","type":"@n8n/n8n-nodes-langchain.agent","position":[-1560,2820],"parameters":{"text":"=You are a financial strategist for guerrilla marketing campaigns. Your task is to create the \"Budget Planning\" section.\n\nInstructions:\n- Estimate the necessary costs for all campaign activities.\n- Prioritize low-cost, high-impact solutions.\n- Identify critical areas where budget must be allocated (content creation, materials, permits, logistics).\n- Recommend contingency reserve for unexpected expenses.\n\nYou must:\n- Research reasonable cost ranges for guerrilla tactics.\n- Ensure all planned costs are realistic and aligned with project scale.\n- Avoid overestimations or underestimations.\n- Focus on maximum ROI (Return on Investment).\n\nFormat:\n- Output must be clean paragraphs.\n- If strong data missing, leave blank without assuming.\n\nthe output should only contain the result, not any pre or post result note\n\nHere is the project description: \n{{ $json.output }}","options":{},"promptType":"define"},"typeVersion":1.8},{"id":"8cc0f4c9-ac63-4d7e-9484-fae55587b490","name":"Monitoring and KPIs Expert","type":"@n8n/n8n-nodes-langchain.agent","position":[-1560,3080],"parameters":{"text":"=You are a performance measurement expert. Your task is to complete the \"Monitoring & KPIs\" section.\n\nInstructions:\n- Define clear KPIs (Key Performance Indicators) for campaign success.\n- Focus on awareness, engagement, and conversion metrics.\n- Suggest tools and methods for measuring campaign performance.\n\nYou must:\n- Research standard practices for guerrilla campaign measurement.\n- Validate that KPIs are realistic, meaningful, and measurable.\n- Avoid vague KPIs or overcomplicated metrics.\n\nFormat:\n- Output must be clean paragraphs.\n- If strong data missing, leave blank without assuming.\n\nthe output should only contain the result, not any pre or post result note\n\nHere is the project description: \n{{ $json.output }}","options":{},"promptType":"define"},"typeVersion":1.8},{"id":"31912a29-a8c2-4616-9bd6-d0865963d3ca","name":"Risk Management Expert","type":"@n8n/n8n-nodes-langchain.agent","position":[-1560,3340],"parameters":{"text":"=You are a risk strategist specialized in marketing campaigns. Your task is to complete the \"Risk Management\" section.\n\nInstructions:\n- Identify key risks: legal, operational, branding.\n- Propose realistic mitigation strategies for each risk.\n- Focus on minimizing negative public impact and legal exposure.\n\nYou must:\n- Analyze real-world case studies of guerrilla marketing risks.\n- Validate the practicality of suggested risk mitigation strategies.\n- Ensure risk management approaches are lightweight but effective.\n\nFormat:\n- Output must be clean paragraphs.\n- If strong data missing, leave blank without assuming.\n\nthe output should only contain the result, not any pre or post result note\n\nHere is the project description: \n{{ $json.output }}","options":{},"promptType":"define"},"typeVersion":1.8},{"id":"c0f84840-e25a-4b4c-a14a-c3a3c14b4141","name":"Do's and Don'ts Advisor","type":"@n8n/n8n-nodes-langchain.agent","position":[-1560,3600],"parameters":{"text":"=You are an advisor in guerrilla marketing best practices. Your task is to complete the \"Do’s and Don’ts\" section.\n\nInstructions:\n- Highlight critical actions that must be done to ensure campaign success.\n- Highlight critical actions that must be avoided to prevent failure.\n- Emphasize creativity, legality, and ethical practices.\n\nYou must:\n- Base advice on real-world guerrilla marketing successes and failures.\n- Ensure points are practical, sharp, and directly actionable.\n- Focus on lessons specifically tied to nontraditional, shock-driven marketing.\n\nFormat:\n- Output must be clean paragraphs and bullet points.\n- If strong data missing, leave blank without assuming.\n\nthe output should only contain the result, not any pre or post result note\n\nHere is the project description: \n{{ $json.output }}","options":{},"promptType":"define"},"typeVersion":1.8},{"id":"0fc661cd-1b77-49f9-bf61-2071ce7f4c36","name":"Final To-Do List Creator","type":"@n8n/n8n-nodes-langchain.agent","position":[-1560,3860],"parameters":{"text":"=You are an operations and action planning specialist. Your task is to complete the \"Final To-Do List\" section.\n\nInstructions:\n- Summarize essential actionable steps from all previous sections.\n- Organize logically from preparation to execution.\n- Keep list concise but comprehensive.\n\nYou must:\n- Cross-reference all campaign elements carefully.\n- Avoid missing any critical step.\n- Prioritize actions critical for campaign success.\n\nFormat:\n- Output must be clean paragraphs and bullet points.\n- If strong data missing, leave blank without assuming.\n\nthe output should only contain the result, not any pre or post result note\n\nHere is the project description: \n{{ $json.output }}","options":{},"promptType":"define"},"typeVersion":1.8},{"id":"62ef19de-e112-43fb-987e-c57865f1b376","name":"Post-Campaign Analyst","type":"@n8n/n8n-nodes-langchain.agent","position":[-1560,4120],"parameters":{"text":"=You are a post-campaign analyst with expertise in learning optimization. Your task is to complete the \"Post-Campaign Activities\" section.\n\nInstructions:\n- Define how to evaluate the campaign's success versus goals.\n- Outline the feedback collection process.\n- Summarize key learnings and improvement opportunities.\n\nYou must:\n- Base analysis on real post-campaign industry practices.\n- Ensure the learning loop is practical, quick, and meaningful.\n- Focus on building reusability for future campaigns.\n\nFormat:\n- Output must be clean paragraphs.\n- If strong data missing, leave blank without assuming.\n\nthe output should only contain the result, not any pre or post result note\n\nHere is the project description: \n{{ $json.output }}","options":{},"promptType":"define"},"typeVersion":1.8},{"id":"e3bf7e06-0fe4-4c60-87f0-68affbaf1d57","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[-2880,4800],"parameters":{"sessionKey":"={{ $json.session_id }}","sessionIdType":"customKey","contextWindowLength":15},"typeVersion":1.3},{"id":"fae3499b-4a69-4a36-8726-07def17289c8","name":"Market Analyst","type":"@n8n/n8n-nodes-langchain.agent","position":[-4640,2040],"parameters":{"text":"=You are a highly critical and realistic Feasibility and Market Validator. Your task is to complete the section \\\"Critical Validation\\\".\\n\\nAnalyze the provided idea very pessimistically and critically, focusing on finding flaws, risks, and weaknesses first. Your approach is to:\\n\\n- Check if the idea is realistically executable (technical, financial, and operational feasibility)\\n- Critically assess if the idea fits market needs (market demand, competition, differentiation)\\n- If the idea can be improved, provide precise and actionable improvement feedback to enhance it\\n- If the idea is fundamentally weak or unlikely to succeed, clearly recommend discarding it and starting a new idea on the same topic\\n- If the idea is strong, innovative, and suitable for guerrilla marketing, approve it confidently\\n\\nNever sugarcoat problems. Focus on honest, actionable feedback, with the goal of reaching the strongest possible idea.\\n\\nFormat the answer as a clean paragraph. Do not include any titles, headers, numbering, or extra notes.\\n\\nIf you cannot properly evaluate, leave the section blank.\\n\\nHere is the provided project description:\\n {{ $json.output }}\n\nfor the output write is it accepted, or what things exaclty need to modify to be acceptable, and also if the idea is completely not achievable, write to move new gurilla idea and and also give feedback to improve. the result should only contain whether feedbacks (that if those apply on the idea everything will be fixed, so name all the feedbacks with detail, or just tell move to new ideas. do not write both feedback and move to anoteher idea)\nAnd at first explixitly mention this idea is feasable or not with saying it is accepted or not, ","options":{},"promptType":"define"},"typeVersion":1.9},{"id":"fb698621-922e-41ae-8532-10d333ed38ff","name":"Idea Generator","type":"@n8n/n8n-nodes-langchain.agent","position":[-5080,2040],"parameters":{"text":"=You are an Gurilla Marketing Idea Creator wich think different and out of box (but feasiable to do) and cheap. Your task is to complete the section \\\"Idea Proposal\\\".\\n\\nBased on the provided project description, conduct the necessary brainstorming and generate creative amazing guerrilla marketing ideas that are feasable. Then elaborate briefly on the idea, explaining what problem it solves and why it could succeed.\\n\\nFocus on:\\n- Invent a fresh, relevant idea\\n- Provide a short but clear elaboration\\n- Ensure the idea is practical, not purely fantasy\\n\\nFormat the answer as a clean paragraph. No titles, headers, numbering, or extra notes. Only the main paragraph, ready to copy-paste.\\n\\nIf you cannot create a valid idea, and everytime only generate one idea (whether imrpove previous idea by considering all given feedbacks, or weather completely write new one) leave it blank.\\n\\nHere is the provided project description:\\n{{ $json.output }}","options":{},"promptType":"define"},"typeVersion":1.9},{"id":"79a149f3-cfd0-4f94-9874-830bb8bb2173","name":"Information Extractor","type":"@n8n/n8n-nodes-langchain.informationExtractor","position":[-4220,2040],"parameters":{"text":"={{ $json.output }}","options":{},"schemaType":"manual","inputSchema":"{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"isItAccepted\": {\n\t\t\t\"type\": \"boolean\"\n\t\t}\n\t\n\t}\n}"},"typeVersion":1},{"id":"eac1ccbc-6b4b-47f8-8f8b-b406ab6cb34e","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[-3160,4800],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4.1-mini","cachedResultName":"gpt-4.1-mini"},"options":{}},"credentials":{"openAiApi":{"id":"S34avj2vC22wwvGz","name":"OpenAi account"}},"typeVersion":1.2},{"id":"b41dbab0-e505-49a5-b413-7b5cc6011a0e","name":"Input Parser","type":"n8n-nodes-base.code","position":[-5580,2040],"parameters":{"jsCode":"const workflowStaticData = $getWorkflowStaticData('global');\n\n// get new access token\nworkflowStaticData.originalIdea = $input.first().json.chatInput;\nreturn {\"output\":$input.first().json.chatInput};"},"typeVersion":2},{"id":"abcfffeb-7369-47ab-b936-1be2e88a3180","name":"Merge failed results","type":"n8n-nodes-base.merge","position":[-3440,2840],"parameters":{"numberInputs":3},"typeVersion":3.1},{"id":"282bb284-bcf7-4f6d-9d85-7888d21bd597","name":"combine outputs","type":"n8n-nodes-base.code","position":[-3240,2840],"parameters":{"jsCode":"// Get the global workflow static data\nconst workflowStaticData = $getWorkflowStaticData('global');\n\n// Check if $input.all()[3] exists and its output is false\n// Check the condition\nif (!$input.all()[2]) {\n  return[]; // Stop, do nothing\n}\n\n\n// Access its data\nconst originalIdea = workflowStaticData.originalIdea;\n\nreturn {\"output\": `This is business description: '${originalIdea}', And this is generated idea:${$input.all()[0].json.output}, and this the final feedback that you should apply (maybe modify the current idea or maybe generate a more realistic gurilla marketing idea) : ${$input.all()[1].json.output}`};"},"typeVersion":2,"alwaysOutputData":false},{"id":"9857d479-dede-49ad-88a1-ae00b5343681","name":"Merge successful result","type":"n8n-nodes-base.merge","position":[-3420,1140],"parameters":{"numberInputs":3},"typeVersion":3.1},{"id":"7c98f796-4273-4117-814c-11c809238085","name":"Combine outputs","type":"n8n-nodes-base.code","position":[-3200,1140],"parameters":{"jsCode":"\n// Get the global workflow static data\nconst workflowStaticData = $getWorkflowStaticData('global');\n\n// Access its data\nconst originalIdea = workflowStaticData.originalIdea;\nconst sessionId = (+new Date).toString(36).slice(-5) + Math.random().toString(36).substr(2, 5)\n\nreturn {\"output\": `This is business description: '${originalIdea}', And this is generated idea:${$input.all()[0].json.output}, and this the final feedback that you should apply consider it to have a better and more realistic output: ${$input.all()[1].json.output}`,\"session_id\":sessionId};"},"typeVersion":2},{"id":"b8077851-175d-4aa6-b03b-555d5ae05b2f","name":"Merge results 1/2","type":"n8n-nodes-base.merge","position":[-180,1260],"parameters":{"numberInputs":10},"typeVersion":3.1},{"id":"25deeee6-3546-4944-8c07-27835811c227","name":"Merge results 2/2","type":"n8n-nodes-base.merge","position":[-180,3280],"parameters":{"numberInputs":6},"typeVersion":3.1},{"id":"f75a3534-f185-427e-9531-18cf18edd2d5","name":"Merge results","type":"n8n-nodes-base.merge","position":[440,2320],"parameters":{},"typeVersion":3.1},{"id":"6de3bbc8-8908-4f28-afdd-7dcfde723f02","name":"Result organizer","type":"n8n-nodes-base.code","position":[640,2320],"parameters":{"jsCode":"// const input = $input.all()\n// // Simple merge\n// const output = {\n//   introduction: input[0].json.output,\n//   campaign_definition: input[1].json.output,\n//   campaign_objectives: input[2].json.output, // combining both\n//   current_situation_analysis: input[3].json.output,\n//   target_audience_persona: input[4].json.output,\n//   key_messaging: input[5].json.output,\n//   main_marketing_strategy: input[6].json.output,\n//   guerrilla_marketing_tactics: input[7].json.output,\n//   channels_and_distribution : input[8].json.output,\n//   execution_plan: input[9].json.output,\n//   budget_planning: input[10].json.output,\n//   monitoring_and_kpis: input[11].json.output,\n//   risk_management: input[12].json.output,\n//   dos_and_donts: input[13].json.output,\n//   fina_todo_list: input[14].json.output,\n//   post_campaign_activities: input[15].json.output,\n// };\n\n// return {\n//   \"raw_output\": output,\n//     \"text\" : `# Introduction\\n${output.introduction}\\n\\n\n// # Campaign Definition\\n${output.campaign_definition}\\n\\n\n// # Campaign Objectives\\n${output.campaign_objectives}\\n\\n\n// # Current Situation Analysis\\n${output.current_situation_analysis}\\n\\n\n// # Target Audience Persona\\n${output.target_audience_persona}\\n\\n\n// # Key Messaging\\n${output.key_messaging}\\n\\n\n// # Main Marketing Strategy\\n${output.main_marketing_strategy}\\n\\n\n// # guerrilla Marketing Tactics\\n${output.guerrilla_marketing_tactics}\\n\\n\n// # Channels and Distribution\\n${output.channels_and_distribution}\\n\\n\n// # Execution Plan\\n${output.execution_plan}\\n\\n\n// # Budget Planning\\n${output.budget_planning}\\n\\n\n// # Monitoring and KPIs\\n${output.monitoring_and_kpis}\\n\\n\n// # Risk Management\\n${output.risk_management}\\n\\n\n// # Dos and Don'ts\\n${output.dos_and_donts}\\n\\n\n// # Final To-Do List\\n${output.fina_todo_list}\\n\\n\n// # Post Campaign Activities\\n${output.post_campaign_activities}\\n\\n`\n// }\n\n\n\n\n\nconst input = $input.all();\n\nfunction decode(str) {\n  try {\n    return JSON.parse(`\"${str}\"`);\n  } catch (e) {\n    return str;\n  }\n}\n\nfunction fixNewLines(str) {\n  return decode(str).replace(/\\\\n/g, `\n  `);\n}\n\nconst sections = [\n  { title: \"Introduction\", content: fixNewLines(input[0].json.output) },\n  { title: \"Campaign Definition\", content: fixNewLines(input[1].json.output) },\n  { title: \"Campaign Objectives\", content: fixNewLines(input[2].json.output) },\n  { title: \"Current Situation Analysis\", content: fixNewLines(input[3].json.output) },\n  { title: \"Target Audience Persona\", content: fixNewLines(input[4].json.output) },\n  { title: \"Key Messaging\", content: fixNewLines(input[5].json.output) },\n  { title: \"Main Marketing Strategy\", content: fixNewLines(input[6].json.output) },\n  { title: \"guerrilla Marketing Tactics\", content: fixNewLines(input[7].json.output) },\n  { title: \"Channels and Distribution\", content: fixNewLines(input[8].json.output) },\n  { title: \"Execution Plan\", content: fixNewLines(input[9].json.output) },\n  { title: \"Budget Planning\", content: fixNewLines(input[10].json.output) },\n  { title: \"Monitoring and KPIs\", content: fixNewLines(input[11].json.output) },\n  { title: \"Risk Management\", content: fixNewLines(input[12].json.output) },\n  { title: \"Dos and Don'ts\", content: fixNewLines(input[13].json.output) },\n  { title: \"Final To-Do List\", content: fixNewLines(input[14].json.output) },\n  { title: \"Post Campaign Activities\", content: fixNewLines(input[15].json.output) }\n];\n\nlet text = \"\";\n\nsections.forEach(section => {\n  text += `# ${section.title}\n${section.content}\n\n`;\n});\n\nreturn {\n  raw_output: sections,\n  text: text\n};"},"typeVersion":2},{"id":"31e1e0a0-ad77-4f7a-ba29-ee0d0dc95dba","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-5340,1000],"parameters":{"width":2400,"height":2180,"content":"## Swarm Intelligence (Mission : Critical campaign generator)\n\nThis part includes two AI agents: one generates an idea, and the other critiques it and provides an opinion. If the idea isn’t suitable, instead of initiating a feedback loop for improvement, the second agent asks for a new idea."},"typeVersion":1},{"id":"43ff5d3b-9f8a-47e8-9a0a-1f8fc75f49da","name":"Idea is good enough?","type":"n8n-nodes-base.if","position":[-3780,2040],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"loose"},"combinator":"and","conditions":[{"id":"f0c32b9c-56f7-4514-865e-cb2a01eb5490","operator":{"type":"boolean","operation":"true","singleValue":true},"leftValue":"={{ $json.output.isItAccepted }}","rightValue":""}]},"looseTypeValidation":true},"executeOnce":false,"typeVersion":2.2},{"id":"b5b1e48d-5693-4838-932c-71ee4cd0c83c","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-6500,1700],"parameters":{"color":4,"width":840,"height":520,"content":"## How to Use It\n\nTo get started, open the chat and describe your business.  \nThe more specific you are, the better the guerrilla marketing campaign plan will be.\n\nIt’s a good idea to include details like your **available budget** and any other relevant information.\n\nThis template introduces a new feature called **Swarm Intelligence**, where multiple agents collaborate in a loop to generate the most effective response.\n\nIf you already have a specific idea and don’t need brainstorming, you can **disable the Swarm Intelligence** part and use only the remaining nodes.\n\nIf you have any questions, feel free to email me at:  \n**sinamirshafiee@gmail.com**\n\n\n**Note:**  \nThis is version **0.1.0**, so please keep in mind that there may still be some bugs.  \nI'd love to hear your feedback, just drop me a message at **sinamirshafiee@gmail.com**!"},"typeVersion":1},{"id":"b29ecbae-ebe8-42c4-b76b-13ab0dabbe9d","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[-4120,4780],"parameters":{"color":7,"width":1100,"height":140,"content":"## LLM is changeable\nYou can change the LLM to others like Ollama, it is better to use Reasonable models if you keep **Swarm Intelligence** active."},"typeVersion":1},{"id":"9a16f079-b6a5-4844-947b-5a8ee1ab145e","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-360,1100],"parameters":{"color":7,"width":940,"height":2600,"content":"## Merging all outputs\n"},"typeVersion":1},{"id":"8589c4cf-d064-4140-972b-c4891b35c5f5","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-1820,-100],"parameters":{"color":5,"width":760,"height":4460,"content":"## Writing Individual Chapters\n\nEach node represents an agent that is highly skilled in its specific area of expertise.  \nIt generates the content for its assigned section based on the provided idea."},"typeVersion":1},{"id":"7d58d91b-11b6-40b4-89a8-e0340c36f6f3","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[800,1800],"parameters":{"width":560,"height":720,"content":"## End of Process\n\nAfter completing all the steps, click on this node to download the final result file.\n\nIf you have any further questions, feel free to contact me:  \n📧 **sinamirshafiee@gmail.com**"},"typeVersion":1},{"id":"6d488e0c-08fb-4072-b4bb-9070c43da16f","name":"Final result","type":"n8n-nodes-base.convertToFile","position":[860,2320],"parameters":{"options":{"fileName":"marketing_plan.md"},"operation":"toText","sourceProperty":"text"},"typeVersion":1.1}],"active":true,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"94640b98-e316-4740-a952-2905bd792eea","connections":{"Input Parser":{"main":[[{"node":"Idea Generator","type":"main","index":0}]]},"Merge results":{"main":[[{"node":"Result organizer","type":"main","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"Introduction Writer","type":"ai_memory","index":0},{"node":"Campaign Definition Agent","type":"ai_memory","index":0},{"node":"Current Situation Analyst","type":"ai_memory","index":0},{"node":"Target Persona Researcher","type":"ai_memory","index":0},{"node":"Key Messaging Specialist","type":"ai_memory","index":0},{"node":"Campaign Objectives Specialist","type":"ai_memory","index":0},{"node":"Main Strategy Architect","type":"ai_memory","index":0},{"node":"guerrilla Tactics Designer","type":"ai_memory","index":0},{"node":"Channel Strategy Expert","type":"ai_memory","index":0},{"node":"Execution Planner","type":"ai_memory","index":0},{"node":"Budget Planning Specialist","type":"ai_memory","index":0},{"node":"Monitoring and KPIs Expert","type":"ai_memory","index":0},{"node":"Risk Management Expert","type":"ai_memory","index":0},{"node":"Do's and Don'ts Advisor","type":"ai_memory","index":0},{"node":"Final To-Do List Creator","type":"ai_memory","index":0},{"node":"Post-Campaign Analyst","type":"ai_memory","index":0}]]},"Idea Generator":{"main":[[{"node":"Market Analyst","type":"main","index":0},{"node":"Merge failed results","type":"main","index":0},{"node":"Merge successful result","type":"main","index":0}]]},"Market Analyst":{"main":[[{"node":"Information Extractor","type":"main","index":0},{"node":"Merge failed results","type":"main","index":1},{"node":"Merge successful result","type":"main","index":1}]]},"Combine outputs":{"main":[[{"node":"Introduction Writer","type":"main","index":0},{"node":"Campaign Definition Agent","type":"main","index":0},{"node":"Campaign Objectives Specialist","type":"main","index":0},{"node":"Current Situation Analyst","type":"main","index":0},{"node":"Target Persona Researcher","type":"main","index":0},{"node":"Key Messaging Specialist","type":"main","index":0},{"node":"Main Strategy Architect","type":"main","index":0},{"node":"guerrilla Tactics Designer","type":"main","index":0},{"node":"Channel Strategy Expert","type":"main","index":0},{"node":"Execution Planner","type":"main","index":0},{"node":"Budget Planning Specialist","type":"main","index":0},{"node":"Monitoring and KPIs Expert","type":"main","index":0},{"node":"Risk Management Expert","type":"main","index":0},{"node":"Do's and Don'ts Advisor","type":"main","index":0},{"node":"Final To-Do List Creator","type":"main","index":0},{"node":"Post-Campaign Analyst","type":"main","index":0}]]},"combine outputs":{"main":[[{"node":"Idea Generator","type":"main","index":0}]]},"Result organizer":{"main":[[{"node":"Final result","type":"main","index":0}]]},"Execution Planner":{"main":[[{"node":"Merge results 1/2","type":"main","index":9}]]},"Merge results 1/2":{"main":[[{"node":"Merge results","type":"main","index":0}]]},"Merge results 2/2":{"main":[[{"node":"Merge results","type":"main","index":1}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"Idea Generator","type":"ai_languageModel","index":0},{"node":"Market Analyst","type":"ai_languageModel","index":0},{"node":"Information Extractor","type":"ai_languageModel","index":0},{"node":"Post-Campaign Analyst","type":"ai_languageModel","index":0},{"node":"Final To-Do List Creator","type":"ai_languageModel","index":0},{"node":"Do's and Don'ts Advisor","type":"ai_languageModel","index":0},{"node":"Risk Management Expert","type":"ai_languageModel","index":0},{"node":"Monitoring and KPIs Expert","type":"ai_languageModel","index":0},{"node":"Budget Planning Specialist","type":"ai_languageModel","index":0},{"node":"Execution Planner","type":"ai_languageModel","index":0},{"node":"Channel Strategy Expert","type":"ai_languageModel","index":0},{"node":"guerrilla Tactics Designer","type":"ai_languageModel","index":0},{"node":"Main Strategy Architect","type":"ai_languageModel","index":0},{"node":"Key Messaging Specialist","type":"ai_languageModel","index":0},{"node":"Target Persona Researcher","type":"ai_languageModel","index":0},{"node":"Current Situation Analyst","type":"ai_languageModel","index":0},{"node":"Campaign Objectives Specialist","type":"ai_languageModel","index":0},{"node":"Campaign Definition Agent","type":"ai_languageModel","index":0},{"node":"Introduction Writer","type":"ai_languageModel","index":0}]]},"Introduction Writer":{"main":[[{"node":"Merge results 1/2","type":"main","index":0}]]},"Idea is good enough?":{"main":[[{"node":"Merge successful result","type":"main","index":2}],[{"node":"Merge failed results","type":"main","index":2}]]},"Merge failed results":{"main":[[{"node":"combine outputs","type":"main","index":0}]]},"Information Extractor":{"main":[[{"node":"Idea is good enough?","type":"main","index":0}]]},"Post-Campaign Analyst":{"main":[[{"node":"Merge results 2/2","type":"main","index":5}]]},"Risk Management Expert":{"main":[[{"node":"Merge results 2/2","type":"main","index":2}]]},"Channel Strategy Expert":{"main":[[{"node":"Merge results 1/2","type":"main","index":8}]]},"Do's and Don'ts Advisor":{"main":[[{"node":"Merge results 2/2","type":"main","index":3}]]},"Main Strategy Architect":{"main":[[{"node":"Merge results 1/2","type":"main","index":6}]]},"Merge successful result":{"main":[[{"node":"Combine outputs","type":"main","index":0}]]},"Final To-Do List Creator":{"main":[[{"node":"Merge results 2/2","type":"main","index":4}]]},"Key Messaging Specialist":{"main":[[{"node":"Merge results 1/2","type":"main","index":5}]]},"Campaign Definition Agent":{"main":[[{"node":"Merge results 1/2","type":"main","index":1}]]},"Current Situation Analyst":{"main":[[{"node":"Merge results 1/2","type":"main","index":3}]]},"Target Persona Researcher":{"main":[[{"node":"Merge results 1/2","type":"main","index":4}]]},"Budget Planning Specialist":{"main":[[{"node":"Merge results 2/2","type":"main","index":0}]]},"Monitoring and KPIs Expert":{"main":[[{"node":"Merge results 2/2","type":"main","index":1}]]},"When chat message received":{"main":[[{"node":"Input Parser","type":"main","index":0}]]},"guerrilla Tactics Designer":{"main":[[{"node":"Merge results 1/2","type":"main","index":7}]]},"Campaign Objectives Specialist":{"main":[[{"node":"Merge results 1/2","type":"main","index":2}]]}}}


