Your n8n Agent Has Amnesia. Give It a Knowledge Graph

thumbnail
FalkorDB · engineering notes GraphRAG × n8n · build log
Complete build log

Ask your handbook anything: docs become a team brain

The whole machine, documented: point n8n at hosted GraphRAG, hand an AI Agent five graph tools, publish a chat page, and keep a FalkorDB knowledge graph in lock-step with every merged PR. Every setting, every node config, every architecture decision.

01

The flow at a glance

One n8n workflow, two entry points, one brain. A Chat Trigger serves your team’s questions; a GitHub Trigger feeds repository changes into the same AI Agent. Both paths end at the same FalkorDB knowledge graph.

The canvas has fourteen nodes. The chat branch is the classic n8n agent stack: Chat Trigger → AI Agent, with a chat model and window-buffer memory attached, and five GraphRAG tool nodes hanging off the agent. The GitHub branch is a five-node pipeline that normalizes a push webhook into an agent instruction: GitHub Trigger → branch filter → changed-files Code node → HTTP fetch → instruction-builder Code node → agent.

Everything graph-related happens through tools on the agent. The @falkordb/n8n-nodes-graphrag community node exposes GraphRAG’s REST operations as AI Agent tools, so the LLM decides which operation to call and with what arguments (via $fromAI expressions). No custom HTTP wiring, no Cypher.

One n8n workflow with two triggers converging on one AI agent backed by a FalkorDB knowledge graph
One workflow. Humans arrive through the Chat Trigger; merged PRs arrive through the GitHub Trigger. Both end at the same agent, backed by the same graph. FIG. 01
02

Why a graph, and why n8n

For this build we used a real company handbook, Basecamp’s public handbook: a GitHub repository of Markdown documents covering policies, benefits, job ladders, onboarding, and internal rituals. Exactly the kind of corpus every team owns: prose, versioned in git, changed by pull request. (We worked from a fork, so we could merge PRs of our own for the sync half; point the workflow at whatever repository your team actually edits.)

Bootstrapping took one chat message: “ingest github.com/basecamp/handbook”. The agent called Ingest GitHub Repo, and the server chunked every file, ran LLM extraction, resolved duplicate entities, and wrote the result into a FalkorDB property graph holding three layers: document chunks with vector embeddings, the entities and relationships extracted from them, and provenance edges tying each fact back to its source chunk.

Why a graph and not just embeddings? Handbook questions are relationship questions. “Which policies affect refunds for EU customers?” spans three documents linked by shared entities; similarity search returns look-alike paragraphs, while the graph walks Policy → EXTENDS → Policy → APPLIES_TO → Region and answers with the chain intact, citing every source document along the way.

?Why n8n for the plumbing

  • Webhook infrastructure for free. The GitHub Trigger registers and verifies the repository webhook itself on publish. No Express server, no signature-validation code, no route handlers.
  • The agent loop is a node. Tool-calling, retries, memory, and model wiring are the AI Agent node’s job. Swap GPT for Claude by swapping one attached node; the graph tools don’t change.
  • Credentials live in one place. GraphRAG API token, GitHub PAT, and the LLM key are n8n credentials: encrypted, reusable across workflows, out of the JSON you commit.
  • Both halves stay on one canvas. The chat assistant and the sync pipeline share the same agent, the same tools, and the same execution log, so there is exactly one code path that touches the graph.
The graph does the thinking. n8n does the plumbing. You write one Code node.
03

Architecture: the whole machine

Before touching a single node, hold the full picture. One hosted service, one workflow runtime, three credentials, and a strict separation between the part that thinks and the part that routes.

There are two LLM seats in this system, and keeping them straight saves you an hour of debugging. The agent model (attached to the AI Agent node in n8n) decides which tool to call. The GraphRAG-side models (your BYO key profile, added in the GraphRAG settings) do the heavy lifting: entity extraction at ingest time, retrieval and answer composition at query time, plus an embedder for vector search. They can be the same key or completely different vendors; n8n never sees GraphRAG’s keys, and GraphRAG never sees n8n’s.

Full system architecture: browser and GitHub reach your n8n instance directly; n8n's AI agent calls hosted GraphRAG over https with an API token; GraphRAG orchestrates LLM extraction and retrieval against a managed FalkorDB graph
Two LLM seats, zero shared secrets. n8n’s model routes tools; GraphRAG’s models extract, retrieve, and embed. The only wire between the two worlds is one https call with your API token. FIG. 02

