-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHR Employee Risk & Engagement Monitor.json
More file actions
2453 lines (2453 loc) · 92.9 KB
/
HR Employee Risk & Engagement Monitor.json
File metadata and controls
2453 lines (2453 loc) · 92.9 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
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"name": "My workflow 3",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "signal-webhook",
"responseMode": "responseNode",
"options": {}
},
"id": "09263d17-3428-4c93-a916-b55564a1e9ff",
"name": "Signal Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2.1,
"position": [
-3008,
3632
],
"webhookId": "69c80165-235d-47ee-a86b-6128402aefad"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "id-1",
"name": "source",
"value": "={{ $json.body.source }}",
"type": "string"
},
{
"id": "id-2",
"name": "channel",
"value": "={{ $json.body.channel }}",
"type": "string"
},
{
"id": "id-3",
"name": "content",
"value": "={{ $json.body.content }}",
"type": "string"
},
{
"id": "id-4",
"name": "timestamp",
"value": "={{ $json.body.timestamp }}",
"type": "string"
}
]
},
"options": {}
},
"id": "f1d8fb88-54a3-4423-8d5e-e94460b5d4d7",
"name": "Workflow Configuration",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-2784,
3632
]
},
{
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"intent\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"The detected intent of the signal\"\n\t\t},\n\t\t\"urgency\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Urgency level: low, medium, high, critical\"\n\t\t},\n\t\t\"sentiment\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Sentiment: positive, neutral, negative\"\n\t\t},\n\t\t\"confidence_score\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"description\": \"Confidence score from 0 to 1\"\n\t\t},\n\t\t\"risk_flags\": {\n\t\t\t\"type\": \"array\",\n\t\t\t\"items\": {\n\t\t\t\t\"type\": \"string\"\n\t\t\t},\n\t\t\t\"description\": \"Array of identified risk flags\"\n\t\t},\n\t\t\"recommended_action\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Recommended action: notify_human, create_crm_task, escalate_management, or open_support_ticket\"\n\t\t}\n\t},\n\t\"required\": [\"intent\", \"urgency\", \"sentiment\", \"confidence_score\", \"risk_flags\", \"recommended_action\"]\n}"
},
"id": "d1baaa14-197f-40cb-81f9-9c31ca02c46f",
"name": "Structured Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"typeVersion": 1.3,
"position": [
-2552,
3856
]
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o-mini"
},
"builtInTools": {},
"options": {}
},
"id": "93ae1a1b-d8f3-4478-9014-e2cbb069d8d8",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.3,
"position": [
-2424,
3856
]
},
{
"parameters": {
"promptType": "define",
"text": "=Signal Data:\nSource: {{ $json.source }}\nChannel: {{ $json.channel }}\nContent: {{ $json.content }}\nTimestamp: {{ $json.timestamp }}\n\nAnalyze this signal and provide a structured assessment:\n\n1. INTENT: What is the user trying to communicate or achieve?\n2. URGENCY: Rate as low, medium, high, or critical based on:\n - Time-sensitive keywords (urgent, asap, immediately)\n - Problem severity indicators\n - Business impact signals\n3. SENTIMENT: Classify as positive, neutral, or negative\n4. CONFIDENCE_SCORE: Your confidence in this analysis (0.0 to 1.0)\n5. RISK_FLAGS: Identify any concerning elements:\n - Security threats\n - Compliance issues\n - Customer churn risk\n - Legal concerns\n - Data breach indicators\n6. RECOMMENDED_ACTION: Choose the most appropriate action:\n - notify_human: For general alerts requiring human awareness\n - create_crm_task: For sales/customer success follow-ups\n - escalate_management: For high-priority issues requiring leadership\n - open_support_ticket: For technical support requests",
"hasOutputParser": true,
"options": {
"systemMessage": "You are an AI Signal Analyzer that evaluates incoming signals and determines the appropriate action. Analyze signals for intent, urgency, sentiment, confidence, risk flags, and recommend the most appropriate action from: notify_human, create_crm_task, escalate_management, or open_support_ticket."
}
},
"id": "a84fd299-7c46-4552-9b0c-6e94ab93aa6d",
"name": "AI Signal Analyzer",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [
-2560,
3632
]
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"leftValue": "={{ $json.recommended_action }}",
"rightValue": "notify_human",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Notify Human"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"leftValue": "={{ $json.recommended_action }}",
"rightValue": "create_crm_task",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Create CRM Task"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"leftValue": "={{ $json.recommended_action }}",
"rightValue": "escalate_management",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Escalate Management"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"leftValue": "={{ $json.recommended_action }}",
"rightValue": "open_support_ticket",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Open Support Ticket"
}
]
},
"options": {}
},
"id": "c59712db-75e6-467b-9d60-fbd5b7a27cd5",
"name": "Route by Action",
"type": "n8n-nodes-base.switch",
"typeVersion": 3.4,
"position": [
-2208,
3600
]
},
{
"parameters": {
"select": "channel",
"channelId": {
"__rl": true,
"mode": "id",
"value": "YOUR_SLACK_CHANNEL_ID"
},
"text": "=🚨 Signal Alert - Human Notification Required\n\n*Source:* {{ $('Workflow Configuration').item.json.source }}\n*Channel:* {{ $('Workflow Configuration').item.json.channel }}\n*Timestamp:* {{ $('Workflow Configuration').item.json.timestamp }}\n\n*Intent:* {{ $json.intent }}\n*Urgency:* {{ $json.urgency }}\n*Sentiment:* {{ $json.sentiment }}\n*Confidence:* {{ $json.confidence_score }}\n\n*Content:*\n{{ $('Workflow Configuration').item.json.content }}\n\n*Risk Flags:* {{ $json.risk_flags.join(', ') || 'None' }}",
"otherOptions": {}
},
"id": "82273327-c4af-4d1f-b924-785107a319f3",
"name": "Send Slack Notification",
"type": "n8n-nodes-base.slack",
"typeVersion": 2.4,
"position": [
-1984,
3344
],
"webhookId": "6d1f2cf1-a5b3-4fe6-8767-c175f360f72d"
},
{
"parameters": {
"method": "POST",
"url": "https://your-crm-api.example.com/api/tasks",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "Authorization",
"value": "Bearer YOUR_CRM_API_TOKEN"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ {\"title\": \"Follow-up: \" + $('Workflow Configuration').item.json.source, \"description\": $('Workflow Configuration').item.json.content, \"priority\": $json.urgency, \"source\": $('Workflow Configuration').item.json.channel, \"metadata\": {\"intent\": $json.intent, \"sentiment\": $json.sentiment, \"confidence\": $json.confidence_score, \"risk_flags\": $json.risk_flags, \"timestamp\": $('Workflow Configuration').item.json.timestamp}} }}",
"options": {}
},
"id": "b6e16e44-1901-4d94-a3e3-8408f3b0346a",
"name": "Create CRM Task",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.3,
"position": [
-1984,
3536
]
},
{
"parameters": {
"fromEmail": "alerts@yourcompany.com",
"toEmail": "management@yourcompany.com",
"subject": "=🚨 ESCALATION REQUIRED: {{ $json.urgency }} Priority Signal",
"emailFormat": "text",
"text": "=MANAGEMENT ESCALATION REQUIRED\n\nA signal has been flagged for immediate management attention.\n\n=== SIGNAL DETAILS ===\nSource: {{ $('Workflow Configuration').item.json.source }}\nChannel: {{ $('Workflow Configuration').item.json.channel }}\nTimestamp: {{ $('Workflow Configuration').item.json.timestamp }}\n\n=== AI ANALYSIS ===\nIntent: {{ $json.intent }}\nUrgency: {{ $json.urgency }}\nSentiment: {{ $json.sentiment }}\nConfidence Score: {{ $json.confidence_score }}\n\nRisk Flags: {{ $json.risk_flags.join(', ') || 'None identified' }}\n\n=== ORIGINAL CONTENT ===\n{{ $('Workflow Configuration').item.json.content }}\n\n=== RECOMMENDED ACTION ===\nImmediate review and response required.\n\nThis is an automated alert from the Signal Decision Engine.",
"options": {}
},
"id": "31dcb675-f7f9-467c-905c-a1edd0811fad",
"name": "Escalate to Management",
"type": "n8n-nodes-base.emailSend",
"typeVersion": 2.1,
"position": [
-1984,
3728
],
"webhookId": "d536c126-c8a2-441d-997b-02f926c8175a"
},
{
"parameters": {
"method": "POST",
"url": "https://your-helpdesk-api.example.com/api/tickets",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "Authorization",
"value": "Bearer YOUR_HELPDESK_API_TOKEN"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ {\"subject\": \"Support Request: \" + $json.intent, \"description\": $('Workflow Configuration').item.json.content, \"priority\": $json.urgency, \"source\": $('Workflow Configuration').item.json.source, \"channel\": $('Workflow Configuration').item.json.channel, \"tags\": $json.risk_flags, \"metadata\": {\"sentiment\": $json.sentiment, \"confidence_score\": $json.confidence_score, \"timestamp\": $('Workflow Configuration').item.json.timestamp}} }}",
"options": {}
},
"id": "bf8016c3-520b-4fb9-adb9-0b80a0575750",
"name": "Open Support Ticket",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.3,
"position": [
-1984,
3920
]
},
{
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 9
}
]
}
},
"id": "df24ffbc-2ce1-4e4a-bf89-5bbd968f5fe1",
"name": "Daily Revenue Check",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.3,
"position": [
-3008,
4624
]
},
{
"parameters": {
"httpMethod": "POST",
"path": "revenue-events",
"responseMode": "responseNode",
"options": {}
},
"id": "89205b21-167e-4513-b571-9612c5f67da8",
"name": "Real-time Payment Events",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2.1,
"position": [
-3008,
4816
],
"webhookId": "8740ed43-98d3-4540-bf70-e5b251d34d82"
},
{
"parameters": {},
"id": "41d19dba-8d34-4a59-89dd-522218fbec33",
"name": "Merge Triggers",
"type": "n8n-nodes-base.merge",
"typeVersion": 3.2,
"position": [
-2784,
4720
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "id-1",
"name": "trigger_source",
"value": "={{ $json.body ? 'webhook' : 'schedule' }}",
"type": "string"
},
{
"id": "id-2",
"name": "event_type",
"value": "={{ $json.body?.event_type || 'scheduled_check' }}",
"type": "string"
},
{
"id": "id-3",
"name": "timestamp",
"value": "={{ $now.toISO() }}",
"type": "string"
}
]
},
"includeOtherFields": true,
"options": {}
},
"id": "71611e78-3f96-4b96-8fe6-c3dce3595dfc",
"name": "Workflow Configuration1",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-2560,
4720
]
},
{
"parameters": {
"url": "https://api.stripe.example.com/v1/payment_intents",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "status",
"value": "failed"
},
{
"name": "created",
"value": "={{ $now.minus({ days: 7 }).toUnixInteger() }}"
}
]
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer YOUR_STRIPE_API_KEY"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"options": {}
},
"id": "d8d24bfc-8b7a-46f9-a874-acc5a50724ba",
"name": "Fetch Payment Data",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.3,
"position": [
-2336,
4528
]
},
{
"parameters": {
"url": "https://api.crm.example.com/v1/leads",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "status",
"value": "stale"
},
{
"name": "last_contact_before",
"value": "={{ $now.minus({ days: 14 }).toISO() }}"
}
]
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer YOUR_CRM_API_KEY"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"options": {}
},
"id": "6b9cc959-e203-4c5a-89c7-9039ca93cd39",
"name": "Fetch CRM Data",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.3,
"position": [
-2336,
4720
]
},
{
"parameters": {
"url": "https://api.billing.example.com/v1/subscriptions",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "status",
"value": "at_risk"
},
{
"name": "renewal_within_days",
"value": "30"
}
]
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer YOUR_BILLING_API_KEY"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"options": {}
},
"id": "bdf3df4f-124a-4d9b-a091-6c856a80c198",
"name": "Fetch Subscription Data",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.3,
"position": [
-2336,
4912
]
},
{
"parameters": {
"mode": "combine",
"options": {}
},
"id": "a539d12b-7bde-41de-a346-fc99cc1184c7",
"name": "Combine All Data Sources",
"type": "n8n-nodes-base.merge",
"typeVersion": 3.2,
"position": [
-2112,
4624
]
},
{
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n \"type\": \"object\",\n \"properties\": {\n \"leak_type\": {\n \"type\": \"string\",\n \"enum\": [\"failed_payment\", \"abandoned_lead\", \"missed_follow_up\", \"renewal_risk\", \"churn_detected\", \"unknown\"],\n \"description\": \"Type of revenue leak detected\"\n },\n \"risk_level\": {\n \"type\": \"string\",\n \"enum\": [\"low\", \"medium\", \"high\", \"critical\"],\n \"description\": \"Financial impact risk level\"\n },\n \"estimated_impact\": {\n \"type\": \"string\",\n \"description\": \"Estimated revenue at risk (e.g., $5,000)\"\n },\n \"confidence_score\": {\n \"type\": \"number\",\n \"minimum\": 0,\n \"maximum\": 1,\n \"description\": \"Confidence in analysis from 0.0 to 1.0\"\n },\n \"recommended_action\": {\n \"type\": \"string\",\n \"enum\": [\"retry_payment\", \"notify_finance\", \"create_sales_task\", \"trigger_retention_flow\", \"escalate_management\", \"ignore\"],\n \"description\": \"Recommended corrective action\"\n },\n \"action_reason\": {\n \"type\": \"string\",\n \"description\": \"Explanation for the recommended action\"\n }\n },\n \"required\": [\"leak_type\", \"risk_level\", \"estimated_impact\", \"confidence_score\", \"recommended_action\", \"action_reason\"]\n}"
},
"id": "f9e7a7b2-15fe-4531-88dd-64f3f8ae629b",
"name": "Revenue Leak Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"typeVersion": 1.3,
"position": [
-1880,
4848
]
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o-mini"
},
"builtInTools": {},
"options": {}
},
"id": "d1e0cc4b-fdd9-4eb9-9c2b-9e8c35213723",
"name": "OpenAI Chat Model1",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.3,
"position": [
-1752,
4848
]
},
{
"parameters": {
"promptType": "define",
"text": "=Revenue Data Analysis:\n\nPayment Data: {{ JSON.stringify($('Fetch Payment Data').item.json, null, 2) }}\n\nCRM Data: {{ JSON.stringify($('Fetch CRM Data').item.json, null, 2) }}\n\nSubscription Data: {{ JSON.stringify($('Fetch Subscription Data').item.json, null, 2) }}\n\nAnalyze this revenue data and identify potential revenue leaks:\n\n1. LEAK_TYPE: Classify the revenue leak:\n - failed_payment: Payment processing failures\n - abandoned_lead: Sales leads not followed up\n - missed_follow_up: Customer touchpoints missed\n - renewal_risk: Subscriptions at risk of not renewing\n - churn_detected: Active churn signals detected\n - unknown: Unable to classify\n\n2. RISK_LEVEL: Assess financial impact (low, medium, high, critical):\n - Consider revenue amount at risk\n - Customer lifetime value\n - Urgency of intervention needed\n\n3. ESTIMATED_IMPACT: Quantify the potential revenue loss (e.g., $5,000, $50,000)\n\n4. CONFIDENCE_SCORE: Your confidence in this analysis (0.0 to 1.0)\n\n5. RECOMMENDED_ACTION: Choose the most appropriate action:\n - retry_payment: Attempt to reprocess failed payment\n - notify_finance: Alert finance team for manual review\n - create_sales_task: Create follow-up task for sales team\n - trigger_retention_flow: Initiate customer retention campaign\n - escalate_management: Escalate to executive leadership\n - ignore: No action needed\n\n6. ACTION_REASON: Explain why this action is recommended",
"hasOutputParser": true,
"options": {
"systemMessage": "You are a Revenue Leak Detection AI that analyzes payment failures, stale leads, subscription churn risks, and missed renewals. Identify the leak type, assess financial impact, score confidence, and recommend corrective actions."
}
},
"id": "a46b8ef1-38c4-44a3-af9e-37f1c0976aa4",
"name": "Revenue Leak Analyzer",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [
-1888,
4624
]
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"leftValue": "={{ $json.recommended_action }}",
"rightValue": "retry_payment",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Retry Payment"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"leftValue": "={{ $json.recommended_action }}",
"rightValue": "notify_finance",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Notify Finance"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"leftValue": "={{ $json.recommended_action }}",
"rightValue": "create_sales_task",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Create Sales Task"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"leftValue": "={{ $json.recommended_action }}",
"rightValue": "trigger_retention_flow",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Trigger Retention Flow"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"leftValue": "={{ $json.recommended_action }}",
"rightValue": "escalate_management",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Escalate Management"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"leftValue": "={{ $json.recommended_action }}",
"rightValue": "ignore",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Ignore"
}
]
},
"options": {}
},
"id": "09422b5d-0b42-4df1-aa6f-578bb37866c7",
"name": "Route by Recommended Action",
"type": "n8n-nodes-base.switch",
"typeVersion": 3.4,
"position": [
-1536,
4560
]
},
{
"parameters": {
"method": "POST",
"url": "https://api.stripe.example.com/v1/payment_intents/retry",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer YOUR_STRIPE_API_KEY"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ { \"payment_intent_id\": $json.payment_intent_id } }}",
"options": {}
},
"id": "350d25ef-237e-4761-892b-7903b1f881a0",
"name": "Retry Payment Request",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.3,
"position": [
-1312,
4144
]
},
{
"parameters": {
"select": "channel",
"channelId": {
"__rl": true,
"mode": "id",
"value": "YOUR_FINANCE_SLACK_CHANNEL"
},
"text": "=💰 Revenue Leak Alert - Finance Team Notification\n\n*Leak Type:* {{ $json.leak_type }}\n*Risk Level:* {{ $json.risk_level }}\n*Estimated Impact:* ${{ $json.estimated_impact }}\n\n*Customer Details:*\n• Customer ID: {{ $json.customer_id }}\n• Account Status: {{ $json.account_status }}\n• MRR: ${{ $json.mrr }}\n\n*Issue Description:*\n{{ $json.description }}\n\n*Root Cause:*\n{{ $json.root_cause }}\n\n*Recommended Action:*\n{{ $json.recommended_action }}\n\n*Confidence Score:* {{ $json.confidence_score }}\n\n---\n_Detected by Revenue Leak Analyzer at {{ $json.timestamp }}_",
"otherOptions": {}
},
"id": "3e00f027-714f-4c0a-95d6-22fdfe4c079c",
"name": "Send Finance Alert",
"type": "n8n-nodes-base.slack",
"typeVersion": 2.4,
"position": [
-1312,
4336
],
"webhookId": "b0e75fdc-5d0b-462a-9ff0-cab7a1fa57f4"
},
{
"parameters": {
"method": "POST",
"url": "https://api.crm.example.com/v1/tasks",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer YOUR_CRM_API_KEY"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ {\n \"title\": \"Revenue Leak: \" + $json.leak_type,\n \"description\": \"Action required: \" + $json.action_reason,\n \"estimated_impact\": $json.estimated_impact,\n \"leak_type\": $json.leak_type,\n \"priority\": $json.urgency || \"medium\",\n \"metadata\": {\n \"confidence_score\": $json.confidence_score,\n \"timestamp\": $now\n }\n} }}",
"options": {}
},
"id": "b18e8175-4e9e-4130-a91f-ceb7aea92efb",
"name": "Create Sales Task in CRM",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.3,
"position": [
-1312,
4528
]
},
{
"parameters": {
"fromEmail": "retention@yourcompany.com",
"toEmail": "={{ $('Combine All Data Sources').item.json.customer_email }}",
"subject": "We'd Love to Keep You - Special Retention Offer",
"html": "<!DOCTYPE html>\n<html>\n<head>\n <style>\n body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }\n .container { max-width: 600px; margin: 0 auto; padding: 20px; }\n .header { background-color: #4CAF50; color: white; padding: 20px; text-align: center; }\n .content { padding: 30px; background-color: #f9f9f9; }\n .offer-box { background-color: #fff; border: 2px solid #4CAF50; padding: 20px; margin: 20px 0; border-radius: 8px; }\n .cta-button { display: inline-block; background-color: #4CAF50; color: white; padding: 15px 30px; text-decoration: none; border-radius: 5px; margin: 20px 0; }\n .footer { text-align: center; padding: 20px; color: #666; font-size: 12px; }\n </style>\n</head>\n<body>\n <div class=\"container\">\n <div class=\"header\">\n <h1>We Value Your Partnership</h1>\n </div>\n <div class=\"content\">\n <p>Dear Valued Customer,</p>\n \n <p>We noticed some recent changes with your account, and we wanted to reach out personally. Your business means a lot to us, and we'd like to offer you something special to show our appreciation.</p>\n \n <div class=\"offer-box\">\n <h2 style=\"color: #4CAF50; margin-top: 0;\">🎁 Exclusive Retention Offer</h2>\n <p><strong>We're offering you:</strong></p>\n <ul>\n <li>20% discount on your next 3 months</li>\n <li>Priority customer support</li>\n <li>Free upgrade to premium features</li>\n <li>Dedicated account manager</li>\n </ul>\n <p style=\"color: #666; font-size: 14px;\"><em>This offer is exclusively for you and expires in 7 days.</em></p>\n </div>\n \n <p>We understand that circumstances change, and we're here to help make things work for you. If there's anything we can do to improve your experience, we'd love to hear from you.</p>\n \n <center>\n <a href=\"https://yourcompany.com/retention-offer\" class=\"cta-button\">Claim Your Offer</a>\n </center>\n \n <p>If you have any questions or would like to discuss your account, please don't hesitate to reach out. We're here to help.</p>\n \n <p>Thank you for being a valued customer.</p>\n \n <p>Best regards,<br>\n <strong>The Customer Success Team</strong><br>\n Your Company</p>\n </div>\n <div class=\"footer\">\n <p>This email was sent to you because we value your business.<br>\n If you have any questions, contact us at retention@yourcompany.com</p>\n </div>\n </div>\n</body>\n</html>",
"options": {}
},
"id": "22b587e8-12a3-494e-b241-7ac3831552bf",
"name": "Send Retention Email",
"type": "n8n-nodes-base.emailSend",
"typeVersion": 2.1,
"position": [
-1312,
4720
],
"webhookId": "45e7471f-d8f3-48dd-96cb-e443bfcf3215"
},
{
"parameters": {
"fromEmail": "alerts@yourcompany.com",
"toEmail": "executives@yourcompany.com",
"subject": "={{ '🚨 CRITICAL REVENUE LEAK: ' + $json.risk_level + ' - ' + $json.leak_type }}",
"emailFormat": "text",
"text": "=EXECUTIVE ALERT - CRITICAL REVENUE LEAK DETECTED\n\nA critical revenue leak has been identified and requires immediate executive attention.\n\n=== LEAK DETAILS ===\nLeak Type: {{ $json.leak_type }}\nRisk Level: {{ $json.risk_level }}\nEstimated Impact: {{ $json.estimated_impact }}\nConfidence Score: {{ $json.confidence_score }}\n\n=== IMMEDIATE ACTION REQUIRED ===\n{{ $json.recommended_action }}\n\n=== ANALYSIS SUMMARY ===\n{{ $json.analysis_summary }}\n\nThis is an automated critical alert from the Revenue Leak Detection System.\nImmediate review and action required.",
"options": {}
},
"id": "cf56a454-5559-4492-b26a-008ccbc0f05e",
"name": "Escalate to Executives",
"type": "n8n-nodes-base.emailSend",
"typeVersion": 2.1,
"position": [
-1312,
4912
],
"webhookId": "9136ee46-ccc7-4120-9a40-b2c059bb1850"
},
{
"parameters": {},
"id": "5bf6cd87-5334-4ba0-8866-28271684ce79",
"name": "No Action Required",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
-1312,
5104
]
},
{
"parameters": {},
"id": "e94efebb-7e63-44e8-864f-bfe0eb3f1cb9",
"name": "Manual Trigger",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
-3008,
5616
]
},
{
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 9
}
]
}
},
"id": "7ecdd6da-44a2-450f-98e7-3343af7d3081",
"name": "Daily Contract Check",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.3,
"position": [
-3008,
5808
]
},
{
"parameters": {
"httpMethod": "POST",
"path": "contract-upload",
"responseMode": "responseNode",
"options": {}
},
"id": "55b3b970-551d-40c1-ad6d-a805fc7421b7",
"name": "Contract Upload Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2.1,
"position": [
-3008,
6000
],
"webhookId": "e1232fd8-be6e-4e1b-8fa9-941b5bf1d690"
},
{
"parameters": {
"numberInputs": 3
},
"id": "6a4157f3-a050-45b7-b276-588a458ccad9",
"name": "Merge All Triggers",
"type": "n8n-nodes-base.merge",
"typeVersion": 3.2,
"position": [
-2784,
5792
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "id-1",
"name": "trigger_source",
"value": "={{ $json.body ? 'webhook' : ($json.path ? 'webhook' : 'schedule') }}",
"type": "string"
},
{
"id": "id-2",
"name": "file_id",
"value": "={{ $json.body?.file_id || 'PLACEHOLDER_GOOGLE_DRIVE_FILE_ID' }}",
"type": "string"
},
{
"id": "id-3",
"name": "timestamp",
"value": "={{ $now.toISO() }}",
"type": "string"
}
]
},
"includeOtherFields": true,
"options": {}
},
"id": "b0c300d8-98c8-4771-a18c-f33246b3f325",
"name": "Workflow Configuration2",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-2560,
5808
]
},
{
"parameters": {
"operation": "download",
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.file_id }}"
},
"options": {
"fileName": "={{ 'contract_' + $now.toFormat('yyyy-MM-dd') }}"
}
},
"id": "a2ec9237-3f68-493f-8aa7-1696571b3e13",
"name": "Download Contract from Google Drive",
"type": "n8n-nodes-base.googleDrive",
"typeVersion": 3,
"position": [
-2336,
5808
]
},
{
"parameters": {
"operation": "pdf",
"options": {}
},
"id": "2dc9120b-2005-482c-b35b-7609ca323adb",
"name": "Extract Text from Document",
"type": "n8n-nodes-base.extractFromFile",
"typeVersion": 1.1,
"position": [
-2112,
5808
]
},
{
"parameters": {