-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Expand file tree
/
Copy pathTransport_Request_Intake_Lite.json
More file actions
216 lines (216 loc) · 6.39 KB
/
Copy pathTransport_Request_Intake_Lite.json
File metadata and controls
216 lines (216 loc) · 6.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
{
"name": "Transport Request Intake Lite",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "transport-intake-lite",
"responseMode": "responseNode"
},
"id": "webhook-start",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
0,
0
],
"disabled": false,
"description": "Accepts a transport request via POST webhook"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "field-pickup-postcode",
"name": "pickup_postcode",
"value": "={{ $json.pickup_postcode != null ? String($json.pickup_postcode).trim() : '' }}",
"type": "string"
},
{
"id": "field-delivery-postcode",
"name": "delivery_postcode",
"value": "={{ $json.delivery_postcode != null ? String($json.delivery_postcode).trim() : '' }}",
"type": "string"
},
{
"id": "field-pickup-date",
"name": "pickup_date",
"value": "={{ $json.pickup_date != null ? String($json.pickup_date).trim() : '' }}",
"type": "string"
},
{
"id": "field-weight-kg",
"name": "weight_kg",
"value": "={{ $json.weight_kg != null ? parseFloat(String($json.weight_kg).replace(/\\s/g, '').replace(',', '.')) : NaN }}",
"type": "number"
}
]
},
"options": {}
},
"id": "normalize-fields",
"name": "Normalize Fields",
"type": "n8n-nodes-base.set",
"typeVersion": 3.3,
"position": [
220,
0
],
"disabled": false,
"description": "Trim strings and convert weight to number"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "field-missing",
"name": "missing_fields",
"value": "={{ [\n ($json.pickup_postcode === '' ? 'pickup_postcode' : null),\n ($json.delivery_postcode === '' ? 'delivery_postcode' : null),\n ($json.pickup_date === '' ? 'pickup_date' : null),\n (isNaN($json.weight_kg) ? 'weight_kg' : null)\n].filter(f => f !== null) }}",
"type": "array"
},
{
"id": "field-status",
"name": "status",
"value": "={{ [\n ($json.pickup_postcode === '' ? 'pickup_postcode' : null),\n ($json.delivery_postcode === '' ? 'delivery_postcode' : null),\n ($json.pickup_date === '' ? 'pickup_date' : null),\n (isNaN($json.weight_kg) ? 'weight_kg' : null)\n].filter(f => f !== null).length === 0 ? 'ready' : 'needs_review' }}",
"type": "string"
}
]
},
"options": {}
},
"id": "validate-required",
"name": "Validate Required Fields",
"type": "n8n-nodes-base.set",
"typeVersion": 3.3,
"position": [
440,
0
],
"disabled": false,
"description": "Check which of the four fields are empty and set status"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "field-status-out",
"name": "status",
"value": "={{ $json.status }}",
"type": "string"
},
{
"id": "field-missing-out",
"name": "missing_fields",
"value": "={{ $json.missing_fields }}",
"type": "array"
},
{
"id": "field-normalized",
"name": "normalized_request",
"value": "={{ {\n pickup_postcode: $json.pickup_postcode,\n delivery_postcode: $json.delivery_postcode,\n pickup_date: $json.pickup_date,\n weight_kg: isNaN($json.weight_kg) ? null : $json.weight_kg\n} }}",
"type": "object"
}
]
},
"options": {}
},
"id": "build-result",
"name": "Build Result",
"type": "n8n-nodes-base.set",
"typeVersion": 3.3,
"position": [
660,
0
],
"disabled": false,
"description": "Assemble the final output object"
},
{
"parameters": {
"responseCode": 200,
"body": "={{ JSON.stringify({\n status: $json.status,\n missing_fields: $json.missing_fields,\n normalized_request: $json.normalized_request\n}, null, 2) }}",
"options": {
"responseHeaders": {
"entries": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
}
},
"id": "respond-webhook",
"name": "Respond to Webhook",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
880,
0
],
"disabled": false,
"description": "Return JSON response with status, missing fields, and normalized data"
}
],
"connections": {
"Webhook": {
"main": [
[
{
"node": "Normalize Fields",
"type": "main",
"index": 0
}
]
]
},
"Normalize Fields": {
"main": [
[
{
"node": "Validate Required Fields",
"type": "main",
"index": 0
}
]
]
},
"Validate Required Fields": {
"main": [
[
{
"node": "Build Result",
"type": "main",
"index": 0
}
]
]
},
"Build Result": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"staticData": null,
"meta": {
"instanceId": null,
"instanceBaseUrl": null
},
"pinData": {},
"versionId": "lite-1.0.0",
"description": "Free demonstration workflow - Transport Request Intake Lite by AW Automation. Normalizes four basic fields and returns ready or needs_review. No credentials or paid APIs required."
}