n8n Master Workflows

repository·master·Indexed 20 days ago

https://github.com/djeknet/n8n-master-workflows

A curated collection of n8n automation templates designed for use with the n8n Master browser extension. The repository provides ready-to-use workflows across categories including AI & LLMs (RAG, OpenAI), Communication (Telegram, Slack, WhatsApp), Productivity (Google Sheets, Notion, Airtable), and Social Media. It includes detailed implementation guides for building PDF-based knowledge bases using PostgreSQL PGVector, handling Telegram voice-to-text transcription, and creating 'human-in-the-loop' AI agent tools.

Tokens
2.4K
Snippets
5
Records
9
Agent score
70%

What's inside n8n-master-workflows

  1. Explore n8n Automation Template Categories

    master

    This repository serves as a collection of ready-made n8n automation templates. These templates are categorized by the services they integrate with, allowing you to automate tasks across various platforms.

    Available categories include:

    • Communication: Telegram, Gmail & Email, Slack, WhatsApp, Discord, LINE.
    • Productivity & Data: Google Drive & Google Sheets, Notion, Airtable, Google Calendar.
    • AI & LLMs: OpenAI, LLMs, RAG (Retrieval-Augmented Generation), AI Research, and Data Analysis.
    • Social Media: Instagram, Twitter (X), TikTok, Pinterest, YouTube.
    • Content & Documents: WordPress, PDF & Document Processing.
    • Business & Dev Tools: CRM (Pipedrive, HubSpot), Databases (Postgres, MongoDB, Supabase), and Forms (n8n Forms).
  2. Create an Internal Policy Vector Store with PostgreSQL

    master

    A vector store enables Retrieval-Augmented Generation (RAG) by matching natural language queries to relevant text chunks. This workflow uses PostgreSQL with PGVector support for production-ready storage.

    The RAG Pipeline:

    1. Text Splitting: Use the Recursive Character Text Splitter to break large documents into manageable segments (e.g., chunkSize: 2000).
    2. Embedding: Use an embedding model (like Embeddings OpenAI) to transform text segments into numerical vectors.
    3. Storage: Use the vectorStorePGVector node in insert mode to store these vectors and their metadata in PostgreSQL.
    4. Retrieval: When a user asks a question, the system embeds the query and finds the most relevant vectors in the database.
    // Example configuration for the Recursive Character Text Splitter
    {
      "name": "Recursive Character Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "parameters": {
        "options": {},
        "chunkSize": 2000
      }
    }
  3. Workflow Logic: Validating user email in a sub-workflow

    master

    When an AI agent calls a sub-workflow for help, you can implement logic to ensure the agent has enough information to proceed.

    Logic Flow:

    1. Trigger: Execute Workflow Trigger receives data from the AI tool.
    2. Validation: Use an If node with a Regex condition to check if the chatInput contains a valid email address.
      • Regex: /([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)/gi
    3. Branch - No Email: If the regex fails, use a Code node to return a message prompting the user to provide an email address.
    4. Branch - Email Found: If the regex passes, use a Slack node to notify a support channel with the user's message, then use a Code node to confirm to the user that a human has been notified.
  4. Configure an AI Agent for Helpdesk Support

    master

    The AI Agent acts as the central intelligence, providing conversational support by accessing the knowledge base and maintaining conversation context.

    Key Components for the Agent:

    • Vector Store Tool: Connect the agent to the Postgres PGVector Store using a toolVectorStore node. This allows the agent to perform RAG to answer specific policy questions.
    • Chat Memory: Use Postgres Chat Memory to track the sessionId (typically the Telegram chat.id). This allows the agent to remember previous parts of the conversation.
    • Language Model: Connect an OpenAI Chat Model to drive the reasoning and response generation.
    • System Prompt: Configure the systemMessage (e.g., "You are a helpful assistant for HR and employee policies") to define the agent's persona and boundaries.
    // Example AI Agent configuration
    {
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "You are a helpful assistant for HR and employee policies"
        },
        "promptType": "define"
      }
    }
  5. Build a Knowledge Base from PDF Documents

    master

    To create a knowledge base for an HR or IT helpdesk assistant, you must first ingest and parse your internal policy documents (e.g., employee handbooks, FAQs).

    Steps:

    1. Fetch the Document: Use the HTTP Request node to download the PDF from a direct URL (e.g., a shared cloud storage link).
    2. Parse Content: Use the Extract from File node with the operation set to pdf to convert the binary PDF data into extractable text.
    3. Prepare for Vectorization: The extracted text is then passed to a data loader to be processed into the vector store.
    // Example node configuration for extracting PDF text
    {
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "parameters": {
        "operation": "pdf"
      }
    }
  6. Implement a 'Human-in-the-loop' tool for AI Agents

    master

    You can enable an AI Agent to request human assistance by using the Tool Workflow node. This allows the agent to call a sub-workflow when it encounters a query it cannot answer or lacks confidence in.

    Implementation Pattern

    1. Main Workflow: Create an AI Agent with a Chat Trigger. Attach a Tool Workflow node to the agent's ai_tool input.
    2. Tool Configuration: In the Tool Workflow node, set the description to instruct the agent when to use it (e.g., "Use this tool if you don't know the answer...").
    3. Sub-workflow: Create a separate workflow starting with an Execute Workflow Trigger. This sub-workflow handles the logic of what happens when the tool is called (e.g., checking for user data or sending a notification to Slack).
    4. Data Passing: Use the fields parameter in the Tool Workflow node to pass relevant data from the main workflow (like chatInput) to the sub-workflow.
    {
      "name": "dont_know_tool",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "parameters": {
        "workflowId": "={{ $workflow.id }}",
        "description": "Use this tool if you don't know the answer to the user's question, or if you're not very confident about your answer.",
        "fields": {
          "values": [
            {
              "name": "chatInput",
              "stringValue": "={{ $('Chat Trigger').item.json.chatInput }}"
            }
          ]
        }
      }
    }
  7. Handle Telegram Text and Voice Messages

    master

    This workflow processes incoming Telegram messages by distinguishing between text and audio inputs to ensure a consistent experience for the AI agent.

    Message Routing Logic:

    1. Trigger: The Telegram Trigger listens for incoming messages.
    2. Type Verification: A Switch node checks the keys in $json.message:
      • Text: If the message contains text, it is routed to an Edit Fields node to normalize the format.
      • Voice: If the message contains voice, the workflow uses the Telegram node to fetch the file, then uses the OpenAI node with the audio/transcribe operation to convert the voice to text.
      • Fallback: If the message type is unsupported, a Telegram node sends a fallback response: "I'm not able to process this message type."
    3. Unified Input: Both text and transcribed audio are sent to the AI Agent in a standardized format.
    // Example OpenAI transcription configuration
    {
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "binaryPropertyName": "=data"
      }
    }
  8. Configure the 'Not sure?' Tool Workflow node

    master

    The Tool Workflow node (used as dont_know_tool in this example) allows an AI Agent to trigger a sub-workflow.

    Key Parameters:

    • name: The internal identifier for the tool.
    • description: A natural language instruction for the AI Agent explaining when and why it should invoke this tool.
    • workflowId: The ID of the sub-workflow to execute.
    • fields: Defines the schema of data passed to the sub-workflow. In this pattern, chatInput is passed to ensure the sub-workflow knows what the user originally asked.