构建迷你工作流#
¥Building a Mini-workflow
在本课中,你将构建一个小型 workflow,用于从 Hacker News 获取 10 篇关于自动化的文章。该过程包含五个步骤:
¥In this lesson, you will build a small workflow that gets 10 articles about automation from Hacker News. The process consists of five steps:
¥Add a Manual Trigger node 2. 添加 Hacker News 节点
¥Add the Hacker News node 3. 配置 Hacker News 节点
¥Configure the Hacker News node 4. 执行节点
完成的工作流程将如下所示:
¥The finished workflow will look like this:
Workflow preview placeholder.
1. 添加手动触发节点#
¥ Add a Manual Trigger node
打开节点面板(提示:你可以通过选择 canvas 右上角的“+”图标或按键盘上的“Tab”键打开此面板)。
¥Open the nodes panel (reminder: you can open this by selecting the + icon in the top right corner of the canvas or selecting Tab on your keyboard).
然后:
¥Then:
- 搜索“手动触发”节点。
¥Search for the Manual Trigger node. 2. 在搜索结果中出现时点击。
¥Select it when it appears in the search.
这将把 手动触发器 节点添加到你的画布,你可以通过选择“执行工作流”按钮随时运行工作流。
¥This will add the Manual Trigger node to your canvas, which allows you to run the workflow at any time by selecting the Execute workflow button.
Manual triggers
为了更快地创建工作流,你可以稍后跳过此步骤。添加任何其他未设置触发器的节点都会将“手动触发”节点添加到工作流中。
¥For faster workflow creation, you can skip this step in the future. Adding any other node without a trigger will add the Manual Trigger node to the workflow.
在实际场景中,你可能需要设置一个计划任务或其他 trigger 来运行工作流。
¥In a real-world scenario, you would probably want to set up a schedule or some other trigger to run the workflow.
2. 添加 Hacker News 节点#
¥ Add the Hacker News node
选择“手动触发”节点右侧的“+”图标,打开节点面板。
¥Select the + icon to the right of the Manual Trigger node to open the nodes panel.
然后:
¥Then:
- 搜索 Hacker News 节点。
¥Search for the Hacker News node. 2. 在搜索结果中出现时点击。
¥Select it when it appears in the search. 3. 在“操作”部分,选择“获取多个项目”。
¥In the Actions section, select Get many items.
n8n 向画布添加节点,并打开节点窗口以显示其配置详细信息。
¥n8n adds the node to your canvas and the node window opens to display its configuration details.
3. 配置 Hacker News 节点#
¥ Configure the Hacker News node
向编辑器界面添加新节点后,该节点会自动激活。节点详细信息将在包含多个选项的窗口中打开:
¥When you add a new node to the Editor UI, the node is automatically activated. The node details will open in a window with several options:
- 参数:调整参数以优化和控制节点的功能。
¥Parameters: Adjust parameters to refine and control the node's functionality.
- 设置:调整设置以控制节点的设计和执行。
¥Settings: Adjust settings to control the node's design and executions.
- 文档:在新窗口中打开此节点的 n8n 文档。
¥Docs: Open the n8n documentation for this node in a new window.
Parameters vs. Settings
- 每个节点的参数都不同,具体取决于其功能。
¥Parameters are different for each node, depending on its functionality.
- 所有节点的设置相同。
¥Settings are the same for all nodes.
参数#
¥Parameters
我们需要为 Hacker News 节点配置几个参数才能使其正常工作:
¥We need to configure several parameters for the Hacker News node to make it work:
- 资源:全部
此资源选择所有数据记录(文章)。
¥Resource: All
This resource selects all data records (articles).
- 操作:获取多个
此操作将获取所有选定的文章。
¥Operation: Get Many
This operation fetches all the selected articles.
- 限制:10
此参数限制“获取多个结果”操作返回的结果数量。
¥Limit: 10
This parameter sets a limit to the number of results the Get Many operation returns.
- 附加字段 > 添加字段 > 关键字:自动化
附加字段是你可以添加到某些节点的选项,以使你的请求更具体或筛选结果。在此示例中,我们只想获取包含关键字 "自动化。" 的文章。
¥Additional Fields > Add Field > Keyword: automation
Additional fields are options that you can add to certain nodes to make your request more specific or filter the results. For this example, we want to get only articles that include the keyword "automation."
Hacker News 节点的参数配置现在应如下所示:
¥The configuration of the parameters for the Hacker News node should now look like this:

设置#
¥Settings
“设置”部分包含多个节点设计和执行选项。在这种情况下,我们仅配置最后两个设置,它们决定节点在编辑器 UI 画布中的外观。
¥The Settings section includes several options for node design and executions. In this case, we'll configure only the final two settings, which set the node's appearance in the Editor UI canvas.
在“Hacker News”节点的“设置”中,进行编辑:
¥In the Hacker News node Settings, edit:
- 备注:获取最新的 10 篇文章
¥Notes: Get the 10 latest articles.
Node notes
1 | |
- 流程中是否显示注释?:切换到 true 选项
此选项将在画布中的节点下方显示“备注”。
¥Display note in flow?: toggle to true
This option will display the Note under the node in the canvas.
Hacker News 节点的设置配置现在应如下所示:
¥The configuration of the settings for the Hacker News node should now look like this:

