Fetch dynamic prompts from GitHub and auto-populate n8n expressions in prompt
Workflow preview
DISCOUNT 20%
Important notice
This workflow is provided as-is. Please review and test before using in production.
Overview
Who Is This For?
This workflow is designed for AI engineers, automation specialists, and content creators who need a scalable system to dynamically manage prompts stored in GitHub. It eliminates manual updates, enforces required variable checks, and ensures that AI interactions always receive fully processed prompts.
๐ What Problem Does This Solve?
Manually managing AI prompts can be inefficient and error-prone. This workflow:
โ
Fetches dynamic prompts from GitHub
โ
Auto-populates placeholders with values from the setVars node
โ
Ensures all required variables are present before execution
โ
Processes the formatted prompt through an AI agent
๐ How This Workflow Works
This workflow consists of three key branches, ensuring smooth prompt retrieval, variable validation, and AI processing.
1๏ธโฃ Retrieve the Prompt from GitHub (HTTP Request โ Extract from File โ SetPrompt)
- The workflow starts manually or via an external trigger.
- It fetches a text-based prompt stored in a GitHub repository.
- The Extract from File Node retrieves the content from the GitHub file.
- The SetPrompt Node stores the prompt, making it accessible for processing.
๐ Note:
The prompt must contain n8n expression format variables (e.g., {{ $json.company }}) so they can be dynamically replaced.
2๏ธโฃ Extract & Auto-Populate Variables (Check All Prompt Vars โ Replace Variables)
- A Code Node scans the prompt for placeholders in the n8n expression format (
{{ $json.variableName }}). - The workflow compares required variables against the
setVarsnode:- โ If all variables are present, it proceeds to variable replacement.
- โ If any variables are missing, the workflow stops and returns an error listing them.
- The Replace Variables Node replaces all placeholders with values from
setVars.
๐ Example of a properly formatted GitHub prompt:
Hello {{ $json.company }}, your product {{ $json.features }} launches on {{ $json.launch_date }}.
This ensures seamless replacement when processed in n8n.
3๏ธโฃ AI Processing & Output (AI Agent โ Prompt Output)
- The Set Completed Prompt Node stores the final, processed prompt.
- The AI Agent Node (Ollama Chat Model) processes the prompt.
- The Prompt Output Node returns the fully formatted response.
๐ Optional: Modify this to use OpenAI, Claude, or other AI models.
โ ๏ธ Error Handling: Missing Variables
If a required variable is missing, the workflow stops execution and provides an error message:
โ ๏ธ Missing Required Variables: ["launch_date"]
This ensures no incomplete prompts are sent to AI agents.
โ Example Use Case
๐ GitHub Prompt File (Using n8n Expressions)
Hello {{ $json.company }}, your product {{ $json.features }} launches on {{ $json.launch_date }}.
๐น Variables in setVars Node
{
"company": "PropTechPro",
"features": "AI-powered Property Management",
"launch_date": "March 15, 2025"
}
โ Successful Output
Hello PropTechPro, your product AI-powered Property Management launches on March 15, 2025.
๐จ Error Output (If Missing launch_date)
โ ๏ธ Missing Required Variables: ["launch_date"]
๐ง Setup Instructions
1๏ธโฃ Connect Your GitHub Repository
- Store your prompt in a public or private GitHub repo.
- The workflow will fetch the raw file using the GitHub API.
2๏ธโฃ Configure the SetVars Node
- Define the required variables in the SetVars Node.
- Make sure the variable names match those used in the prompt.
3๏ธโฃ Test & Run
- Click Test Workflow to execute.
- If variables are missing, it will show an error.
- If everything is correct, it will output the fully formatted prompt.
โก How to Customize This Workflow
๐ก Need CRM or Database Integration?
- Connect the
setVarsnode to an Airtable, Google Sheets, or HubSpot API to pull variables dynamically.
๐ก Want to Modify the AI Model?
- Replace the Ollama Chat Model with OpenAI, Claude, or a custom LLM endpoint.
๐ Why Use This Workflow?
โ
No Manual Updates Required โ Fetches prompts dynamically from GitHub.
โ
Prevents Broken Prompts โ Ensures required variables exist before execution.
โ
Works for Any Use Case โ Handles AI chat prompts, marketing messages, and chatbot scripts.
โ
Compatible with All n8n Deployments โ Works on Cloud, Self-Hosted, and Desktop versions.