And here is what one question physically does, hop by hop:

Request lifecycle: a chat message hits n8n's webhook, the agent selects the Ask Knowledge Graph tool, hosted GraphRAG runs vector search plus graph traversal against FalkorDB and returns a grounded answer with sources
Every arrow is a failure surface. Wrong base URL or expired token? The second arrow 401s. Mismatched LLM key profile? GraphRAG errors before FalkorDB is ever touched. Knowing which arrow failed is half the diagnosis. FIG. 03
04

Part I · Connect the brain

GraphRAG is the only component that understands documents, and it’s already running for you at graphrag.falkordb.com. No containers, no .env, no database to babysit. Three clicks of setup, then everything else is wiring.

1Create your account

Sign in at graphrag.falkordb.com. The hosted service comes with a managed FalkorDB behind it (the property graph, the vector index, the ingestion pipeline), all provisioned per account. What you bring is one thing: an LLM key.

2Add an LLM key profile

GraphRAG does its own LLM work, ingestion (entity extraction) and retrieval (answer composition), with your key, stored encrypted server-side. In Settings, add your key as a named profile, e.g. mykey, provider openai. Graphs bind to a profile by id.

The #1 silent killer: a provider/key mismatch. An OpenAI sk-... key saved under provider azure (or vice versa) doesn’t fail when you save it; it fails on the first real call. If ingests or queries mysteriously error, check the profile’s provider first.
Rotating a key later? Add the new profile first, re-point your graphs to it, then delete the old one. Deletion is blocked while any graph still uses the profile (“This key is still used by N graph(s)”). That guard exists precisely so a rotation can’t strand a live graph.

3Mint the API token n8n will use

Go to Settings → API Access and generate a token. This single token is the credential the n8n community node authenticates with; it scopes every call to your account and your graphs. Copy it now; you’ll paste it into n8n when you wire credentials in section 07.

graphrag.falkordb.com · Settings → API Access
GraphRAG Settings, API Access tab: an LLM key profile named mykey (provider openai, marked Default) on the left, and two generated API tokens with creation and last-used dates on the right
Settings → API Access: your LLM key profile on the left, the API tokens n8n authenticates with on the right. Tokens run on your key, so usage is uncapped.IMG. A
05

Part II · Run n8n, install the nodes

Two ways to get the GraphRAG nodes into your n8n: install the published package from the community registry (one click), or build the GraphRAG-n8n repo from source and load it as a local node. The second is the right choice if you want to hack on the node itself.

1Get an n8n instance

Community nodes install on self-hosted n8n (≥ 1.0). One command:

terminalbash
npx n8n start
# editor: http://localhost:5678
Need the chat page or GitHub webhooks from outside? Two outsiders must reach your instance: humans on the chat page and GitHub’s webhook servers. Put n8n behind a public https address and set WEBHOOK_URL to it, because n8n bakes that address into every chat page and webhook registration at startup. The quickest way is a free Cloudflare tunnel:
terminal · public URL via tunnelbash
brew install cloudflared
cloudflared tunnel --url http://localhost:5678
# copy the printed https://<random>.trycloudflare.com, then restart n8n with it:
WEBHOOK_URL=https://<random>.trycloudflare.com npx n8n start

2Option A · Install from the community registry (recommended)

In the n8n editor: Settings → Community Nodes → Install → search for @falkordb/n8n-nodes-graphrag and confirm. The FalkorDB GraphRAG and FalkorDB GraphRAG Tool nodes appear in the panel under the FalkorDB category, ready to attach to any AI Agent. Prefer the terminal? Same result:

terminal · manual installbash
# in n8n's custom-nodes folder, typically ~/.n8n/nodes
npm install @falkordb/n8n-nodes-graphrag
# then restart n8n

3Option B · Run the repo from source

For contributing, debugging, or trying unreleased changes: clone, build, and point n8n’s custom-nodes folder at your working copy:

terminal · build & linkbash
git clone https://github.com/FalkorDB/GraphRAG-n8n.git
cd GraphRAG-n8n
npm install
npm run build               # tsc + icons → dist/

