AutomationFlowsAI & RAG › Forex AI Trading Assistant for Telegram Using Chatgpt-4o (with Position Sizing)

Forex AI Trading Assistant for Telegram Using Chatgpt-4o (with Position Sizing)

ByCj Elijah Garay @elijahbuilds-ai on n8n.io

Open trades for forex/xauusd/gold with this n8n template. It demonstrates how to automate MetaTrader 5 trading executions through natural language commands via Telegram, enabling hands-free trade management with AI-powered intent classification and parameter parsing.

Event trigger★★★★★ complexityAI-powered48 nodesTelegramHTTP RequestTelegram TriggerChain LlmOpenAI Chat
AI & RAG Trigger: Event Nodes: 48 Complexity: ★★★★★ AI nodes: yes Added:

This workflow corresponds to n8n.io template #11461 — we link there as the canonical source.

This workflow follows the Chainllm → HTTP Request recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "nodes": [
    {
      "id": "726e394b-9fae-4c7c-97ef-4009cf727a15",
      "name": "respond: all clear",
      "type": "n8n-nodes-base.telegram",
      "position": [
        496,
        1616
      ],
      "parameters": {},
      "retryOnFail": true,
      "typeVersion": 1.2
    },
    {
      "id": "ba10b444-fad4-4bba-af00-3b72ddbdf43c",
      "name": "respond: No pending signals",
      "type": "n8n-nodes-base.telegram",
      "position": [
        688,
        1344
      ],
      "parameters": {},
      "retryOnFail": true,
      "typeVersion": 1.2
    },
    {
      "id": "d72be431-d4ce-42ce-8de2-38d04a59d123",
      "name": "respond: No pending signals1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        688,
        1168
      ],
      "parameters": {},
      "retryOnFail": true,
      "typeVersion": 1.2
    },
    {
      "id": "ede3ef4a-4f32-4e4f-b578-401117dc8b46",
      "name": "respond to query",
      "type": "n8n-nodes-base.telegram",
      "position": [
        272,
        864
      ],
      "parameters": {},
      "retryOnFail": true,
      "typeVersion": 1.2
    },
    {
      "id": "82e80d7c-b949-4694-ad27-8c7563ad5b1f",
      "name": "respond: missing params",
      "type": "n8n-nodes-base.telegram",
      "position": [
        640,
        560
      ],
      "parameters": {},
      "retryOnFail": true,
      "typeVersion": 1.2
    },
    {
      "id": "52d586c2-b765-49bc-b346-8756cd896662",
      "name": "respond: LLM fallback",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1328,
        96
      ],
      "parameters": {},
      "retryOnFail": true,
      "typeVersion": 1.2
    },
    {
      "id": "83d26cc7-b838-4f18-a7f2-a7a2469251ea",
      "name": "respond: error1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2000,
        144
      ],
      "parameters": {},
      "retryOnFail": true,
      "typeVersion": 1.2
    },
    {
      "id": "5220b9bf-1888-4184-a562-a2716a1e09a5",
      "name": "respond: http req error",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1360,
        1392
      ],
      "parameters": {},
      "retryOnFail": true,
      "typeVersion": 1.2
    },
    {
      "id": "d6058e7b-b06e-4010-b4de-f5b384178783",
      "name": "respond: trade placement success",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2048,
        1056
      ],
      "parameters": {},
      "retryOnFail": true,
      "typeVersion": 1.2
    },
    {
      "id": "a6d4eeae-50ba-4f12-bed8-7cb0b19c7d06",
      "name": "respond: error in trade placement",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2048,
        1280
      ],
      "parameters": {},
      "retryOnFail": true,
      "typeVersion": 1.2
    },
    {
      "id": "d231f762-c41f-4fe6-806e-92cdc3898f3e",
      "name": "react to message",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -640,
        944
      ],
      "parameters": {},
      "typeVersion": 4.2
    },
    {
      "id": "aafc99f1-91ff-4a57-9cc4-2f54aa88b2df",
      "name": "respond: part 1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        480,
        992
      ],
      "parameters": {},
      "retryOnFail": true,
      "typeVersion": 1.2
    },
    {
      "id": "dd7ceb7a-cc44-46d7-be5a-749a1451d685",
      "name": "respond: part 2",
      "type": "n8n-nodes-base.telegram",
      "position": [
        656,
        992
      ],
      "parameters": {},
      "retryOnFail": true,
      "typeVersion": 1.2
    },
    {
      "id": "7e21b004-1767-440a-9223-f539d3d05e76",
      "name": "respond: part 3",
      "type": "n8n-nodes-base.telegram",
      "position": [
        816,
        992
      ],
      "parameters": {},
      "retryOnFail": true,
      "typeVersion": 1.2
    },
    {
      "id": "8f5f55ea-37cf-4932-a422-290371e3cba1",
      "name": "Telegram Chat Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1072,
        944
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "3c7b0ed6-f667-41a8-aa09-cef3ea0495e8",
      "name": "parse ai response1",
      "type": "n8n-nodes-base.code",
      "position": [
        1696,
        400
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "6b8d1753-f3bc-45b9-a03f-6829a27b38b5",
      "name": "if there is an error1",
      "type": "n8n-nodes-base.if",
      "position": [
        1840,
        288
      ],
      "parameters": {},
      "typeVersion": 2.2
    },
    {
      "id": "7a7795f8-46b7-4cbf-a270-4db6d7599f8b",
      "name": "HTTP Request send market order1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1360,
        896
      ],
      "parameters": {},
      "typeVersion": 4.2
    },
    {
      "id": "4c260a42-02fb-46b0-8560-6bc8fb2b777a",
      "name": "Switch2",
      "type": "n8n-nodes-base.switch",
      "position": [
        -16,
        880
      ],
      "parameters": {},
      "typeVersion": 3.3
    },
    {
      "id": "ee617064-e00e-4cd6-8302-afb6b973c8ab",
      "name": "parse LLM output1",
      "type": "n8n-nodes-base.code",
      "position": [
        -176,
        944
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "8c6d7acb-5f84-411d-8906-561e94ce16d4",
      "name": "Trading Assistant Classifier & Responder2",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -400,
        944
      ],
      "parameters": {},
      "typeVersion": 1.7
    },
    {
      "id": "871c7432-ea69-4ace-aa98-247b7588a501",
      "name": "Trading Assistant Classifier & Responder3",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1472,
        400
      ],
      "parameters": {},
      "typeVersion": 1.7
    },
    {
      "id": "a047d28a-b6a4-47d0-a0e6-4ef9ab6325fd",
      "name": "If trade was successful1",
      "type": "n8n-nodes-base.if",
      "position": [
        1808,
        1168
      ],
      "parameters": {},
      "typeVersion": 2.2
    },
    {
      "id": "8c4872f1-e28e-4d9c-8cd8-4130de44745a",
      "name": "Switch3",
      "type": "n8n-nodes-base.switch",
      "position": [
        1104,
        1040
      ],
      "parameters": {},
      "typeVersion": 3.3
    },
    {
      "id": "47cce05e-65fe-4359-a692-789ee71dc716",
      "name": "HTTP Request send limit order",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1568,
        1168
      ],
      "parameters": {},
      "typeVersion": 4.2
    },
    {
      "id": "5ea904af-980b-4ddc-bfdf-a81c50c13a52",
      "name": "parse if AI says content is complete2",
      "type": "n8n-nodes-base.code",
      "position": [
        240,
        400
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "bfba5095-b752-4053-812a-f4b958a1c8bb",
      "name": "needs LLM fallback?1",
      "type": "n8n-nodes-base.switch",
      "position": [
        432,
        384
      ],
      "parameters": {},
      "typeVersion": 3.3
    },
    {
      "id": "88c12ef0-2037-4404-8d5e-0c5aed70382c",
      "name": "parse if AI says content is complete3",
      "type": "n8n-nodes-base.code",
      "position": [
        928,
        192
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "1de0d862-3e44-46b9-b982-372b4342b28f",
      "name": "basic LLM fallback check1",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        640,
        192
      ],
      "parameters": {},
      "typeVersion": 1.7
    },
    {
      "id": "60546436-419f-4e0f-a726-9ac471bdb5be",
      "name": "parameters are missing?1",
      "type": "n8n-nodes-base.if",
      "position": [
        1136,
        192
      ],
      "parameters": {},
      "typeVersion": 2.2
    },
    {
      "id": "53dd5a44-1008-4a6f-a356-349c974f003b",
      "name": "4o - mini1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        640,
        336
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "345c1bef-c2bd-4197-a35e-f8199791bc05",
      "name": "If ai says complete1",
      "type": "n8n-nodes-base.if",
      "position": [
        1328,
        304
      ],
      "parameters": {},
      "typeVersion": 2.2
    },
    {
      "id": "e0d1bddc-e68b-41d7-9bc7-105a534b46ca",
      "name": "4o mini1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -320,
        1168
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "e23bf076-550d-4930-84a9-032304a9bbec",
      "name": "Parse switch output1",
      "type": "n8n-nodes-base.code",
      "position": [
        1360,
        1072
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "03896810-2c94-473f-b7ae-acb84dc4b546",
      "name": "HTTP get pending signals1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        272,
        1264
      ],
      "parameters": {},
      "typeVersion": 4.2
    },
    {
      "id": "d09dfdc7-c080-4298-8688-933a67fc604a",
      "name": "if there is signal1",
      "type": "n8n-nodes-base.if",
      "position": [
        480,
        1264
      ],
      "parameters": {},
      "typeVersion": 2.2
    },
    {
      "id": "ca687180-0a8a-413f-bc5d-5784a8324d5e",
      "name": "Http req clear all signals1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        256,
        1616
      ],
      "parameters": {},
      "typeVersion": 4.2
    },
    {
      "id": "d5756cae-3b75-4cd9-9a08-16c859fd99e9",
      "name": "4o mini3",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1472,
        576
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "9db3d696-47c9-46bd-870e-77a5ad81747a",
      "name": "ai agent instructions1",
      "type": "n8n-nodes-base.set",
      "position": [
        272,
        1056
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "64f41b4b-1bca-4535-acd2-dd8ea01ccc6f",
      "name": "\ud83d\udccb Overview1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1600,
        96
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "b4d7a5f9-9e50-4bb7-9140-b7837795c938",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        768
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "33268aa3-6a78-454c-9b71-55044a31f746",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        1536
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "bed1590c-1548-4981-b5d6-c848f1427af8",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        768
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "2425250e-d459-4141-8626-54f23e528ed4",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -448,
        768
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "d3480907-c931-47ff-b3f5-6c2bbff994cb",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        48
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "5c9c45d7-128b-4313-b381-f78ccc22a0c5",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1072,
        768
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "28723c97-e38b-4f6e-8952-c8a79bd5d59d",
      "name": "set credentials and params1",
      "type": "n8n-nodes-base.set",
      "position": [
        -848,
        944
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "fa1e9345-008b-4dec-b155-55e09fddacda",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        96
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Switch2": {
      "main": [
        [
          {
            "node": "parse if AI says content is complete2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "respond to query",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "respond to query",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "ai agent instructions1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HTTP get pending signals1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Http req clear all signals1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch3": {
      "main": [
        [
          {
            "node": "HTTP Request send market order1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HTTP Request send market order1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Parse switch output1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HTTP Request send limit order",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "respond: http req error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4o mini1": {
      "ai_languageModel": [
        [
          {
            "node": "Trading Assistant Classifier & Responder2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "4o mini3": {
      "ai_languageModel": [
        [
          {
            "node": "Trading Assistant Classifier & Responder3",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "4o - mini1": {
      "ai_languageModel": [
        [
          {
            "node": "basic LLM fallback check1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "respond: part 1": {
      "main": [
        [
          {
            "node": "respond: part 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "respond: part 2": {
      "main": [
        [
          {
            "node": "respond: part 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "react to message": {
      "main": [
        [
          {
            "node": "Trading Assistant Classifier & Responder2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "parse LLM output1": {
      "main": [
        [
          {
            "node": "Switch2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "parse ai response1": {
      "main": [
        [
          {
            "node": "if there is an error1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "if there is signal1": {
      "main": [
        [
          {
            "node": "respond: No pending signals1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "respond: No pending signals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If ai says complete1": {
      "main": [
        [
          {
            "node": "if there is an error1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Trading Assistant Classifier & Responder3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse switch output1": {
      "main": [
        [
          {
            "node": "HTTP Request send limit order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "needs LLM fallback?1": {
      "main": [
        [
          {
            "node": "basic LLM fallback check1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Trading Assistant Classifier & Responder3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "respond: missing params",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Chat Trigger": {
      "main": [
        [
          {
            "node": "set credentials and params1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "if there is an error1": {
      "main": [
        [
          {
            "node": "respond: error1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Switch3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ai agent instructions1": {
      "main": [
        [
          {
            "node": "respond: part 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If trade was successful1": {
      "main": [
        [
          {
            "node": "respond: trade placement success",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "respond: error in trade placement",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "parameters are missing?1": {
      "main": [
        [
          {
            "node": "respond: LLM fallback",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If ai says complete1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP get pending signals1": {
      "main": [
        [
          {
            "node": "if there is signal1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "basic LLM fallback check1": {
      "main": [
        [
          {
            "node": "parse if AI says content is complete3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Http req clear all signals1": {
      "main": [
        [
          {
            "node": "respond: all clear",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "set credentials and params1": {
      "main": [
        [
          {
            "node": "react to message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request send limit order": {
      "main": [
        [
          {
            "node": "If trade was successful1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request send market order1": {
      "main": [
        [
          {
            "node": "If trade was successful1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "parse if AI says content is complete2": {
      "main": [
        [
          {
            "node": "needs LLM fallback?1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "parse if AI says content is complete3": {
      "main": [
        [
          {
            "node": "parameters are missing?1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trading Assistant Classifier & Responder2": {
      "main": [
        [
          {
            "node": "parse LLM output1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trading Assistant Classifier & Responder3": {
      "main": [
        [
          {
            "node": "parse ai response1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Open trades for forex/xauusd/gold with this n8n template. It demonstrates how to automate MetaTrader 5 trading executions through natural language commands via Telegram, enabling hands-free trade management with AI-powered intent classification and parameter parsing.

Source: https://n8n.io/workflows/11461/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

A Telegram bot that converts natural-language work descriptions into detailed cost estimates using AI parsing, vector search, and the open-source DDC CWICR database with 55,000+ construction work item

HTTP Request, Telegram, Telegram Trigger +6
AI & RAG

With this workflow you can extract data from resume documents uploaded via a Telegram bot. Workflow transform readable content of PDF resume into structured data, using AI nodes and returns PDF with f

OpenAI Chat, Output Parser Autofixing, Output Parser Structured +4
AI & RAG

This n8n template demonstrates how to create authentic-looking User Generated Content (UGC) advertisements using AI image generation, voice synthesis, and lip-sync technology. The workflow transforms

Chain Llm, Output Parser Structured, Agent +5
AI & RAG

📌 How it works

Telegram Trigger, Telegram, OpenAI +5
AI & RAG

++HOW IT WORKS:++ This workflow automates the processing of invoices sent via Telegram. It extracts the data using LlamaIndex OCR, logs it in Google Sheets, and optionally pushes the structured data t

Chain Llm, OpenAI Chat, Telegram Trigger +4