Automated Prompt Loading from GitHub for Dynamic AI Responses

somdn_product_page

This n8n workflow automates the process of loading prompts stored in a GitHub repository and dynamically populates them with variables for AI processing. Starting with a manual trigger, the workflow fetches a prompt file from GitHub, extracts and replaces placeholders with predefined variables, checks for completeness, and then feeds the final prompt into an AI language model (Ollama) for generating responses.

Here’s a step-by-step breakdown:

1. Manual trigger initiates the workflow when a user clicks ‘Test workflow’.

2. Variables such as account info, repository name, file path, and other contextual data are set in the ‘setVars’ node.

3. The GitHub node retrieves the specified file (e.g., a Markdown prompt) from a public or private repository.

4. The content of the prompt file is extracted using ‘Extract from File’.

5. The prompt content and variables are passed to a custom code node (‘replace variables’) which replaces placeholder tags like {{ company }} with actual values.

6. The ‘Check All Prompt Vars Present’ node verifies whether all placeholders in the prompt have corresponding variables. If any are missing, the workflow stops and reports errors.

7. If all variables are in place, the final prompt is set and sent to the AI agent node, which interacts with the Ollama AI model to generate a response.

8. The output from the AI model is captured and stored or used as needed.

This workflow is useful for dynamically generating AI prompts based on external files stored in GitHub, which is ideal for teams managing large sets of prompts or content templates. It ensures prompts are filled with real-time data, maintains consistency, and streamlines AI interactions for varied use cases such as content generation, report automation, or customer support responses.

Node Count

11 – 20 Nodes

Nodes Used

@n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.lmChatOllama, code, extractFromFile, github, if, manualTrigger, set, stickyNote, stopAndError

Reviews

There are no reviews yet.

Be the first to review “Automated Prompt Loading from GitHub for Dynamic AI Responses”

Your email address will not be published. Required fields are marked *