
AI Trading Assistant (Discord)
The summer I became a "Finance Bro" (briefly).
Over the summer, my friends and I got deep into stock trading. We needed an edge; something faster than Googling and smarter than standard bots. I decided to build a custom Discord bot that we could ping in our chat to get real-time analysis using natural language.
This was my first time using the Discord API, and I pushed the limits of what AI Agents can do in n8n.
🏗️ The Hybrid Architecture
Instead of building a massive Node.js application, I designed a hybrid architecture for speed and flexibility.
- The Gateway (Node.js on Railway): A lightweight, 24/7 Node.js terminal running
discord.js. It listens for pings, packages the message context (user, server, history), and fires it off via webhook. - The Brain (n8n): The actual logic lives in an
n8nworkflow. This is where the AI decides which tools to use, and formats the response.

Thanks to the terminal, the bot runs 24/7 and it's always online on Discord. You can ping it at any time and it will reply instantly.


🧠 The n8n "Brain" & The Huge Prompt
I chose n8n because I wanted to get an AI agent running fast and n8n is the perfect tool for that.
The workflow is triggered by the Discord webhook. It uses a massive system prompt to tell GPT-4o exactly how to behave as a financial analyst.

The Two-Step Response: Because AI takes time to "think", the bot sends an immediate acknowledgement (e.g., "On it, boss. Checking the charts.") so the user knows it's working, before sending the final detailed analysis.

🛠️ The Agent's Tool Belt
The real power comes from the 5 tools I gave the AI agent access to. It doesn't just hallucinate answers; it fetches real-time data.
- Financial Data: Uses the
Financial Modeling PrepAPI for real-time prices, company profiles, and historical data. - Market Sentiment: Fetches the current Fear & Greed Index.
- Web Research: Uses
Tavilyto perform live Google searches and extract content from news articles to understand why a stock is moving. - Charting: It can even generatex full graphs in the chat using the
quickchart.ioAPI


🚀 Lessons Learned
This project was a blast.
- Discord API: Surprisingly straightforward.
discord.jsmakes event handling easy. - AI Agents: I've used
n8nmany times before, but integrating 5 different tools and ensuring the AI chooses the right one required a lot of prompt engineering and testing.
Right now, the bot remains in private beta for me and my friends, but the architecture could be scaled enough to be public someday.

