-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Expand file tree
/
Copy pathResumeBot.json
More file actions
3866 lines (3866 loc) · 186 KB
/
Copy pathResumeBot.json
File metadata and controls
3866 lines (3866 loc) · 186 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
{
"nodes": [
{
"parameters": {
"chatId": "={{ ($('Telegram Trigger').item.json.callback_query ? $('Telegram Trigger').item.json.callback_query.message.chat.id : $('Telegram Trigger').item.json.message.chat.id) }}",
"text": "Error parsing your attached file. Ensure it is in .pdf format.",
"additionalFields": {
"appendAttribution": false,
"parse_mode": "HTML"
}
},
"id": "103672de-acf8-4a64-b2cc-dec473d6ffe9",
"name": "Send PDF Error Message",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.1,
"position": [
35184,
138432
],
"webhookId": "39b080ba-2187-40c4-a3d2-88e49ee5bdf5",
"credentials": {
"telegramApi": {
"id": "C4WFoCaBCTYvtSS5",
"name": "AI Agent Bot"
}
}
},
{
"parameters": {
"updates": [
"message",
"callback_query"
],
"additionalFields": {
"download": true
}
},
"id": "a1718ecf-6f76-44e2-9011-557768eca2ec",
"name": "Telegram Trigger",
"type": "n8n-nodes-base.telegramTrigger",
"typeVersion": 1.1,
"position": [
32112,
138832
],
"webhookId": "b1af7cf5-ac6a-49ee-b2b3-b16fd40009a3",
"credentials": {
"telegramApi": {
"id": "C4WFoCaBCTYvtSS5",
"name": "AI Agent Bot"
}
}
},
{
"parameters": {
"operation": "getAll",
"tableId": "Profiles",
"returnAll": true,
"filters": {
"conditions": [
{
"keyName": "telegram_id",
"condition": "eq",
"keyValue": "={{ ($('Telegram Trigger').item.json.callback_query ? $('Telegram Trigger').item.json.callback_query.message.chat.id : $('Telegram Trigger').item.json.message.chat.id) }}"
}
]
}
},
"id": "6844e6a4-a820-40c2-bb56-ea60a26cdf8d",
"name": "Supabase Fetch by ID",
"type": "n8n-nodes-base.supabase",
"typeVersion": 1,
"position": [
32336,
138832
],
"alwaysOutputData": true,
"credentials": {
"supabaseApi": {
"id": "nc9cyvCFuivX90d4",
"name": "Resume Bot"
}
}
},
{
"parameters": {
"jsCode": "const raw = $('Supabase Fetch').first().json.master_profile;\nlet profile = null;\ntry { profile = typeof raw === 'string' ? JSON.parse(raw) : raw; } catch (e) { profile = null; }\n\nconst missing = [];\nconst addMissing = (label) => { if (!missing.includes(label)) missing.push(label); };\nconst hasProfile = profile && typeof profile === 'object';\n\nif (!hasProfile) {\n addMissing('your resume data');\n} else {\n if (!profile.name || !String(profile.name).trim()) addMissing('your full name');\n const contact = profile.contact || {};\n if (!contact.email && !contact.phone) addMissing('a contact email or phone number');\n if (!profile.summary || !String(profile.summary).trim()) addMissing('a short professional summary');\n const hasSkills = Array.isArray(profile.skills) && profile.skills.some((s) => {\n const items = Array.isArray(s?.items) ? s.items.join(', ') : (s?.items ?? s?.skills);\n return items && String(items).trim();\n });\n if (!hasSkills) addMissing('your key skills');\n if (!Array.isArray(profile.education) || profile.education.length === 0) addMissing('your education details');\n if (!Array.isArray(profile.work_experience) || profile.work_experience.length === 0) addMissing('your work experience');\n if (!Array.isArray(profile.projects) || profile.projects.length === 0) addMissing('your projects');\n}\n\nconst isSufficient = missing.length === 0;\nlet prompt = '';\nif (!isSufficient) {\n if (!hasProfile) {\n prompt = 'Your profile is currently empty. Please upload your resume PDF or send your professional details (starting with your full name) to establish your baseline profile.';\n } else {\n prompt = 'Your profile is incomplete. Please provide your ' + missing[0] + ' next to complete your profile. You can paste the text here or upload your resume PDF.';\n }\n}\n\nreturn [{ json: { ...$input.item.json, profile_status: { isSufficient, missing, prompt } } }];"
},
"id": "eb5ba993-bae9-42d9-ad60-32de7220abce",
"name": "Assess Master Profile",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
33456,
138832
]
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ (() => { const msg = $('Telegram Trigger').first().json.message?.text || ''; const text = msg.trim().toLowerCase(); if (!text) return false; const greetings = ['hi','hlo','oi','hoi','yo', 'hello', 'hey', 'hiya', 'good morning', 'good afternoon', 'good evening']; return greetings.some(g => text === g || text.startsWith(g + ' ')); })() }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "918143bf-4a1d-4331-90a8-1aad5f3f830c"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "greeting"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ (() => { const t = ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase(); return t === '/start' || t === '/info'; })() }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "r1fix-info-text-only-aaaa-bbbbcccc"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "info"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ (() => { const msg = ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')); const text = msg.trim().toLowerCase(); return !!text && text.startsWith('/') && text !== '/view' && text !== '/clear' && !$('Assess Master Profile').item.json.profile_status.isSufficient; })() }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "7dd0c85d-cb65-43e0-b225-e1c6266aa5b6"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "profileIncomplete"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ !!$('Telegram Trigger').item.json.message.text }}",
"rightValue": false,
"operator": {
"type": "boolean",
"operation": "false"
},
"id": "fix04-aaaa-1111-bbbb-2222ccccdddd"
},
{
"leftValue": "={{ $('Telegram Trigger').first().json.message?.document ? true : false }}",
"rightValue": false,
"operator": {
"type": "boolean",
"operation": "false"
},
"id": "fix04-eeee-3333-ffff-4444aaaabbbb"
},
{
"leftValue": "={{ $('Telegram Trigger').first().json.callback_query ? true : false }}",
"rightValue": false,
"operator": {
"type": "boolean",
"operation": "false"
},
"id": "fix04-cccc-5555-dddd-6666eeeeffff"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "mediaGuard"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase() }}",
"rightValue": "/view",
"operator": {
"type": "string",
"operation": "equals"
},
"id": "2f0e7dfa-4ab2-428b-8f2d-fb59f66dc905"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "view"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ (() => { const t = ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase(); return t === '/clear'; })() }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "clear-profile-router-id"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "clear"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ $('Telegram Trigger').first().json.message?.document ? true : false }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "43ad1b8d-21e4-49af-9c1b-f36da83100f5"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "pdf"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ $('Telegram Trigger').first().json.message?.document ? true : false }}",
"rightValue": false,
"operator": {
"type": "boolean",
"operation": "false"
},
"id": "22895ab4-8bad-464e-8d42-692854c6525d"
},
{
"leftValue": "={{ ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase() }}",
"rightValue": "/view",
"operator": {
"type": "string",
"operation": "notEquals"
},
"id": "cba85e23-8929-4422-a8db-f90f63e26af0"
},
{
"leftValue": "={{ ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase() }}",
"rightValue": "/download",
"operator": {
"type": "string",
"operation": "notEquals"
},
"id": "9e8d0735-ae9a-46a3-a865-d5e02786eb86"
},
{
"leftValue": "={{ ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase() }}",
"rightValue": "/viewoptimized",
"operator": {
"type": "string",
"operation": "notEquals"
},
"id": "44199f86-2947-4f6d-b86d-8b4fb3e897b6"
},
{
"leftValue": "={{ ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase() }}",
"rightValue": "/downloadoptimized",
"operator": {
"type": "string",
"operation": "notEquals"
},
"id": "d8037150-22bf-46b2-9bfd-77675f44ab92"
},
{
"leftValue": "={{ ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase() }}",
"rightValue": "/start",
"operator": {
"type": "string",
"operation": "notEquals"
},
"id": "981e3c79-f92c-4775-8c89-5c2a197ee67b"
},
{
"leftValue": "={{ ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase() }}",
"rightValue": "/optimize",
"operator": {
"type": "string",
"operation": "notStartsWith"
},
"id": "4b657bfe-b368-4762-b662-bf152bc419a3"
},
{
"leftValue": "={{ ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase() }}",
"rightValue": "/coverletter",
"operator": {
"type": "string",
"operation": "notStartsWith"
},
"id": "cfa85e23-8929-4422-a8db-f90f63e26af1"
},
{
"leftValue": "={{ ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase() }}",
"rightValue": "/analyze",
"operator": {
"type": "string",
"operation": "notStartsWith"
},
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
},
{
"leftValue": "={{ ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase() }}",
"rightValue": "/clear",
"operator": {
"type": "string",
"operation": "notEquals"
},
"id": "clear-chat-exclusion-id"
},
{
"leftValue": "={{ (() => { const msg = $('Telegram Trigger').first().json.message?.text || ''; const text = msg.trim().toLowerCase(); if (!text) return false; const greetings = ['hi','hlo','oi','hoi','yo', 'hello', 'hey', 'hiya', 'good morning', 'good afternoon', 'good evening']; return greetings.some(g => text === g || text.startsWith(g + ' ')); })() }}",
"rightValue": false,
"operator": {
"type": "boolean",
"operation": "false"
},
"id": "4c691f33-d9f0-413c-b584-4536477e1a3d"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "chat"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase() }}",
"rightValue": "/download",
"operator": {
"type": "string",
"operation": "equals"
},
"id": "9dd827b0-90b7-4068-866c-778a0f9b773a"
},
{
"leftValue": "={{ $('Assess Master Profile').item.json.profile_status.isSufficient }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "d229a0fd-0c5c-460f-a8a2-718a4f0d7607"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "download"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase() }}",
"rightValue": "/downloadoptimized",
"operator": {
"type": "string",
"operation": "equals"
},
"id": "390d492d-c55a-475b-80ba-533c11f69ccc"
},
{
"leftValue": "={{ $('Assess Master Profile').item.json.profile_status.isSufficient }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "55fcf488-2778-4e33-a08a-1c3b4b84c2e1"
},
{
"leftValue": "={{ $('Supabase Fetch').first().json.tailored_profile ? true : false }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "fix01-aaaa-bbbb-cccc-ddddeeeeeeee"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "downloadOptimized"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ (() => { const t = ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase(); return t.startsWith('/optimize') && t.replace(/^\\/optimize\\s*/, '').length > 0; })() }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "1c8659fe-12a2-42c3-b3ac-9fa2eb0acae0"
},
{
"leftValue": "={{ $('Assess Master Profile').item.json.profile_status.isSufficient }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "5c351eaa-9558-4c5d-a7c9-7c07c16d62fd"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "optimize"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ (() => { const t = ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase(); return t === '/viewoptimized' || (t === '/downloadoptimized' && !$('Supabase Fetch').first().json.tailored_profile); })() }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "a022defd-3406-4492-b41e-9fd5d998a9b0"
},
{
"leftValue": "={{ $('Assess Master Profile').item.json.profile_status.isSufficient }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "c0f02df8-6613-45db-bbc1-5a4a28e0be07"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "viewOptimized"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase() }}",
"rightValue": "/coverletter",
"operator": {
"type": "string",
"operation": "startsWith"
},
"id": "e568a147-93ad-4463-a1cc-0022b5e89f87"
},
{
"leftValue": "={{ $('Assess Master Profile').item.json.profile_status.isSufficient }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "3a0282d5-67e6-4741-a4f2-cd9760d25cd7"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "coverletter"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ (() => { const t = ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase(); return t.startsWith('/analyze') && t.replace(/^\\/analyze\\s*/, '').length > 0; })() }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "b2c3d4e5-f6a7-8901-bcde-f12345678901"
},
{
"leftValue": "={{ $('Assess Master Profile').item.json.profile_status.isSufficient }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "c3d4e5f6-a7b8-9012-cdef-123456789012"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "analyze"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ (() => { const t = ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase(); return t === '/optimize'; })() }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "e0b4b83a-12a2-42c3-b3ac-9fa2eb0acae2"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "optimizeNoJd"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ (() => { const t = ($('Telegram Trigger').first().json.callback_query ? $('Telegram Trigger').first().json.callback_query.data : ($('Telegram Trigger').first().json.message?.text || '')).trim().toLowerCase(); return t === '/analyze'; })() }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true"
},
"id": "c0b4b83a-e5f6-7890-abcd-ef1234567892"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "analyzeNoJd"
}
]
},
"options": {}
},
"id": "e9e57b51-8c13-425a-81ae-f264511d910f",
"name": "Command Router",
"type": "n8n-nodes-base.switch",
"typeVersion": 3,
"position": [
33680,
138608
]
},
{
"parameters": {
"jsCode": "const raw = $input.item.json.master_profile\n ?? $('Supabase Fetch').first().json.master_profile;\n\nif (!raw) return [{ json: { text: \"📭 No profile found. Send me your resume PDF or tell me about yourself!\" } }];\n\nlet p;\ntry { p = typeof raw === 'string' ? JSON.parse(raw) : raw; }\ncatch(e) { return [{ json: { text: \"❌ Could not read profile data. Try uploading your resume PDF again.\" } }]; }\n\nif (!p || typeof p !== 'object') return [{ json: { text: \"📭 No profile found. Send me your resume PDF!\" } }];\n\nconst hasData = p.name || p.summary || p.tagline\n || (p.skills && p.skills.length > 0)\n || (p.work_experience && p.work_experience.length > 0)\n || (p.education && p.education.length > 0)\n || (p.projects && p.projects.length > 0)\n || (p.certifications && p.certifications.length > 0)\n || (p.contact && (p.contact.email || p.contact.phone));\n\nif (!hasData) return [{ json: { text: \"📭 Your profile appears empty. Please upload your resume PDF or tell me your details!\" } }];\n\nlet msg = `<b>Master Resume Profile</b>\\n━━━━━━━━━━━━━━━━━━━━\\n\\n`;\n\nif (p.name) msg += `<b>${p.name}</b>\\n`;\nif (p.tagline) msg += `<i>${p.tagline}</i>\\n`;\nif (p.name || p.tagline) msg += `\\n`;\n\nif (p.contact) {\n const c = p.contact;\n const hasContact = c.email || c.phone || c.linkedin_display || c.linkedin_url || c.github_display || c.github_url || c.portfolio_display || c.portfolio_url;\n if (hasContact) {\n msg += `<b>Contact Details</b>\\n`;\n if (c.email) msg += ` Email: ${c.email}\\n`;\n if (c.phone) msg += ` Phone: ${c.phone}\\n`;\n if (c.linkedin_display || c.linkedin_url) {\n if (c.linkedin_display && c.linkedin_url && c.linkedin_display !== c.linkedin_url) msg += ` LinkedIn: ${c.linkedin_display} (${c.linkedin_url})\\n`;\n else msg += ` LinkedIn: ${c.linkedin_url || c.linkedin_display}\\n`;\n }\n if (c.github_display || c.github_url) {\n if (c.github_display && c.github_url && c.github_display !== c.github_url) msg += ` GitHub: ${c.github_display} (${c.github_url})\\n`;\n else msg += ` GitHub: ${c.github_url || c.github_display}\\n`;\n }\n if (c.portfolio_display || c.portfolio_url) {\n if (c.portfolio_display && c.portfolio_url && c.portfolio_display !== c.portfolio_url) msg += ` Portfolio: ${c.portfolio_display} (${c.portfolio_url})\\n`;\n else msg += ` Portfolio: ${c.portfolio_url || c.portfolio_display}\\n`;\n }\n msg += `\\n`;\n }\n}\nif (p.summary) msg += `<b>Professional Summary</b>\\n${p.summary}\\n\\n`;\n\nif (p.education && p.education.length > 0) {\n msg += `<b>Education</b>\\n`;\n p.education.forEach(e => {\n msg += ` - <b>${e.degree}</b>\\n ${e.institution}\\n`;\n if (e.score) msg += ` Score: ${e.score}\\n`;\n if (e.year) msg += ` Year: ${e.year}\\n`;\n });\n msg += `\\n`;\n}\n\nif (p.work_experience && p.work_experience.length > 0) {\n msg += `<b>Work Experience</b>\\n`;\n p.work_experience.forEach(w => {\n msg += `\\n <b>${w.title}</b> at ${w.company}`;\n if (w.location) msg += `, ${w.location}`;\n msg += `\\n`;\n if (w.start_date) msg += ` <i>${w.start_date}${w.end_date ? ' – ' + w.end_date : ' – Present'}</i>\\n`;\n if (w.bullet_points && w.bullet_points.length > 0)\n w.bullet_points.forEach(b => msg += ` - ${b}\\n`);\n });\n msg += `\\n`;\n}\n\nif (p.projects && p.projects.length > 0) {\n msg += `<b>Projects</b>\\n`;\n p.projects.forEach(proj => {\n msg += `\\n <b>${proj.name}</b>\\n`;\n if (proj.tech_stack) msg += ` <i>${proj.tech_stack}</i>\\n`;\n if (proj.duration) msg += ` <i>${proj.duration}</i>\\n`;\n if (proj.link_display || proj.link_url) {\n if (proj.link_display && proj.link_url && proj.link_display !== proj.link_url) msg += ` 🔗 ${proj.link_display} (${proj.link_url})\\n`;\n else msg += ` 🔗 ${proj.link_url || proj.link_display}\\n`;\n }\n if (proj.bullet_points && proj.bullet_points.length > 0)\n proj.bullet_points.forEach(b => msg += ` - ${b}\\n`);\n });\n msg += `\\n`;\n}\n\nif (p.skills && p.skills.length > 0) {\n msg += `<b>Technical Skills</b>\\n`;\n p.skills.forEach(s => msg += ` - <b>${s.category || 'Skill'}:</b> ${s.items || s}\\n`);\n msg += `\\n`;\n}\n\nif (p.certifications && p.certifications.length > 0) {\n msg += `<b>Certifications</b>\\n`;\n p.certifications.forEach(cert => {\n msg += ` - <b>${cert.name}</b>\\n ${cert.issuer}`;\n if (cert.year) msg += ` (${cert.year})`;\n msg += `\\n`;\n });\n msg += `\\n`;\n}\n\nif (msg.length <= 4096) return [{ json: { text: msg, isLast: true } }];\nconst chunks = []; let current = '';\nfor (const line of msg.split('\\n')) {\n if ((current + line + '\\n').length > 4000) { chunks.push(current.trim()); current = line + '\\n'; }\n else current += line + '\\n';\n}\nif (current.trim()) chunks.push(current.trim());\nreturn chunks.map((text, index) => ({ json: { text, isLast: index === chunks.length - 1 } }));"
},
"id": "afb2ace1-385b-44ec-9acd-105325b8e06e",
"name": "Format Profile View",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
33968,
138064
]
},
{
"parameters": {
"chatId": "={{ ($('Telegram Trigger').item.json.callback_query ? $('Telegram Trigger').item.json.callback_query.message.chat.id : $('Telegram Trigger').item.json.message.chat.id) }}",
"text": "={{ $json.text }}",
"replyMarkup": "={{ $json.isLast ? 'inlineKeyboard' : 'none' }}",
"forceReply": {},
"inlineKeyboard": {
"rows": [
{
"row": {
"buttons": [
{
"text": "Download PDF",
"additionalFields": {
"callback_data": "/download"
}
}
]
}
}
]
},
"replyKeyboardOptions": {},
"replyKeyboardRemove": {},
"additionalFields": {
"appendAttribution": false,
"disable_web_page_preview": true,
"parse_mode": "HTML"
}
},
"id": "95c37f98-9544-48e4-88d6-db1c277cf919",
"name": "Telegram View Reply",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.1,
"position": [
34256,
138064
],
"webhookId": "4c259a21-b8ae-4725-bfd8-fad039f14906",
"credentials": {
"telegramApi": {
"id": "C4WFoCaBCTYvtSS5",
"name": "AI Agent Bot"
}
}
},
{
"parameters": {
"jsCode": "const msg = $('Telegram Trigger').item.json.callback_query ? $('Telegram Trigger').item.json.callback_query.data : ($('Telegram Trigger').item.json.message.text || '');\nconst isOptimized = msg.toLowerCase().startsWith('/downloadoptimized');\nconst rawTailored = $('Supabase Fetch').first().json.tailored_profile;\nconst rawMaster = $('Supabase Fetch').first().json.master_profile;\nconst rawProfile = isOptimized ? rawTailored : rawMaster;\n\nif (!rawProfile) {\n return [{\n json: {\n text: isOptimized\n ? \"📭 No optimized resume yet. Use `/optimize [paste JD here]` to create one!\"\n : \"📭 No profile found. Please upload your resume PDF first!\"\n }\n }];\n}\nconst p = typeof rawProfile === 'string' ? JSON.parse(rawProfile) : rawProfile;\n\nfunction esc(str) {\n if (!str) return '';\n return String(str)\n .replace(/\\\\/g, '\\\\textbackslash{}')\n .replace(/([&%$#{}])/g, '\\\\$1')\n .replace(/~/g, '\\\\textasciitilde{}')\n .replace(/\\^/g, '\\\\textasciicircum{}')\n .replace(/_/g, '\\\\_');\n}\n\nfunction url(str) {\n if (!str) return '';\n // Only encode characters that would actually break LaTeX href parsing.\n // Do NOT apply esc() to URLs — it breaks underscores and # anchors.\n return String(str).replace(/%/g, '\\\\%').replace(/\\\\/g, '/');\n}\n\nfunction extractUrls(text) {\n if (!text) return [];\n const regex = /(?:https?:\\/\\/|www\\.)[^\\s,\\|'\"]+|[a-zA-Z0-9.-]+\\.(?:com|app|net|io|me|dev|tech|co|org)(?:\\/[^\\s,\\|'\"]*)?/gi;\n return text.match(regex) || [];\n}\n\nfunction getValidUrl(urlStr, displayStr) {\n const urls = [];\n if (urlStr) urls.push(...extractUrls(urlStr));\n if (urls.length === 0 && displayStr) urls.push(...extractUrls(displayStr));\n if (urls.length > 0) {\n let u = urls[0];\n if (!u.startsWith('http')) u = 'https://' + u;\n return u;\n }\n return null;\n}\n\nconst c = p.contact || {};\n\nconst nameBlock = `{\\\\LARGE \\\\textbf{${esc(p.name)}}}`;\nconst taglineBlock = p.tagline ? `\\\\textit{${esc(p.tagline.substring(0, 100))}}` : '';\nconst emailBlock = c.email ? `\\\\href{mailto:${url(c.email)}}{${esc(c.email)}}` : '';\n\nlet phoneBlock = '';\nif (c.phone) {\n const cleanPhone = c.phone.replace(/[^+\\d]/g, '');\n phoneBlock = `\\\\href{tel:${cleanPhone}}{${esc(c.phone)}}`;\n}\n\nfunction getCleanDisplay(urlStr, displayVal, defaultLabel) {\n if (displayVal && displayVal.trim() && displayVal.trim().toLowerCase() !== defaultLabel.toLowerCase()) {\n return displayVal.trim();\n }\n if (urlStr) {\n return urlStr.trim().replace(/^(https?:\\/\\/)?(www\\.)?/, '').replace(/\\/$/, '');\n }\n return defaultLabel;\n}\n\nlet linkedinBlock = '';\nif (c.linkedin_url || c.linkedin_display) {\n const display = getCleanDisplay(c.linkedin_url, c.linkedin_display, 'LinkedIn');\n const u = getValidUrl(c.linkedin_url, c.linkedin_display);\n linkedinBlock = u ? `\\\\href{${url(u)}}{LinkedIn: ${esc(display)}}` : `LinkedIn: ${esc(display)}`;\n}\n\nlet githubBlock = '';\nif (c.github_url || c.github_display) {\n const display = getCleanDisplay(c.github_url, c.github_display, 'GitHub');\n const u = getValidUrl(c.github_url, c.github_display);\n githubBlock = u ? `\\\\href{${url(u)}}{GitHub: ${esc(display)}}` : `GitHub: ${esc(display)}`;\n}\n\nlet portfolioBlock = '';\nif (c.portfolio_url || c.portfolio_display) {\n const display = getCleanDisplay(c.portfolio_url, c.portfolio_display, 'Portfolio');\n const u = getValidUrl(c.portfolio_url, c.portfolio_display);\n portfolioBlock = u ? `\\\\href{${url(u)}}{Portfolio: ${esc(display)}}` : `Portfolio: ${esc(display)}`;\n}\n\nlet row3Right = '';\nlet row4Left = '';\nif (portfolioBlock) {\n row3Right = portfolioBlock;\n row4Left = githubBlock;\n} else {\n row3Right = githubBlock;\n row4Left = '';\n}\n\nlet headerBlock = '\\\\begin{tabular*}{\\\\textwidth}{l@{\\\\extracolsep{\\\\fill}}r}\\n';\nheaderBlock += ` ${nameBlock} & ${emailBlock} \\\\\\\\\\n`;\nheaderBlock += ` ${taglineBlock} & ${phoneBlock} \\\\\\\\\\n`;\nheaderBlock += ` ${linkedinBlock} & ${row3Right} \\\\\\\\\\n`;\nif (row4Left) {\n headerBlock += ` ${row4Left} & \\\\\\\\\\n`;\n}\nheaderBlock += '\\\\end{tabular*}\\n';\n\n\nlet eduBlock = '';\n(p.education || []).forEach(e => {\n eduBlock += ` ${esc(e.degree)} & ${esc(e.institution)} & ${esc(e.score)} & ${esc(e.year)} \\\\\\\\\\n \\\\hline\\n`;\n});\n\nlet expBlock = '';\n(p.work_experience || []).forEach(w => {\n expBlock += ` \\\\resumeSubheading{${esc(w.title)}}{${esc(w.location)}}{${esc(w.company)}}{${esc(w.start_date)} -- ${esc(w.end_date || 'Present')}}\\n`;\n expBlock += ` \\\\resumeItemListStart\\n`;\n (w.bullet_points || []).forEach(b => { expBlock += ` \\\\item {${esc(b)}}\\n`; });\n expBlock += ` \\\\resumeItemListEnd\\n`;\n});\n\nlet projBlock = '';\n(p.projects || []).forEach(proj => {\n let lTex = '';\n const urls = [];\n if (proj.link_url) urls.push(...extractUrls(proj.link_url));\n if (urls.length === 0 && proj.link_display) urls.push(...extractUrls(proj.link_display));\n if (urls.length > 0) {\n let liveDemo = null;\n let github = null;\n for (let u of urls) {\n if (!u.startsWith('http')) u = 'https://' + u;\n if (/github\\.com/i.test(u)) github = u;\n else liveDemo = u;\n }\n if (liveDemo) lTex = `\\\\href{${url(liveDemo)}}{Live Demo}`;\n else if (github) lTex = `\\\\href{${url(github)}}{GitHub}`;\n }\n projBlock += ` \\\\resumeProject{${esc(proj.name)}}{${esc(proj.tech_stack)}}{${esc(proj.duration)}}{${lTex}}\\n`;\n projBlock += ` \\\\resumeItemListStart\\n`;\n (proj.bullet_points || []).forEach(b => { projBlock += ` \\\\item {${esc(b)}}\\n`; });\n projBlock += ` \\\\resumeItemListEnd\\n`;\n});\n\nlet skillBlock = '';\n(p.skills || []).forEach(s => {\n let items = '';\n if (Array.isArray(s.items)) items = s.items.join(', ');\n else if (typeof s.items === 'string') items = s.items;\n else if (s.skills) items = Array.isArray(s.skills) ? s.skills.join(', ') : s.skills;\n if (!items || !items.trim()) return;\n const cat = s.category || s.name || 'Skills';\n skillBlock += ` \\\\resumeSubItem{${esc(cat)}}{${esc(items)}}\\n`;\n});\n\nlet certBlock = '';\n(p.certifications || []).forEach(cert => {\n certBlock += ` \\\\resumePOR{${esc(cert.issuer)}}{${esc(cert.name)}}{${esc(cert.year)}}\\n`;\n});\n\nconst tex = `\\\\documentclass[a4paper,11pt]{article}\n\\\\usepackage{latexsym}\n\\\\usepackage{xcolor}\n\\\\usepackage{float}\n\\\\usepackage{ragged2e}\n\\\\usepackage[empty]{fullpage}\n\\\\usepackage{wrapfig}\n\\\\usepackage{tabularx}\n\\\\usepackage{titlesec}\n\\\\usepackage{geometry}\n\\\\usepackage{marvosym}\n\\\\usepackage{verbatim}\n\\\\usepackage{enumitem}\n\\\\usepackage[hidelinks]{hyperref}\n\\\\usepackage{fancyhdr}\n\\\\usepackage{multicol}\n\\\\usepackage{graphicx}\n\\\\usepackage{cfr-lm}\n\\\\usepackage[T1]{fontenc}\n\\\\setlength{\\\\multicolsep}{0pt}\n\\\\pagestyle{fancy}\n\\\\fancyhf{}\n\\\\fancyfoot{}\n\\\\renewcommand{\\\\headrulewidth}{0pt}\n\\\\renewcommand{\\\\footrulewidth}{0pt}\n\\\\geometry{left=1.4cm, top=0.8cm, right=1.2cm, bottom=1cm}\n\\\\usepackage[most]{tcolorbox}\n\\\\tcbset{frame code={} center title, left=0pt, right=0pt, top=0pt, bottom=0pt, colback=gray!20, colframe=white, width=\\\\dimexpr\\\\textwidth\\\\relax, enlarge left by=-2mm, boxsep=4pt, arc=0pt, outer arc=0pt}\n\\\\urlstyle{same}\n\\\\raggedright\n\\\\setlength{\\\\tabcolsep}{0in}\n\\\\titleformat{\\\\section}{\\\\vspace{-4pt}\\\\scshape\\\\raggedright\\\\large}{}{0em}{}[\\\\color{black}\\\\titlerule \\\\vspace{-7pt}]\n\\\\newcommand{\\\\resumeItem}[2]{\\\\item{\\\\textbf{#1}{: #2 \\\\vspace{-0.5mm}}}}\n\\\\newcommand{\\\\resumePOR}[3]{\\\\vspace{0.5mm}\\\\item\\\\begin{tabular*}{0.97\\\\textwidth}[t]{l@{\\\\extracolsep{\\\\fill}}r}\\\\textbf{#1}: #2 & \\\\textit{\\\\small{#3}}\\\\end{tabular*}\\\\vspace{-2mm}}\n\\\\newcommand{\\\\resumeSubheading}[4]{\\\\vspace{0.5mm}\\\\item\\\\begin{tabular*}{0.98\\\\textwidth}[t]{l@{\\\\extracolsep{\\\\fill}}r}\\\\textbf{#1} & \\\\textit{\\\\footnotesize{#4}} \\\\\\\\ \\\\textit{\\\\footnotesize{#3}} & \\\\footnotesize{#2}\\\\\\\\\\\\end{tabular*}\\\\vspace{-2.4mm}}\n\\\\newcommand{\\\\resumeProject}[4]{\\\\vspace{0.5mm}\\\\item\\\\begin{tabular*}{0.98\\\\textwidth}[t]{l@{\\\\extracolsep{\\\\fill}}r}\\\\textbf{#1} & \\\\textit{\\\\footnotesize{#3}} \\\\\\\\ \\\\footnotesize{\\\\textit{#2}} & \\\\footnotesize{#4}\\\\end{tabular*}\\\\vspace{-2.4mm}}\n\\\\newcommand{\\\\resumeSubItem}[2]{\\\\resumeItem{#1}{#2}\\\\vspace{-4pt}}\n\\\\renewcommand{\\\\labelitemi}{$\\\\vcenter{\\\\hbox{\\\\tiny$\\\\bullet$}}$}\n\\\\newcommand{\\\\resumeSubHeadingListStart}{\\\\begin{itemize}[leftmargin=*,labelsep=0mm]}\n\\\\newcommand{\\\\resumeHeadingSkillStart}{\\\\begin{itemize}[leftmargin=*,itemsep=1.7mm, rightmargin=2ex]}\n\\\\newcommand{\\\\resumeItemListStart}{\\\\begin{justify}\\\\begin{itemize}[leftmargin=3ex, rightmargin=2ex, noitemsep,labelsep=1.2mm,itemsep=0mm]\\\\small}\n\\\\newcommand{\\\\resumeSubHeadingListEnd}{\\\\end{itemize}\\\\vspace{2mm}}\n\\\\newcommand{\\\\resumeHeadingSkillEnd}{\\\\end{itemize}\\\\vspace{-2mm}}\n\\\\newcommand{\\\\resumeItemListEnd}{\\\\end{itemize}\\\\end{justify}\\\\vspace{-2mm}}\n\\\\newcolumntype{L}{>{\\\\raggedright\\\\arraybackslash}X}\n\\\\newcolumntype{R}{>{\\\\raggedleft\\\\arraybackslash}X}\n\\\\newcolumntype{C}{>{\\\\centering\\\\arraybackslash}X}\n\n\\\\begin{document}\n\\\\fontfamily{cmr}\\\\selectfont\n\n${headerBlock}\n\n\\\\section{Profile Summary}\n\\\\vspace{1mm}\n{\\\\small \\\\begin{justify}\\n${esc(p.summary)}\\n\\\\end{justify}}\n\\\\vspace{1mm}\n\n\\\\section{Education}\n\\\\setlength{\\\\tabcolsep}{5pt}\n{\\\\small \\\\begin{tabularx}{\\\\linewidth}{|L|L|c|c|}\n \\\\hline\n \\\\textbf{Degree/Certificate} & \\\\textbf{Institute/Board} & \\\\textbf{Score} & \\\\textbf{Year}\\\\\\\\\n \\\\hline\n${eduBlock}\\\\end{tabularx}}\n\\\\vspace{2mm}\n\n\\\\section{Experience}\n\\\\resumeSubHeadingListStart\n${expBlock}\\\\resumeSubHeadingListEnd\n\\\\vspace{-5.5mm}\n\n\\\\section{Projects}\n\\\\resumeSubHeadingListStart\n${projBlock}\\\\resumeSubHeadingListEnd\n\\\\vspace{-5.5mm}\n\n\\\\section{Technical Skills}\n\\\\resumeHeadingSkillStart\n${skillBlock}\\\\resumeHeadingSkillEnd\n\n\\\\section{Certifications}\n\\\\vspace{-0.2mm}\n\\\\resumeSubHeadingListStart\n${certBlock}\\\\resumeSubHeadingListEnd\n\n\\\\end{document}`;\n\nreturn [{\n json: { success: true, tex_b64: Buffer.from(tex).toString('base64') },\n binary: {\n tex_file: {\n data: Buffer.from(tex).toString('base64'),\n mimeType: 'application/x-tex',\n fileName: `resume_${($('Telegram Trigger').item.json.callback_query ? $('Telegram Trigger').item.json.callback_query.message.chat.id : $('Telegram Trigger').item.json.message.chat.id)}.tex`\n }\n }\n}];"
},
"id": "2e446cd5-78d0-4601-a31b-0a015e4e772f",
"name": "Generate LaTeX",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
34256,
139584
]
},
{
"parameters": {
"command": "=echo \"{{ ($('Telegram Trigger').item.json.callback_query ? $('Telegram Trigger').item.json.callback_query.message.chat.id : $('Telegram Trigger').item.json.message.chat.id) }}\" > /tmp/chat_{{ $execution.id }}\necho \"{{ $('Generate LaTeX').item.json.tex_b64 }}\" | base64 -d > /tmp/resume_{{ $execution.id }}.tex\ncd /tmp\npdflatex -interaction=nonstopmode resume_{{ $execution.id }}.tex > /tmp/compile_{{ $execution.id }}.log 2>&1\npdflatex -interaction=nonstopmode resume_{{ $execution.id }}.tex >> /tmp/compile_{{ $execution.id }}.log 2>&1\nif [ $? -eq 0 ] && [ -f resume_{{ $execution.id }}.pdf ]; then\n echo \"SUCCESS\"\nelse\n echo \"COMPILE_ERROR\"\n cat /tmp/compile_{{ $execution.id }}.log\nfi"
},
"id": "b44ccc5f-e7fb-441a-bda2-f4145704ad0a",
"name": "Write LaTeX File",
"type": "n8n-nodes-base.ssh",
"typeVersion": 1,
"position": [
34896,
139488
],
"credentials": {
"sshPassword": {
"id": "E3zS3TopCpOFhIu5",
"name": "SSH Password account"
}
}
},
{
"parameters": {
"jsCode": "const b64 = $input.item.json.stdout.trim();\nconst chatId = ($('Telegram Trigger').item.json.callback_query ? $('Telegram Trigger').item.json.callback_query.message.chat.id : $('Telegram Trigger').item.json.message.chat.id);\nlet texB64 = '';\ntry {\n texB64 = $('Base64 Encode Fixed LaTeX').first().json.fixed_tex_b64;\n} catch (e) {\n try {\n texB64 = $('Generate LaTeX').first().json.tex_b64;\n } catch (err) {\n texB64 = '';\n }\n}\nconst msg = $('Telegram Trigger').item.json.callback_query ? $('Telegram Trigger').item.json.callback_query.data : ($('Telegram Trigger').item.json.message.text || '');\nconst isOptimized = msg.toLowerCase().startsWith('/downloadoptimized');\nconst prefix = isOptimized ? 'resume_optimized' : 'resume';\nreturn [{\n json: { success: true },\n binary: {\n pdf_doc: {\n data: b64,\n mimeType: 'application/pdf',\n fileName: `${prefix}_${chatId}.pdf`\n },\n tex_file: {\n data: texB64,\n mimeType: 'application/x-tex',\n fileName: `${prefix}_${chatId}.tex`\n }\n }\n}];"
},
"id": "a7f3d4b7-7b83-4431-a26b-3de9c030b2ec",
"name": "Decode PDF Binary",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
37120,
139584
]
},
{
"parameters": {
"operation": "sendDocument",
"chatId": "={{ ($('Telegram Trigger').item.json.callback_query ? $('Telegram Trigger').item.json.callback_query.message.chat.id : $('Telegram Trigger').item.json.message.chat.id) }}",
"binaryData": true,
"binaryPropertyName": "pdf_doc",
"additionalFields": {
"caption": "Here is your compiled, ATS-friendly resume!",
"parse_mode": "HTML"
}
},
"id": "5d2061b0-1767-403d-97ec-0d74f544e1b9",
"name": "Send PDF (Telegram)",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.1,
"position": [
37344,
139216
],
"webhookId": "d53fcf7a-fa23-465d-a986-390f05874262",
"credentials": {
"telegramApi": {
"id": "C4WFoCaBCTYvtSS5",
"name": "AI Agent Bot"
}
}
},
{
"parameters": {
"operation": "sendDocument",
"chatId": "={{ ($('Telegram Trigger').item.json.callback_query ? $('Telegram Trigger').item.json.callback_query.message.chat.id : $('Telegram Trigger').item.json.message.chat.id) }}",
"binaryData": true,
"binaryPropertyName": "tex_file",
"additionalFields": {
"caption": "Here is the editable LaTeX source (.tex). You can customize it in Overleaf or any LaTeX editor.",
"parse_mode": "HTML"
}
},
"id": "31a12241-f462-475f-8e81-b64d2ff62ac1",
"name": "Send LaTeX Source (Telegram)",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.1,
"position": [
37344,
139680
],
"webhookId": "latex-src-webhook-001",
"credentials": {
"telegramApi": {
"id": "C4WFoCaBCTYvtSS5",
"name": "AI Agent Bot"
}
}
},
{
"parameters": {
"jsCode": "const triggerItem = $('Telegram Trigger').item;\nreturn [{ json: $input.item.json, binary: triggerItem.binary }];"
},
"id": "08903e92-6392-42fd-8c9a-2828355d009f",
"name": "Reattach Binary",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
34544,
138448
]
},
{
"parameters": {
"operation": "pdf",
"options": {}
},
"id": "638048c6-53f4-4d56-a396-0b5a39da84d3",
"name": "Extract PDF Text",
"type": "n8n-nodes-base.extractFromFile",
"typeVersion": 1,
"position": [
34896,
138448
],
"onError": "continueErrorOutput"
},
{
"parameters": {
"jsCode": "return { json: { promptText: \"I have uploaded my existing resume. Please parse this unstructured text and carefully map it into my structured master_profile database object. Here is the raw PDF text:\\n\\n\" + $input.item.json.text } };"
},
"id": "5fd945e0-62c1-401a-a6f1-1590e2b73a98",
"name": "Format PDF Prompt",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
35184,
138624
]
},
{
"parameters": {
"jsCode": "return { json: { promptText: $('Telegram Trigger').item.json.message.text } };"
},
"id": "25089ce7-f409-4f9e-9e81-8977f3dfdc42",
"name": "Format Chat Prompt",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
35184,
139216
]
},
{
"parameters": {
"promptType": "define",
"text": "={{ $json.promptText }}",
"needsFallback": true,
"options": {
"systemMessage": "You are an expert AI Resume assistant. Your job is to extract user information and perfectly structure it for a LaTeX compiler.\n\n[USER CONTEXT FROM DATABASE]\n{{ $('Supabase Fetch').first().json.master_profile ? (typeof $('Supabase Fetch').first().json.master_profile === 'string' ? JSON.stringify(JSON.parse($('Supabase Fetch').first().json.master_profile), null, 2) : JSON.stringify($('Supabase Fetch').first().json.master_profile, null, 2)) : 'NO_PROFILE' }}\n\n\n[CRITICAL DATA PRESERVATION & MERGING RULES]\n- The data under `[USER CONTEXT FROM DATABASE]` represents the user's current master profile and is your absolute baseline.\n- **INCREMENTAL MERGING**: When the user chats to update their profile, you MUST only modify, add, or delete the specific fields/facts mentioned in their message. \n- **PRESERVE UNCHANGED DATA**: All other existing fields, bullet points, sections, and values in the `master_profile` that are not explicitly updated or removed by the user's current message MUST be copied and preserved EXACTLY.\n- **NEVER WIPE OUT EXISTING DATA**: If the user corrects a single field (e.g., their name or email), you must update only that specific field in `master_profile` while keeping the rest of their profile (e.g. contact, education, work experience, projects, skills, and certifications) completely intact. Never return a profile that only contains the new information while omitting the old.\n- **CONVERSATIONAL PROFILE QUERIES**: If the user asks a question about their saved profile or resume details (e.g., \"What was my Semester 1 mark?\", \"Did I add Python to my skills?\", \"What is my GPA?\", etc.), you MUST analyze their saved profile under `[USER CONTEXT FROM DATABASE]` to answer their question.\n - Set `profile_updated` to `false` (since no new information is being added or updated).\n - In `chat_reply`, provide a clear, direct, and concise answer to their question in a highly natural, human voice.\n - Return `master_profile` exactly as-is without any modifications.\n - If the profile is empty or does not contain the requested information, explain politely and clearly what is missing or that the profile has not been created yet.\n\n\n\n[TAGLINE RULE]\nThe `tagline` MUST strictly be a short role title ONLY (e.g., 'Full-stack developer and UI/UX designer', 'Software Engineer', 'Data Scientist'). Do NOT write descriptive sentences or add extra context (e.g., no 'building production-ready applications'). Keep it under 50 characters.\n\n[HUMAN WRITING STYLE & TONE RULES (CRITICAL ANTI-AI CONSTRAINTS)]\nTo ensure all generated resume content (summaries, tagline, bullet points), cover letters, and chat responses look and sound like highly natural, professional, human-written text rather than robotic AI-generated text, you MUST adhere to the following rules:\n\n1. HARD CONSTRAINT ON EM DASHES AND DOUBLE HYPHENS:\n - Your final output MUST contain absolutely no em dashes (—), en dashes (–), or double hyphens (--, ---) inside text sentences.\n - Replace each one using a period (to start a new sentence), a comma (for tight asides), a colon (introducing explanation), or parentheses (for true asides), or restructure the sentence entirely.\n\n2. COPULA AVOIDANCE (USE SIMPLE \"IS/ARE/HAS/HAVE\"):\n - Do not replace simple copulas with elaborate constructions like \"serves as\", \"stands as\", \"boasts\", \"features\", \"offers\", or \"marks\".\n - Use simple verbs like \"is\", \"are\", \"has\", \"have\", or direct active verbs (e.g., instead of \"boasts 5 years of experience\", write \"has 5 years of experience\").\n\n3. BANNED \"AI VOCABULARY\" WORDS:\n - Do not use high-frequency AI words. Banned list: align with, crucial, delve, emphasizing, enduring, enhance, fostering, garner, highlight (verb), interplay, intricate, intricacies, key (adjective), landscape (abstract), pivotal, showcase, tapestry, testament, underscore (verb), valuable, vibrant, seamlessly, cutting-edge, revolutionary, leverage, leveraging, transformative, meticulously, expertly, proven track record, elevate, multifaceted, catalyst, passionate.\n\n4. NO SUPERFICIAL \"-ING\" ENDINGS:\n - Do not tack present participle clauses onto the end of sentences to pad the length (e.g., avoid: \"...highlighting X\", \"...ensuring Y\", \"...reflecting Z\", \"...fostering W\", \"...encompassing K\"). Write these as independent clauses or separate sentences.\n\n5. AVOID PERSUASIVE AND NOTABILITY PUFFERY:\n - Do not add artificial statements about legacy, significance, or broader trends (e.g., \"marking a pivotal moment\", \"setting the stage for\", \"indelible mark\", \"testament to\", \"deeply rooted\"). Keep it completely factual, direct, and grounded.\n - Do not use persuasive tropes like \"At its core\", \"In reality\", \"What really matters is\", \"Fundamentally\".\n\n6. STRUCTURAL RULES (RULE OF THREE, BOLDING, NEGATIVE PARALLELISMS):\n - Avoid forcing bullet points or lists into rigid groups of three (the \"rule of three\" tell). Let items have natural lengths.\n - Avoid boldface overuse inside text blocks.\n - Do not use negative parallelisms like \"Not only... but also...\" or tailing negation fragments (e.g. \"no guessing\"). Write clean, direct active clauses.\n - Avoid passive voice; use clear, direct active voice.\n\n\n8. STRICTLY NO EMOJIS:\n - You are completely banned from using any emojis anywhere in the profile data or chat reply. Do not use emojis in bullet points, project names, or summaries.\n\n7. NATURAL VOICE AND SOUL:\n - Write with a grounded, calm, and understated voice. Avoid overly eager, sycophantic, or enthusiastic chatbot phrases (e.g., do not say \"Great! Here is X\", \"I hope this helps!\", \"Certainly!\").\n - When writing cover letters, avoid generic, excited introductions. Start directly with a clear, calm statement of interest and alignment with the role.\n\n[RESUME CONTENT & QUALITY RULES (CRITICAL ATS & IMPACT IMPROVEMENTS)]\n1. QUANTIFY IMPACT: Ensure bullet points in work experience and projects include specific, tangible metrics (e.g., percentage increases, time saved, project outcomes, scale of data/traffic) where possible rather than just listing duties.\n2. ACTION-ORIENTED LANGUAGE: Use strong, varied active verbs at the start of bullet points. Avoid repeating the same verbs across different sections.\n3. CRISPNESS & CONCISENESS: Keep bullet points crisp, concise, and focused on key achievements. Avoid filler words and overly wordy descriptions.\n4. ATS KEYWORDS: Naturally integrate role-specific keywords and searchability terminology.\n5. FORMAL & CONSISTENT TONE: Maintain a professional, consistent third-person tone (no personal pronouns) and avoid clichés or buzzwords. Ensure uniform formatting and bullet styles across all sections.\n\n[PROFILE SUMMARY AUTO-REFRESH ON EVERY UPDATE]\nEvery time the user provides new information and profile_updated = true, you MUST rewrite the 'summary' field in master_profile to accurately reflect ALL current profile data — including any newly added or modified details such as updated CGPA, new certifications, new work experience, new projects, or new skills. Never leave the summary stale or contradicting the rest of the profile. The summary should be 3-5 concise sentences written in a professional third-person tone (NO first-person pronouns like 'I', 'me', 'my', 'we'). It must NOT start with 'I am [Name]' or similar. Start directly with the professional role/description (e.g., 'Computer Science undergraduate at CET (2027), focused on...'). Focus on key skills, engineering fundamentals, building reliable software, and notable projects. Apply all the Human Writing Style rules above when rewriting the summary.\n\n[MANDATORY PROFILE SUMMARY FORMAT (CRITICAL)]\n- The 'summary' field MUST NOT contain any first-person pronouns ('I', 'me', 'my', 'we', 'our') or name introductions (e.g., 'I am John Doe', 'John Doe is...').\n- The 'summary' field MUST strictly follow the third-person tone and start directly with a professional noun phrase describing the candidate (e.g., 'Computer Science undergraduate at CET (2027), focused on...').\n- Clean and rewrite the summary to enforce this format on EVERY parse, every update, and every optimization. Never copy a summary verbatim if it violates these rules.\n\n[CRITICAL INSTRUCTION: STRICT JSON SCHEMA]\nYou MUST output ONLY a raw JSON object and nothing else. The JSON must contain exactly these three keys:\n1. \"chat_reply\": Your friendly natural language response.\n2. \"profile_updated\": boolean. Set TRUE if ANY new info was added, FALSE if no new facts.\n3. \"master_profile\": { name, tagline, contact: { email, phone, linkedin_url, linkedin_display, github_url, github_display, portfolio_url, portfolio_display }, summary, skills: [{category, items}], work_experience: [{ title, company, location, start_date, end_date, bullet_points: [] }], education: [{ degree, institution, score, year }], projects: [{ name, tech_stack, duration, link_url, link_display, bullet_points: [] }], certifications: [{ issuer, name, year }] }"
}
},
"id": "443571ea-7597-46f6-97b7-50790ae7699f",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [
35472,
138528
],
"retryOnFail": true,
"maxTries": 3,
"waitBetweenTries": 3000
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "={{ ($('Telegram Trigger').item.json.callback_query ? $('Telegram Trigger').item.json.callback_query.message.chat.id : $('Telegram Trigger').item.json.message.chat.id) }}"
},
"id": "69cd0498-47ba-4969-8fa4-76367a72069b",
"name": "Window Buffer Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1.2,
"position": [
35664,
138752
]
},
{
"parameters": {
"jsCode": "let rawText = $input.item.json.output || \"\";\nlet parsed = {};\ntry {\n let cleaned = rawText.replace(/```json|```/gi, \"\").trim();\n const jsonMatch = cleaned.match(/\\{[\\s\\S]*\\}/);\n if (jsonMatch) cleaned = jsonMatch[0];\n parsed = JSON.parse(cleaned);\n if (typeof parsed.profile_updated === \"string\") parsed.profile_updated = parsed.profile_updated.toLowerCase() === \"true\";\n if (parsed.profile_updated === undefined) parsed.profile_updated = !!parsed.master_profile;\n\n const existingRow = $(\"Supabase Fetch\").first().json;\n const isNewUser = !existingRow || !existingRow.telegram_id;\n const hasProfileData = parsed.master_profile && typeof parsed.master_profile === \"object\" && Object.keys(parsed.master_profile).length > 0;\n if (isNewUser && hasProfileData) parsed.profile_updated = true;\n} catch (e) {\n parsed = { chat_reply: \"Sorry, I had trouble parsing that. Could you try again?\", profile_updated: false, master_profile: null };\n}\n\nconst buildStatus = (profile) => {\n const missing = [];\n const addMissing = (label) => { if (!missing.includes(label)) missing.push(label); };\n const hasProfile = profile && typeof profile === \"object\";\n\n if (!hasProfile) {\n addMissing(\"your resume data\");\n } else {\n if (!profile.name || !String(profile.name).trim()) addMissing(\"your full name\");\n const contact = profile.contact || {};\n if (!contact.email && !contact.phone) addMissing(\"a contact email or phone number\");\n if (!profile.summary || !String(profile.summary).trim()) addMissing(\"a short professional summary\");\n const hasSkills = Array.isArray(profile.skills) && profile.skills.some((s) => {\n const items = Array.isArray(s?.items) ? s.items.join(\", \") : (s?.items ?? s?.skills);\n return items && String(items).trim();\n });\n if (!hasSkills) addMissing(\"your key skills\");\n if (!Array.isArray(profile.education) || profile.education.length === 0) addMissing(\"your education details\");\n if (!Array.isArray(profile.work_experience) || profile.work_experience.length === 0) addMissing(\"your work experience\");\n if (!Array.isArray(profile.projects) || profile.projects.length === 0) addMissing(\"your projects\");\n }\n\n const isSufficient = missing.length === 0;\n let prompt = \"\";\n if (!isSufficient) {\n if (!hasProfile) {\n prompt = \"Your profile is currently empty. Please upload your resume PDF or send your professional details (starting with your full name) to establish your baseline profile.\";\n } else {\n prompt = \"Your profile is incomplete. Please provide your \" + missing[0] + \" next to complete your profile. You can paste the text here or upload your resume PDF.\";\n }\n }\n\n return { isSufficient, missing, prompt };\n};\n\nconst rawProfile = parsed.master_profile ?? $(\"Supabase Fetch\").first().json.master_profile;\nlet profile = null;\ntry { profile = typeof rawProfile === \"string\" ? JSON.parse(rawProfile) : rawProfile; } catch (e) { profile = null; }\n\nconst profile_status = buildStatus(profile);\nparsed.profile_status = profile_status;\n\n// Only append incomplete-profile nudge when the user just updated their profile\n// (not on every query/reply while profile is still being built up)\nif (profile_status.prompt && parsed.profile_updated === true) {\n parsed.chat_reply = parsed.chat_reply ? parsed.chat_reply + \"\\n\\n\" + profile_status.prompt : profile_status.prompt;\n}\n\nreturn [{ json: parsed }];"
},
"id": "6e16fd29-888e-40cb-b14b-a836b7b503a1",
"name": "Parse JSON",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
35936,
138624
]
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{ $json.profile_updated }}",
"value2": true
}
]
}
},
"id": "6bfc3a0b-f3d4-4034-9621-d4cb4b2b1834",
"name": "Profile Updated?",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
36448,
138624
]
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $('Supabase Fetch').item.json.telegram_id }}",
"operation": "isNotEmpty"
}
]
}
},
"id": "57ab8fb2-7c6a-4630-aee3-b29014f83303",
"name": "Row Exists?",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
36672,
138560
]
},
{
"parameters": {
"operation": "update",
"tableId": "Profiles",
"filters": {
"conditions": [
{
"keyName": "telegram_id",
"condition": "eq",
"keyValue": "={{ ($('Telegram Trigger').item.json.callback_query ? $('Telegram Trigger').item.json.callback_query.message.chat.id : $('Telegram Trigger').item.json.message.chat.id) }}"
}
]
},
"fieldsUi": {
"fieldValues": [
{
"fieldId": "master_profile",
"fieldValue": "={{ JSON.stringify($('Safe Profile Merge').item.json.master_profile) }}"
},
{
"fieldId": "telegram_username",
"fieldValue": "={{ ($('Telegram Trigger').item.json.callback_query ? $('Telegram Trigger').item.json.callback_query.from.username : $('Telegram Trigger').item.json.message.from.username) }}"
}
]
}
},
"id": "14e8fe37-44f1-4ba2-b466-373dbd6bf5d6",
"name": "Supabase Update",
"type": "n8n-nodes-base.supabase",
"typeVersion": 1,
"position": [