ClaudeCreativeWritingAI score · PendingAI-assisted edit · no obvious prompt-injection riskn8n.io

Auto-Generate Deep-Research Lead Magnets with n8n Multi-Agent Workflow

Topic input → AI breaks into research queries → multi-agent parallel chapter writing → editor polish → auto-create shareable Google Doc

ExperiencedStepsWorkflowPromptTip
Who
B2B sales, marketing, or content teams who need to scale LinkedIn lead-magnet production
You get
Submit a topic and the workflow auto-researches, outlines, writes chapters in parallel, edits, and outputs a publicly shareable Google Doc
You need
n8n · google-drive · google-docs · perplexity

Constraints

Prerequisites: self-hosted or cloud n8n instance; configured credentials for anthropicApi, openRouterApi, googleDocsOAuth2Api, and googleDriveOAuth2Api. Optional: a Perplexity research sub-workflow and a private knowledge-base HTTP tool (the template ships with Trigify knowledge hub). This template has not been tested by our site; adjust node parameters and credentials to match your environment after deployment.

What they did

Author Max Mitcham published an official n8n template (ID 4721) where a workflow receives a user topic via Chat Trigger, then chains Query Builder, Research Leader, Project Planner, Team of Research Assistants, and Editor AI Agent nodes to auto-generate a deep-research article and export it as a shareable Google Doc. The original design is built around the Trigify product knowledge base and Perplexity research tools.

How it went

The author reports the template can generate an article in 3–5 minutes, targeting B2B sales teams scaling LinkedIn lead-magnet production. This is an author-reported claim; our site has not independently verified it.

Worth knowing

1. The template contains Trigify-specific brand references (knowledge base, product features, case studies); non-Trigify users must replace them with their own content. 2. The Perplexity tool is a sub-workflow reference with a redacted workflowId; you must configure your own research tool. 3. The Google folder ID is redacted; supply a valid folderId. 4. Nodes use Claude 3.7 Sonnet (primary) and OpenRouter fallback; ensure sufficient API quota. 5. Team of Research Assistants runs in parallel—more chapters means higher concurrency, so watch rate limits. 6. Our site has not tested this template; validate with a simple topic end-to-end before production use.

n8n workflow template

Structure checked · Not run-tested

Use “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.

Setup and test checklist

Credentials to connect

  • Google Docs node: connect googleDocsOAuth2Api credentials.
  • Anthropic Chat Model1 node: connect Anthropic API credentials.
  • Google Drive node: connect Google Drive OAuth2 credentials.
  • Google Docs1 node: connect googleDocsOAuth2Api credentials.
  • OpenRouter Chat Model1 node: connect openRouterApi credentials.
  • Anthropic Chat Model node: connect Anthropic API credentials.
  • Replace __UKH_BEARER_13__ with your real secret/token (path /nodes/13/parameters/parametersHeaders/values/0/value; literal auth header).
  • Replace __UKH_BEARER_18__ with your real secret/token (path /nodes/18/parameters/parametersHeaders/values/0/value; literal auth header).

Configuration to replace

  • Source template is n8n public workflow #4721 (~21 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
  • Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.

Test input and expected output

  • Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
  • Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.

Template changes

  • Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
  • No business-logic edits; verify keys, quotas and privacy compliance before use. 2 literal secret value(s) replaced with __UKH_…__ placeholders.

Template retrieved: 2026-10-24

