{ "name": "Schedule n8n Workflow Activity", "tags": [ { "id": "0IPbflTW7vujkmxO", "name": "DevOps", "createdAt": "2025-03-16T13:11:38.707Z", "updatedAt": "2025-03-16T13:11:38.707Z" } ], "nodes": [ { "id": "schedule-n8n-workflow-activity-0", "name": "Activate at 08:00 daily", "type": "n8n-nodes-base.scheduleTrigger", "position": [ -320, -200 ], "parameters": { "rule": { "interval": [ { "field": "cronExpression", "expression": "0 8 * * *" } ] } }, "typeVersion": 1.2 }, { "id": "schedule-n8n-workflow-activity-1", "name": "Deactivate at 20:00 daily", "type": "n8n-nodes-base.scheduleTrigger", "position": [ -320, 160 ], "parameters": { "rule": { "interval": [ { "field": "cronExpression", "expression": "0 20 * * *" } ] } }, "typeVersion": 1.2 }, { "id": "schedule-n8n-workflow-activity-2", "name": "Workflow ID", "type": "n8n-nodes-base.set", "position": [ -60, -80 ], "parameters": { "options": {}, "assignments": { "assignments": [ { "id": "86a66597-b7c3-4e26-aab9-fdf6cc4e43b5", "name": "workflowID", "type": "string", "value": "YOUR_N8N_WORKFLOW_ID" } ] } }, "typeVersion": 3.4 }, { "name": "Validate the target", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForAllItems", "jsCode": "return $input.all().map(x=>{const id=x.json.workflowID;if(typeof id!=='string'||!id.trim()||id.startsWith('YOUR_')||id===$workflow.id)throw Error('Configure a different target workflow ID');return x});" }, "id": "schedule-n8n-workflow-activity-3" }, { "id": "schedule-n8n-workflow-activity-4", "name": "Merge in Workflow ID for activation", "type": "n8n-nodes-base.merge", "position": [ 180, -180 ], "parameters": { "mode": "combine", "options": {}, "combineBy": "combineByPosition" }, "typeVersion": 3 }, { "id": "schedule-n8n-workflow-activity-5", "name": "Merge in Workflow ID for deactivation", "type": "n8n-nodes-base.merge", "position": [ 180, 140 ], "parameters": { "mode": "combine", "options": {}, "combineBy": "combineByPosition" }, "typeVersion": 3 }, { "id": "schedule-n8n-workflow-activity-6", "name": "n8n Activate", "type": "n8n-nodes-base.n8n", "position": [ 360, -180 ], "parameters": { "operation": "activate", "workflowId": { "__rl": true, "mode": "id", "value": "={{ $json.workflowID }}" }, "requestOptions": {} }, "typeVersion": 1 }, { "id": "schedule-n8n-workflow-activity-7", "name": "n8n Deactivate", "type": "n8n-nodes-base.n8n", "position": [ 360, 140 ], "parameters": { "operation": "deactivate", "workflowId": { "__rl": true, "mode": "id", "value": "={{ $json.workflowID }}" }, "requestOptions": {} }, "typeVersion": 1 }, { "name": "Confirm activation", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForAllItems", "jsCode": "const r=$input.first().json,id=$('Workflow ID').first().json.workflowID;if(!r||r.id!==id||r.active!==true)throw Error('n8n did not confirm the requested workflow status');return [{json:r}];" }, "id": "schedule-n8n-workflow-activity-8" }, { "name": "Confirm deactivation", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForAllItems", "jsCode": "const r=$input.first().json,id=$('Workflow ID').first().json.workflowID;if(!r||r.id!==id||r.active!==false)throw Error('n8n did not confirm the requested workflow status');return [{json:r}];" }, "id": "schedule-n8n-workflow-activity-9" } ], "active": false, "pinData": {}, "settings": { "executionOrder": "v1", "timezone": "UTC" }, "connections": { "Activate at 08:00 daily": { "main": [ [ { "node": "Workflow ID", "type": "main", "index": 0 }, { "node": "Merge in Workflow ID for activation", "type": "main", "index": 0 } ] ] }, "Deactivate at 20:00 daily": { "main": [ [ { "node": "Workflow ID", "type": "main", "index": 0 }, { "node": "Merge in Workflow ID for deactivation", "type": "main", "index": 1 } ] ] }, "Workflow ID": { "main": [ [ { "node": "Validate the target", "type": "main", "index": 0 } ] ] }, "Validate the target": { "main": [ [ { "node": "Merge in Workflow ID for activation", "type": "main", "index": 1 }, { "node": "Merge in Workflow ID for deactivation", "type": "main", "index": 0 } ] ] }, "Merge in Workflow ID for activation": { "main": [ [ { "node": "n8n Activate", "type": "main", "index": 0 } ] ] }, "Merge in Workflow ID for deactivation": { "main": [ [ { "node": "n8n Deactivate", "type": "main", "index": 0 } ] ] }, "n8n Activate": { "main": [ [ { "node": "Confirm activation", "type": "main", "index": 0 } ] ] }, "n8n Deactivate": { "main": [ [ { "node": "Confirm deactivation", "type": "main", "index": 0 } ] ] } } }