Skip to content

Core N8N Workflow Automation

antonyrag edited this page Aug 15, 2026 · 1 revision

Core Engine — n8n Workflow Automation

Scope note: this page documents ragleap-core's engine (core/, channels/), not the ragleap-rag/ragleap-graph pip packages covered by the rest of this wiki. See Home for the packages wiki index.

Configure a webhook, pick which channels should trigger it, and it fires automatically after the AI replies — no code required per automation. Single-tenant, open since #141.

How it works

core/workflows.py's call_n8n_workflows(channel, message, ai_reply, context) looks up every active workflow configured for the given channel and POSTs a JSON payload to each one's webhook URL:

{
  "channel": "whatsapp",
  "message": "the user's original message",
  "ai_reply": "the AI's answer",
  "context": {}
}

It never raises — a broken or slow webhook can't break the main chat reply. Each channel adapter calls it right after sending the AI's reply, wrapped in its own try/except as a second layer of safety.

Wired channels

Channel Status
WhatsApp ✅ Wired
Telegram ✅ Wired
Discord ✅ Wired
Voice ❌ Not yet — different protocol shape (WebSocket, not send-then-return). See #143

API routes

Route Purpose
GET /n8n-workflows List workflows, optionally filtered by channel/active status
POST /n8n-workflows Create a workflow (name, webhook_url, channels, is_active)
GET /n8n-workflows/{id} Get one workflow
PATCH /n8n-workflows/{id} Update any field
DELETE /n8n-workflows/{id} Delete

Verification

Tested end-to-end against a real, non-mocked webhook endpoint — including confirming the negative case (a workflow with channels: ["api_test"] correctly does not fire when called with channel="whatsapp") before confirming the positive case fires correctly across all three wired channels.

What's still hosted-only

Multi-tenant per-workspace workflow routing, and Voice channel coverage.

Open good-first-issue

#143 — wire n8n triggers into the Voice channel. The three wired text channels are a clear reference implementation for the pattern needed.

Clone this wiki locally