-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuto_Comment_reply (1).json
More file actions
2222 lines (2222 loc) Β· 65.4 KB
/
Auto_Comment_reply (1).json
File metadata and controls
2222 lines (2222 loc) Β· 65.4 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": "Auto Comment reply",
"nodes": [
{
"parameters": {},
"id": "7e4c789d-8a45-4528-b0df-77841d09e371",
"name": "Cron - Daily Post Trigger",
"type": "n8n-nodes-base.cron",
"position": [
-5140,
-1200
],
"typeVersion": 1
},
{
"parameters": {
"documentId": {
"__rl": true,
"value": "1pwmyByA5m0dErOhLutIXjCdMcuL5KHaEVyrieVWnGic",
"mode": "list",
"cachedResultName": "E- commerce ",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pwmyByA5m0dErOhLutIXjCdMcuL5KHaEVyrieVWnGic/edit?usp=drivesdk"
},
"sheetName": {
"__rl": true,
"value": 1038482886,
"mode": "list",
"cachedResultName": "Sheet5",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pwmyByA5m0dErOhLutIXjCdMcuL5KHaEVyrieVWnGic/edit#gid=1038482886"
},
"filtersUI": {
"values": [
{
"lookupColumn": "Status "
}
]
},
"options": {}
},
"id": "7eee3a8f-068f-43ba-9383-0a82a469ee4e",
"name": "Google Sheets - Get Post",
"type": "n8n-nodes-base.googleSheets",
"position": [
-4920,
-1200
],
"typeVersion": 4.6,
"credentials": {
"googleSheetsOAuth2Api": {
"id": "bu0ChUOj3XcpBA2x",
"name": "Google Sheets account"
}
}
},
{
"parameters": {},
"type": "n8n-nodes-base.limit",
"typeVersion": 1,
"position": [
-4700,
-1200
],
"id": "675a6523-f92a-4082-8c6a-39077b82ad12",
"name": "Limit"
},
{
"parameters": {
"method": "POST",
"url": "https://graph.facebook.com/717040184826000/feed",
"sendBody": true,
"contentType": "form-urlencoded",
"bodyParameters": {
"parameters": [
{
"name": "message",
"value": "={{ $json['Facebook post '] }}\n\n{{ $json.Keywords }}"
},
{
"name": "access_token",
"value": "EAALOzZC6yAa4BPQJwqn4SZAsWoI9eVFLiziX82hgDsRUETCRHAMGzgsRIlUNZBofMZCEBqleJZAhEatlxNBytG7QZAv5UePrVZABB0cNXCd0Ha0GYwMW5d2hAohi8U4BP4HDI0hmSRsU5Gg81eVmXwgUQWxXSUaYdF9ZByuI64yB6Ob45x1a8iUIQEcf5dP1ikucoTkBtAZDZD"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-4480,
-1200
],
"id": "58c6908b-2502-43eb-937e-9b194f6eb965",
"name": "Facebook Status Post "
},
{
"parameters": {
"promptType": "define",
"text": "=You are a social media assistant. Answer in a short, friendly way. If user asks for price, say: Thank you or Any kind of sentecne for love. with emoji\n\nHere is the comment: {{ $json.body.entry[0].changes[0].value.message }}\n\n\nhere is the Id name : {{ $json.body.entry[0].changes[0].value.from.name }}\n\nhere is the Comment Id : {{ $json.body.entry[0].changes[0].value.comment_id }}",
"hasOutputParser": true,
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 2,
"position": [
-6280,
-3440
],
"id": "2c78f80a-920f-4ab7-a4cb-04a68443197f",
"name": "AI Agent"
},
{
"parameters": {
"jsCode": "// Safely get the message from the input field\nconst inputData = items[0]?.json || {};\nconst rawMessage = inputData.output || \"\";\n\n// Replace line breaks with \\u000A\nconst formattedMessage = rawMessage.replace(/\\n/g, \"\\\\u000A\");\n\n// Return the updated JSON\nreturn [\n {\n json: {\n ...inputData,\n formattedMessage,\n },\n },\n];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-5900,
-3440
],
"id": "d4b2ac2c-1d4c-4494-b281-1cb820e8db97",
"name": "Code"
},
{
"parameters": {
"method": "POST",
"url": "=https://graph.facebook.com/v21.0/ {{ $('Webhook').item.json.body.entry[0].changes[0].value.comment_id }}/comments\n",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer EAALVS2XwV2sBPVvCZB8RDO6kp4H3siRDp27dVsA5qQ4xL5rCm0I7av81VhFULaF3UHc9DetKlmkaVvZBzbifcY7NvPZAQWVonIZAKHKvCiTFuLBGtPaEnzZBMeOmubuKrcm5p8amTRBzolLYXUWiRbCfp0GIJc82bYuH0rTaQbEUD7ryELZB6G0rSxHMNlBigAHfsszAZDZD"
}
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "message",
"value": "={{ $json.formattedMessage }}"
}
]
},
"options": {
"response": {}
}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-5440,
-3420
],
"id": "84d95612-d081-4980-9329-91eeaca5dd31",
"name": "HTTP Request"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
-4720,
-2800
],
"id": "e083b15b-283b-4e99-888a-cdcc0974a0f3",
"name": "OpenAI Chat Model1",
"credentials": {
"openAiApi": {
"id": "G1jwiFKZXNXg2sh6",
"name": "Api4"
}
}
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "Key",
"contextWindowLength": 10
},
"type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
"typeVersion": 1.3,
"position": [
-4560,
-2800
],
"id": "a9e4b472-6c2c-4ddd-ad7f-f986ca25090e",
"name": "Postgres Chat Memory",
"credentials": {
"postgres": {
"id": "bVwtfSqrxfkud4LU",
"name": "Postgres account"
}
}
},
{
"parameters": {
"method": "POST",
"url": "=https://graph.facebook.com/v23.0/{{ $('Webhook').item.json.body.entry[0].messaging[0].recipient.id }}/messages",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "access_token",
"value": "EAALOzZC6yAa4BPQJwqn4SZAsWoI9eVFLiziX82hgDsRUETCRHAMGzgsRIlUNZBofMZCEBqleJZAhEatlxNBytG7QZAv5UePrVZABB0cNXCd0Ha0GYwMW5d2hAohi8U4BP4HDI0hmSRsU5Gg81eVmXwgUQWxXSUaYdF9ZByuI64yB6Ob45x1a8iUIQEcf5dP1ikucoTkBtAZDZD"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"recipient\": {\n \"id\": \" {{ $('Webhook').item.json.body.entry[0].messaging[0].sender.id }}\"\n },\n \"messaging_type\": \"RESPONSE\",\n \"message\": {\n \"text\":\" {{ $json.formattedMessage }} \"\n }\n} ",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-5420,
-2180
],
"id": "f39a2102-1e2a-4478-a249-93a9aaecb1ed",
"name": "HTTP Request3"
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "ee984994-fe35-43a3-80d2-b3ff4e61aad5",
"leftValue": "={{ $json.body.entry[0].messaging[0].message.text }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Text"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "0effeb75-973f-400e-9d02-d1e84aa879d8",
"leftValue": "={{ $json.body.entry[0].messaging[0].message.attachments[0].type }}",
"rightValue": "=image",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Image"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "d3917e1e-7613-4f95-b16e-2109f4214004",
"leftValue": "={{ $json.body.entry[0].messaging[0].message.attachments[0].type }}",
"rightValue": "audio",
"operator": {
"type": "string",
"operation": "equals",
"name": "filter.operator.equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "audio"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "8a62bcbf-a530-4e09-9afc-760a3d7d3c58",
"leftValue": "={{ $json.body.entry[0].changes[0].value.message }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Page Comment"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.switch",
"typeVersion": 3.2,
"position": [
-7700,
-2480
],
"id": "6c269177-16e3-4e8e-aa8f-7fb8e1b2e6d3",
"name": "Switch1"
},
{
"parameters": {
"mode": "retrieve-as-tool",
"toolDescription": "call this tool to get data. ",
"tableName": {
"__rl": true,
"value": "business",
"mode": "list",
"cachedResultName": "business"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
"typeVersion": 1.3,
"position": [
-5200,
-2540
],
"id": "d2a53909-31ed-466e-b247-d65b88822131",
"name": "Supabase Vector Store",
"credentials": {
"supabaseApi": {
"id": "RWFF7blCIC1twvd7",
"name": "Supabase account"
}
}
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"typeVersion": 1.2,
"position": [
-5120,
-2340
],
"id": "7ca53944-24cb-4bd8-89ef-0c959f732ebb",
"name": "Embeddings OpenAI",
"credentials": {
"openAiApi": {
"id": "G1jwiFKZXNXg2sh6",
"name": "Api4"
}
}
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "Key"
},
"type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
"typeVersion": 1.3,
"position": [
-5320,
-2540
],
"id": "9933c0e6-594d-41e7-acf2-d75a3201d9a0",
"name": "Postgres Chat Memory2",
"credentials": {
"postgres": {
"id": "bVwtfSqrxfkud4LU",
"name": "Postgres account"
}
}
},
{
"parameters": {
"operation": "search",
"base": {
"__rl": true,
"value": "appEy1XSRkS5kIw8K",
"mode": "list",
"cachedResultName": "E commerce ",
"cachedResultUrl": "https://airtable.com/appEy1XSRkS5kIw8K"
},
"table": {
"__rl": true,
"value": "tblTaTFdftJbfNnec",
"mode": "list",
"cachedResultName": "Table 1",
"cachedResultUrl": "https://airtable.com/appEy1XSRkS5kIw8K/tblTaTFdftJbfNnec"
},
"returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}",
"options": {}
},
"type": "n8n-nodes-base.airtableTool",
"typeVersion": 2.1,
"position": [
-4920,
-2540
],
"id": "fb84ef02-2a6c-430a-820c-d08111537c0d",
"name": "Airtable2",
"credentials": {
"airtableTokenApi": {
"id": "5fVnXMk6mjAvr5cH",
"name": "n8n connection "
}
}
},
{
"parameters": {
"sendTo": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('To', ``, 'string') }}",
"subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}",
"emailType": "text",
"message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
"options": {
"appendAttribution": false
}
},
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
-4800,
-2540
],
"id": "99511740-1902-409a-acfa-8a8a74a7dc2c",
"name": "Gmail",
"webhookId": "c1718c65-75c8-4ae9-a3bd-8c5418aded09",
"credentials": {
"gmailOAuth2": {
"id": "MSVdhSM7rQAf0Jma",
"name": "Gmail account"
}
}
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "Create a record in Airtable",
"operation": "create",
"base": {
"__rl": true,
"value": "appEy1XSRkS5kIw8K",
"mode": "list",
"cachedResultName": "E commerce ",
"cachedResultUrl": "https://airtable.com/appEy1XSRkS5kIw8K"
},
"table": {
"__rl": true,
"value": "tblFwXqt7BXX4iIjy",
"mode": "list",
"cachedResultName": "Table 2",
"cachedResultUrl": "https://airtable.com/appEy1XSRkS5kIw8K/tblFwXqt7BXX4iIjy"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"Email": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Email', ``, 'string') }}",
"Destination": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Destination', ``, 'string') }}",
"Current quantity": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Current_quantity', ``, 'number') }}",
"Order Quantity": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Order_Quantity', ``, 'number') }}",
"Buyer Name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Buyer_Name', ``, 'string') }}",
"Phone": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Phone', ``, 'string') }}",
"Order Date": "={{ $fromAI('Order_Date', ``, 'string') }}",
"Send email? ": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Send_email__', ``, 'string') }}",
"Products Id": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Products_Id', ``, 'string') }}"
},
"matchingColumns": [
"Buyer name"
],
"schema": [
{
"id": "Buyer Name",
"displayName": "Buyer Name",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "string",
"readOnly": false,
"removed": false
},
{
"id": "Phone",
"displayName": "Phone",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "string",
"readOnly": false,
"removed": false
},
{
"id": "Email",
"displayName": "Email",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "string",
"readOnly": false,
"removed": false
},
{
"id": "Destination",
"displayName": "Destination",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "string",
"readOnly": false,
"removed": false
},
{
"id": "Order Date",
"displayName": "Order Date",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "dateTime",
"readOnly": false,
"removed": false
},
{
"id": "Send email? ",
"displayName": "Send email? ",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "string",
"readOnly": false,
"removed": false
},
{
"id": "Products Id",
"displayName": "Products Id",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "string",
"readOnly": false,
"removed": false
},
{
"id": "Order Quantity",
"displayName": "Order Quantity",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "number",
"readOnly": false,
"removed": false
},
{
"id": "Current quantity",
"displayName": "Current quantity",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "number",
"readOnly": false,
"removed": false
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {
"typecast": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Typecast', ``, 'boolean') }}"
}
},
"type": "n8n-nodes-base.airtableTool",
"typeVersion": 2.1,
"position": [
-4680,
-2540
],
"id": "1af78d26-8943-44ae-a283-f0bfe879ec75",
"name": "Airtable3",
"credentials": {
"airtableTokenApi": {
"id": "5fVnXMk6mjAvr5cH",
"name": "n8n connection "
}
}
},
{
"parameters": {
"model": {
"__rl": true,
"value": "gpt-4o-mini",
"mode": "list",
"cachedResultName": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
-5440,
-2540
],
"id": "c437003e-d556-4d62-92ac-b5b171a0b657",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"id": "G1jwiFKZXNXg2sh6",
"name": "Api4"
}
}
},
{
"parameters": {
"url": "={{ $json.body.entry[0].messaging[0].message.attachments[0].payload.url }}",
"options": {
"response": {
"response": {}
}
}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-5880,
-2560
],
"id": "2051b18e-27a3-4b46-8d38-05a2a05c09d4",
"name": "HTTP Request1"
},
{
"parameters": {
"resource": "audio",
"operation": "transcribe",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.8,
"position": [
-5660,
-2560
],
"id": "e707b182-b1d9-4301-9fa4-6841be65e68e",
"name": "OpenAI",
"credentials": {
"openAiApi": {
"id": "G1jwiFKZXNXg2sh6",
"name": "Api4"
}
}
},
{
"parameters": {
"promptType": "define",
"text": "=Smart Prompt (With Full Order & Current Quantity Update)\n\nYou are an AI Agent connected with Airtable (Products + Orders), Supabase (Company Details), and Gmail.\nAlways follow these rules strictly:\n\n\n---\n\nπ’ General Conversation Rules\n\n1. Always reply in a friendly, human-like tone with emojis.\n\n\n2. Keep answers short, clear, and structured.\n\n\n\n\n---\n\nπ¦ Product Queries (Airtable - Products Table)\n\nIf user asks about products:\nβ
Fetch only from Airtable Products.\nβ
Do NOT say total product count.\nβ
Politely ask for Product ID first.\n\nExample:\n\n> π Sure! Please share the π Product ID so I can show you details.\n\n\n\nProduct Reply Format:\nπ¦ Product Name: XYZ\nπ° Price: $99\nβ
Availability: In Stock (5 left)\n\nβ οΈ Stock Rules:\n\nIf Current Quantity > 0 β Show: \"In Stock (X left)\"\n\nIf Current Quantity = 0 β Show: \"β Out of Stock\"\n\n\nπ‘ Update Rule:\n\nWhen an order is placed:\n\n1. Update Current Quantity = Previous Current Quantity - Ordered Quantity\n\n\n2. Update all other order-related fields (Name, Phone, Email, Destination, Product ID, Quantity, Order Date, Send Email) for that user/order.\n\n\n\nDo NOT create any new field. Only update existing ones.\n\n\n\n---\n\nπ’ Company Queries (Supabase - Company Details)\n\nIf user asks about company details, reply like this:\n\nπ’ Company Name: ABC Ltd\nπ Address: Dhaka\nπ Contact: +8801XXXXXXX\n\n\n---\n\nπ Order Process (Airtable Orders + Gmail)\n\n1. Collect mandatory fields:\nπ€ Name\nπ Phone Number\nπ§ Email\nπ Destination\nπ Product ID\nπ’ Quantity\nπ
Order Date = Automatically set as today ({{ $now }})\nβοΈ Send Email? (Yes/No)\n\n\n\n> β οΈ Do not ask the user for the order date. Always set it automatically as today.\n\n\n\n2. Validate all info. If missing or wrong, ask again nicely.\nExample:\n\n\n\n> β οΈ Oops! I need your π§ Email to confirm the order. Please share it.\n\n\n\n3. Once all info is correct:\n\n\n\nSave order in Airtable Orders.\n\nUpdate Current Quantity in Products = Previous Current Quantity - Ordered Quantity.\n\nUpdate all other user/order-related fields in the order record.\n\nIf Current Quantity becomes 0 β mark product as β Out of Stock.\n\nDo NOT create any new field.\n\nIf Send Email = Yes β send confirmation email via Gmail.\n\n\n4. Confirmation Reply Example:\n\n\n\n> β
Order Confirmed!\nπ¦ Product: XYZ (2 pcs)\nπ€ Name: John Doe\nπ
Date: 24 Aug 2025 (Today)\nβοΈ Confirmation email sent to: john@example.com\n\n\nπ΄ Important Rules\n\nNever mix Airtable (Products/Orders) and Supabase (Company) data in the same answer.\n\nAlways update Current Quantity and all order-related fields only.\n\nAlways double-check order info before confirming.\n\nAlways keep replies polite, professional & engaging.\n\nHere is the Text :{{ $json.text }}",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 2,
"position": [
-5100,
-2760
],
"id": "968ebf19-93a6-4b82-ae2c-5ca6387077e7",
"name": "AI Agent2"
},
{
"parameters": {
"method": "POST",
"url": "=https://graph.facebook.com/v23.0/{{ $('Webhook').item.json.body.entry[0].messaging[0].recipient.id }}/messages",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "access_token",
"value": "EAALOzZC6yAa4BPQJwqn4SZAsWoI9eVFLiziX82hgDsRUETCRHAMGzgsRIlUNZBofMZCEBqleJZAhEatlxNBytG7QZAv5UePrVZABB0cNXCd0Ha0GYwMW5d2hAohi8U4BP4HDI0hmSRsU5Gg81eVmXwgUQWxXSUaYdF9ZByuI64yB6Ob45x1a8iUIQEcf5dP1ikucoTkBtAZDZD"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"recipient\": {\n \"id\": \" {{ $('Webhook').item.json.body.entry[0].messaging[0].sender.id }}\"\n },\n \"messaging_type\": \"RESPONSE\",\n \"message\": {\n \"text\":\" {{ $json.formattedMessage }} \"\n }\n} ",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-4260,
-2560
],
"id": "f7994a8a-989c-415c-8490-cbbfb510dc42",
"name": "HTTP Request4"
},
{
"parameters": {
"jsCode": "// Safely get the message from the input field\nconst inputData = items[0]?.json || {};\nconst rawMessage = inputData.output || \"\";\n\n// Replace line breaks with \\u000A\nconst formattedMessage = rawMessage.replace(/\\n/g, \"\\\\u000A\");\n\n// Return the updated JSON\nreturn [\n {\n json: {\n ...inputData,\n formattedMessage,\n },\n },\n];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-4480,
-2560
],
"id": "39eb93de-8197-4f90-84aa-415c1107f9fc",
"name": "Code1"
},
{
"parameters": {
"url": "={{ $json.body.entry[0].messaging[0].message.attachments[0].payload.url }}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-5720,
-3060
],
"id": "0534372a-db7b-4ef2-b915-32e49ce23a73",
"name": "HTTP Request2"
},
{
"parameters": {
"jsCode": "// Get the current item\nconst item = $input.item;\n\n// Make sure binary data exists\nif (item.binary && item.binary.data) {\n const binaryData = item.binary.data;\n\n // Default MIME type\n let correctMimeType = 'image/jpeg';\n\n // Try to detect from file extension\n const fileExtension = binaryData.fileExtension?.toLowerCase();\n\n if (fileExtension === 'png') {\n correctMimeType = 'image/png';\n } else if (fileExtension === 'gif') {\n correctMimeType = 'image/gif';\n } else if (fileExtension === 'jpg' || fileExtension === 'jpeg') {\n correctMimeType = 'image/jpeg';\n }\n\n // Set the corrected MIME type\n item.binary.data.mimeType = correctMimeType;\n}\n\n// Return the updated item\nreturn item;\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-5500,
-3060
],
"id": "a4807b97-7993-481d-a5b2-775bb34e4ae0",
"name": "Code2"
},
{
"parameters": {
"promptType": "define",
"text": "=You are an AI Assistant connected with a product database. \nYour tasks are: \n\n1οΈβ£ If the user sends an image: \n - Extract all visible text, numbers, or product IDs from the image carefully. \n - Check if any of those IDs or text match with the product IDs in the database. \n\n2οΈβ£ If a match is found: \n - Return only the exact product details from the database. \n - Format response short, clear, and user-friendly with emojis. \n\n3οΈβ£ If no match is found: \n - Politely say: \"Sorry π, And you will suggest Similer products from your database.\"\"\nβ‘ Important Rules: \n- Do not guess or make up product details. \n- Only reply based on confirmed matches from the database. \n- Keep answers friendly and structured with emojis. \n\nπ Example Response (if match found): \n\"β
Product found! \nπ¦ Product Name: Lotion \nπ Product ID: 110 \nπ° Price: $20 \nπ¦ Stock: 5 pieces\"\n\nHere is the content: {{ $json.content }}\n\n\n",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 2,
"position": [
-4660,
-3020
],
"id": "a22913f5-d6c7-4917-b0cd-d576c7dabc6d",
"name": "AI Agent3"
},
{
"parameters": {
"operation": "search",
"base": {
"__rl": true,
"value": "appEy1XSRkS5kIw8K",
"mode": "list",
"cachedResultName": "E commerce ",
"cachedResultUrl": "https://airtable.com/appEy1XSRkS5kIw8K"
},
"table": {
"__rl": true,
"value": "tblTaTFdftJbfNnec",
"mode": "list",
"cachedResultName": "Table 1",
"cachedResultUrl": "https://airtable.com/appEy1XSRkS5kIw8K/tblTaTFdftJbfNnec"
},
"returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}",
"options": {}
},
"type": "n8n-nodes-base.airtableTool",
"typeVersion": 2.1,
"position": [
-4440,
-2800
],
"id": "449d3eb6-4088-426c-aa7f-b30142587c34",
"name": "Airtable4",
"credentials": {
"airtableTokenApi": {
"id": "5fVnXMk6mjAvr5cH",
"name": "n8n connection "
}
}
},
{
"parameters": {
"resource": "image",
"operation": "analyze",
"modelId": {
"__rl": true,
"value": "gpt-4o-mini",
"mode": "list",
"cachedResultName": "GPT-4O-MINI"
},
"text": "Extract this image and inner all data.. ",
"inputType": "base64",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.8,
"position": [
-5280,
-3060
],
"id": "b6c755f0-d46e-46c2-b9a3-2f4aa425dc00",
"name": "OpenAI1",
"credentials": {
"openAiApi": {
"id": "G1jwiFKZXNXg2sh6",
"name": "Api4"
}
}
},
{
"parameters": {
"jsCode": "// Safely get the message from the input field\nconst inputData = items[0]?.json || {};\nconst rawMessage = inputData.output || \"\";\n\n// Replace line breaks with \\u000A\nconst formattedMessage = rawMessage.replace(/\\n/g, \"\\\\u000A\");\n\n// Return the updated JSON\nreturn [\n {\n json: {\n ...inputData,\n formattedMessage,\n },\n },\n];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-5060,
-3060
],
"id": "de9ae9f0-3735-471a-886d-b344336d455b",
"name": "Code3"
},
{
"parameters": {
"jsCode": "// Safely get the message from the input field\nconst inputData = items[0]?.json || {};\nconst rawMessage = inputData.output || \"\";\n\n// Replace line breaks with \\u000A\nconst formattedMessage = rawMessage.replace(/\\n/g, \"\\\\u000A\");\n\n// Return the updated JSON\nreturn [\n {\n json: {\n ...inputData,\n formattedMessage,\n },\n },\n];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-4240,
-3020
],
"id": "c85cbbb9-8b54-4197-bf2a-a0316f900473",
"name": "Code4"
},
{
"parameters": {
"method": "POST",
"url": "=https://graph.facebook.com/v23.0/{{ $('Webhook').item.json.body.entry[0].messaging[0].recipient.id }}/messages",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "access_token",
"value": "EAALOzZC6yAa4BPQJwqn4SZAsWoI9eVFLiziX82hgDsRUETCRHAMGzgsRIlUNZBofMZCEBqleJZAhEatlxNBytG7QZAv5UePrVZABB0cNXCd0Ha0GYwMW5d2hAohi8U4BP4HDI0hmSRsU5Gg81eVmXwgUQWxXSUaYdF9ZByuI64yB6Ob45x1a8iUIQEcf5dP1ikucoTkBtAZDZD"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"recipient\": {\n \"id\": \" {{ $('Webhook').item.json.body.entry[0].messaging[0].sender.id }}\"\n },\n \"messaging_type\": \"RESPONSE\",\n \"message\": {\n \"text\":\" {{ $json.formattedMessage }} \"\n }\n} ",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-4020,
-3020
],
"id": "0d57cc6a-f77f-46e0-bdd3-7b257d960f92",
"name": "HTTP Request5"
},
{
"parameters": {},
"type": "n8n-nodes-base.limit",
"typeVersion": 1,
"position": [
-3300,
-2940
],
"id": "26affd94-c296-4560-a8ea-b1beb3bc28ef",
"name": "Limit1"
},
{
"parameters": {
"promptType": "define",
"text": "=Smart Prompt (With Full Order & Current Quantity Update)\n\nYou are an AI Agent connected with Airtable (Products + Orders), Supabase (Company Details), and Gmail.\nAlways follow these rules strictly:\n\n\n---\n\nπ’ General Conversation Rules\n\n1. Always reply in a friendly, human-like tone with emojis.\n\n\n2. Keep answers short, clear, and structured.\n\n\n\n\n---\n\nπ¦ Product Queries (Airtable - Products Table)\n\nIf user asks about products:\nβ
Fetch only from Airtable Products.\nβ
Do NOT say total product count.\nβ
Politely ask for Product ID first.\n\nExample:\n\n> π Sure! Please share the π Product ID so I can show you details.\n\n\n\nProduct Reply Format:\nπ¦ Product Name: XYZ\nπ° Price: $99\nβ
Availability: In Stock (5 left)\n\nβ οΈ Stock Rules:\n\nIf Current Quantity > 0 β Show: \"In Stock (X left)\"\n\nIf Current Quantity = 0 β Show: \"β Out of Stock\"\n\n\nπ‘ Update Rule:\n\nWhen an order is placed:\n\n1. Update Current Quantity = Previous Current Quantity - Ordered Quantity\n\n\n2. Update all other order-related fields (Name, Phone, Email, Destination, Product ID, Quantity, Order Date, Send Email) for that user/order.\n\n\n\nDo NOT create any new field. Only update existing ones.\n\n\n\n---\n\nπ’ Company Queries (Supabase - Company Details)\n\nIf user asks about company details, reply like this:\n\nπ’ Company Name: ABC Ltd\nπ Address: Dhaka\nπ Contact: +8801XXXXXXX\n\n\n---\n\nπ Order Process (Airtable Orders + Gmail)\n\n1. Collect mandatory fields:\nπ€ Name\nπ Phone Number\nπ§ Email\nπ Destination\nπ Product ID\nπ’ Quantity\nπ
Order Date = Automatically set as today ({{ $now }})\nβοΈ Send Email? (Yes/No)\n\n\n\n> β οΈ Do not ask the user for the order date. Always set it automatically as today.\n\n\n\n2. Validate all info. If missing or wrong, ask again nicely.\nExample:\n\n\n\n> β οΈ Oops! I need your π§ Email to confirm the order. Please share it.\n\n\n\n3. Once all info is correct:\n\n\n\nSave order in Airtable Orders.\n\nUpdate Current Quantity in Products = Previous Current Quantity - Ordered Quantity.\n\nUpdate all other user/order-related fields in the order record.\n\nIf Current Quantity becomes 0 β mark product as β Out of Stock.\n\nDo NOT create any new field.\n\nIf Send Email = Yes β send confirmation email via Gmail.\n\n\n4. Confirmation Reply Example:\n\n\n\n> β
Order Confirmed!\nπ¦ Product: XYZ (2 pcs)\nπ€ Name: John Doe\nπ
Date: 24 Aug 2025 (Today)\nβοΈ Confirmation email sent to: john@example.com\n\n\nπ΄ Important Rules\n\nNever mix Airtable (Products/Orders) and Supabase (Company) data in the same answer.\n\nAlways update Current Quantity and all order-related fields only.\n\nAlways double-check order info before confirming.\n\nAlways keep replies polite, professional & engaging.\n\nHere is the Text : {{ $json.body.entry[0].messaging[0].message.text }}\n",
"hasOutputParser": true,
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 2,
"position": [
-6160,
-2180
],
"id": "60e4d7cd-d826-4dc9-a9dc-5895d6b4f517",
"name": "AI Agent1"
},
{
"parameters": {
"jsCode": "// Safely get the message from the input field\nconst inputData = items[0]?.json || {};\nconst rawMessage = inputData.output || \"\";\n\n// Replace line breaks with \\u000A\nconst formattedMessage = rawMessage.replace(/\\n/g, \"\\\\u000A\");\n\n// Return the updated JSON\nreturn [\n {\n json: {\n ...inputData,\n formattedMessage,\n },\n },\n];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-5640,
-2180
],
"id": "95e2d68a-2c16-4e52-93ef-19ba117c514b",
"name": "Code5"
},
{
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"type": "n8n-nodes-base.telegramTrigger",
"typeVersion": 1.2,
"position": [
-8280,
-1700
],
"id": "e2cd3bd1-5e64-47d9-abe1-c23d5924de54",
"name": "Telegram Trigger",
"webhookId": "7a6a7158-667c-47f9-814b-190b7c53cb43",
"credentials": {
"telegramApi": {
"id": "UXXgucnFNMCDYEzx",
"name": "voice agent "
}
}
},
{
"parameters": {
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"text": "=Your post is The output:\n{{ $json.output }}\n\n\nPlease tap [Post]({{ $execution.resumeUrl }}?answer=post) \n\nor [Do Not Post]({{ $execution.resumeUrl }}?answer=notPost),\n",
"additionalFields": {
"appendAttribution": false
}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
-6400,
-1640
],
"id": "f2c88d81-646c-4897-b7b8-bd40a056b135",
"name": "Telegram",
"webhookId": "aa959d8a-6bf3-4e9b-a1ed-cba074b74f55",
"credentials": {
"telegramApi": {
"id": "UXXgucnFNMCDYEzx",
"name": "voice agent "
}
}
},
{
"parameters": {
"resume": "webhook",
"options": {}