# load the local build instead of the npm package:
cd ~/.n8n/nodes
npm install /path/to/GraphRAG-n8n

npx n8n start               # nodes now come from your checkout

While iterating, npm run dev keeps dist/ rebuilt on save; restart n8n to pick up changes. The repo’s checks all run through just (just lint, just test), so what you run locally is exactly what CI runs. Bonus: the repo’s workflows/ folder ships importable example workflows for every operation, pipeline and agent-tool variants alike.

06

Part III · The canvas, node by node

Fourteen nodes. Here is every one of them, with the exact configuration that matters: the settings you’d otherwise reverse-engineer from the workflow JSON.

AThe chat branch · four nodes

Chat Triggertrigger

The front door. Publishing the workflow exposes a hosted chat page. No frontend to build.

modepublic chat
webhookIdkb-chatbot
page URL/webhook/kb-chatbot/chat
AI Agentbrain

The only decision-maker. Its system message sets three hard rules (below). Tools, model, and memory all attach here.

tools5 × GraphRAG
input{{ $json.chatInput }}
Model + Memoryattachments

Any chat model works; swap vendors by swapping this node. Window-buffer memory keys on the session.

memory key{{ $json.sessionId }}
windowbuffer

BThe agent’s three hard rules

The system message declares the five tools and then constrains the agent. These three rules are what make the bot reliable rather than plausible:

01Factual question ⇒ always call Ask Knowledge Graph. Never answer from conversation memory: documents change between turns, and yesterday’s answer may cite a paragraph that no longer exists.
02Before updating, resolve the name. Call List Documents first so document_name matches exactly what the graph has. No fuzzy guessing against upload paths.
03Updates carry complete content, never diffs. The server’s chunk cache (section 08) makes full-content updates cheap, so the agent never has to reason about patches.

CFive tools, one credential

Each GraphRAG tool node points at the server with the same n8n credential (base URL + API token) and pins a named graph. Every parameter defaults to a $fromAI() expression, so the agent fills in document_name, document_text, or the question at call time:

Ask Knowledge Graph
Retrieves connected context (entities, relationships, document excerpts) and lets the agent compose a grounded answer with sources. Hits POST /api/query.
Ingest Text
Paste anything into the chat and it becomes part of the graph: new entities link up with what’s already there. Hits POST /api/ingest.
Ingest GitHub Repo
Point it at a repository URL and every Markdown file is chunked, extracted, and connected. The fast way to bootstrap a knowledge base.
Update Document
Replace an ingested document in place via PUT /api/documents/{name}. Chunk-level caching skips identical chunks; only what changed is re-extracted.
List Documents
Every document in the graph with its chunk, entity, and relation counts. The agent uses it to resolve names before updating.
n8n · GraphRAG KB · Chat + GitHub Ingest
The full n8n canvas: the GitHub branch (GitHub Trigger, Main Branch Only, Changed Markdown Files, Fetch Raw File, Build Agent Instruction) and the Chat Trigger both feed one AI Agent, with the OpenAI chat model, conversation memory, and five FalkorDB GraphRAG tools attached beneath it
The finished canvas: both triggers converge on one AI Agent; the five GraphRAG tools hang off it like a tool belt.IMG. B

DThe GitHub branch · five nodes

When a push lands on the repository, the webhook payload flows through five nodes before reaching the agent:

01GitHub Trigger receives the push webhook for the repository. On publish, n8n registers the webhook with GitHub for you, using your instance’s public URL.
02Branch filter (IF, “Main Branch Only”) lets through only pushes to the default branch; feature-branch commits don’t touch the graph.
03Changed Markdown Files (Code) walks the push payload and emits one item per added or modified .md file.
04Fetch Raw File (HTTP Request) pulls the complete new content from raw.githubusercontent.com.
05Build Agent Instruction (Code) hands the agent one sentence of intent: update this document with exactly this content.
06The AI Agent calls its Update Document tool, the same tool a human could invoke from chat.
Build Agent Instruction · Code nodejavascript
// Turn each changed file into an instruction for the AI Agent.
return $input.all().map((item) => ({
  json: {
    chatInput: `A file changed on GitHub (merge to main).
Update the knowledge graph: call the Update Document tool
with document_name "${$('Changed Markdown Files').item.json.name}"
and document_text set EXACTLY to the following content,
verbatim and complete:

${item.json.content}`,
    sessionId: "github-sync",
  },
}));