Renaming a node
你可以将节点重命名为更符合你使用场景的名称。有三种方法可以执行此操作:
¥You can rename the node with a name that's more descriptive for your use case. There are three ways to do this:
- 选择要重命名的节点,同时按下键盘上的 F2 键。
¥Select the node you want to rename and at the same time press the F2 key on your keyboard.
- 双击节点以打开节点窗口。点击窗口左上角的节点名称,将其重命名,然后点击“重命名”按钮以新名称保存节点。
¥Double-click on the node to open the node window. Click on the name of the node in the top left corner of the window, rename it as you like, then click Rename to save the node under the new name.
- 右键单击节点,然后选择“重命名”选项。
¥Right-click on the node and select the Rename option.

要查找原始节点名称(节点类型),请打开节点窗口并选择“设置”。页面底部包含节点类型和版本。
¥To find the original node name (the type of node), open the node window and select Settings. The bottom of the page contains the node type and version.
4. 执行节点#
¥ Execute the node
在节点详细信息窗口中选择“执行步骤”按钮。你应该在“输出表”视图中看到 10 个结果。
¥Select the Execute step button in the node details window. You should see 10 results in the Output Table view.

节点执行#
¥Node executions
Node execution
节点执行表示运行该节点以检索或处理指定数据。
¥A node execution represents a run of that node to retrieve or process the specified data.
如果节点执行成功,画布中该节点的顶部会出现一个绿色的小对勾。
¥If a node executes successfully, a small green checkmark appears on top of the node in the canvas

如果参数没有问题且一切运行正常,则请求的数据将以表格、JSON 和模式格式显示在节点窗口中。你可以通过节点窗口顶部的“表格 | JSON | 架构”按钮切换所需的视图。
¥If there are no problems with the parameters and everything works fine, the requested data displays in the node window in Table, JSON, and Schema format. You can switch between these views by selecting the one you want from the Table | JSON | Schema button at the top of the node window.
Table vs JSON views
表格视图是默认视图。它以表格形式显示请求的数据,其中行是记录,列是这些记录的可用属性。
¥The Table view is the default. It displays the requested data in a table, where the rows are the records and the columns are the available attributes of those records.
以下是 Hacker News 的 JSON 输出:
¥Here's our Hacker News output in JSON view:

节点窗口将显示有关节点执行的更多信息:
¥The node window displays more information about the node execution:
- 在“Output”(输出)标题旁边,你会看到一个小图标(如果节点执行成功,则会显示绿色对勾)。旁边有一个信息图标。将鼠标悬停在图标上,你将获得另外两项信息,这些信息可以帮助你了解工作流中每个节点的性能:
¥Next to the Output title, notice a small icon (this will be a green checkmark if the node execution succeeded). Beside it, there is an info icon. If you hover on it, you'll get two more pieces of information that can provide insights into the performance of each individual node in a workflow:
-
开始时间:节点执行开始时。
¥Start Time: When the node execution started.
-
执行时间:节点从开始执行到返回结果所花费的时间。
¥Execution Time: How long it took for the node to return the results from the moment it started executing.
-
在“输出”标题下方,你会看到另一条信息:10 个项目。此字段显示节点请求返回的项目(记录)数量。本示例中,预期值为 10,因为这是我们在步骤 2 中设置的限制。但如果你没有设置限制,查看实际返回的记录数会很有用。
¥Just below the Output title, you'll notice another piece of information: 10 items. This field displays the number of items (records) that the node request returned. In this example, it's expected to be 10, since this is the limit we set in step 2. But if you don't set a limit, it's useful to see how many records are actually returned.
Error in nodes
节点上的红色警告图标表示该节点存在错误。如果节点凭据缺失或不正确,或者节点参数配置不正确,则可能会发生这种情况。
¥A red warning icon on a node means that the node has errors. This might happen if the node credentials are missing or incorrect or the node parameters aren't configured correctly.

5. 保存工作流#
¥ Save the workflow
编辑完节点后,选择“返回画布”返回主画布。
¥Once you're finished editing the node, select Back to canvas to return to the main canvas.
默认情况下,你的工作流会自动保存为 "我的工作流程"。
¥By default, your workflow is automatically saved as "My workflow."
在本教程中,请将工作流重命名为 "Hacker News 工作流程。"
¥For this lesson, rename the workflow to be "Hacker News workflow."
Reminder
你可以通过点击编辑器界面顶部的流程名称来重命名流程。
¥You can rename a workflow by clicking on the workflow's name at the top of the Editor UI.
重命名工作流后,请务必保存。
¥Once you've renamed the workflow, be sure to save it.
你可以通过两种方式保存工作流:
¥There are two ways in which you can save a workflow:
- 在编辑器 UI 的画布中,按键盘上的 Ctrl + S 或 Cmd + S。
¥From the Canvas in Editor UI, click Ctrl + S or Cmd + S on your keyboard.
- 选择编辑器 UI 右上角的“保存”按钮。你可能需要先单击对话框外部退出节点编辑器。
¥Select the Save button in the top right corner of the Editor UI. You may need to leave the node editor first by clicking outside the dialog.
如果你看到灰色的“已保存”文本而不是“保存”按钮,则表示你的工作流已自动保存。
¥If you see a grey Saved text instead of the Save button, your workflow was automatically saved.
摘要#
¥Summary
恭喜,你刚刚构建了你的第一个工作流!在本课中,你学习了如何在应用节点中使用操作、配置其参数和设置,以及如何保存和执行工作流。
¥Congratulations, you just built your first workflow! In this lesson, you learned how to use actions in app nodes, configure their parameters and settings, and save and execute your workflow.
在下一课中,你将见到你的新客户 Nathan,他需要实现销售报告工作的自动化。你将为他的用例构建一个更复杂的工作流,帮助他提高工作效率。
¥In the next lesson, you'll meet your new client, Nathan, who needs to automate his sales reporting work. You will build a more complex workflow for his use case, helping him become more productive at work.