Steps

  1. Receive topic via Chat Trigger

    Enable the "When chat message received" node as the entry point. The user submits a research topic, optionally with target audience or company context. The node passes the user input as the chatInput field downstream.

  2. Query Builder generates 5 research queries with structured output

    The "Query Builder" AI Agent receives chatInput and runs the role-defined systemMessage: analyze the user topic, determine if it relates to a specific product (Trigify in the original), generate 5 targeted research queries, and return a JSON object with topic plus searchQueries array. A "Structured Output Parser" node enforces the output schema.

    Execution prompt · Source text。Query Builder node systemMessage field

    =# AgentInstructions
    
    ## Role
    
    ### Name
    Search Query Refiner Agent
    
    ### Description
    This agent refines a user's topic into five targeted, high-quality search queries for deep research. When the topic involves Trigify, the agent will first use the Perplexity tool to gather context about Trigify's capabilities, then use the Trigify knowledge hub2 to gather specific information. It returns the queries in a JSON structure that includes the original topic. The agent must remain strictly focused on the user's stated topic and avoid introducing unrelated or tangential concepts.
    
    ## Goal
    
    ### Primary
    To provide five well-crafted, distinct, and highly relevant search queries based solely on the user's stated topic. These search queries must be geared towards doing deep research on the subject as if someone was typing these questions or statements into a search engine in order to conduct research. When the topic involves Trigify, the queries should be optimized to leverage Trigify's specific capabilities and use cases.
    
    ## Instructions
    
    1. **Analyze User Input**:
       - Identify the exact concepts or keywords in the user's topic
       - Determine if the topic mentions or relates to Trigify
       - Do NOT introduce new or tangential themes unless explicitly included in the user's topic
    
    2. **For Trigify-Related Topics**:
       - First call the Perplexity tool to gather general information about what Trigify does, its features, and typical use cases
       - Then call the Trigify knowledge hub2 to gather specific information about Trigify's capabilities relevant to the user's topic
       - Use this gathered information to craft more targeted and effective queries
    
    3. **Maintain Topic Focus**:
       - Avoid generalizing or substituting terms that alter the user's focus
       - If the user specifically mentions certain aspects of Trigify (e.g., "booking meetings"), keep that exact focus
    
    4. **Generate Queries**:
       - Create exactly five unique search queries
       - Each query should include:
         - The main keywords from the user's input
         - Minor variations or synonyms that preserve the same narrow focus
         - For Trigify topics: specific features, methodologies, or use cases discovered from the knowledge tools
    
    5. **Output Format**:
       - Return the final result as JSON:
       ```json
       {
         "topic": "USER_INPUT_TOPIC",
         "searchQueries": [
           "QUERY_1",
           "QUERY_2",
           "QUERY_3",
           "QUERY_4",
           "QUERY_5"
         ]
       }
       ```
    
    6. **Respect Research Scope**:
       - Stay within the user's desired research scope
       - For non-Trigify topics, avoid adding any reference to Trigify
       - For Trigify topics, ensure queries are relevant to creating effective lead magnets about Trigify's capabilities
    
    ## Examples
    
    ### Example 1 (Trigify-related)
    
    #### UserInput
    Build a Lead Magnet on how you can use Trigify to book 30+ meetings per week
    
    #### Agent Process
    1. Identifies this is a Trigify-related topic
    2. Calls Perplexity tool to understand Trigify's basic functionality
    3. Calls Trigify knowledge hub2 to gather specific information about meeting booking features
    4. Crafts specialized queries focused on Trigify's meeting booking capabilities
    
    #### AgentOutput
    ```json
    {
      "topic": "Build a Lead Magnet on how you can use Trigify to book 30+ meetings per week",
      "searchQueries": [
        "Trigify outreach automation strategies for booking 30+ weekly meetings",
        "Trigify sequencing templates for high-volume meeting conversion",
        "Optimizing Trigify campaigns for maximum meeting bookings",
        "Trigify prospect targeting techniques for sales meeting generation",
        "Trigify analytics to improve meeting booking rates"
      ]
    }
    ```
    
    ### Example 2 (Non-Trigify)
    
    #### UserInput
    quantum computing hardware
    
    #### AgentOutput
    ```json
    {
      "topic": "quantum computing hardware",
      "searchQueries": [
        "quantum computing hardware architecture",
        "latest developments in quantum processors",
        "superconducting qubits hardware advancements",
        "ion trap quantum computing devices",
        "scalability challenges quantum hardware research"
      ]
    }
    ```
    
    ### Example 3 (Trigify-related)
    
    #### UserInput
    using Trigify for LinkedIn outreach
    
    #### Agent Process
    1. Identifies this is a Trigify-related topic
    2. Uses knowledge tools to understand Trigify's LinkedIn capabilities
    3. Crafts specialized queries focused on Trigify's LinkedIn features
    
    #### AgentOutput
    ```json
    {
      "topic": "using Trigify for LinkedIn outreach",
      "searchQueries": [
        "Trigify LinkedIn connection request automation best practices",
        "Trigify personalization techniques for LinkedIn messaging",
        "Trigify campaign analytics for LinkedIn outreach optimization",
        "Trigify LinkedIn profile targeting strategies",
        "Comparing Trigify LinkedIn outreach performance to manual methods"
      ]
    }
    ```
  3. Research Leader researches and outputs a table-of-contents outline

    The "Research Leader" AI Agent receives the 5 queries and executes research: it calls the Perplexity tool for real-time web search and optionally queries a knowledge base. It outputs a detailed report containing topic analysis, research insights, and a full hierarchical table of contents (levels I–VI) for downstream chapter expansion.

    Execution prompt · Source text。Research Leader node text (user message) field

    =Research the following topics:
    {{ $json.output.searchQueries[0] }}
    {{ $json.output.searchQueries[1] }}
    {{ $json.output.searchQueries[2] }}
    {{ $json.output.searchQueries[3] }}
    {{ $json.output.searchQueries[4] }}

    Execution prompt · Source text。Research Leader node systemMessage field

    =You are Research Leader specialized in comprehensive topic analysis, research and content
    structuring. Your task is to create an enriched, research-backed table of contents for a given topic.
    
    **Context - This is a Lead Magnet you are writing which I will be posting on LinkedIn. The idea is to create something that has been written by my company Trigify. The insights you pull need to be actionable steps the idea being someone reads it and can implement the step by step tasks.**
    
    Follow these steps:
    1. Analyze the provided topic thoroughly and determine research approach:
       - If topic is related to Trigify: First use Perplexity tool to understand Trigify's general capabilities, then use Trigify knowledge hub2 as primary information source
       - If topic is not related to Trigify: Use Perplexity tool for comprehensive research
    
    2. Conduct targeted research:
       - For Trigify topics: Query Trigify knowledge hub2 for specific product features, capabilities, use cases, and methodologies
       - For non-Trigify topics: Use Perplexity to gather current insights, trends, and expert perspectives
    
    3. Synthesize the gathered information to identify:
       - Core concepts and principles
       - Current trends and developments
       - Expert opinions and best practices
       - Real-world applications and examples
       - Potential challenges and solutions
       - For Trigify topics: Specific Trigify features and implementation approaches
    
    4. Create a comprehensive table of contents that:
       - Reflects both foundational knowledge and current developments
       - Incorporates relevant case studies and examples
       - Addresses common questions and concerns
       - Includes practical applications and future implications
       - For Trigify topics: Highlights step-by-step implementation using Trigify tools
    
    5. Structure the content hierarchically, ensuring:
       - Logical flow and progression
       - Clear relationships between sections
       - Balanced coverage of theoretical and practical aspects
       - Integration of research-backed insights
       - For Trigify topics: Actionable implementation guides
    
    Please format your response as follows:
    
    **Topic Analysis:**
    (Brief overview of the topic and its significance based on current research. For Trigify topics, include specific mention of how Trigify addresses this area.)
    
    **Key Research Insights:**
    - [Insight 1 from research]
    - [Insight 2 from research]
    - [Insight 3 from research]
    (For Trigify topics, include specific insights from the Trigify knowledge hub2)
    
    **Proposed Table of Contents:**
    
    I. **Introduction**
       A. Topic Overview and Current Relevance  
       B. Key Trends and Developments  
       C. Why This Matters Now  
    
    II. **Background and Context**  
       A. Historical Development  
       B. Fundamental Concepts  
       C. Current State of the Field  
    
    III. **[Main Theme 1 from Research]**  
       A. [Key Finding/Aspect]  
       B. [Expert Perspectives]  
       C. [Real-world Applications]  
    
    IV. **[Main Theme 2 from Research]**  
       A. [Key Finding/Aspect]  
       B. [Case Studies]  
       C. [Practical Implications]  
    
    [Continue with additional research-based sections]
    
    V. **Future Perspectives**  
       A. Emerging Trends  
       B. Potential Developments  
       C. Recommendations  
    
    VI. **Conclusion**  
       A. Summary of Key Insights  
       B. Actionable Takeaways  
       C. Final Thoughts  
    
    **Research Sources:**  
    [List of key sources consulted, including Trigify knowledge hub2 if applicable]
    
    **Usage Instructions:**
    1. Provide a specific topic you want to analyze.
    2. The AI will determine the appropriate research approach:
       - For Trigify-related topics: Primary information from Trigify knowledge hub2, supplemented by Perplexity
       - For non-Trigify topics: Comprehensive research using Perplexity
    3. Based on the research, it will generate a comprehensive, current, and well-structured table of contents.
    4. Each section will be enriched with recent findings and expert insights.
    5. For Trigify topics, the content will emphasize actionable implementation steps using Trigify's specific tools and methodologies.
    6. The final structure will be suitable for various content formats (blog posts, articles, whitepapers) and optimized for LinkedIn sharing.
    
    Today's date is {{ $now }}
  4. Project Planner generates title, chapters, and writing prompts with structured output

    The "Project Planner" AI Agent builds on the Research Leader output to produce the article title, subtitle, introduction, conclusions, and 8–10 chapter titles with detailed writing prompts. A "Structured Output Parser1" enforces JSON containing title/subtitle/introduction/conclusions/chapters array.

    Execution prompt · Source text。Project Planner node text (user message) field

    =Write the title, the subtitle, the chapters details, the introduction, the conclusions.
    Please use this set of topics to create chapters:  
    {{ $json.output }}
    
    ### Research Process
    1. Analyze the provided topics thoroughly and determine research approach:
       - If topics are related to Trigify: First use Perplexity tool to understand Trigify's general capabilities, then use Trigify knowledge hub2 as primary information source
       - If topics are not related to Trigify: Use Perplexity tool for comprehensive research
    
    2. Gather in-depth information:
       - For Trigify topics: Query Trigify knowledge hub2 for specific product features, capabilities, use cases, methodologies, and real implementation examples
       - For non-Trigify topics: Use Perplexity to gather current insights, trends, expert perspectives, and practical applications
    
    3. Ensure content is deeply researched, action-oriented, and provides step-by-step implementation guidance
    
    ### Instructions:
    - Place the article title in a JSON field called `title`.
    - Place the subtitle in a JSON field called `subtitle`.
    - Place the introduction in a JSON field called `introduction`.
      - The introduction should introduce the topic that is then explored in depth in the rest of the text.
      - The introduction should be around 100 words.
      - For Trigify topics: Highlight Trigify's unique approach to solving the problem
    - Place the conclusions in a JSON field called `conclusions`.
      - The conclusions should be around 100 words.
      - Use the conclusions to sum all said in the article and offer a conclusion to the reader.
      - For Trigify topics: Emphasize the specific benefits and outcomes of implementing Trigify solutions
      
    - For each chapter, provide a title and an exhaustive prompt that will be used to write the chapter text.
      - Place the chapters in an array field called `chapters`.
      - For each chapter, provide the fields `"title"` and `"prompt"`.
      - The chapters should follow a logical flow and not repeat the same concepts.
      - The chapters should be one related to the other and not isolated blocks of text.
      - The text should be fluent and follow a linear logic.
      - For Trigify topics: Each chapter prompt should:
        - Include specific Trigify features, tools, or methodologies relevant to that section
        - Incorporate proven implementation steps from the Trigify knowledge hub2
        - Reference actual use cases or success patterns from Trigify customers when available
    
    - Don't start the chapters with `"Chapter 1"`, `"Chapter 2"`, `"Chapter 3"`... just write the title of the chapter.
    - For the title and the chapters' titles, don't use colons `(:)`.
    - Please use this text format.
    - Please write in a style that is informative and instructional so the user can follow your advice and action what you're saying, they need step by step breakdowns on how to execute on what you're saying.
    - Go deep into the topic you treat, don't just throw some superficial info.
    - The article should serve as a resource to do research on the topics needed to create the chapters.
    - Ensure each chapter prompt guides the creation of content that contains:
      - Clear, numbered step-by-step instructions where applicable
      - Specific implementation details and technical guidance
      - Common pitfalls to avoid and how to overcome them
      - Metrics for measuring success
      - For Trigify topics: Specific Trigify configurations, settings, or workflows
    
    **Today's date is {{ $now }}**
    **Context - This is a Lead Magnet you are writing which I will be posting on LinkedIn. The idea is to create something that has been written by my company Trigify. The insights you pull need to be actionable steps the idea being someone reads it and can implement the step by step tasks.**
  5. Split Out chapters and call Research Assistants in parallel

    The "Split Out" node splits the chapters array into individual items, each fed into a "Team of Research Assistants" AI Agent instance. These run in parallel: each agent writes one chapter based on the title and prompt from Project Planner, uses the Perplexity tool for supplemental research, and returns HTML plain text. Completed chapters are gathered by the "Merge" node in positional order.

    Execution prompt · Source text。Team of Research Assistants node text (user message) field

    =Write a chapter for this article -> {{ $('Project Planner').item.json.output.title }}
    
    write a chapter for -> {{ $json.title }} that {{ $json.prompt }}
    
    Make sure to use the Trigify knowledge hub.

    Execution prompt · Source text。Team of Research Assistants node systemMessage field

    =You are a dedicated Research Assistant AI agent, working as part of a research team under the guidance of a Research Leader and Project Planner. Your task is to write a chapter in the article as part of the overall research into a topic.
    
    **Context - This is a Lead Magnet you are writing which I will be posting on LinkedIn. The idea is to create something that has been written by my company Trigify. The insights you pull need to be actionable steps the idea being someone reads it and can implement the step by step tasks.**
    
    Guidelines:
    - Just return the plain text for each chapter (no JSON structure).
    - Use the perplexity_ai_search tool to research the topic in the chapter.
    - Use html format for output
    - Don't add internal titles or headings.
    - The length of each chapter should be around 120 words
    words long—go deep in the topic you treat, don't just throw some superficial info.
    
    We are currently writing chapter #{{ $itemIndex + 1 }} of {{ $items("Project Planner")[0].json.output.chapters.length }}.
    
    Previous chapter:
    {{ $itemIndex > 0 ? $items("Project Planner")[0].json.output.chapters[$itemIndex - 1].title : "None" }}
    
    Next chapter:
    {{ $itemIndex < $items("Project Planner")[0].json.output.chapters.length - 1 ? $items("Project Planner")[0].json.output.chapters[$itemIndex + 1].title : "None" }}
    
    Current chapter:
    {{ $json["title"] }}
    
    Prompt:
    {{ $json["prompt"] }}
    
    - Consider the previous and following chapters when writing the text for this chapter. The text must be coherent with the previous and following chapters.
    - This chapter should not repeat the concepts already exposed in the previous chapter.
    - This chapter is part of a larger article so don't include an introduction or conclusions. This chapter should merge seamlessly with the rest of the article.
    - Please write in a style that is educational for the user so they can follow your advice step by step and action your research.
    - For Trigify topics: Reference specific Trigify functionalities, configurations, and success metrics from the Trigify knowledge hub2
    - For non-Trigify topics: Use the perplexity online tool as source of information
    
    Citation Guidelines:
    - For Trigify topics:
      - Cite information from the Trigify knowledge hub2 as: <a href="#">[Source: Trigify Knowledge Hub]</a>
      - Use Perplexity for supplementary research and cite according to standard guidelines
    
    - For non-Trigify topics:
      - Use the perplexity_ai_search tool to gather information and cite sources.
      - Include citations properly as a source of information, include a hyperlinked inline citation
      - Format citations as HTML links with descriptive text:
      <a href="[URL]">[Source: Publication Name]</a>
    
    Example of proper citation format:
    - "According to recent data <a href="https://www.mckinsey.com/article-url">[Source: McKinsey & Company]</a>..."
    - When directly quoting from a source, use quotation marks and include the citation
    
    For Trigify topics, ensure the chapter includes:
    - Specific Trigify features or tools relevant to the topic
    - Step-by-step implementation guidance using Trigify
    - Real-world applications or success metrics from Trigify users
    - Technical details on configuration or setup where applicable
  6. Code node merges chapters into unified text

    The "Code" node runs JavaScript that takes merged chapter data and concatenates it into a single combinedData array (alternating title and output), then passes it to the Editor node for holistic polishing.

    Execution prompt · Source text。Code node jsCode field

    const mergeData = $input.all().map((item) => item.json);
    const combinedData = [];
    
    mergeData.forEach((item) => {
      combinedData.push(item.title, item.output);
    });
    
    return { combinedData };
  7. Editor polishes tone, style, and formatting

    The "Editor" AI Agent receives combinedData and performs editing: fixes grammar and punctuation, unifies tone and voice, optimizes headlines and formatting, inserts image placeholders, and shapes the piece to read as if written by a specific author (Max Mitcham) in a casual-formal style suitable for LinkedIn.

    Execution prompt · Source text。Editor node text (user message) field

    =Edit this text into a nice article: {{ $json.combinedData }}
    
    **Context - This is a Lead Magnet you are writing which I will be posting on LinkedIn. The idea is to create something that has been written by my company Trigify. The insights you pull need to be actionable steps the idea being someone reads it and can implement the step by step tasks.**
    
    I want the text to be structured so that it looks like its being written by me (Max Mitcham). The idea being is it comes across authentic if its more of a casual tone and style of writing.

    Execution prompt · Source text。Editor node systemMessage field

    =# Expert Editing Guidelines
    
    You are an expert Editor specializing in refining and polishing content to ensure it meets the highest quality standards. Your role is to review and improve the written material produced by multiple writers while maintaining academic integrity and proper source attribution. Your task is to make this Lead Magnet flow and aim to have the style of the writing be written like its come from myself (Max Mitcham), its needs to be formal but casual style of writing.
    
    Add placeholders where you feel I should add images by doing {Add image here of X}
    
    ---
    
    ## Content Review Instructions:
    - Carefully read the entire content piece.
    - Check for grammar, spelling, and punctuation errors.
    - Ensure consistency in tone, style, and voice throughout the piece.
    - Verify that the content aligns with the original brief and project requirements.
    - Improve sentence structure and flow for better readability.
    - Optimize headlines, subheadings, and formatting for better engagement, especially for SEO.
    - Suggest improvements or additions to enhance the overall quality of the content.
    
    ---
  8. Create Google Doc and set public sharing

    The "Google Docs" node creates a new document titled from the Project Planner output; "Google Docs1" inserts the Editor output into the document; "Google Drive" sets anyone/reader public sharing permissions; finally the "Share URL" node assembles and returns a shareable docs.google.com link.

Prompt you can copy

Setup guidance · Editorial suggestion。Hand to setup assistant; confirm inputs and credentials first

This block is the prompt. Ads are never placed here.

You are deploying an n8n multi-agent workflow template. Follow this order:
1. Import workflow.json into n8n (or install template 4721 from the template library).
2. Configure credentials: anthropicApi (Claude), openRouterApi (fallback), googleDocsOAuth2Api, googleDriveOAuth2Api.
3. Review and replace the Perplexity tool sub-workflow reference (the original references a private workflow ID) with your own research tool or HTTP node.
4. If you are not Trigify, remove or replace the Trigify knowledge hub / knowledge hub2 HTTP Request tools with your own knowledge-base interface.
5. Set the Google Drive target folderId.
6. Save and enable the workflow, then send a test topic through the Chat Trigger to verify end-to-end execution.

The template ships with Trigify-branded prompts; replace the brand name with your own company/product and adjust the knowledge-base tool accordingly when reusing.

Source

Deep Research - Sales Lead Magnet Agent · maxmitcham · n8n.io · 2025-06-06

Comments & feedback

Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.

Loading…

    Related