I wanted a Discord bot that could actually hold a conversation, not just respond to slash commands — so I wired one up using n8n and the Anthropic API, running entirely on my own homelab infrastructure.
The stack
- n8n as the automation/orchestration layer, self-hosted at
n8n.humfurie.org - Discord Trigger node in n8n, connected directly to Discord via bot token (no public webhook needed — it listens over a WebSocket connection)
- Claude (Anthropic API) as the model handling the actual replies — I used Haiku for cost efficiency, since a chat bot fires on every message and token costs add up fast
- PostgreSQL to persist conversation history, so the bot remembers recent context instead of treating every message as a cold start
- Everything sits behind Traefik on Unraid, with automatic SSL via Let's Encrypt
How it works
Discord Trigger fires whenever a message comes in on the allowed channel. n8n pulls the last few messages from Postgres for context, sends the conversation plus the new message to Claude, and posts the reply back to Discord — as an actual threaded reply, not just a new message in the channel. Early on I was using a webhook-based setup, but switching to the native Discord Trigger node removed a layer of complexity: no webhook URL to manage, no exposing anything publicly, just a direct bot connection.
The lesson I didn't want to learn
At one point I ran docker compose down -v while cleaning up a different part of my homelab — and the -v flag wiped every volume tied to that compose file, including the Postgres database backing this whole setup. Every workflow, every bit of conversation history, gone.
Rebuilding meant piecing the setup back together: the docker-compose config, the n8n workflow itself, the Discord bot credentials, the webhook path (before I'd even switched to Discord Trigger). It was a good reminder that -v is not a flag to use casually, and that workflow exports and database backups are not optional extras for anything running unattended.
Takeaways
- Discord Trigger > webhook for this use case — fewer moving parts, nothing exposed publicly.
- Cheap models make sense for chat bots — Haiku-class models handle casual conversation fine without frontier-model pricing.
- Back up your compose volumes before you ever run
down -vnear anything you care about. I learned this one the hard way.
It's a small project, but it's been a good sandbox for testing how far a self-hosted, low-cost AI integration can go before you actually need something heavier.