-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Expand file tree
/
Copy pathHandling Appointment Leads and Follow-up With Twilio, Cal.com and AI.json
More file actions
1664 lines (1664 loc) · 43.1 KB
/
Copy pathHandling Appointment Leads and Follow-up With Twilio, Cal.com and AI.json
File metadata and controls
1664 lines (1664 loc) · 43.1 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
{
"meta": {
"instanceId": "408f9fb9940c3cb18ffdef0e0150fe342d6e655c3a9fac21f0f644e8bedabcd9"
},
"nodes": [
{
"id": "f55b3110-f960-4d89-afba-d47bc58102eb",
"name": "Twilio Trigger",
"type": "n8n-nodes-base.twilioTrigger",
"position": [
100,
180
],
"webhookId": "bfc8f587-8183-46f8-9e76-3576caddf8c0",
"parameters": {
"updates": [
"com.twilio.messaging.inbound-message.received"
]
},
"credentials": {
"twilioApi": {
"id": "TJv4H4lXxPCLZT50",
"name": "Twilio account"
}
},
"typeVersion": 1
},
{
"id": "8472f5b0-329f-45ac-b35f-c42558daa7c7",
"name": "OpenAI Chat Model1",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1140,
1360
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "8gccIjcuf3gvaoEr",
"name": "OpenAi account"
}
},
"typeVersion": 1
},
{
"id": "4b3e8a26-c808-46e5-bbcf-2e1279989a0b",
"name": "Find Follow-Up Candidates",
"type": "n8n-nodes-base.airtable",
"position": [
720,
1240
],
"parameters": {
"base": {
"__rl": true,
"mode": "list",
"value": "appO2nHiT9XPuGrjN",
"cachedResultUrl": "https://airtable.com/appO2nHiT9XPuGrjN",
"cachedResultName": "Twilio-Scheduling-Agent"
},
"table": {
"__rl": true,
"mode": "list",
"value": "tblokH7uw63RpIlQ0",
"cachedResultUrl": "https://airtable.com/appO2nHiT9XPuGrjN/tblokH7uw63RpIlQ0",
"cachedResultName": "Lead Tracker"
},
"options": {},
"operation": "search",
"filterByFormula": "=AND(\n {appointment_id} = '',\n {status} != 'STOP',\n {followup_count} < 3,\n DATETIME_DIFF(TODAY(), {last_followup_at}, 'days') >= 3\n)"
},
"credentials": {
"airtableTokenApi": {
"id": "Und0frCQ6SNVX3VV",
"name": "Airtable Personal Access Token account"
}
},
"typeVersion": 2.1
},
{
"id": "04dc979c-ad36-4e57-93d4-905929fe1af0",
"name": "Send Follow Up Message",
"type": "n8n-nodes-base.twilio",
"position": [
1880,
1240
],
"parameters": {
"to": "={{ $('Find Follow-Up Candidates').item.json.session_id }}",
"from": "={{ $('Find Follow-Up Candidates').item.json.twilio_service_number }}",
"message": "={{ $('Generate Follow Up Message').item.json.text }}\nReply STOP to stop recieving these messages.",
"options": {}
},
"credentials": {
"twilioApi": {
"id": "TJv4H4lXxPCLZT50",
"name": "Twilio account"
}
},
"typeVersion": 1
},
{
"id": "55e222af-fb59-4ffd-9661-350b1972e802",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
570,
943
],
"parameters": {
"color": 7,
"width": 408.6631332343324,
"height": 515.2449997772154,
"content": "## Step 6. Filter Open Enquiries from Airtable\n\n### 💡Criteria For Follow Up Candidates\n* No Scheduled Appointment\n* No Request to STOP\n* No Previous Follow-up in Past 3 days\n* Follow-up is less than 3 times"
},
"typeVersion": 1
},
{
"id": "50d0c632-233b-4b31-b396-3fa603aecd03",
"name": "Update Follow-Up Count and Date",
"type": "n8n-nodes-base.airtable",
"position": [
1700,
1240
],
"parameters": {
"base": {
"__rl": true,
"mode": "list",
"value": "appO2nHiT9XPuGrjN",
"cachedResultUrl": "https://airtable.com/appO2nHiT9XPuGrjN",
"cachedResultName": "Twilio-Scheduling-Agent"
},
"table": {
"__rl": true,
"mode": "list",
"value": "tblokH7uw63RpIlQ0",
"cachedResultUrl": "https://airtable.com/appO2nHiT9XPuGrjN/tblokH7uw63RpIlQ0",
"cachedResultName": "Lead Tracker"
},
"columns": {
"value": {
"session_id": "={{ $('Find Follow-Up Candidates').item.json.session_id }}",
"followup_count": "={{ ($('Find Follow-Up Candidates').item.json.followup_count ?? 0) + 1 }}",
"last_followup_at": "={{ $now.toISO() }}"
},
"schema": [
{
"id": "id",
"type": "string",
"display": true,
"removed": true,
"readOnly": true,
"required": false,
"displayName": "id",
"defaultMatch": true
},
{
"id": "session_id",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "session_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "status",
"type": "options",
"display": true,
"options": [
{
"name": "ACTIVE",
"value": "ACTIVE"
},
{
"name": "STOP",
"value": "STOP"
}
],
"removed": true,
"readOnly": false,
"required": false,
"displayName": "status",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "customer_name",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "customer_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "customer_summary",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "customer_summary",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "chat_messages",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "chat_messages",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "scheduled_at",
"type": "dateTime",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "scheduled_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "appointment_id",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "appointment_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "last_message_at",
"type": "dateTime",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "last_message_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "last_followup_at",
"type": "dateTime",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "last_followup_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "followup_count",
"type": "number",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "followup_count",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "assignee",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "assignee",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"session_id"
]
},
"options": {},
"operation": "update"
},
"credentials": {
"airtableTokenApi": {
"id": "Und0frCQ6SNVX3VV",
"name": "Airtable Personal Access Token account"
}
},
"typeVersion": 2.1
},
{
"id": "e1331352-c3da-4586-9d64-4be4dab49748",
"name": "Create/Update Session",
"type": "n8n-nodes-base.airtable",
"position": [
2240,
269
],
"parameters": {
"base": {
"__rl": true,
"mode": "list",
"value": "appO2nHiT9XPuGrjN",
"cachedResultUrl": "https://airtable.com/appO2nHiT9XPuGrjN",
"cachedResultName": "Twilio-Scheduling-Agent"
},
"table": {
"__rl": true,
"mode": "list",
"value": "tblokH7uw63RpIlQ0",
"cachedResultUrl": "https://airtable.com/appO2nHiT9XPuGrjN/tblokH7uw63RpIlQ0",
"cachedResultName": "Lead Tracker"
},
"columns": {
"value": {
"session_id": "={{ $('Twilio Trigger').item.json.From }}",
"scheduled_at": "={{\n$('Appointment Scheduling Agent').item.json.output.has_appointment_scheduled\n ? $('Appointment Scheduling Agent').item.json.output.appointment.scheduled_at\n : (\n $('Get Existing Chat Session').item.json.isNotEmpty()\n ? $('Get Existing Chat Session').item.json.scheduled_at\n : $now.toISO()\n )\n}}",
"chat_messages": "={{\nJSON.stringify(\n ($('Get Existing Chat Session').item.json.chat_messages ? JSON.parse($('Get Existing Chat Session').item.json.chat_messages) : [])\n .concat(\n { \"role\": \"human\", \"message\": $('Twilio Trigger').item.json.Body },\n { \"role\": \"assistant\", \"message\": $('Appointment Scheduling Agent').item.json.output.reply }\n )\n)\n}}",
"customer_name": "={{\n !$('Get Existing Chat Session').item.json.customer_name &&\n $('Appointment Scheduling Agent').item.json.output.customer_name\n ? $('Appointment Scheduling Agent').item.json.output.customer_name\n : ($('Get Existing Chat Session').item.json.customer_name ?? '')\n}}",
"appointment_id": "={{\n$('Appointment Scheduling Agent').item.json.output.has_appointment_scheduled\n ? $('Appointment Scheduling Agent').item.json.output.appointment.appointment_id\n : (\n $('Get Existing Chat Session').item.json.isNotEmpty()\n ? $('Get Existing Chat Session').item.json.appointment_id\n : ''\n )\n}}",
"followup_count": "={{\n !$('Get Existing Chat Session').item.json.followup_count\n ? 0\n : $('Get Existing Chat Session').item.json.followup_count\n}}",
"last_message_at": "={{ $now.toISO() }}",
"customer_summary": "={{\n !$('Get Existing Chat Session').item.json.appointment_id\n && $('Appointment Scheduling Agent').item.json.output.has_appointment_scheduled\n ? $json.output.enquiry_summary\n : $('Get Existing Chat Session').item.json.customer_summary\n}}",
"last_followup_at": "={{\n !$('Get Existing Chat Session').item.json.last_followup_at\n ? $now.toISO()\n : $('Get Existing Chat Session').item.json.last_followup_at\n}}",
"twilio_service_number": "={{ $('Twilio Trigger').item.json.To }}"
},
"schema": [
{
"id": "id",
"type": "string",
"display": true,
"removed": true,
"readOnly": true,
"required": false,
"displayName": "id",
"defaultMatch": true
},
{
"id": "session_id",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "session_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "status",
"type": "options",
"display": true,
"options": [
{
"name": "ACTIVE",
"value": "ACTIVE"
},
{
"name": "STOP",
"value": "STOP"
}
],
"removed": true,
"readOnly": false,
"required": false,
"displayName": "status",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "customer_name",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "customer_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "customer_summary",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "customer_summary",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "chat_messages",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "chat_messages",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "scheduled_at",
"type": "dateTime",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "scheduled_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "appointment_id",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "appointment_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "last_message_at",
"type": "dateTime",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "last_message_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "last_followup_at",
"type": "dateTime",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "last_followup_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "followup_count",
"type": "number",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "followup_count",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "assignee",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "assignee",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "twilio_service_number",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "twilio_service_number",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"session_id"
]
},
"options": {},
"operation": "update"
},
"credentials": {
"airtableTokenApi": {
"id": "Und0frCQ6SNVX3VV",
"name": "Airtable Personal Access Token account"
}
},
"typeVersion": 2.1
},
{
"id": "de8eaa46-2fe8-4afd-a400-9c528f578d24",
"name": "Get Existing Chat Session",
"type": "n8n-nodes-base.airtable",
"position": [
740,
240
],
"parameters": {
"base": {
"__rl": true,
"mode": "list",
"value": "appO2nHiT9XPuGrjN",
"cachedResultUrl": "https://airtable.com/appO2nHiT9XPuGrjN",
"cachedResultName": "Twilio-Scheduling-Agent"
},
"limit": 1,
"table": {
"__rl": true,
"mode": "list",
"value": "tblokH7uw63RpIlQ0",
"cachedResultUrl": "https://airtable.com/appO2nHiT9XPuGrjN/tblokH7uw63RpIlQ0",
"cachedResultName": "Lead Tracker"
},
"options": {},
"operation": "search",
"returnAll": false,
"filterByFormula": "={session_id}=\"{{ $('Twilio Trigger').item.json.From }}\""
},
"credentials": {
"airtableTokenApi": {
"id": "Und0frCQ6SNVX3VV",
"name": "Airtable Personal Access Token account"
}
},
"typeVersion": 2.1,
"alwaysOutputData": true
},
{
"id": "16aabbf0-fdf7-4940-a3a3-962e0b877299",
"name": "Every 24hrs",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
220,
1160
],
"parameters": {
"rule": {
"interval": [
{}
]
}
},
"typeVersion": 1.2
},
{
"id": "9471b840-3a59-491d-a309-180d5a69fb7e",
"name": "Send Reply",
"type": "n8n-nodes-base.twilio",
"position": [
2420,
269
],
"parameters": {
"to": "={{ $('Twilio Trigger').item.json.From }}",
"from": "={{ $('Twilio Trigger').item.json.To }}",
"message": "={{ $('Appointment Scheduling Agent').item.json.output.reply }}",
"options": {}
},
"credentials": {
"twilioApi": {
"id": "TJv4H4lXxPCLZT50",
"name": "Twilio account"
}
},
"typeVersion": 1
},
{
"id": "601aa9ea-f3f4-49bd-a391-84e32c47f7ba",
"name": "Send Confirmation",
"type": "n8n-nodes-base.twilio",
"position": [
900,
-280
],
"parameters": {
"to": "={{ $('Twilio Trigger').item.json.From }}",
"from": "={{ $('Twilio Trigger').item.json.To }}",
"message": "Thank you. You won't receive any more messages from us!",
"options": {}
},
"credentials": {
"twilioApi": {
"id": "TJv4H4lXxPCLZT50",
"name": "Twilio account"
}
},
"typeVersion": 1
},
{
"id": "a8b9fffe-f814-4cb4-9e1a-bf7eb57e7afd",
"name": "User Request STOP",
"type": "n8n-nodes-base.airtable",
"position": [
660,
-280
],
"parameters": {
"base": {
"__rl": true,
"mode": "list",
"value": "appO2nHiT9XPuGrjN",
"cachedResultUrl": "https://airtable.com/appO2nHiT9XPuGrjN",
"cachedResultName": "Twilio-Scheduling-Agent"
},
"table": {
"__rl": true,
"mode": "list",
"value": "tblokH7uw63RpIlQ0",
"cachedResultUrl": "https://airtable.com/appO2nHiT9XPuGrjN/tblokH7uw63RpIlQ0",
"cachedResultName": "Lead Tracker"
},
"columns": {
"value": {
"status": "STOP",
"session_id": "={{ $('Twilio Trigger').item.json.From }}"
},
"schema": [
{
"id": "id",
"type": "string",
"display": true,
"removed": true,
"readOnly": true,
"required": false,
"displayName": "id",
"defaultMatch": true
},
{
"id": "session_id",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "session_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "status",
"type": "options",
"display": true,
"options": [
{
"name": "ACTIVE",
"value": "ACTIVE"
},
{
"name": "STOP",
"value": "STOP"
}
],
"removed": false,
"readOnly": false,
"required": false,
"displayName": "status",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "chat_messages",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "chat_messages",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "scheduled_at",
"type": "dateTime",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "scheduled_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "last_message_at",
"type": "dateTime",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "last_message_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "last_followup_at",
"type": "dateTime",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "last_followup_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "followup_count",
"type": "number",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "followup_count",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "assignee",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "assignee",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"session_id"
]
},
"options": {},
"operation": "update"
},
"credentials": {
"airtableTokenApi": {
"id": "Und0frCQ6SNVX3VV",
"name": "Airtable Personal Access Token account"
}
},
"typeVersion": 2.1
},
{
"id": "3e7797f0-5449-404c-bac9-e0019223cea8",
"name": "Check For Command Words",
"type": "n8n-nodes-base.switch",
"position": [
295,
180
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "STOP",
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "string",
"operation": "contains"
},
"leftValue": "={{ $json.Body }}",
"rightValue": "STOP"
}
]
},
"renameOutput": true
}
]
},
"options": {
"fallbackOutput": "extra"
}
},
"typeVersion": 3
},
{
"id": "e636ebb5-16c6-43ef-9fee-fe2b9a8c95a9",
"name": "Structured Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
1960,
560
],
"parameters": {
"jsonSchemaExample": "{\n \"reply\": \"\",\n \"customer_name\": \"\",\n \"enquiry_summary\": \"\",\n\t\"has_appointment_scheduled\": false,\n \"appointment\": {\n \"appointment_id\": \"\",\n \"scheduled_at\": \"\"\n }\n}"
},
"typeVersion": 1.2
},
{
"id": "3469740d-bd2f-4d34-a86b-59b088917d74",
"name": "Auto-fixing Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserAutofixing",
"position": [
1820,
440
],
"parameters": {},
"typeVersion": 1
},
{
"id": "fc0adfdf-724c-45d2-84f6-cb2b43254cc0",
"name": "OpenAI Chat Model2",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1840,
560
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "8gccIjcuf3gvaoEr",
"name": "OpenAi account"
}
},
"typeVersion": 1
},
{
"id": "0e0d8236-0f10-4f8f-88c1-bba2ef084e90",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1080,
-50.317404874203476
],
"parameters": {
"color": 7,
"width": 1011.8938194478603,
"height": 917.533068142247,
"content": "## Step 3. Appointment Scheduling With AI\n[Learn about using AI Agents](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent)\n\nUsing an AI Agent is a powerful way to simplify and enhance workflows using the latest in AI technology. Our appointment scheduling agent is equipped to converse with the customer and all the necessary tools to schedule, re-schedule and cancel appointments.\n\nUsing the **HTTP Tool** node, it's easy to connect to third party API services to perform actions. In this workflow, we're calling the Cal.com API to handle scheduling events."
},
"typeVersion": 1
},
{
"id": "380b437e-fa29-4ebb-bebd-1984d371bc93",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
549.8696404310444,
-49.46972087742148
],
"parameters": {
"color": 7,
"width": 504.0066355303578,
"height": 557.8466102697549,
"content": "## Step 2. Check for Existing Chat History\n[Read more about using Airtable](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.airtable)\n\nWe're using Airtable for customer session management and to capture chat history. Airtable is an ideal choice because it acts as a persistent database with a flexible API which could prove essential for further extension.\n\nWe'll pull any previous chat history and pass this to our agent to continue the conversation."
},
"typeVersion": 1
},
{
"id": "f89762f5-8520-4af6-987d-a71381c603e3",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
0,
-52.79744987055557
],
"parameters": {
"color": 7,
"width": 523.6927529886705,
"height": 479.4432905734608,
"content": "## Step 1. Wait For Customer SMS\n[Read more about Twilio trigger](https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.twiliotrigger)\n\nFor this workflow, we'll use the twilio SMS trigger to receive enquiries from customers looking to book a PC or laptop repair.\n\nSince we'll be working with SMS, we'll have a check to see if the customer wishes to STOP any further follow-up messages. This is an optional step that we'll get to later."
},
"typeVersion": 1
},
{
"id": "de525648-ef11-4b48-85ea-c6e5463c87cf",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
540,
-450.0217713292123
],
"parameters": {
"color": 7,
"width": 563.7797724327219,
"height": 358.6710117357418,
"content": "## Step 9. Cancelling Follow-Up Messages \n\nIf the customer messages the bot with the word STOP, we'll update our customer record in Airtable which will prevent further follow-ups from being trigger. A confirmation message is sent after to the customer."
},
"typeVersion": 1
},
{
"id": "028e4253-d1e6-4cf8-b181-ba27b03fa66e",
"name": "Sticky Note7",
"type": "n8n-nodes-base.stickyNote",
"position": [
2120,
-40
],
"parameters": {
"color": 7,
"width": 521.5259177258192,
"height": 558.7093446159199,
"content": "## Step 4. Updating Airtable and Responding to the Customer \n[Read more about using Twilio](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.twilio)\n\nOnce the agent formulates a response, we can update our appointment table accordingly ensuring the conversation at any stage is captured.\n\nIf no appointment is scheduled, we can move onto the second half of this workflow which covers following up with prospective customers and their enquiries."
},
"typeVersion": 1
},
{
"id": "f321ded9-c5d3-418d-bf1c-e29bf9845098",
"name": "Sticky Note8",
"type": "n8n-nodes-base.stickyNote",
"position": [
20,
940
],
"parameters": {
"color": 7,
"width": 509.931737588259,
"height": 433.74984757777247,
"content": "## Step 5. Following Up With Open Enquiries\n[Read more about using scheduled trigger](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.scheduletrigger)\n\nThe second half of this workflow deals with identifying customers who have engaged our chatbot but have not yet confirmed an appointment. We intend to send a follow-up message asking if the enquiry is still valid and encourage an appointment to be made with the customer."
},
"typeVersion": 1
},
{
"id": "4485e39a-3e84-49ee-9d3f-a271a98a330a",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1000,
940
],
"parameters": {
"color": 7,
"width": 567.1169284476533,
"height": 601.5572296901626,
"content": "## Step 7. Generating a Follow-Up Message\n[Read more about Basic LLM Chain](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.chainllm)\n\nWith our session and chat history retrieved from Airtable, we can simple ask our AI to generate a nicely worded follow-up message to re-engage the customer.\n\nWhere the logic is linear, the Basic LLM chain is suitable for many workflows. An agent is not always required!"
},
"typeVersion": 1
},
{
"id": "f2d66e44-cf18-4e8f-80d5-e8d03e10e5ff",
"name": "Generate Follow Up Message",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
1140,
1200
],
"parameters": {
"text": "=",
"messages": {
"messageValues": [
{
"message": "=You are an appointment scheduling assistant for PC and Laptop Repairs for a company called \"PC Parts Ltd\". You shall refer to yourself as the \"service team\". You had a conversation with a customer on {{ $json.last_message_at }} but the enquiry did not end with an appointment being scheduled.\n{{ $json.last_followup_at ? `You last sent a follow-up message on ${$json.last_followup_at}` : '' }}.\n\nYou task is to ask if the prospective customer would like to continue with the enquiry using the following information gather to construct a relevant follow-up message. Try to entice the user to continue the conversation and ultimately schedule an appointment.\n\n## About the customer\nname: {{ $json.customer_name ?? '<unknown>' }}\nenquiry summary: {{ $json.customer_summary ?? '<uknown>' }}\n\n# Existing conversation\nHere are the chat logs of the existing conversation:\n{{ $json.chat_messages }}"
}
]
},
"promptType": "define"
},
"typeVersion": 1.4
},
{
"id": "0b93a300-b9ab-4c28-8ac0-fddc49247b74",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1600,
940
],
"parameters": {
"color": 7,
"width": 496.0833287715134,
"height": 526.084030034264,
"content": "## Step 8. Update Follow-Up Properties and Send Message\n[Read more about using Twilio](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.twilio/)\n\nFinally, we'll update our follow-up activity as part of the customer record in Airtable. Keeping track of the number of times we follow-up helps prevent spamming the customer unnecessarily.\n\nThe follow-up message is sent via Twilio and includes instruction to disable further follow-up messages using the keyword STOP."
},
"typeVersion": 1
},
{