{
  "name": "Manage Claude Code sessions from Matrix with YouTrack and GitLab",
  "nodes": [
    {
      "id": "7c31b18c",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        -352
      ],
      "parameters": {
        "width": 540,
        "height": 520,
        "content": "## Manage AI coding sessions from Matrix\nA chat-ops bridge between Matrix, Claude Code,\nYouTrack, and GitLab. Your team talks to an AI\ncoding assistant from a chat room — with issue\ntracking and CI/CD"
      }
    },
    {
      "id": "4ceda743",
      "name": "Sticky Note 4fa9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        224
      ],
      "parameters": {
        "width": 260,
        "height": 228,
        "content": "### 1. Configuration\nUser-configurable variables."
      }
    },
    {
      "id": "277ed962",
      "name": "Sticky Note 7417",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        224
      ],
      "parameters": {
        "width": 960,
        "height": 228,
        "content": "### 2. Matrix polling\nPolls Matrix /sync every 30 seconds, extracts new messages, filters empty batches."
      }
    },
    {
      "id": "874e52f1",
      "name": "Sticky Note 782c",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1472,
        224
      ],
      "parameters": {
        "width": 500,
        "height": 420,
        "content": "### 3. Command routing\nParses `!commands`, routes to handlers."
      }
    },
    {
      "id": "8489758d",
      "name": "Sticky Note c9e3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2016,
        -304
      ],
      "parameters": {
        "width": 1576,
        "height": 374,
        "content": "### 4. Message handler\nChecks lock, reads session, resumes Claude via SSH, posts response to Matrix."
      }
    },
    {
      "id": "2e04a109",
      "name": "Sticky Note 6e7b",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2016,
        128
      ],
      "parameters": {
        "width": 592,
        "height": 1248,
        "content": "### 5. Command handlers\n**!session** current, list, done, cancel, pause, resume\n**!issue** status, info, start, verify, done, comment\n**!pipeline** status, logs, retry\n**!system** status | **!help** r"
      }
    },
    {
      "id": "7c36c474",
      "name": "Sticky Note dbbd",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2656,
        496
      ],
      "parameters": {
        "width": 760,
        "height": 288,
        "content": "### 6. Response and session end\nPosts output to Matrix. Archives session to SQLite on done."
      }
    },
    {
      "id": "gateway-config",
      "name": "Gateway Config",
      "type": "n8n-nodes-base.set",
      "position": [
        208,
        304
      ]
    },
    {
      "id": "poll-trigger",
      "name": "Poll Every 30s",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        512,
        304
      ]
    },
    {
      "id": "get-sync-token",
      "name": "Get Sync Token",
      "type": "n8n-nodes-base.code",
      "position": [
        704,
        304
      ]
    },
    {
      "id": "poll-matrix",
      "name": "Poll Matrix Sync",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        912,
        304
      ]
    },
    {
      "id": "extract-messages",
      "name": "Extract Messages",
      "type": "n8n-nodes-base.code",
      "position": [
        1104,
        304
      ]
    },
    {
      "id": "has-messages",
      "name": "Has Messages?",
      "type": "n8n-nodes-base.if",
      "position": [
        1312,
        304
      ]
    },
    {
      "id": "detect-command",
      "name": "Detect Command",
      "type": "n8n-nodes-base.code",
      "position": [
        1504,
        304
      ]
    },
    {
      "id": "command-router",
      "name": "Command Router",
      "type": "n8n-nodes-base.switch",
      "position": [
        1760,
        304
      ]
    },
    {
      "id": "check-lock",
      "name": "Check Lock",
      "type": "n8n-nodes-base.ssh",
      "position": [
        2064,
        -112
      ]
    },
    {
      "id": "is-locked",
      "name": "Is Locked?",
      "type": "n8n-nodes-base.if",
      "position": [
        2272,
        -112
      ]
    },
    {
      "id": "post-busy",
      "name": "Post Busy Notice",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2608,
        -240
      ]
    },
    {
      "id": "read-session",
      "name": "Read Session & Acquire Lock",
      "type": "n8n-nodes-base.ssh",
      "position": [
        2496,
        -112
      ]
    },
    {
      "id": "resume-claude",
      "name": "Resume Claude Session",
      "type": "n8n-nodes-base.ssh",
      "position": [
        2720,
        -112
      ]
    },
    {
      "id": "parse-response",
      "name": "Parse Claude Response",
      "type": "n8n-nodes-base.code",
      "position": [
        2944,
        -112
      ]
    },
    {
      "id": "post-response",
      "name": "Post Response to Matrix",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3152,
        -112
      ]
    },
    {
      "id": "release-lock",
      "name": "Release Lock",
      "type": "n8n-nodes-base.ssh",
      "position": [
        3376,
        -112
      ]
    },
    {
      "id": "handle-session",
      "name": "Handle Session Command",
      "type": "n8n-nodes-base.ssh",
      "position": [
        2064,
        272
      ]
    },
    {
      "id": "format-session",
      "name": "Format Session Response",
      "type": "n8n-nodes-base.code",
      "position": [
        2272,
        272
      ]
    },
    {
      "id": "handle-issue",
      "name": "Handle Issue Command",
      "type": "n8n-nodes-base.ssh",
      "position": [
        2064,
        480
      ]
    },
    {
      "id": "format-issue",
      "name": "Format Issue Response",
      "type": "n8n-nodes-base.code",
      "position": [
        2272,
        432
      ]
    },
    {
      "id": "handle-pipeline",
      "name": "Handle Pipeline Command",
      "type": "n8n-nodes-base.ssh",
      "position": [
        2064,
        640
      ]
    },
    {
      "id": "format-pipeline",
      "name": "Format Pipeline Response",
      "type": "n8n-nodes-base.code",
      "position": [
        2272,
        592
      ]
    },
    {
      "id": "handle-help",
      "name": "Handle Help",
      "type": "n8n-nodes-base.code",
      "position": [
        2064,
        832
      ]
    },
    {
      "id": "handle-system",
      "name": "Handle System Command",
      "type": "n8n-nodes-base.ssh",
      "position": [
        2064,
        976
      ]
    },
    {
      "id": "format-system",
      "name": "Format System Response",
      "type": "n8n-nodes-base.code",
      "position": [
        2272,
        912
      ]
    },
    {
      "id": "handle-unknown",
      "name": "Handle Unknown Command",
      "type": "n8n-nodes-base.code",
      "position": [
        2064,
        1168
      ]
    },
    {
      "id": "post-cmd-response",
      "name": "Post Command Response",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2496,
        592
      ]
    },
    {
      "id": "session-end-check",
      "name": "Is Session Done?",
      "type": "n8n-nodes-base.if",
      "position": [
        2720,
        592
      ]
    },
    {
      "id": "cleanup-session",
      "name": "Clean Up & End Session",
      "type": "n8n-nodes-base.ssh",
      "position": [
        2944,
        592
      ]
    },
    {
      "id": "post-session-ended",
      "name": "Post Session Ended",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3152,
        592
      ]
    },
    {
      "id": "cred-sticky",
      "name": "Sticky Note Credentials",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        800
      ],
      "parameters": {
        "width": 520,
        "height": 508,
        "content": "### Credentials Setup\n\n**Do NOT store API tokens in workflow nodes.**\nUse n8n's credential system instead:\n\n1. **Matrix Bot Token** — HTTP Header Auth\n   `Authorization: Bearer <token>`\n\n2. **SSH Priv"
      }
    }
  ],
  "connections": {
    "Check Lock": {
      "main": [
        [
          {
            "node": "Is Locked?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Locked?": {
      "main": [
        [
          {
            "node": "Post Busy Notice",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Read Session & Acquire Lock",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle Help": {
      "main": [
        [
          {
            "node": "Post Command Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Messages?": {
      "main": [
        [
          {
            "node": "Detect Command",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Command Router": {
      "main": [
        [
          {
            "node": "Check Lock",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle Session Command",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle Help",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle Issue Command",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle Pipeline Command",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle System Command",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle Unknown Command",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect Command": {
      "main": [
        [
          {
            "node": "Command Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Sync Token": {
      "main": [
        [
          {
            "node": "Poll Matrix Sync",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Poll Every 30s": {
      "main": [
        [
          {
            "node": "Get Sync Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Messages": {
      "main": [
        [
          {
            "node": "Has Messages?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Session Done?": {
      "main": [
        [
          {
            "node": "Clean Up & End Session",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Poll Matrix Sync": {
      "main": [
        [
          {
            "node": "Extract Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle Issue Command": {
      "main": [
        [
          {
            "node": "Format Issue Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Issue Response": {
      "main": [
        [
          {
            "node": "Post Command Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle System Command": {
      "main": [
        [
          {
            "node": "Format System Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Claude Response": {
      "main": [
        [
          {
            "node": "Post Response to Matrix",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post Command Response": {
      "main": [
        [
          {
            "node": "Is Session Done?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Resume Claude Session": {
      "main": [
        [
          {
            "node": "Parse Claude Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean Up & End Session": {
      "main": [
        [
          {
            "node": "Post Session Ended",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format System Response": {
      "main": [
        [
          {
            "node": "Post Command Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle Session Command": {
      "main": [
        [
          {
            "node": "Format Session Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle Unknown Command": {
      "main": [
        [
          {
            "node": "Post Command Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Session Response": {
      "main": [
        [
          {
            "node": "Post Command Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle Pipeline Command": {
      "main": [
        [
          {
            "node": "Format Pipeline Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post Response to Matrix": {
      "main": [
        [
          {
            "node": "Release Lock",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Pipeline Response": {
      "main": [
        [
          {
            "node": "Post Command Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Session & Acquire Lock": {
      "main": [
        [
          {
            "node": "Resume Claude Session",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}