【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.7 调度工作流 (Scheduling the workflow)
https://docs.n8n.io/courses/
https://docs.n8n.io/courses/level-one/chapter-5/chapter-5.7/
文章目录
- 7. Scheduling the Workflow
- Remove the Manual Trigger node
- Add the Schedule Trigger node
- Connect the Schedule Trigger node
- What's next?
7. Scheduling the Workflow
In this step of the workflow, you will learn how to schedule your workflow so that it runs automatically at a set time/interval using the Schedule Trigger node. After this step, your workflow should look like this:
The workflow you’ve built so far executes only when you click on Execute Workflow. But Nathan needs it to run automatically every Monday morning. You can do this with the Schedule Trigger, which allows you to schedule workflows to run periodically at fixed dates, times, or intervals.
To achieve this, we’ll remove the Manual Trigger node we started with and replace it with a Schedule Trigger node instead.
Remove the Manual Trigger node
First, let’s remove the Manual Trigger node:
- Select the Manual Trigger node connected to your HTTP Request node.
- Select the trash can icon to delete.
This removes the Manual Trigger node and you’ll see an “Add first step” option.
(I didn’t see that option.)
Add the Schedule Trigger node
-
Open the nodes panel and search for Schedule Trigger.
-
Select it when it appears in the search results.
In the Schedule Trigger node window, configure these parameters:
- Trigger Interval: Select Weeks.
- Weeks Between Triggers: Enter
1
. - Trigger on weekdays: Select Monday (and remove Sunday if added by default).
- Trigger at Hour: Select 9am.
- Trigger at Minute: Enter
0
.
(If the parameters do not show, refresh the page.)
Your Schedule Trigger node should look like this:

To ensure accurate scheduling with the Schedule Trigger node, be sure to set the correct timezone for your n8n instance or the workflow’s settings. The Schedule Trigger node will use the workflow’s timezone if it’s set; it will fall back to the n8n instance’s timezone if it’s not.
Connect the Schedule Trigger node
Return to the canvas and connect your Schedule Trigger node to the HTTP Request node by dragging the arrow from it to the HTTP Request node.
Your full workflow should look like this:
{"name": "Nathan's workflow.","nodes": [{"parameters": {"url": "https://internal.users.n8n.cloud/webhook/custom-erp","authentication": "genericCredentialType","genericAuthType": "httpHeaderAuth","sendHeaders": true,"headerParameters": {"parameters": [{"name": "unique_id","value": "62ca9f8ed425673b38422727e4a2f125"}]},"options": {}},"type": "n8n-nodes-base.httpRequest","typeVersion": 4.2,"position": [224,-48],"id": "4a75adea-48bd-475c-9fe7-6e5faf66a068","name": "HTTP Request","credentials": {"httpHeaderAuth": {"id": "wM2seN7VyHbQ9pPV","name": "Header Auth account for 'Getting data from the data warehouse' demo"}}},{"parameters": {"operation": "create","base": {"__rl": true,"value": "appYvuu6rzHbFUTq8","mode": "list","cachedResultName": "beginner course","cachedResultUrl": "https://airtable.com/appYvuu6rzHbFUTq8"},"table": {"__rl": true,"value": "tbllb8POBryjogSIJ","mode": "list","cachedResultName": "processingOrders","cachedResultUrl": "https://airtable.com/appYvuu6rzHbFUTq8/tbllb8POBryjogSIJ"},"columns": {"mappingMode": "autoMapInputData","value": {"orderID": 0},"matchingColumns": [],"schema": [{"id": "orderID","displayName": "orderID","required": false,"defaultMatch": false,"canBeUsedToMatch": true,"display": true,"type": "number","readOnly": false,"removed": false},{"id": "employeeName","displayName": "employeeName","required": false,"defaultMatch": false,"canBeUsedToMatch": true,"display": true,"type": "string","readOnly": false,"removed": false}],"attemptToConvertTypes": false,"convertFieldsToString": false},"options": {}},"type": "n8n-nodes-base.airtable","typeVersion": 2.1,"position": [896,-144],"id": "df141bba-5756-4500-9a6b-875b555813e4","name": "Create a record","credentials": {"airtableTokenApi": {"id": "KtAe8BvdCk4WPFEd","name": "Airtable Personal Access Token account"}}},{"parameters": {"conditions": {"options": {"caseSensitive": true,"leftValue": "","typeValidation": "strict","version": 2},"conditions": [{"id": "1d639488-a491-4cfd-8ebe-d809f982ea12","leftValue": "={{ $json.orderStatus }}","rightValue": "processing","operator": {"type": "string","operation": "equals","name": "filter.operator.equals"}}],"combinator": "and"},"options": {}},"type": "n8n-nodes-base.if","typeVersion": 2.2,"position": [448,-48],"id": "fe7627bf-392b-40a7-b2c0-79c1dba2d46b","name": "If"},{"parameters": {"assignments": {"assignments": [{"id": "ed10d31f-0b4f-4d47-add1-a0b83754950c","name": "orderID","value": "={{ $json.orderID }}","type": "number"},{"id": "da013830-6ee5-4164-b81d-8520f3c95c3a","name": "employeeName","value": "={{ $json.employeeName }}","type": "string"}]},"options": {}},"type": "n8n-nodes-base.set","typeVersion": 3.4,"position": [672,-144],"id": "00d10b2a-31eb-49ab-9d35-caa8fd2c9116","name": "Edit Fields"},{"parameters": {"jsCode": "// Get all input data and store it in a variable called \"items\"\n// $input.all() is a special function that gets all the data passed to this script\nlet items = $input.all();\n\n// Count how many items we have by checking the length of the items array\n// Arrays in JavaScript have a .length property that tells you how many elements they contain\nlet totalBooked = items.length;\n\n// Create a variable to hold the total sum of prices, starting at 0\n// This will be our running total as we add up all the prices\nlet bookedSum = 0;\n\n// Start a loop to go through each item in our list\n// The loop will run once for each item in the array\nfor (let i = 0; i < items.length; i++) {\n // Inside the loop:\n // 1. i starts at 0 (first item)\n // 2. We keep looping while i is less than the number of items\n // 3. After each loop, i increases by 1 (moves to next item)\n \n // Add the current item's price to our running total\n // items[i] gets the item at position i\n // .json is an object that contains data about this item\n // .orderPrice is a specific value inside that object representing the price\n bookedSum = bookedSum + items[i].json.orderPrice;\n}\n\n// After processing all items, return our results\n// We create an array with one object that contains both totals\n// The object has two properties: totalBooked (count of items) and bookedSum (total price)\nreturn [{ json: { totalBooked, bookedSum } }];"},"type": "n8n-nodes-base.code","typeVersion": 2,"position": [672,48],"id": "28f07d45-5463-4e94-8bb6-8af4ccd9f728","name": "Code"},{"parameters": {"authentication": "webhook","content": "=This week we've {{$json[\"totalBooked\"]}} booked orders with a total value of {{$json[\"bookedSum\"]}}. My Unique ID: {{ $('HTTP Request').params[\"headerParameters\"][\"parameters\"][0][\"value\"] }}\n","options": {}},"type": "n8n-nodes-base.discord","typeVersion": 2,"position": [896,48],"id": "edb5db5a-962d-4b31-aae9-00a29431f64b","name": "Discord","webhookId": "53de8efa-514e-4b88-acfc-efb867781b59","credentials": {"discordWebhookApi": {"id": "ByQEWCd8EX13iAwF","name": "Discord Webhook account"}}},{"parameters": {"rule": {"interval": [{"field": "weeks","triggerAtDay": [1],"triggerAtHour": 9}]}},"type": "n8n-nodes-base.scheduleTrigger","typeVersion": 1.2,"position": [0,-48],"id": "1e030312-34ba-4e23-a47e-5d06f052dce7","name": "Schedule Trigger1"}],"pinData": {},"connections": {"HTTP Request": {"main": [[{"node": "If","type": "main","index": 0}]]},"If": {"main": [[{"node": "Edit Fields","type": "main","index": 0}],[{"node": "Code","type": "main","index": 0}]]},"Edit Fields": {"main": [[{"node": "Create a record","type": "main","index": 0}]]},"Code": {"main": [[{"node": "Discord","type": "main","index": 0}]]},"Schedule Trigger1": {"main": [[{"node": "HTTP Request","type": "main","index": 0}]]}},"active": true,"settings": {"executionOrder": "v1"},"versionId": "582e09e8-45e0-46ab-b549-f3c6132e6d89","meta": {"templateCredsSetupCompleted": true,"instanceId": "eb114f6c16aa9569ee9bd3011c15a561af54982ab0e6c0b1886cadad8fa2c9e0"},"id": "f7cNaVWhOnj62wXF","tags": []
}
What’s next?
You 👩🔧: That was it for the workflow! I’ve added and configured all necessary nodes. Now every time you click on Execute workflow, n8n will execute all the nodes: getting, filtering, calculating, and transferring the sales data.
Nathan 🙋: This is just what I needed! My workflow will run automatically every Monday morning, correct?
You 👩🔧: Not so fast. To do that, you need to activate your workflow. I’ll do this in the next step and show you how to interpret the execution log.