Objective: Let the workflow make a simple yes or no decision based on a random number and label the result.
- Nodes Used:
When clicking "Execute Workflow" → Generate Random Number → Is Value > 0.5? → True Path / False Path
- Concept: Boolean logic with an If node and simple labelling on each branch.
- Exercise Steps:
- [ ] Create a new workflow named
Lab 2 - Decision Maker.
- [ ] Add a Manual Trigger node and rename it to
When clicking "Execute Workflow".
- [ ] Add a Code node called
Generate Random Number and set the code to return { json: { value: Math.random() } };.
- [ ] Add an If node called
Is Value > 0.5? and check if value is larger than 0.5.
- [ ] On the true output add a Set node called
True Path and set Result to High Number (True).
- [ ] On the false output add a Set node called
False Path and set Result to Low Number (False).
- [ ] Execute the workflow several times and watch items sometimes go to
True Path and sometimes to False Path, checking the value and Result fields each time.

Lab 2 n8n Workflow
{
"nodes": [
{
"parameters": {},
"id": "bef95d9c-39e8-485f-ad32-aadde977214d",
"name": "When clicking \\"Execute Workflow\\"",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
-416,
16
]
},
{
"parameters": {
"jsCode": "return { json: { value: Math.random() } };"
},
"id": "604f30a1-fe2d-420c-8754-a3bffbb0f9a3",
"name": "Generate Random Number",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [
-192,
16
]
},
{
"parameters": {
"conditions": {
"number": [
{
"value1": "={{ $json.value }}",
"operation": "larger",
"value2": 0.5
}
]
}
},
"id": "65ea504b-eb7f-410b-9d13-f1c08d60e8dd",
"name": "Is Value > 0.5?",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
32,
16
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "true-val",
"name": "Result",
"value": "High Number (True)",
"type": "string"
}
]
},
"options": {}
},
"id": "e425f0e1-d170-424f-9ed3-f94adead5ee4",
"name": "True Path",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
272,
-96
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "false-val",
"name": "Result",
"value": "Low Number (False)",
"type": "string"
}
]
},
"options": {}
},
"id": "36928452-c019-45f6-beff-da935ae918de",
"name": "False Path",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
272,
112
]
},
{
"parameters": {
"content": "## Lab 2: Decision maker (conditional logic)\\n1. **Code Node** generates a random number between 0 and 1.\\n2. **If Node** checks: Is it bigger than 0.5?\\n3. Watch the **Green Line** flow to either the Top or Bottom path.",
"height": 580,
"width": 996,
"color": 4
},
"id": "cf22472c-0288-41eb-8968-07e2c75b02f5",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-496,
-256
],
"name": "Instructions"
}
],
"connections": {
"When clicking \\"Execute Workflow\\"": {
"main": [
[
{
"node": "Generate Random Number",
"type": "main",
"index": 0
}
]
]
},
"Generate Random Number": {
"main": [
[
{
"node": "Is Value > 0.5?",
"type": "main",
"index": 0
}
]
]
},
"Is Value > 0.5?": {
"main": [
[
{
"node": "True Path",
"type": "main",
"index": 0
}
],
[
{
"node": "False Path",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"instanceId": "82cc682d3f33add4f11a78e1f29750bf4ba4e425478ba4b17330f9bf15960ec6"
}
}