Spaces:
Sleeping
Sleeping
File size: 19,961 Bytes
51d1d83 |
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 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 |
{
"nodes": [
{
"id": "9df72ef9-3b9d-40e4-9cb5-a5ada153c0bb",
"name": "Google Drive",
"type": "n8n-nodes-base.googleDrive",
"position": [
120,
-180
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.id }}"
},
"options": {},
"operation": "download"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "wpiZXesxk9S8fkVG",
"name": "Google Drive account 2"
}
},
"typeVersion": 3
},
{
"id": "e21bb906-658c-4a52-9c7b-b77d6e0e7ea5",
"name": "Upload File",
"type": "n8n-nodes-base.httpRequest",
"position": [
360,
-180
],
"parameters": {
"url": "https://api.cloud.llamaindex.ai/api/parsing/upload",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "multipart-form-data",
"sendHeaders": true,
"bodyParameters": {
"parameters": [
{
"name": "webhook_url",
"value": "https://n8n.lowcoding.dev/webhook/0f7f5ebb-8b66-453b-a818-20cc3647c783"
},
{
"name": "file",
"parameterType": "formBinaryData",
"inputDataFieldName": "data"
},
{
"name": "disable_ocr",
"value": "true"
},
{
"name": "disable_image_extraction",
"value": "True"
}
]
},
"headerParameters": {
"parameters": [
{
"name": "accept",
"value": "application/json"
},
{
"name": "Authorization",
"value": "Bearer "
},
{
"name": "parsing_instruction",
"value": "Please extract invoice line items: Name, Quantity, Unit Price, Amount "
}
]
}
},
"typeVersion": 4.2
},
{
"id": "2a0c2331-4612-4b92-a0cc-b316bc663907",
"name": "Google Drive Trigger",
"type": "n8n-nodes-base.googleDriveTrigger",
"position": [
-80,
-180
],
"parameters": {
"event": "fileCreated",
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
},
"triggerOn": "specificFolder",
"folderToWatch": {
"__rl": true,
"mode": "list",
"value": "1IC39VXU8rewBU85offxYlBd9QlYzf8S7",
"cachedResultUrl": "https://drive.google.com/drive/folders/1IC39VXU8rewBU85offxYlBd9QlYzf8S7",
"cachedResultName": "Invoices"
}
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "wpiZXesxk9S8fkVG",
"name": "Google Drive account 2"
}
},
"typeVersion": 1
},
{
"id": "4ad70b03-54f1-4715-9848-56fa6ba18278",
"name": "Create Invoice",
"type": "n8n-nodes-base.airtable",
"position": [
400,
340
],
"parameters": {
"base": {
"__rl": true,
"mode": "list",
"value": "appndgSF4faN4jPXi",
"cachedResultUrl": "https://airtable.com/appndgSF4faN4jPXi",
"cachedResultName": "Philipp's Base"
},
"table": {
"__rl": true,
"mode": "list",
"value": "tbloPc7Eay4Cvwysq",
"cachedResultUrl": "https://airtable.com/appndgSF4faN4jPXi/tbloPc7Eay4Cvwysq",
"cachedResultName": "Invoices"
},
"columns": {
"value": {},
"schema": [
{
"id": "Name",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Line Items",
"type": "array",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "Line Items",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": []
},
"options": {},
"operation": "create"
},
"credentials": {
"airtableTokenApi": {
"id": "XT7hvl1w201jtBhx",
"name": "Airtable Personal Access Token account"
}
},
"typeVersion": 2.1
},
{
"id": "a408eeb4-2dc2-45ff-a989-92676356f596",
"name": "Create Line Item",
"type": "n8n-nodes-base.airtable",
"position": [
800,
340
],
"parameters": {
"base": {
"__rl": true,
"mode": "list",
"value": "appndgSF4faN4jPXi",
"cachedResultUrl": "https://airtable.com/appndgSF4faN4jPXi",
"cachedResultName": "Philipp's Base"
},
"table": {
"__rl": true,
"mode": "list",
"value": "tblIuVR9ocAomznzK",
"cachedResultUrl": "https://airtable.com/appndgSF4faN4jPXi/tblIuVR9ocAomznzK",
"cachedResultName": "Line Items"
},
"columns": {
"value": {
"Qty": "={{ $json.qty }}",
"Amount": "={{ parseFloat($json.amount.replace('$', '').trim()) }}",
"Invoices": "=[\"{{ $('Create Invoice').item.json.id }}\"]",
"Unit price": "={{ parseFloat($json.unit_price.replace('$', '').trim()) }}",
"Description": "={{ $json.description }}"
},
"schema": [
{
"id": "Name",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Description",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Description",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Qty",
"type": "number",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Qty",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Unit price",
"type": "number",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Unit price",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Amount",
"type": "number",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Amount",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Invoices",
"type": "array",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Invoices",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": []
},
"options": {},
"operation": "create"
},
"credentials": {
"airtableTokenApi": {
"id": "XT7hvl1w201jtBhx",
"name": "Airtable Personal Access Token account"
}
},
"typeVersion": 2.1
},
{
"id": "7ee324e8-6df3-48d6-b1b8-6fdb610b1ec7",
"name": "OpenAI - Extract Line Items",
"type": "n8n-nodes-base.httpRequest",
"position": [
180,
340
],
"parameters": {
"url": "=https://api.openai.com/v1/chat/completions",
"method": "POST",
"options": {},
"jsonBody": "={\n \"model\": \"gpt-4o-mini\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": {{ JSON.stringify($('Set Fields').item.json.prompt) }}\n },\n {\n \"role\": \"user\",\n \"content\": {{ JSON.stringify( JSON.stringify($('Webhook').item.json.body.json[0].items) ) }}\n }\n ],\n \"response_format\":{ \"type\": \"json_schema\", \"json_schema\": {{ $('Set Fields').item.json.schema }}\n\n }\n }",
"sendBody": true,
"specifyBody": "json",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "openAiApi"
},
"credentials": {
"openAiApi": {
"id": "9RivS2BmSh1DDBFm",
"name": "OpenAi account 3"
}
},
"typeVersion": 4.2
},
{
"id": "eda31919-9091-4d45-bd73-4609b71f93a9",
"name": "Set Fields",
"type": "n8n-nodes-base.set",
"position": [
-40,
340
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "dc09a5b4-ff6a-4cee-b87e-35de7336ac05",
"name": "prompt",
"type": "string",
"value": "Please, process parsed data and return only needed."
},
{
"id": "4e0f9af6-517f-42af-9ced-df0e8a7118b0",
"name": "schema",
"type": "string",
"value": "={\n \"name\": \"generate_schema\",\n \"description\": \"Generate schema for an array of objects representing items with their descriptions, quantities, unit prices, and amounts.\",\n \"strict\": true,\n \"schema\": {\n \"type\": \"object\",\n \"required\": [\n \"items\"\n ],\n \"properties\": {\n \"items\": {\n \"type\": \"array\",\n \"description\": \"Array of item objects\",\n \"items\": {\n \"type\": \"object\",\n \"required\": [\n \"description\",\n \"qty\",\n \"unit_price\",\n \"amount\"\n ],\n \"properties\": {\n \"description\": {\n \"type\": \"string\",\n \"description\": \"Description of the item\"\n },\n \"qty\": {\n \"type\": \"string\",\n \"description\": \"Quantity of the item\"\n },\n \"unit_price\": {\n \"type\": \"string\",\n \"description\": \"Unit price of the item formatted as a string\"\n },\n \"amount\": {\n \"type\": \"string\",\n \"description\": \"Total amount for the item formatted as a string\"\n }\n },\n \"additionalProperties\": false\n }\n }\n },\n \"additionalProperties\": false\n }\n}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "cc0d97d8-fb62-43eb-b484-4dd39f8db4b4",
"name": "Process Line Items",
"type": "n8n-nodes-base.code",
"position": [
600,
340
],
"parameters": {
"jsCode": "// Get the input from the \"OpenAI - Extract Line Items\" node\nconst input = $(\"OpenAI - Extract Line Items\").first().json;\n\n// Initialize an array for the output\nconst outputItems = [];\n\n// Navigate to the 'content' field in the choices array\nconst content = input.choices[0]?.message?.content;\n\nif (content) {\n try {\n // Parse the stringified JSON in the 'content' field\n const parsedContent = JSON.parse(content);\n\n // Extract 'items' and add them to the output array\n if (Array.isArray(parsedContent.items)) {\n outputItems.push(...parsedContent.items.map(i => ({ json: i })));\n }\n } catch (error) {\n // Handle any parsing errors\n console.error('Error parsing content:', error);\n }\n}\n\n// Return the extracted items\nreturn outputItems;\n"
},
"typeVersion": 2
},
{
"id": "741dc44e-6d47-4a77-80c2-5e18b291da33",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"position": [
-220,
340
],
"webhookId": "0f7f5ebb-8b66-453b-a818-20cc3647c783",
"parameters": {
"path": "0f7f5ebb-8b66-453b-a818-20cc3647c783",
"options": {},
"httpMethod": "POST"
},
"typeVersion": 2
},
{
"id": "fbc196c8-7518-4deb-ac47-f37f1b8150eb",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-260,
-300
],
"parameters": {
"width": 920,
"height": 400,
"content": "## Scenario 1\n\n"
},
"typeVersion": 1
},
{
"id": "96368d41-7886-487f-a8a7-e4dac3b01f45",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-280,
240
],
"parameters": {
"width": 1340,
"height": 460,
"content": "## Scenario 2\n\n"
},
"typeVersion": 1
},
{
"id": "6b7c94d7-c844-4246-ba1a-cea5937792db",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-60,
0
],
"parameters": {
"color": 3,
"width": 270,
"height": 80,
"content": "### Replace Google Drive connection"
},
"typeVersion": 1
},
{
"id": "9c8141d0-428a-44e5-b900-b07fa64db4f5",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
320,
0
],
"parameters": {
"color": 3,
"width": 170,
"height": 80,
"content": "### Replace API key in header"
},
"typeVersion": 1
},
{
"id": "48243fe4-4ed1-43dc-b508-8b3f9472bb67",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
140,
540
],
"parameters": {
"color": 3,
"width": 170,
"height": 80,
"content": "### Replace OpenAI connection"
},
"typeVersion": 1
},
{
"id": "ffc6b530-69ab-4ccb-945d-94f8fdc1e3ab",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
400,
540
],
"parameters": {
"color": 3,
"width": 530,
"height": 80,
"content": "### Replace Airtable connection"
},
"typeVersion": 1
},
{
"id": "15047f43-5f7e-4c70-a754-fffb41c04611",
"name": "Sticky Note9",
"type": "n8n-nodes-base.stickyNote",
"position": [
-760,
380
],
"parameters": {
"color": 7,
"width": 330.5152611046425,
"height": 239.5888196628349,
"content": "### ... or watch set up video [7 min]\n[](https://youtu.be/E4I0nru-fa8)\n"
},
"typeVersion": 1
},
{
"id": "812f6cc7-a093-41d0-9750-48253d9f04a8",
"name": "Sticky Note7",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1060,
-300
],
"parameters": {
"color": 7,
"width": 636,
"height": 657,
"content": "\n## AI Agent for realtime insights on meetings\n**Made by [Mark Shcherbakov](https://www.linkedin.com/in/marklowcoding/) from community [5minAI](https://www.skool.com/5minai)**\n\nTranscribing meetings manually can be tedious and prone to error. This workflow automates the transcription process in real-time, ensuring that key discussions and decisions are accurately captured and easily accessible for later review, thus enhancing productivity and clarity in communications.\n\nThe workflow leverages n8n and LlamaParse to automatically detect new invoices in a designated Google Drive folder, parse essential billing details, and store the extracted data in a structured format. The key functionalities include:\n- Real-time detection of new invoices via Google Drive triggers.\n- Automated HTTP requests to initiate parsing through Lama Cloud.\n- Structured storage of invoice details and line items in a database for future reference.\n\n1. **Google Drive Integration**: Monitors a specific folder in Google Drive for new invoice uploads.\n2. **Parsing with LlamaParse**: Automatically sends invoices for parsing and processes results through webhooks.\n3. **Data Storage in Airtable**: Creates records for invoices and their associated line items, allowing for detailed tracking."
},
"typeVersion": 1
},
{
"id": "a80e6528-cf79-4229-8c58-6856fd86b6e7",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1060,
380
],
"parameters": {
"color": 7,
"width": 280,
"height": 626,
"content": "### Set up steps\n\n1. **Google Drive Trigger**: \n - Set up a trigger to detect new files in a specified folder dedicated to invoices.\n\n2. **File Upload to LlamaParse**: \n - Create an HTTP request that sends the invoice file to LlamaParse for parsing, including relevant header settings and webhook URL.\n\n3. **Webhook Processing**: \n - Establish a webhook node to handle parsed results from LlamaParse, extracting needed invoice details effectively.\n\n4. **Invoice Record Creation**: \n - Create initial records for invoices in your database using the parsed details received from the webhook.\n\n5. **Line Item Processing**: \n - Transform string data into structured line item arrays and create individual records for each item linked to the main invoice."
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Webhook": {
"main": [
[
{
"node": "Set Fields",
"type": "main",
"index": 0
}
]
]
},
"Set Fields": {
"main": [
[
{
"node": "OpenAI - Extract Line Items",
"type": "main",
"index": 0
}
]
]
},
"Google Drive": {
"main": [
[
{
"node": "Upload File",
"type": "main",
"index": 0
}
]
]
},
"Create Invoice": {
"main": [
[
{
"node": "Process Line Items",
"type": "main",
"index": 0
}
]
]
},
"Process Line Items": {
"main": [
[
{
"node": "Create Line Item",
"type": "main",
"index": 0
}
]
]
},
"Google Drive Trigger": {
"main": [
[
{
"node": "Google Drive",
"type": "main",
"index": 0
}
]
]
},
"OpenAI - Extract Line Items": {
"main": [
[
{
"node": "Create Invoice",
"type": "main",
"index": 0
}
]
]
}
}
} |