Load GitHub Prompts & Auto-Populate n8n Expressions

This n8n workflow loads prompt files from a GitHub repository and automatically fills dynamic variables in the prompts for AI processing, saving hours of manual editing and streamlining prompt management.
github
code
agent
+9
Workflow Identifier: 2264
NODES in Use: Manual Trigger, Set, GitHub, Extract From File, Code, If, Stop And Error, AI Agent, Set Prompt, Set Completed Prompt, Prompt Output, Ollama Chat Model
Load GitHub prompts with n8n and GitHub

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What this workflow does

This workflow helps load AI prompt templates from a GitHub repo and fills in variables automatically.
It solves long, error-prone manual editing and speeds up AI prompt creation.
The output is a ready-to-use prompt sent to AI for content generation.


Who should use this workflow

If you need to generate AI prompts often with placeholders to fill,
and want to stop copying and pasting manually,
this workflow fits well.
It suits content creators, digital marketers, or teams handling AI prompts regularly.


Tools and services used

  • n8n platform: To build and run the automation workflow.
  • GitHub API: To fetch prompt text files from repository.
  • Ollama AI and Langchain: For AI prompt processing.

Inputs, processing steps, and output explained

Inputs

  • GitHub account and repo info: Includes owner, repository name, file path, and prompt file name.
  • Variables for prompts: Company name, product, features, sector, etc.

Processing Steps

  1. Fetch prompt file: Downloads prompt markdown file using GitHub node dynamically.
  2. Extract text: Converts file content into plain prompt text.
  3. Detect placeholders: Finds all {{variable}} parts inside prompt text.
  4. Check variables: Compares placeholders to supplied variables to find missing ones.
  5. Replace placeholders: Substitutes missing placeholders with actual values given.
  6. Stop on errors: Halts if any required variable is missing with detail message.
  7. Send to AI: Passed final prompt to AI agents for output generation.

Output

The result is a finalized AI prompt with all needed variables filled.
This prompt is ready for SEO keyword research, content ideas, or other AI-driven tasks.


Beginner step-by-step: How to use this workflow in production

Import the workflow

  1. Download the workflow file by clicking the Download button on this page.
  2. Open your n8n editor where you build automations.
  3. Use the Import from File option to bring the workflow in.

Configure credentials and settings

  1. Add or update your GitHub API credentials with proper access rights.
  2. Insert Ollama AI account credentials for AI processing.
  3. Update any IDs, emails, channels, folders, or tables inside nodes if needed.
  4. Check and modify the setVars node variables like company name, product, and features to match your use case.

Test and activate

  1. Run the workflow manually once to check if it works fine.
  2. Look for errors and fix missing variables or wrong paths.
  3. When tests pass, activate the workflow for regular use.
  4. Consider replacing manual trigger with Webhook node or schedule node to automate.
  5. For users self hosting n8n, visit self-host n8n for hosting info.

Edge cases and failure points

  • If the GitHub node returns 404 or no content,
    check the repo owner, repo name, path, and filename in setVars.
  • If missing prompt variables appear,
    make sure all placeholders in the prompt file have matching keys in setVars.
  • If variable replacement is not happening,
    verify keys in the replacement code exactly match placeholder names.

Customization ideas

  • Add more variables inside the setVars node.
  • Make repo, path or prompt file dynamic by using webhook input or external parameters.
  • Switch Ollama AI with other n8n supported AI services like OpenAI.
  • Change placeholder syntax from {{ var }} to other formats in the code nodes.
  • Send AI outputs to other apps like Google Sheets or email after processing.

Code snippets to help activate the workflow

Check All Prompt Vars Present code node:

// Get prompt text
const prompt = $json.data;

// Extract variables inside {{ }} dynamically
const matches = [...prompt.matchAll(/{{(.*?)}}/g)];
const uniqueVars = [...new Set(matches.map(match => match[1].trim().split('.').pop()))];

// Get variables from the Set Node
const setNodeVariables = $node["setVars"].json || {};

// Check if all required variables are present in the Set Node
const missingKeys = uniqueVars.filter(varName => !setNodeVariables.hasOwnProperty(varName));

// Return false if any required variable is missing, otherwise return true
return [{
  success: missingKeys.length === 0,
  missingKeys: missingKeys
}];

Replace variables code node:

const prompt = $('SetPrompt').first().json.data;

const variables = {
  company: $('setVars').first().json.company,
  features: "Awesome Software",
  keyword: "2025-02-07"
};

const replaceVariables = (text, vars) => {
  return text.replace(/{{(.*?)}}/g, (match, key) => {
    const trimmedKey = key.trim();
    const finalKey = trimmedKey.split('.').pop();
    return vars.hasOwnProperty(finalKey) ? vars[finalKey] : match;
  });
};

return [{
  prompt: replaceVariables(prompt, variables)
}];

Summary of benefits and outcome

✓ Saves hours by automating prompt loading and variable filling.
✓ Stops manual copy-paste errors.
✓ Produces consistent, error-free AI prompts.
✓ Works with popular AI tools like Ollama and Langchain.
→ Get final AI prompts ready for SEO or content generation faster.


Load GitHub prompts with n8n and GitHub

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

Yes. The GitHub node uses your credentials which must have permission to access private repositories.
One API call happens each time the workflow fetches a prompt file. So usage depends on trigger frequency.
Yes. The code nodes contain regex and replacement logic that can be modified to handle different placeholder styles.
Yes. The workflow supports multiple AI integrations. Ollama can be swapped for OpenAI or other services by changing the relevant AI nodes.

Promoted by BULDRR AI

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.