{
  "id": "lk0Q3KRvECMGIcWF",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Murban Brent Crude Price Tracker for Commodity Traders",
  "tags": [],
  "nodes": [
    {
      "id": "0b18f58e-64e4-47ff-b547-73ebb9e7062d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 480,
        "height": 672,
        "content": "## Murban Brent Crude Prices for Commodity Traders\n\n### How it works\n\n1. The workflow is triggered when the market hour starts.\n2. Fetches Murban crude prices from an external API.\n3. Extracts additional WTI futures data for comparison.\n4. Aggregates the crude data for analysis.\n5. Sends a Telegram alert with the aggregated data.\n\n### Setup steps\n\n- [ ] Configure schedule trigger for 'When Market Hour Starts'.\n- [ ] Set up HTTP request node with credentials for fetching Murban crude prices.\n- [ ] Ensure access to data source for 'Extract WTI Futures Data'.\n- [ ] Set up Telegram credentials to send alerts.\n\n### Customization\n\nUsers can customize the data extraction intervals or change the alert medium from Telegram to another platform."
      },
      "typeVersion": 1
    },
    {
      "id": "e9d2ff6d-658b-4db7-952e-3be6b2384c0c",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        0
      ],
      "parameters": {
        "color": 7,
        "height": 320,
        "content": "## Trigger workflow start\n\nInitiates the workflow at the beginning of the market hour."
      },
      "typeVersion": 1
    },
    {
      "id": "149aa476-008e-422f-a692-e938a6ca6c5e",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        32
      ],
      "parameters": {
        "color": 7,
        "height": 304,
        "content": "## Fetch crude price data\n\nFetches Murban crude prices from an external source."
      },
      "typeVersion": 1
    },
    {
      "id": "ed959c81-5d5a-4b12-838c-9498332ab2de",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1104,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 304,
        "content": "## Process and aggregate data\n\nExtracts WTI futures data and aggregates it with Murban crude prices."
      },
      "typeVersion": 1
    },
    {
      "id": "e154aff5-38a1-4305-af12-96c0644b8797",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1536,
        0
      ],
      "parameters": {
        "color": 7,
        "height": 320,
        "content": "## Send alert\n\nSends an alert via Telegram with the aggregated crude data."
      },
      "typeVersion": 1
    },
    {
      "id": "8501869c-241e-4b71-9be5-61caf10718f3",
      "name": "Aggregate Crude Prices",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1360,
        160
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "49cec2c0-592f-4da8-b62b-b2817e99cc30",
      "name": "When Market Opens",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        608,
        160
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1,
                2,
                3,
                4,
                5
              ],
              "triggerAtHour": 9
            },
            {
              "field": "weeks",
              "triggerAtDay": [
                1,
                2,
                3,
                4,
                5
              ],
              "triggerAtHour": 11,
              "triggerAtMinute": 11
            },
            {
              "field": "weeks",
              "triggerAtDay": [
                1,
                2,
                3,
                4,
                5
              ],
              "triggerAtHour": 13,
              "triggerAtMinute": 30
            },
            {
              "field": "weeks",
              "triggerAtDay": [
                1,
                2,
                3,
                4,
                5
              ],
              "triggerAtHour": 16
            },
            {
              "field": "weeks",
              "triggerAtDay": [
                1,
                2,
                3,
                4,
                5
              ],
              "triggerAtHour": 19,
              "triggerAtMinute": 15
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "d3a4a779-d121-4d7c-b125-fe3d52513378",
      "name": "Send Crude Price Alert",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1584,
        160
      ],
      "parameters": {
        "text": "={{ $json.data[0].text }}",
        "chatId": "ENTER YOUR TELEGRAM CHAT ID",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8bff5c53-a58e-4ef7-9a19-d2498b109d8b",
      "name": "Fetch Murban Prices",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        880,
        160
      ],
      "parameters": {
        "url": "https://oilprice.com/futures/murban/",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "5185948d-fb68-4c8f-9049-96ab5511c5d5",
      "name": "Extract Murban Data",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        1152,
        160
      ],
      "parameters": {
        "jsCode": "// ============================================================\n//  MURBAN CRUDE OIL \u2014 FUTURES TELEGRAM ALERT\n//  n8n Code Node | Mode: Run Once for All Items\n// ============================================================\n\n// --- CONTRACT DATA (from OilPrice.com scrape / upstream node) ---\n// Replace this array with $input.all() if fetching live via HTTP Request node\nconst contracts = [\n  { name: \"Jul 2026\", symbol: \"DBN26\", last: 92.82, change: -9.39, open: 96.04, high: 96.04, low: 92.82 },\n  { name: \"Aug 2026\", symbol: \"DBQ26\", last: 89.50, change: -1.10, open: 90.60, high: 90.60, low: 89.50 },\n  { name: \"Dec 2026\", symbol: \"DBZ26\", last: 84.20, change: -0.95, open: 85.15, high: 85.15, low: 84.20 },\n  { name: \"Jan 2027\", symbol: \"DBF27\", last: 82.50, change: -0.88, open: 83.38, high: 83.38, low: 82.50 },\n  { name: \"Jul 2027\", symbol: \"DBN27\", last: 79.80, change: -0.75, open: 80.55, high: 80.55, low: 79.80 },\n  { name: \"Jan 2028\", symbol: \"DBF28\", last: 77.40, change: -0.65, open: 78.05, high: 78.05, low: 77.40 },\n  { name: \"Jul 2028\", symbol: \"DBN28\", last: 76.20, change: -0.60, open: 76.80, high: 76.80, low: 76.20 },\n  { name: \"Jan 2029\", symbol: \"DBF29\", last: 74.71, change: -1.21, open: 74.71, high: 74.71, low: 74.71 },\n  { name: \"Jul 2029\", symbol: \"DBN29\", last: 74.20, change: -0.97, open: 74.20, high: 74.20, low: 74.20 },\n  { name: \"Jan 2030\", symbol: \"DBF30\", last: 73.73, change: -0.68, open: 73.73, high: 73.73, low: 73.73 },\n  { name: \"May 2030\", symbol: \"DBK30\", last: 73.57, change: -0.48, open: 73.57, high: 73.57, low: 73.57 },\n];\n\n// ---- HELPER FUNCTIONS ----\nfunction arrow(change) {\n  return change > 0 ? \"\ud83d\udfe2 \u25b2\" : change < 0 ? \"\ud83d\udd34 \u25bc\" : \"\u26aa \u2014\";\n}\n\nfunction fmt(num) {\n  return Number(num).toFixed(2);\n}\n\nfunction sign(num) {\n  return num > 0 ? `+${fmt(num)}` : `${fmt(num)}`;\n}\n\nfunction trendEmoji(change) {\n  if (change > 1) return \"\ud83d\ude80\";\n  if (change > 0) return \"\ud83d\udcc8\";\n  if (change < -3) return \"\ud83c\udd98\";\n  if (change < 0) return \"\ud83d\udcc9\";\n  return \"\u27a1\ufe0f\";\n}\n\n// ---- DATE & TIME ----\nconst now = new Date();\nconst dateStr = now.toLocaleDateString(\"en-IN\", {\n  weekday: \"long\", year: \"numeric\", month: \"long\", day: \"numeric\",\n  timeZone: \"Asia/Dubai\"\n});\nconst timeStr = now.toLocaleTimeString(\"en-IN\", {\n  hour: \"2-digit\", minute: \"2-digit\", timeZone: \"Asia/Dubai\", timeZoneName: \"short\"\n});\n\n// ---- FRONT MONTH (first contract = spot/near) ----\nconst front = contracts[0];\nconst frontDir = front.change >= 0 ? \"UP\" : \"DOWN\";\nconst mktSentiment = front.change > 1 ? \"BULLISH \ud83d\udc02\" \n                   : front.change > 0 ? \"MILDLY BULLISH \ud83d\udcca\"\n                   : front.change < -3 ? \"BEARISH \ud83d\udc3b\"\n                   : front.change < 0 ? \"MILDLY BEARISH \ud83d\udcca\"\n                   : \"NEUTRAL \u27a1\ufe0f\";\n\n// ---- BUILD CONTRACT TABLE ROWS (near-term 6 contracts) ----\nconst nearTerm = contracts.slice(0, 6);\nconst contractRows = nearTerm.map(c => {\n  const dir = arrow(c.change);\n  return `  <code>${c.name.padEnd(9)}</code>  <b>$${fmt(c.last)}</b>  ${dir} <i>${sign(c.change)}</i>`;\n}).join(\"\\n\");\n\n// ---- CURVE SUMMARY (full forward curve) ----\nconst curveRows = contracts.map(c => {\n  const bar = c.change >= 0 ? \"\u25b2\" : \"\u25bc\";\n  return `<code>${c.symbol}</code> | ${c.name} | <b>$${fmt(c.last)}</b> ${bar}`;\n}).join(\"\\n\");\n\n// ---- SPREAD: Front vs Back ----\nconst spread = contracts[0].last - contracts[contracts.length - 1].last;\nconst curveShape = spread > 2 ? \"\ud83d\udd34 <b>Backwardation</b> (spot premium)\" \n                 : spread < -2 ? \"\ud83d\udfe2 <b>Contango</b> (deferred premium)\"\n                 : \"\u26aa <b>Flat Curve</b>\";\n\n// ---- ASSEMBLE TELEGRAM MESSAGE ----\nconst message = `\n\ud83d\udee2\ufe0f <b>MURBAN CRUDE OIL \u2014 FUTURES REPORT</b>\n<i>ICE Futures Abu Dhabi (IFAD) | FOB Fujairah</i>\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\ud83d\udcc5 <b>${dateStr}</b>\n\ud83d\udd50 <b>${timeStr}</b>\n\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\ud83d\udd06 <b>FRONT MONTH: ${front.name}</b>\n\ud83d\udcb5 <b>Price:</b> <code>$${fmt(front.last)} / bbl</code>\n${trendEmoji(front.change)} <b>Change:</b> <code>${sign(front.change)} (${sign((front.change/front.open*100).toFixed(2))}%)</code>\n\ud83d\udcc2 <b>Open:</b> $${fmt(front.open)}   \ud83d\udcca <b>Range:</b> $${fmt(front.low)} \u2013 $${fmt(front.high)}\n\ud83c\udf21\ufe0f <b>Market Sentiment:</b> ${mktSentiment}\n\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\ud83d\udccb <b>NEAR-TERM FUTURES (6 Contracts)</b>\n\n${contractRows}\n\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\ud83d\udcd0 <b>FORWARD CURVE SHAPE</b>\n${curveShape}\n\u2194\ufe0f <b>Spread (Front vs Dec'30):</b> <code>${sign(spread.toFixed(2))} $/bbl</code>\n\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\ud83d\udcca <b>FULL FORWARD CURVE</b>\n\n${curveRows}\n\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\u2139\ufe0f <i>Murban: UAE Light Crude | API ~39.9\u00b0 | Sulfur ~0.79%</i>\n\ud83c\udfed <i>Produced by ADNOC | Delivered FOB Fujairah, UAE</i>\n\ud83d\udd17 <i>Source: OilPrice.com / ICE IFAD</i>\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n`.trim();\n\n// ---- OUTPUT FOR TELEGRAM NODE ----\nreturn [{\n  json: {\n    chat_id: \"YOUR_CHAT_ID\",          // \ud83d\udd01 Replace with your Telegram chat/channel ID\n    text: message,\n    parse_mode: \"HTML\",\n    disable_web_page_preview: true,\n  }\n}];"
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "1210101e-a73c-4fb7-8766-4231b684222c",
  "connections": {
    "When Market Opens": {
      "main": [
        [
          {
            "node": "Fetch Murban Prices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Murban Data": {
      "main": [
        [
          {
            "node": "Aggregate Crude Prices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Murban Prices": {
      "main": [
        [
          {
            "node": "Extract Murban Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Crude Prices": {
      "main": [
        [
          {
            "node": "Send Crude Price Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}