-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworfklow-template.json
More file actions
980 lines (980 loc) · 35.3 KB
/
Copy pathworfklow-template.json
File metadata and controls
980 lines (980 loc) · 35.3 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
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
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
{
"id": "jshpcczcRyM828wo",
"meta": {
"instanceId": "aa84569cbf257184f6ad1582da635360f2453e8c11206055470b224c285f5b6a",
"templateCredsSetupCompleted": true
},
"name": "N-0135 Maverick Spend Detection",
"tags": [],
"nodes": [
{
"id": "0ff4ad5e-8755-4e7c-b93d-3efae75115c5",
"name": "Mark Transaction as Processed",
"type": "n8n-nodes-base.googleSheets",
"position": [
1056,
1232
],
"parameters": {
"columns": {
"value": {
"processed": "=Yes",
"transaction_id": "={{ $json.transaction_id }}"
},
"schema": [
{
"id": "transaction_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "transaction_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "supplier_name",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "supplier_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "amount",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "amount",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "department",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "department",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "date",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "processed",
"type": "string",
"display": true,
"required": false,
"displayName": "processed",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "status",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "status",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "row_number",
"type": "number",
"display": true,
"removed": true,
"readOnly": true,
"required": false,
"displayName": "row_number",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"transaction_id"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "update",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 701382615,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit#gid=701382615",
"cachedResultName": "Get Transactions"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit?usp=drivesdk",
"cachedResultName": "Maverick"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "MYTlJehpXYhsXd8R",
"name": "Google Sheets OAuth2 API"
}
},
"typeVersion": 4.7
},
{
"id": "01fb5eb5-6901-41ad-a470-26effb0cf912",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1728,
496
],
"parameters": {
"width": 720,
"height": 464,
"content": "## Maverick Spend Detection Workflow\n## How it works:\n\nThis workflow automatically runs every day to monitor procurement transactions and ensure compliance. It compares each transaction against an approved supplier list to detect unauthorized (maverick) spending. When a violation is found, AI generates corrective recommendations, alerts are sent via Slack and Email, and the incident is logged for tracking. If no action is taken within 2 hours, the workflow escalates the issue to management.\n\n## Setup steps:\nConnect Google Sheets and configure supplier and transaction data sources\nEnsure supplier names are standardized (lowercase, trimmed) for accurate matching\nSet up and authenticate Slack integration for real-time alerts\nConfigure Gmail credentials for detailed email notifications\nVerify all required fields (transaction_id, supplier_name, amount, etc.) exist\nAdjust the schedule trigger time based on business requirements\nTest the workflow with sample data before enabling automation\nActivate the workflow for daily automated execution"
},
"typeVersion": 1
},
{
"id": "fdf1fa67-0f63-4571-9fb3-27c774c13351",
"name": "Daily Compliance Scan",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-1616,
1536
],
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 11
}
]
}
},
"typeVersion": 1.3
},
{
"id": "92af11a6-8cab-4281-a244-34dc8a265e92",
"name": "Get Approved Supplier List",
"type": "n8n-nodes-base.googleSheets",
"position": [
-1296,
1440
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit#gid=0",
"cachedResultName": "Get Approved Suppliers"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit?usp=drivesdk",
"cachedResultName": "Maverick"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "MYTlJehpXYhsXd8R",
"name": "Google Sheets OAuth2 API"
}
},
"typeVersion": 4.7
},
{
"id": "6d641df9-b075-48c8-9dfb-608d3959e21e",
"name": "Get Pending Transactions",
"type": "n8n-nodes-base.googleSheets",
"position": [
-1072,
1632
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": 701382615,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit#gid=701382615",
"cachedResultName": "Get Transactions"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit?usp=drivesdk",
"cachedResultName": "Maverick"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "MYTlJehpXYhsXd8R",
"name": "Google Sheets OAuth2 API"
}
},
"typeVersion": 4.7
},
{
"id": "97b41664-17e2-4589-a274-2c1e780180bc",
"name": "Clean & Normalize Transaction Data",
"type": "n8n-nodes-base.set",
"position": [
-1072,
1440
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "8e0234e4-2656-4961-b0f2-b1ed31c52da3",
"name": "supplier_name",
"type": "string",
"value": "={{ $json.supplier_name ? $json.supplier_name.toLowerCase().trim() : '' }}"
},
{
"id": "7bb29a7f-d976-41d2-8dfa-90d00a9b3c21",
"name": "amount",
"type": "string",
"value": "={{ $json.amount }}"
},
{
"id": "799bb90a-adae-4511-a566-65d350a89d1e",
"name": "department",
"type": "string",
"value": "={{ $json.department }}"
},
{
"id": "a98eeb55-0c62-49c6-84ee-3dfb5615104c",
"name": "transaction_id",
"type": "string",
"value": "={{ $json.transaction_id }}"
},
{
"id": "c11de234-9012-4abc-b234-ef5678901234",
"name": "processed",
"type": "string",
"value": "={{ $json.processed }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "8090644a-3e5c-43cb-84d1-595b0170580f",
"name": "Merge Supplier & Transaction Data",
"type": "n8n-nodes-base.merge",
"position": [
-848,
1536
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineAll"
},
"typeVersion": 3.2
},
{
"id": "9d3ba805-d959-44e0-8397-72e19d59bfd2",
"name": "Detect Maverick Spend (Unapproved Supplier)",
"type": "n8n-nodes-base.code",
"position": [
-624,
1536
],
"parameters": {
"jsCode": "// Get all incoming data\nconst allItems = $input.all();\n\n// Separate suppliers & transactions safely\nconst approvedItems = allItems.filter(i => i.json.contract_status);\nconst transactionItems = allItems.filter(i => i.json.transaction_id);\n\n// Create approved supplier set\nconst approvedSet = new Set(\n approvedItems.map(i =>\n String(i.json.supplier_name || '').toLowerCase().trim()\n )\n);\n\n// Process transactions\nreturn transactionItems.map(tx => {\n const supplier = String(tx.json.supplier_name || '').toLowerCase().trim();\n\n return {\n json: {\n transaction_id: tx.json.transaction_id || '',\n supplier_name: tx.json.supplier_name || '',\n amount: tx.json.amount || '',\n department: tx.json.department || '',\n processed: tx.json.processed || '',\n is_maverick: !approvedSet.has(supplier),\n approved_suppliers_list: [...approvedSet].join(', ')\n }\n };\n});"
},
"typeVersion": 2
},
{
"id": "4ed47ec8-2867-433c-8f5c-9b97cf2e06b8",
"name": "Check Maverick Spend Condition",
"type": "n8n-nodes-base.if",
"position": [
-400,
1536
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 3,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "8190c846-3edd-4bd6-8038-2bd97745cf54",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.is_maverick }}",
"rightValue": true
}
]
}
},
"typeVersion": 2.3
},
{
"id": "4a1e6645-035d-49a5-8281-5971578dfdf2",
"name": "Generate AI Compliance Suggestions",
"type": "@n8n/n8n-nodes-langchain.googleGemini",
"position": [
-176,
1232
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "models/gemini-2.5-flash",
"cachedResultName": "models/gemini-2.5-flash"
},
"options": {},
"messages": {
"values": [
{
"content": "=You are a procurement compliance expert.\n\nA purchase was made from an UNAPPROVED supplier:\n\n- Supplier: {{ $json.supplier_name }}\n- Department: {{ $json.department }}\n- Amount: ₹{{ $json.amount }}\n- Transaction ID: {{ $json.transaction_id }}\n\nApproved suppliers list:\n{{ $json.approved_suppliers_list }}\n\nInstructions:\n- If approved suppliers are available, suggest 2–3 relevant suppliers from the list.\n- If no suitable approved supplier is available, clearly say \"No approved supplier available\" and suggest initiating supplier onboarding.\n\nProvide output in EXACT format:\n\n1. Recommended Suppliers:\n- Supplier 1\n- Supplier 2\n- Supplier 3\n\n2. Corrective Action:\n<one clear action>\n\n3. Policy Reminder:\n<one short line>\n\nKeep response short, structured, and professional. Do NOT add extra explanation."
}
]
},
"builtInTools": {}
},
"credentials": {
"googlePalmApi": {
"id": "ZmJ44AfdmkGLdEnE",
"name": "Google Gemini(PaLM) Api account"
}
},
"executeOnce": false,
"typeVersion": 1.1
},
{
"id": "888ab427-20df-491a-962b-241ab28005a0",
"name": "Skip Approved Supplier (No Action)",
"type": "n8n-nodes-base.set",
"position": [
-112,
1632
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "skip-01",
"name": "transaction_id",
"type": "string",
"value": "={{ $json.transaction_id }}"
},
{
"id": "skip-02",
"name": "supplier_name",
"type": "string",
"value": "={{ $json.supplier_name }}"
},
{
"id": "skip-03",
"name": "processed",
"type": "string",
"value": "=Yes"
},
{
"id": "skip-04",
"name": "skip_reason",
"type": "string",
"value": "=Supplier is approved - no action needed"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "59d7ed11-da8c-4ecb-8b76-c61a4c39ad9d",
"name": "Mark Approved Transaction as Processed",
"type": "n8n-nodes-base.googleSheets",
"position": [
176,
1632
],
"parameters": {
"columns": {
"value": {
"processed": "=Yes"
},
"schema": [
{
"id": "transaction_id",
"type": "string",
"display": true,
"required": false,
"displayName": "transaction_id",
"defaultMatch": true,
"canBeUsedToMatch": true
},
{
"id": "processed",
"type": "string",
"display": true,
"required": false,
"displayName": "processed",
"defaultMatch": false,
"canBeUsedToMatch": false
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"transaction_id"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "update",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 701382615,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit#gid=701382615",
"cachedResultName": "Get Transactions"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit?usp=drivesdk",
"cachedResultName": "Maverick"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "MYTlJehpXYhsXd8R",
"name": "Google Sheets OAuth2 API"
}
},
"typeVersion": 4.7
},
{
"id": "0b4b5b27-cf10-4018-b601-b9bf42eb6773",
"name": "Format AI Output & Add Timestamp",
"type": "n8n-nodes-base.code",
"position": [
192,
1232
],
"parameters": {
"jsCode": "// Get the current item\nconst original = $input.item.json;\n\n// Extract AI text — handle all possible output shapes from the Gemini n8n node\nlet aiText = 'No AI suggestions available.';\n\n// Shape 1: n8n Gemini node wraps response in a 'text' field directly\nif (original.text && typeof original.text === 'string' && original.text.trim()) {\n aiText = original.text.trim();\n}\n// Shape 2: some versions use 'output'\nelse if (original.output && typeof original.output === 'string' && original.output.trim()) {\n aiText = original.output.trim();\n}\n// Shape 3: raw Gemini REST-style candidates array (unlikely via n8n node but kept as safety net)\nelse if (original.candidates && original.candidates[0]?.content?.parts) {\n aiText = original.candidates[0].content.parts\n .map(p => p.text || '')\n .join(' ')\n .trim();\n}\n\n// Normalise whitespace\naiText = aiText.replace(/\\n{3,}/g, '\\n\\n').trim();\n\nconst now = new Date();\n\nreturn [\n {\n json: {\n transaction_id: original.transaction_id,\n supplier_name: original.supplier_name,\n amount: original.amount,\n department: original.department,\n is_maverick: original.is_maverick,\n ai_suggestions: aiText,\n timestamp: now.toISOString(),\n timestamp_readable: now.toLocaleString('en-IN', {\n timeZone: 'Asia/Kolkata',\n dateStyle: 'medium',\n timeStyle: 'short'\n })\n }\n }\n];"
},
"typeVersion": 2
},
{
"id": "1b4556f3-3271-4173-8637-a009fd37f5f2",
"name": "Send Slack Alert (Maverick Spend)",
"type": "n8n-nodes-base.slack",
"position": [
432,
1232
],
"webhookId": "6bb8f42a-3437-4eb5-b51c-43fb34d332f4",
"parameters": {
"text": "=*Maverick Spend Detected!*\n\n*Transaction ID:* `{{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.transaction_id }}`\n*Unauthorized Supplier:*{{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.supplier_name }}\n*Amount:* ₹{{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.amount }}\n*Department:* {{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.department }}\n*Detected At:* {{ $json.timestamp_readable }} IST\n\n *AI Suggestions:*\n```{{ $json.ai_suggestions }}```\n\n Please review this transaction within 2 hours or it will be escalated.",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "list",
"value": "C0AP6S28KM3",
"cachedResultName": "all-aishvarya"
},
"otherOptions": {},
"authentication": "oAuth2"
},
"credentials": {
"slackOAuth2Api": {
"id": "8ZJIg7kaqsmsr9M7",
"name": "Slack OAuth2 API"
}
},
"typeVersion": 2.4
},
{
"id": "8f6a3c6b-c72c-450e-b58e-82735110c527",
"name": "Send Email Alert (Violation Report)",
"type": "n8n-nodes-base.gmail",
"position": [
656,
1232
],
"webhookId": "ef872270-0084-4f4c-b642-710ac74df6a6",
"parameters": {
"message": "=<!DOCTYPE html>\n<html>\n<body style=\"font-family: Arial, sans-serif; max-width: 680px; margin: auto; padding: 20px; color: #333;\">\n\n <div style=\"background: #c0392b; color: white; padding: 18px 24px; border-radius: 8px 8px 0 0;\">\n <h2 style=\"margin: 0;\"> Maverick Spend Violation Detected</h2>\n <p style=\"margin: 6px 0 0; font-size: 13px; opacity: 0.9;\">Automated alert from Procurement Compliance System</p>\n </div>\n\n <div style=\"border: 1px solid #ddd; border-top: none; border-radius: 0 0 8px 8px; padding: 24px;\">\n\n <h3 style=\"color: #c0392b; margin-top: 0;\">Transaction Details</h3>\n <table style=\"width: 100%; border-collapse: collapse; margin-bottom: 20px;\">\n <tr style=\"background: #f8f8f8;\">\n <td style=\"padding: 10px; border: 1px solid #ddd; font-weight: bold; width: 40%;\">Transaction ID</td>\n <td style=\"padding: 10px; border: 1px solid #ddd; font-family: monospace;\">{{ $('Check Maverick Spend Condition').item.json.transaction_id }}</td>\n </tr>\n <tr>\n <td style=\"padding: 10px; border: 1px solid #ddd; font-weight: bold;\">Unauthorized Supplier</td>\n <td style=\"padding: 10px; border: 1px solid #ddd; color: #c0392b; font-weight: bold;\">{{ $('Check Maverick Spend Condition').item.json.supplier_name }}</td>\n </tr>\n <tr style=\"background: #f8f8f8;\">\n <td style=\"padding: 10px; border: 1px solid #ddd; font-weight: bold;\">Amount</td>\n <td style=\"padding: 10px; border: 1px solid #ddd; font-size: 18px; font-weight: bold;\">₹{{ $('Check Maverick Spend Condition').item.json.amount }}</td>\n </tr>\n <tr>\n <td style=\"padding: 10px; border: 1px solid #ddd; font-weight: bold;\">Department</td>\n <td style=\"padding: 10px; border: 1px solid #ddd;\">{{ $('Check Maverick Spend Condition').item.json.department }}</td>\n </tr>\n <tr style=\"background: #f8f8f8;\">\n <td style=\"padding: 10px; border: 1px solid #ddd; font-weight: bold;\">Status</td>\n <td style=\"padding: 10px; border: 1px solid #ddd;\">\n <span style=\"background: #e67e22; color: white; padding: 4px 12px; border-radius: 4px; font-size: 13px;\">Pending Review</span>\n </td>\n </tr>\n <tr>\n <td style=\"padding: 10px; border: 1px solid #ddd; font-weight: bold;\">Detected At</td>\n <td style=\"padding: 10px; border: 1px solid #ddd;\">{{ $('Format AI Output & Add Timestamp').item.json.timestamp_readable }} IST</td>\n </tr>\n </table>\n\n <h3 style=\"color: #2980b9;\"> AI-Recommended Compliant Suppliers</h3>\n <div style=\"background: #eaf4fb; border-left: 4px solid #2980b9; padding: 16px; border-radius: 4px; white-space: pre-line; font-size: 14px; line-height: 1.7;\">\n{{ $('Format AI Output & Add Timestamp').item.json.ai_suggestions }}\n </div>\n\n <div style=\"background: #fef9e7; border: 1px solid #f1c40f; border-radius: 6px; padding: 16px; margin-top: 20px;\">\n <p style=\"margin: 0; font-size: 13px;\"> <strong>Action Required:</strong> Please review this transaction within <strong>2 hours</strong>. If no action is taken, this alert will be automatically escalated to senior management.</p>\n </div>\n\n <p style=\"color: #999; font-size: 12px; margin-top: 24px;\">This is an automated message from your n8n Procurement Compliance Workflow.</p>\n </div>\n\n</body>\n</html>",
"options": {},
"subject": "=Maverick Spend Alert - {{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.supplier_name }} | ₹{{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.amount }} | {{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.department }}"
},
"credentials": {
"gmailOAuth2": {
"id": "yAlr1kYBrpnbaOqK",
"name": "Gmail OAuth2 API"
}
},
"typeVersion": 2.2
},
{
"id": "e03ea9c2-afda-4efe-8f01-d8f8f0d12480",
"name": "Log Violation in Sheet",
"type": "n8n-nodes-base.googleSheets",
"position": [
864,
1232
],
"parameters": {
"columns": {
"value": {
"amount": "={{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.amount }}",
"status": "=Pending Review",
"timestamp": "={{ $('Format AI Output & Add Timestamp').item.json.timestamp_readable }}",
"department": "={{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.department }}",
"supplier_name": "={{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.supplier_name }}",
"ai_suggestions": "={{ $('Format AI Output & Add Timestamp').item.json.ai_suggestions }}",
"transaction_id": "={{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.transaction_id }}"
},
"schema": [
{
"id": "violation_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "violation_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "transaction_id",
"type": "string",
"display": true,
"required": false,
"displayName": "transaction_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "supplier_name",
"type": "string",
"display": true,
"required": false,
"displayName": "supplier_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "amount",
"type": "string",
"display": true,
"required": false,
"displayName": "amount",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "department",
"type": "string",
"display": true,
"required": false,
"displayName": "department",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "status",
"type": "string",
"display": true,
"required": false,
"displayName": "status",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "ai_suggestions",
"type": "string",
"display": true,
"required": false,
"displayName": "ai_suggestions",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "timestamp",
"type": "string",
"display": true,
"required": false,
"displayName": "timestamp",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "escalation_status",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "escalation_status",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 1873248992,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit#gid=1873248992",
"cachedResultName": "Violation log "
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit?usp=drivesdk",
"cachedResultName": "Maverick"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "MYTlJehpXYhsXd8R",
"name": "Google Sheets OAuth2 API"
}
},
"typeVersion": 4.7
},
{
"id": "f6ad4596-bead-4c0b-ac29-004f2fe61e3e",
"name": "Wait 2 Hours Before Escalation",
"type": "n8n-nodes-base.wait",
"position": [
1280,
1232
],
"webhookId": "maverick-spend-escalation-wait",
"parameters": {
"unit": "hours",
"amount": 2
},
"typeVersion": 1.1
},
{
"id": "ad1506bd-c533-4f8f-bd03-3715622bc19f",
"name": "Send Escalation Alert",
"type": "n8n-nodes-base.slack",
"position": [
1520,
1232
],
"webhookId": "f6c5f7f8-e576-4bef-963b-eafe95594edf",
"parameters": {
"text": "= *ESCALATION ALERT - Unapproved Transaction Not Reviewed*\n\nThe following maverick spend transaction has been pending for *over 2 hours* with no action taken.\n\n*Transaction ID:* `{{ $json.transaction_id }}`\n*Unauthorized Supplier:* {{ $json.supplier_name }}\n*Amount:* ₹{{ $json.amount }}\n*Department:* {{ $json.department }}\n*Originally Detected:* {{ $json.timestamp_readable }} IST\n\n *Suggested Compliant Alternatives:*\n```{{ $json.ai_suggestions }}```\n\n@channel - Immediate action required by senior procurement management.",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "list",
"value": "C0AP6S28KM3",
"cachedResultName": "all-aishvarya"
},
"otherOptions": {},
"authentication": "oAuth2"
},
"credentials": {
"slackOAuth2Api": {
"id": "8ZJIg7kaqsmsr9M7",
"name": "Slack OAuth2 API"
}
},
"typeVersion": 2.4
},
{
"id": "2bbca330-bb99-435f-a12e-bc7f058de6e3",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1360,
1264
],
"parameters": {
"color": 7,
"width": 656,
"height": 576,
"content": "## Data Ingestion & Preparation\n\nFetches supplier and transaction data from Google Sheets, standardizes formats, and merges datasets into a unified stream for accurate comparison and processing."
},
"typeVersion": 1
},
{
"id": "0810cdd6-70b1-4379-94a6-71e9faa76cf6",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-688,
1440
],
"parameters": {
"color": 7,
"width": 1056,
"height": 384,
"content": "## Maverick Spend Detection & Decision\n\nChecks if transactions involve unapproved suppliers and routes workflow accordingly, either skipping approved entries or forwarding violations for further processing."
},
"typeVersion": 1
},
{
"id": "17e2c3b8-897d-4adf-8be5-845d9835905b",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-256,
1088
],
"parameters": {
"color": 7,
"width": 1952,
"height": 336,
"content": "## Violation Handling, Alerts & Escalation\n\nProcesses violations using AI suggestions, sends Slack and email alerts, logs records, marks transactions processed, and escalates unresolved cases after a defined waiting period."
},
"typeVersion": 1
},
{
"id": "68373227-5dd8-4cda-a8a7-5796b0360243",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1664,
1408
],
"parameters": {
"color": 7,
"width": 256,
"height": 304,
"content": "## Scheduler\nruns automatically every day at 11 :00 AM"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"binaryMode": "separate",
"executionOrder": "v1"
},
"versionId": "7f08dafa-9215-4e6f-bbd9-5e987e3660c8",
"connections": {
"Daily Compliance Scan": {
"main": [
[
{
"node": "Get Approved Supplier List",
"type": "main",
"index": 0
},
{
"node": "Get Pending Transactions",
"type": "main",
"index": 0
}
]
]
},
"Log Violation in Sheet": {
"main": [
[
{
"node": "Mark Transaction as Processed",
"type": "main",
"index": 0
}
]
]
},
"Get Pending Transactions": {
"main": [
[
{
"node": "Merge Supplier & Transaction Data",
"type": "main",
"index": 1
}
]
]
},
"Get Approved Supplier List": {
"main": [
[
{
"node": "Clean & Normalize Transaction Data",
"type": "main",
"index": 0
}
]
]
},
"Mark Transaction as Processed": {
"main": [
[
{
"node": "Wait 2 Hours Before Escalation",
"type": "main",
"index": 0
}
]
]
},
"Check Maverick Spend Condition": {
"main": [
[
{
"node": "Generate AI Compliance Suggestions",
"type": "main",
"index": 0
}
],
[
{
"node": "Skip Approved Supplier (No Action)",
"type": "main",
"index": 0
}
]
]
},
"Wait 2 Hours Before Escalation": {
"main": [
[
{
"node": "Send Escalation Alert",
"type": "main",
"index": 0
}
]
]
},
"Format AI Output & Add Timestamp": {
"main": [
[
{
"node": "Send Slack Alert (Maverick Spend)",
"type": "main",
"index": 0
}
]
]
},
"Merge Supplier & Transaction Data": {
"main": [
[
{
"node": "Detect Maverick Spend (Unapproved Supplier)",
"type": "main",
"index": 0
}
]
]
},
"Send Slack Alert (Maverick Spend)": {
"main": [
[
{
"node": "Send Email Alert (Violation Report)",
"type": "main",
"index": 0
}
]
]
},
"Clean & Normalize Transaction Data": {
"main": [
[
{
"node": "Merge Supplier & Transaction Data",
"type": "main",
"index": 0
}
]
]
},
"Generate AI Compliance Suggestions": {
"main": [
[
{
"node": "Format AI Output & Add Timestamp",
"type": "main",
"index": 0
}
]
]
},
"Skip Approved Supplier (No Action)": {
"main": [
[
{
"node": "Mark Approved Transaction as Processed",
"type": "main",
"index": 0
}
]
]
},
"Send Email Alert (Violation Report)": {
"main": [
[
{
"node": "Log Violation in Sheet",
"type": "main",
"index": 0
}
]
]
},
"Detect Maverick Spend (Unapproved Supplier)": {
"main": [
[
{
"node": "Check Maverick Spend Condition",
"type": "main",
"index": 0
}
]
]
}
}
}