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

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

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

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.


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 Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free