Discord Command to Automated MT5 Trade Execution using AI - n8n Workflow

Automate trading signals from Discord using natural language processing (NLP). This powerful n8n workflow uses OpenAI to extract trade details and execute orders via an external API.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Algorithmic Forex or Crypto Traders.

  • Financial groups sharing trade signals on Discord.

  • Users looking for advanced natural language processing n8n templates.

  • Developers needing to connect chat platforms to external trading APIs using n8n.

Overview

This is a highly specialized and advanced n8n workflow designed to bridge the gap between human-generated trade signals in a Discord channel and automated execution on a trading platform like MetaTrader 5 (MT5) via a custom bridge API. The core value of this n8n workflow lies in its robust use of OpenAI LLMs (Large Language Models) combined with LangChain capabilities to handle complex, natural language inputs. The automation polls Discord for new signals, uses an n8n node chain to classify the intent (place order, get status, clear signals), and then rigorously extracts necessary parameters like symbol, entry price, stop loss, and position sizing.

If parameters are missing, the n8n template includes a sophisticated LLM fallback mechanism to address gaps before sending the final HTTP Request. This intricate n8n node structure ensures that only valid, complete signals are passed for execution, turning Discord into a real-time trading command center. This complex n8n solution significantly reduces latency and human error in trade execution.

How it Works

The automation is initiated by an n8n trigger, specifically a periodic Schedule Trigger n8n node, which checks for activity.


  1. Poll & Filter: The flow first sets environment variables using an n8n node and then uses the Discord n8n node (Get recent message - omni1) to fetch recent messages. A Filter n8n node ensures only unprocessed user messages (those without reactions) are carried forward.

  2. Acknowledge: The React with an emoji Discord n8n node instantly marks the message as being processed, preventing duplicate execution.

  3. Initial Classification: The first LangChain/OpenAI n8n node (Trading Assistant Classifier & Responder2) classifies the user's intent (e.g., 'PLACE TRADE', 'GET SIGNALS', 'HELP').

  4. Routing: A Switch n8n node (Switch2) directs the flow based on the intent.

  5. Parameter Extraction (If Trade): If the intent is to place a trade, a series of Code and LangChain n8n nodes rigorously extracts all required trade parameters (like entry price, volume, risk percentage) from the text. A detailed fallback system checks if mandatory data is missing (needs LLM fallback?1). If critical data is missing, the n8n workflow uses a fallback mechanism (basic LLM fallback check1) to try and confirm the missing information or inform the user.

  6. Trade Execution: Once parameters are validated, a second Switch n8n node (Switch3) routes based on the required order type (Market vs Limit). The flow executes the action via the appropriate HTTP Request n8n node (HTTP Request send market order1 or HTTP Request send limit order) to interact with the external trading bridge API.

  7. Confirmation/Failure: The final If n8n node checks the API response (If trade was successful1) and confirms the outcome (success or failure) back to Discord using a dedicated Discord n8n node.

Installation Guide

To use this robust n8n workflow, follow these steps:


  1. Import: Copy the entire provided JSON and import it into your n8n instance using the "New -> Import from JSON" option. This is a complete n8n template.

  2. Discord Credentials: Set up credentials for the Discord n8n node to allow message reading and replying. Note that this n8n workflow uses multiple Discord nodes, requiring proper API key and bot configuration.

  3. OpenAI Credentials: Ensure your LangChain n8n nodes (4o mini1, 4o mini3, etc.) are configured with valid OpenAI API credentials (using the lmChatOpenAi n8n node) to handle the complex NLP tasks.

  4. MT5 Bridge Configuration: The HTTP Request n8n nodes must be configured with the correct endpoint URLs, API keys, and required headers for your custom MT5 bridge API. These are essential parts of this n8n workflow.

  5. Trigger Setup: Activate the Schedule Trigger n8n trigger and set its interval frequency to match how often you want to poll Discord for new signals.

Node Details

Schedule Trigger1 (n8n trigger): The main entry point, scheduled to run periodically, enabling constant monitoring of Discord for new signals.
Get recent message - omni1 (Discord n8n node): Fetches the latest batch of messages from the specified Discord channel/guild.
Trading Assistant Classifier & Responder2/3 (LangChain n8n node): Utilizes OpenAI's sophisticated models to classify user intent and perform complex structured data extraction (e.g., extracting symbol, risk, and price levels from natural language).
Code nodes (e.g., parse LLM output1, parse ai response1): Custom JavaScript n8n nodes used extensively throughout this n8n workflow to parse the specialized JSON output from the LLMs into usable data structures for downstream nodes.
Switch2 / Switch3 (Switch n8n node): Core flow control components that route the execution path based on the AI's classification (Intent) or the resulting order type (Market vs Limit). This is a critical flow control n8n node.
HTTP Request send market order1 / send limit order (HTTP Request n8n node): Executes the actual trade by sending the carefully extracted parameters to the external MT5 bridge API.


  • If trade was successful1 (If n8n node): Checks the response from the trading API to determine if the trade was placed successfully before confirming back to Discord. This n8n node handles error branching.

Related n8n Workflows

Paid

Nodes: 11 Nodes
Updated: December 26 2025
View all
Created by
Cj Elijah Garay
Cj Elijah Garay

Passionate about AI and intelligent automation, I build smart workflows with n8n, Python, and API integrations. I work with data almost every day, focusing on data manipulation, analytics, trading, marketing, sales, and customer support. Experienced in MQL5 and forex trading, driven to create automations that truly make an impact

Featured*