-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotion_workflow.json
More file actions
257 lines (257 loc) · 8.75 KB
/
notion_workflow.json
File metadata and controls
257 lines (257 loc) · 8.75 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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
{
"name": "Parserdata - Google Drive to Notion",
"nodes": [
{
"parameters": {
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
},
"triggerOn": "specificFolder",
"folderToWatch": {
"__rl": true,
"value": "YOUR_DRIVE_FOLDER_ID",
"mode": "id"
},
"event": "fileCreated",
"options": {}
},
"type": "n8n-nodes-base.googleDriveTrigger",
"typeVersion": 1,
"position": [
-420,
120
],
"id": "3883bcd7-4f91-4ddc-a45b-e075f32c61c2",
"name": "Google Drive Trigger"
},
{
"parameters": {
"operation": "download",
"fileId": "={{$json[\"id\"]}}",
"options": {}
},
"name": "Google Drive (Download file)",
"type": "n8n-nodes-base.googleDrive",
"typeVersion": 2,
"position": [
-210,
120
],
"id": "31080548-0839-482d-bb58-eb2df9753de0"
},
{
"parameters": {
"method": "POST",
"url": "https://api.parserdata.com/v1/extract",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendBody": true,
"contentType": "multipart-form-data",
"bodyParameters": {
"parameters": [
{
"name": "prompt",
"value": "Extract the following fields from the invoice.\n\nInvoice-level fields (single values):\n- invoice_number\n- invoice_date (YYYY-MM-DD)\n- supplier_name\n- total_amount\n\nLine items (one row per item in the invoice table):\n- sku\n- description\n- quantity\n- unit_price\n- net_amount\n\nReturn JSON with this structure:\n\n{\n \"result\": {\n \"invoice_number\": \"...\",\n \"invoice_date\": \"YYYY-MM-DD\",\n \"supplier_name\": \"...\",\n \"total_amount\": ...,\n \"line_items\": [\n {\n \"sku\": \"...\",\n \"description\": \"...\",\n \"quantity\": ...,\n \"unit_price\": ...,\n \"net_amount\": ...\n }\n ]\n }\n}\n\nRules:\n- Ensure numbers are returned as numbers (no currency symbols).\n- If a value is missing, return null or empty string.\n- Keep line_items as an array (empty array if none).\n- Use EXACT keys: sku, description, quantity, unit_price, net_amount.\n"
},
{
"name": "options",
"value": "{ \"return_schema\": false, \"return_selected_fields\": false }"
},
{
"parameterType": "formBinaryData",
"name": "file",
"inputDataFieldName": "data"
}
]
},
"options": {
"timeout": 300000
}
},
"id": "74a1b4e8-e443-4382-ad8d-4d9afd83c948",
"name": "HTTP Request (Parserdata Extract)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [
10,
120
],
"credentials": {
"httpHeaderAuth": {
"id": "YOUR_PARSERDATA_HTTP_HEADER_AUTH_ID",
"name": "Parserdata API (HTTP header auth, replace)"
}
}
},
{
"parameters": {
"resource": "databasePage",
"databaseId": {
"__rl": true,
"value": "YOUR_NOTION_INVOICES_DB_ID",
"mode": "id"
},
"title": "={{ $json.result.invoice_number || $node[\"Google Drive Trigger\"].json.name || \"Invoice\" }}",
"propertiesUi": {
"propertyValues": [
{
"key": "Invoice Date|date",
"date": "={{ $json.result.invoice_date }}"
},
{
"key": "Supplier|rich_text",
"textContent": "={{ $json.result.supplier_name }}"
},
{
"key": "Total Amount|number",
"numberValue": "={{ $json.result.total_amount }}"
},
{
"key": "Drive File ID|rich_text",
"textContent": "={{ $node[\"Google Drive Trigger\"].json.id }}"
}
]
},
"options": {}
},
"id": "fa6a4ec2-a56c-4a17-a902-6fdaf8f500ab",
"name": "Notion - Create Invoice",
"type": "n8n-nodes-base.notion",
"typeVersion": 2,
"position": [
260,
120
]
},
{
"parameters": {
"jsCode": "// Parserdata response\nconst r = $node[\"HTTP Request (Parserdata Extract)\"].json.result || {};\nconst lines = Array.isArray(r.line_items) ? r.line_items : [];\n\n// Invoice page ID created in Notion\nconst invoicePageId = $node[\"Notion - Create Invoice\"].json.id;\n\nreturn lines.map((line, idx) => {\n // Support multiple key names safely\n const description =\n line.description ??\n line.item_description ??\n line.itemDescription ??\n \"\";\n\n const quantity = line.quantity ?? null;\n\n const unit_price =\n line.unit_price ??\n line.unitPrice ??\n line.price ?? null;\n\n // Net amount might be named differently or missing\n let net_amount =\n line.net_amount ??\n line.line_total ??\n line.lineTotal ??\n null;\n\n // Compute fallback if missing\n if ((net_amount === null || net_amount === undefined) && quantity != null && unit_price != null) {\n const q = Number(quantity);\n const p = Number(unit_price);\n if (!Number.isNaN(q) && !Number.isNaN(p)) net_amount = q * p;\n }\n\n return {\n json: {\n invoicePageId,\n\n // header fields (optional)\n invoice_number: r.invoice_number || \"\",\n invoice_date: r.invoice_date || null,\n supplier_name: r.supplier_name || \"\",\n total_amount: r.total_amount ?? null,\n\n // line fields\n sku: line.sku ?? \"\",\n description,\n quantity: quantity == null ? null : Number(quantity),\n unit_price: unit_price == null ? null : Number(unit_price),\n net_amount: net_amount == null ? null : Number(net_amount),\n\n line_index: idx + 1\n }\n };\n});"
},
"id": "665677c8-9341-410b-9a52-2a4ad104aad9",
"name": "Code in JavaScript (Expand line_items)",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
510,
120
]
},
{
"parameters": {
"resource": "databasePage",
"databaseId": {
"__rl": true,
"value": "YOUR_NOTION_LINE_ITEMS_DB_ID",
"mode": "id"
},
"title": "={{ $json.sku || $json.description || (\"Item \" + $json.line_index) }}",
"propertiesUi": {
"propertyValues": [
{
"key": "SKU|rich_text",
"textContent": "={{ $json.sku }}"
},
{
"key": "Description|rich_text",
"textContent": "={{ $json.description }}"
},
{
"key": "Quantity|number",
"numberValue": "={{ $json.quantity }}"
},
{
"key": "Unit Price|number",
"numberValue": "={{ $json.unit_price }}"
},
{
"key": "Net Amount|number",
"numberValue": "={{ $json.net_amount }}"
},
{
"key": "Invoice (backlink)|relation",
"relationValue": "={{ $json.invoicePageId }}"
}
]
},
"options": {}
},
"id": "6fc50b28-9c6b-459b-9695-095f42047aa7",
"name": "Notion - Create Line Item",
"type": "n8n-nodes-base.notion",
"typeVersion": 2,
"position": [
780,
120
]
}
],
"pinData": {},
"connections": {
"Google Drive Trigger": {
"main": [
[
{
"node": "Google Drive (Download file)",
"type": "main",
"index": 0
}
]
]
},
"Google Drive (Download file)": {
"main": [
[
{
"node": "HTTP Request (Parserdata Extract)",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request (Parserdata Extract)": {
"main": [
[
{
"node": "Notion - Create Invoice",
"type": "main",
"index": 0
}
]
]
},
"Notion - Create Invoice": {
"main": [
[
{
"node": "Code in JavaScript (Expand line_items)",
"type": "main",
"index": 0
}
]
]
},
"Code in JavaScript (Expand line_items)": {
"main": [
[
{
"node": "Notion - Create Line Item",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1",
"binaryMode": "separate",
"availableInMCP": false
},
"tags": []
}