> 技术文档 > 【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——4、设计工作流 (Designing the workflow)_node-workflow 教程

【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——4、设计工作流 (Designing the workflow)_node-workflow 教程

https://docs.n8n.io/courses/

文章目录

  • Designing the Workflow

Designing the Workflow

Now that we know what Nathan wants to automate, let’s consider the steps he needs to take to achieve his goals:

  1. Get the relevant data (order id, order status, order value, employee name) from the data warehouse
  2. Filter the orders by their status (Processing or Booked)
  3. Calculate the total value of all the Booked orders
  4. Notify the team members about the Booked orders in the company’s Discord channel
  5. Insert the details about the Processing orders in Airtable for follow-up
  6. Schedule this workflow to run every Monday morning

Nathan’s workflow involves sending data from the company’s data warehouse to two external services:

  • Discord
  • Airtable

Before that, the data has to be wrangled with general functions (conditional filtering, calculation, scheduling).

n8n provides integrations for all these steps, so Nathan’s workflow in n8n would look like this:

【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——4、设计工作流 (Designing the workflow)_node-workflow 教程

{ \"nodes\": [ { \"parameters\": { \"url\": \"https://internal.users.n8n.cloud/webhook/custom-erp\", \"authentication\": \"genericCredentialType\", \"genericAuthType\": \"httpHeaderAuth\", \"sendHeaders\": true, \"headerParameters\": { \"parameters\": [ {  \"name\": \"unique_id\",  \"value\": \"4d259ec5241587a0d2820670fc048f0d\" } ] }, \"options\": {} }, \"type\": \"n8n-nodes-base.httpRequest\", \"typeVersion\": 4.2, \"position\": [ 220, -40 ], \"id\": \"e1fb70b3-0212-4e78-9976-cb77c69f1a92\", \"name\": \"HTTP Request\", \"credentials\": { \"httpHeaderAuth\": { \"id\": \"sMuanZ4xGobAurzY\", \"name\": \"Nathan\'s ABCorp data warehouse account\" } } }, { \"parameters\": { \"operation\": \"create\", \"base\": { \"__rl\": true, \"value\": \"app9nOVsRxdypoknP\", \"mode\": \"list\", \"cachedResultName\": \"beginner course\" }, \"table\": { \"__rl\": true, \"value\": \"tblTIOsm4BLJD9Tql\", \"mode\": \"list\", \"cachedResultName\": \"processingOrders\" }, \"columns\": { \"mappingMode\": \"autoMapInputData\", \"value\": {}, \"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\": [ 880, -140 ], \"id\": \"5cef2ef7-98a6-4dc6-bc30-667eba06fd7b\", \"name\": \"Airtable\", \"credentials\": { \"airtableTokenApi\": { \"id\": \"UT32NHUYnp4pn1H3\", \"name\": \"Airtable Personal Access Token account\" } } }, { \"parameters\": { \"conditions\": { \"options\": { \"caseSensitive\": true, \"leftValue\": \"\", \"typeValidation\": \"strict\", \"version\": 2 }, \"conditions\": [ {  \"id\": \"526cb30c-0f90-4f66-8f98-b64ceb2e52f2\",  \"leftValue\": \"={{ $json.orderStatus }}\",  \"rightValue\": \"processing\",  \"operator\": { \"type\": \"string\", \"operation\": \"equals\"  } } ], \"combinator\": \"and\" }, \"options\": {} }, \"type\": \"n8n-nodes-base.if\", \"typeVersion\": 2.2, \"position\": [ 440, -40 ], \"id\": \"448b2e3c-569d-42e6-a4b9-57c08b2cac1a\", \"name\": \"If\" }, { \"parameters\": { \"assignments\": { \"assignments\": [ {  \"id\": \"20d37948-763a-4d7b-b725-e65f3802af03\",  \"name\": \"orderID\",  \"value\": \"={{ $json.orderID }}\",  \"type\": \"number\" }, {  \"id\": \"9df108a7-6b13-42ab-a6dd-9ca582ba8b49\",  \"name\": \"employeeName\",  \"value\": \"={{ $json.employeeName }}\",  \"type\": \"string\" } ] }, \"options\": {} }, \"type\": \"n8n-nodes-base.set\", \"typeVersion\": 3.4, \"position\": [ 660, -140 ], \"id\": \"7e2a8092-fb0f-4260-84e8-d796cf14d309\", \"name\": \"Edit Fields\" }, { \"parameters\": { \"jsCode\": \"let items = $input.all();\\nlet totalBooked = items.length;\\nlet bookedSum = 0;\\n\\nfor (let i=0; i < items.length; i++) {\\n bookedSum = bookedSum + items[i].json.orderPrice;\\n}\\n\\nreturn [{ json: {totalBooked, bookedSum} }];\" }, \"type\": \"n8n-nodes-base.code\", \"typeVersion\": 2, \"position\": [ 660, 60 ], \"id\": \"26ce1d53-794b-4457-9aa8-0ecf9093b838\", \"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\\\"] }}\", \"options\": {} }, \"type\": \"n8n-nodes-base.discord\", \"typeVersion\": 2, \"position\": [ 880, 60 ], \"id\": \"d8c0b4b6-3bf1-4055-a03f-f0023337777c\", \"name\": \"Discord\", \"webhookId\": \"eff0b651-f0be-4cae-8f18-7d831385be3c\", \"credentials\": { \"discordWebhookApi\": { \"id\": \"lOieo0mIb6h1Wi9R\", \"name\": \"Discord Webhook account\" } } }, { \"parameters\": { \"rule\": { \"interval\": [ {  \"field\": \"weeks\",  \"triggerAtDay\": [ 1  ],  \"triggerAtHour\": 9 } ] } }, \"type\": \"n8n-nodes-base.scheduleTrigger\", \"typeVersion\": 1.2, \"position\": [ 0, -40 ], \"id\": \"15f0b179-6a43-483b-a522-2b8ba834b795\", \"name\": \"Schedule Trigger\" } ], \"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\": \"Airtable\", \"type\": \"main\", \"index\": 0 } ] ] }, \"Code\": { \"main\": [ [ { \"node\": \"Discord\", \"type\": \"main\", \"index\": 0 } ] ] }, \"Schedule Trigger\": { \"main\": [ [ { \"node\": \"HTTP Request\", \"type\": \"main\", \"index\": 0 } ] ] } }, \"pinData\": {}, \"meta\": { \"templateCredsSetupCompleted\": true, \"instanceId\": \"24789c4d5aa56ca018d140332e7a43fd37dd7af0409453314fff12dc1aeebfa8\" }}

You will build this workflow in eight steps:

  1. Getting data from the data warehouse
  2. Inserting data into Airtable
  3. Filtering orders
  4. Setting values for processing orders
  5. Calculating booked orders
  6. Notifying the team
  7. Scheduling the workflow
  8. Activating and examining the workflow

To build this workflow, you will need the credentials found in the email you received from n8n when you signed up for this course. If you haven’t signed up already, you can do it here. If you haven’t received a confirmation email after signing up, contact us.

【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——4、设计工作流 (Designing the workflow)_node-workflow 教程

Start building!