Two deliberate choices here. First, the update routes through the agent rather than a standalone pipeline node, so the canvas keeps one brain in charge of the graph: the same tool set, the same name resolution, the same rules, whether the caller is a human or a webhook. Second, sessionId: "github-sync" gives the sync its own memory lane: robot traffic never pollutes a human chat session, and vice versa.

07

Publish, wire up, run the demo

Import, wire three credentials, activate. Then run the demo end to end.

1Import and wire up

01Import the workflow: Workflows → ⋯ → Import from File → the graphrag-kb-github.json that accompanies this post. It appears as “GraphRAG KB · Chat + GitHub Ingest.” (The GraphRAG-n8n repo also ships smaller per-operation examples in workflows/.)
02FalkorDB GraphRAG credential: base URL https://graphrag.falkordb.com + the API token from section 04, step 3.
03OpenAI credential: any key; this one only powers the agent’s tool routing.
04GitHub credential: a PAT, needed only by the GitHub Trigger branch. Point the trigger at a repository you can merge to (your handbook, or a fork of Basecamp’s).
05Activate (toggle, top-right). This publishes the chat webhook and registers the GitHub webhook.

2The demo

01Open the workflow → Chat button: every node lights up as the agent works. This is the best debugging view in the whole stack.
02Public page: <base>/webhook/kb-chatbot/chat. Share your n8n URL with your team.
03Bootstrap: “ingest github.com/basecamp/handbook” → watch Ingest GitHub Repo fire.
04Merge a PR that edits a policy → the GitHub branch runs → ask the bot about the change. That’s the demo.
Video thumbnail: Powering Agentic Workflows with a Knowledge Graph for n8n and LangGraph
Watch it live, queued to the workflow demo at 11:47. Or open it on YouTube.VID. A
08

Under the hood: why updates are cheap

The GitHub sync only works economically because of one server-side trick: chunk-level extraction caching. Here’s what actually happens when Update Document fires.

First, the graph itself. Every document lives in three layers, and the edges between them are what make both citations and cheap updates possible:

Graph schema: Document connects to Chunks via PART_OF; Entities point at Chunks via MENTIONED_IN and at each other via RELATES; source_chunk_ids properties carry provenance
Provenance everywhere. Entities and relationships both carry source_chunk_ids; this is what powers “answers with sources” and safe cleanup on update. FIG. 04

Now the update. When PUT /api/documents/{name} arrives with the new content, the server does not re-extract the whole document:

01Whole-document short-circuit. If the SHA-256 of the new text matches the stored document hash, the update is a no-op. A merge that touches only code files costs nothing.
02Chunk the new text with the same chunker used at ingest.
03Hash every new chunk and compare against the stored chunks of the same document. Byte-identical chunks are cache hits.
04Cache hits skip the LLM entirely. Their entities and relationships are rebuilt from the live graph (two batched Cypher queries for all cached chunks combined) and remapped onto the new chunk ids, provenance intact.
05Only changed chunks go to extraction. Edit one paragraph in a 50-chunk document and roughly one chunk (plus its overlap neighbors) pays for LLM calls.
06Atomic cutover. The new chunk set replaces the old one in a single transition; stale entities and edges whose last supporting chunk vanished are cleaned up, and anything still referenced elsewhere survives.
Honest numbers: chunk boundaries shift when text length changes, and overlap means an edit dirties its neighbors. In our live test, editing one section of a handbook page re-extracted 2 chunks and served 1 from cache. Not a fantasy 99/1 split, but still a fraction of a full re-ingest, and the fraction shrinks as documents grow.
Merge a typo fix, pay for a typo fix, not for re-reading the whole handbook.

One canvas. One graph. Two triggers.

The full workflow (GraphRAG node, agent configuration, and GitHub sync) is on GitHub, ready to import into your n8n instance.

Author

  • Naseem Ali

    Software Engineer at FalkorDB, working across AI, GraphRAG, and developer platforms. He builds graph-powered AI solutions, contributes to GraphRAG, Snowflake integrations, and MCP tooling, and develops full-stack products while driving automation, testing, and open-source initiatives with Python and TypeScript.