{
  "name": "50_541_WORKFLOW_CONTROL",
  "nodes": [
    {
      "id": "70a-trigger",
      "name": "When Called by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1,
      "position": [
        250,
        300
      ],
      "parameters": {}
    },
    {
      "id": "70a-route",
      "name": "Route Action",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        470,
        300
      ],
      "parameters": {
        "rules": {
          "rules": [
            {
              "outputKey": "LIST",
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": ""
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.intent }}",
                    "rightValue": "LIST_WORKFLOWS",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              }
            },
            {
              "outputKey": "ACTIVATE",
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": ""
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.intent }}",
                    "rightValue": "ACTIVATE_WORKFLOW",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              }
            },
            {
              "outputKey": "DEACTIVATE",
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": ""
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.intent }}",
                    "rightValue": "DEACTIVATE_WORKFLOW",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              }
            },
            {
              "outputKey": "TRIGGER",
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": ""
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.intent }}",
                    "rightValue": "TRIGGER_WORKFLOW",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              }
            },
            {
              "outputKey": "SCHEDULE",
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": ""
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.intent }}",
                    "rightValue": "UPDATE_SCHEDULE",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              }
            },
            {
              "outputKey": "CONFIRM",
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": ""
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.isConfirmation }}",
                    "rightValue": true,
                    "operator": {
                      "type": "boolean",
                      "operation": "equal"
                    }
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      }
    },
    {
      "id": "70a-list-fetch",
      "name": "Fetch All Workflows",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        720,
        80
      ],
      "parameters": {
        "method": "GET",
        "url": "http://10.0.1.29:5678/api/v1/workflows",
        "authentication": "none",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-N8N-API-KEY",
              "value": "={{ $env.N8N_API_KEY }}"
            }
          ]
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "limit",
              "value": "100"
            }
          ]
        },
        "options": {
          "timeout": 8000
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "id": "70a-list-format",
      "name": "Format Workflow List",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        960,
        80
      ],
      "parameters": {
        "jsCode": "const chatId = $('When Called by Another Workflow').first().json.chatId;\nconst data = $input.first().json;\nconst workflows = data?.data ?? data?.workflows ?? [];\n\nif (workflows.length === 0) {\n  return [{ json: { chatId, response: '\u274c Keine Workflows gefunden.' } }];\n}\n\nconst active = workflows.filter(w => w.active);\nconst inactive = workflows.filter(w => !w.active);\n\nconst formatLine = w => {\n  const status = w.active ? '\u2705' : '\u23f8';\n  return `${status} \\`${w.name}\\``;\n};\n\nlet response = `*n8n Workflows (${workflows.length})*\\n\\n`;\nresponse += `*Aktiv (${active.length}):*\\n`;\nresponse += active.map(formatLine).join('\\n') || '_keine_';\nresponse += `\\n\\n*Pausiert (${inactive.length}):*\\n`;\nresponse += inactive.map(formatLine).join('\\n') || '_keine_';\nresponse += `\\n\\n_Befehle: \"aktiviere [Name]\" | \"deaktiviere [Name]\" | \"starte [Name]\"_`;\n\n// Truncate if too long\nif (response.length > 4000) {\n  response = response.substring(0, 3900) + '\\n\\n_[Liste gek\u00fcrzt]_';\n}\n\nreturn [{ json: { chatId, response } }];"
      }
    },
    {
      "id": "70a-find-for-activate",
      "name": "Find Workflow (Activate)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        720,
        200
      ],
      "parameters": {
        "method": "GET",
        "url": "http://10.0.1.29:5678/api/v1/workflows",
        "authentication": "none",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-N8N-API-KEY",
              "value": "={{ $env.N8N_API_KEY }}"
            }
          ]
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "limit",
              "value": "100"
            }
          ]
        },
        "options": {
          "timeout": 8000
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "id": "70a-activate",
      "name": "Activate Workflow",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        960,
        200
      ],
      "parameters": {
        "jsCode": "const input = $('When Called by Another Workflow').first().json;\nconst chatId = input.chatId;\nconst searchName = (input.workflow_name ?? input.workflowName ?? '').toLowerCase();\nconst searchId = input.workflow_id ?? input.workflowId ?? null;\n\nconst data = $input.first().json;\nconst workflows = data?.data ?? data?.workflows ?? [];\n\n// Find by ID or fuzzy name match\nlet target = null;\nif (searchId) {\n  target = workflows.find(w => w.id === searchId || String(w.id) === String(searchId));\n}\nif (!target && searchName) {\n  target = workflows.find(w => w.name.toLowerCase().includes(searchName));\n}\n\nif (!target) {\n  return [{ json: { chatId, response: `\u274c Workflow \\`${input.workflow_name ?? searchId}\\` nicht gefunden.\\n\\nTippe *workflows* um alle anzuzeigen.`, skipActivate: true } }];\n}\n\nreturn [{ json: { chatId, workflowId: target.id, workflowName: target.name, alreadyActive: target.active, skipActivate: false } }];"
      }
    },
    {
      "id": "70a-activate-check",
      "name": "Already Active?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1200,
        200
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "check-skip",
              "leftValue": "={{ $json.skipActivate }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equal"
              }
            }
          ],
          "combinator": "and"
        }
      }
    },
    {
      "id": "70a-activate-api",
      "name": "Call Activate API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1440,
        240
      ],
      "parameters": {
        "method": "POST",
        "url": "=http://10.0.1.29:5678/api/v1/workflows/{{ $json.workflowId }}/activate",
        "authentication": "none",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-N8N-API-KEY",
              "value": "={{ $env.N8N_API_KEY }}"
            }
          ]
        },
        "options": {
          "timeout": 8000
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "id": "70a-activate-response",
      "name": "Activate Response",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1680,
        240
      ],
      "parameters": {
        "jsCode": "const prev = $('Activate Workflow').first().json;\nconst chatId = prev.chatId;\nconst result = $input.first().json;\nconst name = prev.workflowName;\n\nif (result.error || result.message?.includes('error')) {\n  return [{ json: { chatId, response: `\u274c Fehler beim Aktivieren von \\`${name}\\`: ${result.message ?? 'Unbekannter Fehler'}` } }];\n}\n\nreturn [{ json: { chatId, response: `\u2705 Workflow \\`${name}\\` wurde *aktiviert*.` } }];"
      }
    },
    {
      "id": "70a-deactivate-confirm",
      "name": "Send Deactivate Confirmation",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        720,
        340
      ],
      "parameters": {
        "method": "POST",
        "url": "=https://api.telegram.org/bot{{ $env.TELEGRAM_BOT_TOKEN }}/sendMessage",
        "authentication": "none",
        "sendBody": true,
        "specifyBody": "string",
        "body": "={{ JSON.stringify({ chat_id: $json.chatId, text: '\u26a0\ufe0f *Best\u00e4tigung erforderlich*\\n\\nSoll ich Workflow `' + ($json.workflow_name ?? $json.workflowName ?? '?') + '` wirklich *deaktivieren*?', parse_mode: 'Markdown', reply_markup: { inline_keyboard: [[{ text: '\u2705 Ja, deaktivieren', callback_data: 'confirm_deactivate:' + ($json.workflow_name ?? '') }, { text: '\u274c Abbrechen', callback_data: 'cancel' }]] } }) }}",
        "options": {
          "timeout": 8000
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "id": "70a-deactivate-pending",
      "name": "Deactivate Pending Response",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        960,
        340
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1",
              "name": "chatId",
              "value": "={{ $('When Called by Another Workflow').first().json.chatId }}",
              "type": "string"
            },
            {
              "id": "a2",
              "name": "response",
              "value": "",
              "type": "string"
            }
          ]
        }
      }
    },
    {
      "id": "70a-find-for-trigger",
      "name": "Find Workflow (Trigger)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        720,
        460
      ],
      "parameters": {
        "method": "GET",
        "url": "http://10.0.1.29:5678/api/v1/workflows",
        "authentication": "none",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-N8N-API-KEY",
              "value": "={{ $env.N8N_API_KEY }}"
            }
          ]
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "limit",
              "value": "100"
            }
          ]
        },
        "options": {
          "timeout": 8000
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "id": "70a-trigger-workflow",
      "name": "Execute Workflow Now",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        960,
        460
      ],
      "parameters": {
        "jsCode": "// This code node finds the workflow and prepares the trigger\nconst input = $('When Called by Another Workflow').first().json;\nconst chatId = input.chatId;\nconst searchName = (input.workflow_name ?? '').toLowerCase();\nconst searchId = input.workflow_id ?? null;\n\nconst data = $input.first().json;\nconst workflows = data?.data ?? data?.workflows ?? [];\n\nlet target = null;\nif (searchId) {\n  target = workflows.find(w => String(w.id) === String(searchId));\n}\nif (!target && searchName) {\n  target = workflows.find(w => w.name.toLowerCase().includes(searchName));\n}\n\nif (!target) {\n  return [{ json: { chatId, response: `\u274c Workflow \\`${input.workflow_name ?? searchId}\\` nicht gefunden.`, skipTrigger: true } }];\n}\n\nif (!target.active) {\n  return [{ json: { chatId, response: `\u26a0\ufe0f Workflow \\`${target.name}\\` ist *deaktiviert* und kann nicht ausgef\u00fchrt werden.\\n\\nTippe *aktiviere ${target.name}* um ihn zu aktivieren.`, skipTrigger: true } }];\n}\n\nreturn [{ json: { chatId, workflowId: target.id, workflowName: target.name, skipTrigger: false } }];"
      }
    },
    {
      "id": "70a-trigger-check",
      "name": "Skip Trigger?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1200,
        460
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "t-skip",
              "leftValue": "={{ $json.skipTrigger }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equal"
              }
            }
          ],
          "combinator": "and"
        }
      }
    },
    {
      "id": "70a-trigger-api",
      "name": "Call Run API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1440,
        500
      ],
      "parameters": {
        "method": "POST",
        "url": "=http://10.0.1.29:5678/api/v1/workflows/{{ $json.workflowId }}/run",
        "authentication": "none",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-N8N-API-KEY",
              "value": "={{ $env.N8N_API_KEY }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "string",
        "body": "{}",
        "options": {
          "timeout": 10000
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "id": "70a-trigger-response",
      "name": "Trigger Response",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1680,
        500
      ],
      "parameters": {
        "jsCode": "const prev = $('Execute Workflow Now').first().json;\nconst chatId = prev.chatId;\nconst result = $input.first().json;\nconst name = prev.workflowName;\n\nif (result.error) {\n  return [{ json: { chatId, response: `\u274c Fehler beim Starten von \\`${name}\\`: ${result.message ?? 'Unbekannter Fehler'}` } }];\n}\n\nconst execId = result.executionId ?? result.id ?? '';\nreturn [{ json: { chatId, response: `\ud83d\ude80 Workflow \\`${name}\\` wurde *gestartet*.${execId ? '\\nExecution ID: ' + execId : ''}` } }];"
      }
    },
    {
      "id": "70a-schedule-confirm",
      "name": "Send Schedule Confirmation",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        720,
        580
      ],
      "parameters": {
        "method": "POST",
        "url": "=https://api.telegram.org/bot{{ $env.TELEGRAM_BOT_TOKEN }}/sendMessage",
        "authentication": "none",
        "sendBody": true,
        "specifyBody": "string",
        "body": "={{ JSON.stringify({ chat_id: $json.chatId, text: '\u23f0 *Schedule-\u00c4nderung best\u00e4tigen*\\n\\nWorkflow: `' + ($json.workflow_name ?? '?') + '`\\nNeuer Zeitplan: ' + ($json.cron_human ?? $json.cron_expression ?? '?') + '\\n\\nFortfahren?', parse_mode: 'Markdown', reply_markup: { inline_keyboard: [[{ text: '\u2705 Ja, Zeitplan \u00e4ndern', callback_data: 'confirm_schedule:' + ($json.workflow_name ?? '') + ':' + ($json.cron_expression ?? '') }, { text: '\u274c Abbrechen', callback_data: 'cancel' }]] } }) }}",
        "options": {
          "timeout": 8000
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "id": "70a-schedule-pending",
      "name": "Schedule Pending Response",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        960,
        580
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b1",
              "name": "chatId",
              "value": "={{ $('When Called by Another Workflow').first().json.chatId }}",
              "type": "string"
            },
            {
              "id": "b2",
              "name": "response",
              "value": "",
              "type": "string"
            }
          ]
        }
      }
    },
    {
      "id": "70a-confirm-handler",
      "name": "Handle Confirmation",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        720,
        700
      ],
      "parameters": {
        "jsCode": "const input = $('When Called by Another Workflow').first().json;\nconst chatId = input.chatId;\nconst callbackData = input.callbackData ?? '';\n\nif (callbackData === 'cancel') {\n  return [{ json: { chatId, response: '\u274c Abgebrochen.', confirmAction: null } }];\n}\n\nif (callbackData.startsWith('confirm_deactivate:')) {\n  const workflowName = callbackData.replace('confirm_deactivate:', '');\n  return [{ json: { chatId, response: null, confirmAction: 'deactivate', workflowName } }];\n}\n\nif (callbackData.startsWith('confirm_schedule:')) {\n  const parts = callbackData.replace('confirm_schedule:', '').split(':');\n  const workflowName = parts[0];\n  const cronExpression = parts.slice(1).join(':');\n  return [{ json: { chatId, response: null, confirmAction: 'schedule', workflowName, cronExpression } }];\n}\n\nreturn [{ json: { chatId, response: '\u2753 Unbekannte Aktion.', confirmAction: null } }];"
      }
    },
    {
      "id": "70a-confirm-route",
      "name": "Route Confirmed Action",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        960,
        700
      ],
      "parameters": {
        "rules": {
          "rules": [
            {
              "outputKey": "DEACTIVATE",
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": ""
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.confirmAction }}",
                    "rightValue": "deactivate",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              }
            },
            {
              "outputKey": "SCHEDULE",
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": ""
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.confirmAction }}",
                    "rightValue": "schedule",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      }
    },
    {
      "id": "70a-deactivate-find",
      "name": "Find & Deactivate",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1200,
        660
      ],
      "parameters": {
        "method": "GET",
        "url": "http://10.0.1.29:5678/api/v1/workflows",
        "authentication": "none",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-N8N-API-KEY",
              "value": "={{ $env.N8N_API_KEY }}"
            }
          ]
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "limit",
              "value": "100"
            }
          ]
        },
        "options": {
          "timeout": 8000
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "id": "70a-deactivate-exec",
      "name": "Execute Deactivate",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1440,
        660
      ],
      "parameters": {
        "jsCode": "const confirmed = $('Handle Confirmation').first().json;\nconst chatId = confirmed.chatId;\nconst searchName = confirmed.workflowName.toLowerCase();\n\nconst data = $input.first().json;\nconst workflows = data?.data ?? data?.workflows ?? [];\nconst target = workflows.find(w => w.name.toLowerCase().includes(searchName));\n\nif (!target) {\n  return [{ json: { chatId, response: `\u274c Workflow \\`${confirmed.workflowName}\\` nicht gefunden.`, workflowId: null } }];\n}\n\nreturn [{ json: { chatId, workflowId: target.id, workflowName: target.name } }];"
      }
    },
    {
      "id": "70a-deactivate-api",
      "name": "Call Deactivate API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1680,
        660
      ],
      "parameters": {
        "method": "POST",
        "url": "=http://10.0.1.29:5678/api/v1/workflows/{{ $json.workflowId }}/deactivate",
        "authentication": "none",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-N8N-API-KEY",
              "value": "={{ $env.N8N_API_KEY }}"
            }
          ]
        },
        "options": {
          "timeout": 8000
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "id": "70a-deactivate-resp",
      "name": "Deactivate Final Response",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1920,
        660
      ],
      "parameters": {
        "jsCode": "const prev = $('Execute Deactivate').first().json;\nconst chatId = prev.chatId;\nconst name = prev.workflowName;\nconst result = $input.first().json;\n\nif (result.error) {\n  return [{ json: { chatId, response: `\u274c Fehler: ${result.message ?? 'Deaktivierung fehlgeschlagen'}` } }];\n}\n\nreturn [{ json: { chatId, response: `\u23f8 Workflow \\`${name}\\` wurde *deaktiviert*.` } }];"
      }
    },
    {
      "id": "70a-cancel-resp",
      "name": "Cancel Response",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1200,
        780
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c1",
              "name": "chatId",
              "value": "={{ $json.chatId }}",
              "type": "string"
            },
            {
              "id": "c2",
              "name": "response",
              "value": "={{ $json.response }}",
              "type": "string"
            }
          ]
        }
      }
    },
    {
      "id": "70a-merge-all",
      "name": "Merge All Responses",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [
        2160,
        420
      ],
      "parameters": {
        "mode": "passThrough",
        "output": "input1"
      }
    }
  ],
  "connections": {
    "When Called by Another Workflow": {
      "main": [
        [
          {
            "node": "Route Action",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Action": {
      "main": [
        [
          {
            "node": "Fetch All Workflows",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Find Workflow (Activate)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Deactivate Confirmation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Find Workflow (Trigger)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Schedule Confirmation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch All Workflows": {
      "main": [
        [
          {
            "node": "Format Workflow List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Workflow List": {
      "main": [
        [
          {
            "node": "Merge All Responses",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Workflow (Activate)": {
      "main": [
        [
          {
            "node": "Activate Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Activate Workflow": {
      "main": [
        [
          {
            "node": "Already Active?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Already Active?": {
      "main": [
        [
          {
            "node": "Merge All Responses",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "Call Activate API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call Activate API": {
      "main": [
        [
          {
            "node": "Activate Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Activate Response": {
      "main": [
        [
          {
            "node": "Merge All Responses",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Send Deactivate Confirmation": {
      "main": [
        [
          {
            "node": "Deactivate Pending Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Deactivate Pending Response": {
      "main": [
        [
          {
            "node": "Merge All Responses",
            "type": "main",
            "index": 3
          }
        ]
      ]
    },
    "Find Workflow (Trigger)": {
      "main": [
        [
          {
            "node": "Execute Workflow Now",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow Now": {
      "main": [
        [
          {
            "node": "Skip Trigger?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Skip Trigger?": {
      "main": [
        [
          {
            "node": "Merge All Responses",
            "type": "main",
            "index": 4
          }
        ],
        [
          {
            "node": "Call Run API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call Run API": {
      "main": [
        [
          {
            "node": "Trigger Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger Response": {
      "main": [
        [
          {
            "node": "Merge All Responses",
            "type": "main",
            "index": 5
          }
        ]
      ]
    },
    "Send Schedule Confirmation": {
      "main": [
        [
          {
            "node": "Schedule Pending Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Pending Response": {
      "main": [
        [
          {
            "node": "Merge All Responses",
            "type": "main",
            "index": 6
          }
        ]
      ]
    },
    "Handle Confirmation": {
      "main": [
        [
          {
            "node": "Route Confirmed Action",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Confirmed Action": {
      "main": [
        [
          {
            "node": "Find & Deactivate",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge All Responses",
            "type": "main",
            "index": 7
          }
        ],
        [
          {
            "node": "Cancel Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find & Deactivate": {
      "main": [
        [
          {
            "node": "Execute Deactivate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Deactivate": {
      "main": [
        [
          {
            "node": "Call Deactivate API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call Deactivate API": {
      "main": [
        [
          {
            "node": "Deactivate Final Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Deactivate Final Response": {
      "main": [
        [
          {
            "node": "Merge All Responses",
            "type": "main",
            "index": 8
          }
        ]
      ]
    },
    "Cancel Response": {
      "main": [
        [
          {
            "node": "Merge All Responses",
            "type": "main",
            "index": 9
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveDataErrorExecution": "all",
    "saveDataSuccessExecution": "none"
  },
  "staticData": null,
  "tags": [
    "telegram",
    "workflow-control"
  ],
  "meta": {
    "description": "541 \u2014 Sub-Workflow: n8n Workflow-Steuerung (Activate, Deactivate, Trigger, Schedule) via Telegram"
  }
}