Skip to main content

Create custom reasoning patterns for AI agents with GraphRAG & knowledge ontology

Workflow preview

Workflow preview
100%
Create custom reasoning patterns for AI agents with GraphRAG & knowledge ontology preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Teach your AI agent HOW to think, not WHAT to think This workflow demonstrates...

Best for

  • Engineering automation workflows
  • AI RAG automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.chattrigger, @n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.memorybufferwindow, n8n-nodes-base.httprequesttool, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.stickynote

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by InfraNodus.

Original n8n.io source

1.1 Workflow description

Title
Create custom reasoning patterns for AI agents with GraphRAG & knowledge ontology
Workflow name
Create custom reasoning patterns for AI agents with GraphRAG & knowledge ontology

Teach your AI agent HOW to think, not WHAT to think

This workflow demonstrates how you can build an AI agent in n8n that uses the reasoning logic you define. So an LLM learns a way of thinking, which you can then apply to multiple problems:

  • Make an AI chatbot that knows how to convince anybody using the "Getting to Yes" method
  • Build an LLM workflow that uses Ray Dalio's principles to spot investment opportunities
  • Create an AI agent crew of interdisciplinary thinkers: e.g. a specialist in psychology who gives an advice on education programmes.

How it works

This template uses the n8n AI agent node as an orchestrating agent that has access to a certain reasoning logic defined by an InfraNodus knowledge graph.

This graph contains a list of reasoning rules (ontology), which is extracted to provide an advice that is relevant to the original prompt. It uses GraphRAG under the hood to traverse the parts of the graph relevant to the query.

This advice and the reasoning logic extracted is then used by the AI agent to generate a response that is relevant to the user's query but that uses the reasoning logic provided through the graph.

Here's a description step by step:

  • The user submits a question using the AI chatbot (n8n interface, in this case, a web form that can be embedded to any website, or a webhook that can be connected to a Telegram / WhatsApp bot)
  • The AI agent node accesses the Reasoning Logic HTTP InfraNodus nodes. The description of AI agent and the description of the reasoning InfraNodus node provides the agent with an understanding of how to rephrase the original question to retrieve relevant reasoning logic.
  • The request is sent to the InfraNodus node. It provides a response that contains the reasoning logic needed to answer the question.
  • This reasoning logic is then sent back to an LLM along with the original query to produce the response.

InfraNodus uses GraphRAG under the hood:

  • convert user query into graph
  • find the overlap with the reasoning graph (using n=1 or more hops to include more relations)
  • use similarity search to get additional parts of the graph
  • generate a response based on this intersection as well as the context provided
  • provide information about the underlying structure

How to use

You need an InfraNodus account to use this workflow.

  • Create an InfraNodus account
  • Get the API key at https://infranodus.com/api-access and create a Bearer authorization key for the InfraNodus HTTP nodes.
  • Create a separate knowledge graph for the reasoning logic
  • Use the AI ontology creator to generate an ontology for a certain topic or text using AI. Then augment it with your own data. See our help article on creating ontologies for detailed instructions
  • For each graph, go to the workflow, paste the name of the graph into the request JSON body name field.
  • Change the system prompt in the AI agent node to reflect the nature of your reasoning logic. For instance, if it's an expert in interactions, you specify that, if it's a psychology expert, you need to specify that as well.
  • Change the description of the reasoning node (HTTP tool). Use the InfraNodus summary and Project Notes > RAG prompt buttons to generate a description for the reasoning logic, which you can then reuse in your workflow.
  • add the LLM key to the OpenAI node (or to the model of your choice) and launch the workflow

Requirements

  • An InfraNodus account and API key
  • An OpenAI (or any other LLM) API key

Customizing this workflow

You can use this same workflow with a Telegram bot, so you can interact with it using Telegram. There are many more customizations available.

Check out the complete guide at https://support.noduslabs.com/hc/en-us/articles/21429518472988-Using-Knowledge-Graphs-as-Reasoning-Experts

Also check out the video tutorial with a demo:

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - When chat message received

Type / Role
@n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
Config choices
Version 1.1

Block 2 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 3 - Simple Memory

Type / Role
@n8n/n8n-nodes-langchain.memoryBufferWindow - memoryBufferWindow
Config choices
Version 1.3

Block 4 - Interaction Dynamics Expert

Type / Role
n8n-nodes-base.httpRequestTool - httpRequestTool
Config choices
Version 4.2

Block 5 - Reasoning Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.9

Block 6 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 8 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Create custom reasoning patterns for AI agents with GraphRAG & knowledge ontology
Complexity intermediate
Nodes 8
Categories Engineering, AI RAG
Author InfraNodus
Published 01 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/6816/6816.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Create custom reasoning patterns for AI agents with GraphRAG & knowledge ontology do?

Teach your AI agent HOW to think, not WHAT to think This workflow demonstrates...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering, AI RAG use case.