main.dsl
20.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
import "commonReactions/all.dsl";
context {
input phone: string;
input caller: string;
//input waiting: number;
output cjm: string[] = [];
output need_ask_name: boolean = true;
output template_id: number = 1;
output conversation_start: number = 0;
output conversation_begin: number = 0;
output conversation_stop: number = 0;
output conversation_status: string = "normal";
output abonent_request: string[] = [];
output another_messager: string ="";
output another_phone_number: string = "";
output accepted_code: boolean = false;
output phone_suffix: string = "";
output conversation_end: number = 0;
output channel_type: string = "";
output mail: string = "";
}
external function numbers_from_text(text: string): string;
external function dates_from_text(text: string): string;
external function part_of_the_day(): string;
external function is_empty(check: unknown): boolean;
external function sleep_ms(duration: number): unknown;
external function json_encode(object: unknown): string;
external function time_stamp(): number;
external function math_floor(value: number, presision: number|empty = 0): number;
external function math_round(value: number, presision: number|empty = 0): number;
external function math_ceil(value: number, presision: number|empty = 0): number;
external function phone_human(phone: string): string;
external function last_four(phone: string): string;
external function hours_now(): number;
external function check_mobile_code(phone: string): boolean;
external function countWords(message: string): number;
external function sendTelegram(): string;
external function sendTelegramChannel(channel_type: string, mail: string): string;
start node root
{
do
{
$cjm.push("root");
set $conversation_start = external time_stamp();
goto caller_id;
}
transitions
{
caller_id: goto caller_id;
}
}
block SkipMessagesBlock():boolean
{
start node root
{
do
{
return true;
}
}
}
node caller_id
{
do
{
$cjm.push("caller_id");
#connectSafe($phone);
#waitForSpeech(1000);
digression disable { conference_time, zoom_cost };
//external sendTelegram();
// Запоминаем временной штамп перед самой первой репликой
set $conversation_begin = external time_stamp();
#say("greeting");
var result = blockcall SkipMessagesBlock();
wait *;
}
transitions
{
//end_conversation: goto end_conversation on true;
canttalkrn: goto cant_talk_rn on #messageHasAnyIntent(["decline", "cant_talk_rn", "potential_call_later"]) || #messageHasSentiment("negative");
cantalk: goto can_talk on #messageHasAnyIntent(["accept", "can_talk"]) || #messageHasSentiment("positive");
whoyouare: goto who_you_are on #messageHasIntent("who_you_are");
gift: goto gift on #messageHasAnyIntent(["what_you_want", "what_do_you_want"]);
}
}
node wait_choice
{
do
{
$cjm.push("wait_choice");
var result = blockcall SkipMessagesBlock();
wait *;
}
transitions
{
allready_have_sub: goto allready_have_sub on #messageHasIntent("allready_have_sub");
allready_been_inacademy: goto allready_been_inacademy on #messageHasIntent("allready_been_inacademy");
allready_sent_promo: goto allready_sent_promo on #messageHasIntent("allready_sent_promo");
is_studing_free: goto is_studing_free on #messageHasIntent("studing_cost");
options: goto options on #messageHasIntent("what_options");
for_what: goto for_what on #messageHasIntent("what_promo");
tg: goto tg on #messageHasData("telegram") || #messageHasAnyIntent(["send_it", "another_messangers"]);
watsup: goto watsup on #messageHasData("watsup");
mail: goto mail on #messageHasData("mail");
positive: goto tg on #messageHasSentiment("positive");
//positive: goto send_it on #messageHasSentiment("positive") || #messageHasAnyIntent(["send_it", "another_messangers", "what_options"]);
negative: goto dont_use on #messageHasSentiment("negative") || #messageHasIntent("decline");
}
}
node tg
{
do
{
$cjm.push("tg");
#say("is_tg");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
positive: goto yes_tg on #messageHasSentiment("positive");
negative: goto no_whatsapp on #messageHasSentiment("negative");
}
onexit
{
positive: do
{
set $channel_type = "Telegram";
external sendTelegramChannel($channel_type, "");
}
}
}
node yes_tg
{
do
{
$cjm.push("yes_tg");
external sendTelegram();
goto yes_whatsapp;
}
transitions
{
yes_whatsapp: goto yes_whatsapp;
}
}
node watsup
{
do
{
//Подскажите, а на этом номере есть вотсап?
$cjm.push("watsup");
#say("have_whatsapp");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
positive: goto yes_whatsapp on #messageHasSentiment("positive");
negative: goto no_whatsapp on #messageHasSentiment("negative") || #messageHasIntent("no_whatsapp");
}
onexit
{
positive: do
{
set $channel_type = "WhatsApp";
external sendTelegramChannel($channel_type, "");
}
}
}
node mail
{
do
{
$cjm.push("mail");
#say("is_mail");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
positive: goto yes_whatsapp on #messageHasSentiment("positive");
negative: goto no_whatsapp on #messageHasSentiment("negative") || #messageHasIntent("no_whatsapp");
}
onexit
{
positive: do
{
//здесь будет определение мыла через mail recognizer
//var mail = external getMailByVoice();
//а здесь отправка
//external sendMail($mail, $promocode);
var mail = "temp@mail.ru";
set $channel_type = "почту";
external sendTelegramChannel($channel_type, mail);
}
}
}
node dont_use
{
do
{
$cjm.push("dont_use");
#say("dont_use");
#setVadPauseLength(2.0);
#say("in_that_case");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
negative: goto thanks_bye on true;
}
}
node allready_sent_promo
{
do
{
$cjm.push("allready_sent_promo");
#say("allready_sent_promo");
var result = blockcall SkipMessagesBlock();
goto thanks_bye;
}
transitions
{
thanks_bye: goto thanks_bye;
}
}
node options
{
do
{
$cjm.push("options");
#say("send_to");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
transition1: goto no_whatsapp on true;
}
}
node is_studing_free
{
do
{
$cjm.push("is_studing_free");
#say("study_cost");
#say("where_send_short");
var result = blockcall SkipMessagesBlock();
goto wait_choice;
}
transitions
{
wait_choice: goto wait_choice;
}
}
node who_you_are //кто вы такие?
{
do
{
$cjm.push("who_you_are");
#say("whoiam");
var result = blockcall SkipMessagesBlock();
wait *;
}
transitions
{
//end_conversation: goto end_conversation on true;
canttalkrn: goto cant_talk_rn on #messageHasAnyIntent(["decline", "cant_talk_rn"]) || #messageHasSentiment("negative");
cantalk: goto can_talk on #messageHasAnyIntent(["accept", "can_talk"]) || #messageHasSentiment("positive");
}
}
node gift //короткий переход к предложению промокода
{
do
{
$cjm.push("gift");
#say("gift");
var result = blockcall SkipMessagesBlock();
//wait *;
goto wait_choice;
}
transitions
{
//positive: goto send_it on #messageHasSentiment("positive") || #messageHasIntent("send_it");
//negative: goto dont_need on #messageHasSentiment("negative");
wait_choice: goto wait_choice;
}
}
node helpful_pos
{
do
{
//Спасибо за ваше мнение! Поздравляю! Вы были...
$cjm.push("helpful_pos");
#say("helpful_pos");
var result = blockcall SkipMessagesBlock();
//wait*;
goto wait_choice;
}
transitions
{
wait_choice: goto wait_choice;
}
}
node allready_been_inacademy
{
do
{
$cjm.push("allready_been_inacademy");
#say("allready_been_inacademy");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
positive: goto cant_talk_rn on #messageHasSentiment("positive");
negative: goto dont_need on #messageHasSentiment("negative");
}
}
node denial
{
do
{
$cjm.push("denial");
#say("thanks_for_time_2");
goto end_conversation;
}
transitions
{
end_conversation: goto end_conversation;
}
}
node allready_have_sub
{
do
{
$cjm.push("allready_have_sub");
#say("allready_have_sub");
#say("thanks_for_time");
var result = blockcall SkipMessagesBlock();
goto do_before_exit;
}
transitions
{
do_before_exit: goto do_before_exit;
}
}
node helpful_neg //pair2
{
do
{
//Подскажите, пожалуйста, что Вам не понравилось?
$cjm.push("helpful_neg");
#say("helpful_neg");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
understood: goto understood on true;
}
}
node understood //pair3
{
do
{
//Поняла Вас. Мы постараемся учесть Ваши пожел
$cjm.push("understood");
#say("understood");
var result = blockcall SkipMessagesBlock();
//wait*;
goto wait_choice;
}
transitions
{
wait_choice: goto wait_choice;
}
}
node send_it
{
do
{
//Подскажите, а на этом номере есть вотсап?
$cjm.push("send_it");
#say("have_whatsapp");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
positive: goto yes_whatsapp on #messageHasSentiment("positive");
negative: goto no_whatsapp on #messageHasSentiment("negative") || #messageHasIntent("no_whatsapp");
}
}
node dont_need
{
do
{
//почему отказываетесь
$cjm.push("dont_need");
#say("why_reject");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
negative: goto thanks_bye on true;
//#messageHasSentiment("negative") || #messageHasIntent("not_interested");
}
}
node thanks_bye_2
{
do
{
//Благодарю за уделенное время. Всего доброго.
$cjm.push("thanks_bye_2");
#say("thanks_for_time_2");
var result = blockcall SkipMessagesBlock();
goto do_before_exit;
}
transitions
{
do_before_exit: goto do_before_exit;
}
}
node yes_whatsapp
{
do
{
//Отлично. Сейчас отправлю Вам промокод. Всего доброго до свидания.
$cjm.push("yes_whatsapp");
set $accepted_code = true;
#say("gonna_send_code");
var result = blockcall SkipMessagesBlock();
goto end_conversation;
}
transitions
{
end_conversation: goto end_conversation;
}
}
node no_whatsapp
{
do
{
//Продиктуйте, пожалуйста данные, куда я могу отпр промокод
$cjm.push("no_whatsapp");
#say("give_contacts");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
thanks_bye: goto thanks_bye on true;
another_messangers: goto thanks_bye on #messageHasIntent("another_messangers");
}
onexit
{
thanks_bye: do
{
var contact = #getMessageText();
set $another_phone_number = external numbers_from_text(contact);
set $accepted_code = true;
}
another_messangers: do
{
set $another_messager = #getMessageText();
set $accepted_code = true;
}
}
}
node thanks_bye
{
do
{
//Благодарю за уделенное время. Всего доброго.
$cjm.push("thanks_bye");
#say("thanks_bye");
goto end_conversation;
}
transitions
{
end_conversation: goto end_conversation;
}
}
node can_talk //могу говорить
{
do
{
//вы недавно посетили вебинар...
$cjm.push("can_talk");
#say("how_helpful");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
positive: goto helpful_pos on (#messageHasSentiment("positive")|| #messageHasAnyIntent(["accept", "what_interested"])) && !#messageHasIntent("ididnt_watch");
negative: goto helpful_neg on #messageHasAnyIntent(["did_not_liked", "not_really", "decline"]) && !#messageHasIntent("ididnt_watch");
didnt_whatc: goto not_present on #messageHasIntent("ididnt_watch");
when_was: goto when_was on #messageHasIntent("when_webinar");
dont_remember: goto dont_remember on #messageHasIntent("dont_remember");
}
}
node when_was
{
do
{
$cjm.push("when_was");
#say("it_was_wensday");
#say("how_helpful_short");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
positive: goto helpful_pos on #messageHasSentiment("positive") && !#messageHasIntent("ididnt_watch") || #messageHasIntent("accept") && !#messageHasIntent("ididnt_watch");
negative: goto helpful_neg on #messageHasSentiment("negative") || #messageHasAnyIntent(["decline", "did_not_liked", "not_really"]);
didnt_whatc: goto not_present on #messageHasIntent("ididnt_watch");
dont_remember: goto dont_remember on #messageHasIntent("dont_remember");
}
}
node for_what
{
do
{
$cjm.push("for_what");
#say("promo_for");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
positive: goto helpful_pos on (#messageHasSentiment("positive")|| #messageHasAnyIntent(["accept", "what_interested"])) && !#messageHasIntent("ididnt_watch");
negative: goto helpful_neg on #messageHasAnyIntent(["did_not_liked", "not_really", "decline"]) && !#messageHasIntent("ididnt_watch");
}
}
node dont_remember
{
do
{
$cjm.push("dont_remember");
#say("remember_web");
#say("how_helpful_short");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
positive: goto helpful_pos on #messageHasSentiment("positive") && !#messageHasIntent("ididnt_watch") || #messageHasIntent("accept") && !#messageHasIntent("ididnt_watch");
negative: goto helpful_neg on #messageHasSentiment("negative") || #messageHasAnyIntent(["decline", "did_not_liked", "not_really"]);
didnt_whatc: goto not_present on #messageHasIntent("ididnt_watch");
dont_remember: goto dont_remember on #messageHasIntent("dont_remember");
}
}
node not_present // Давайте проведем бесплатный Зум, где вы за полчаса
{
do
{
digression enable { conference_time, zoom_cost };
$cjm.push("not_present");
#say("free_zoom");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
positive: goto zoom_positive on #messageHasSentiment("positive");
negative: goto zoom_negitive on #messageHasSentiment("negative");
//when_zoom: goto when_zoom on #messageHasIntent("when_conference");
//is_free: goto is_free_zoom on #messageHasIntent("zoom_cost");
}
}
node zoom_positive // Ожидайте звонка. Всего доброго, до свидания!
{
do
{
$cjm.push("zoom_positive");
#say("zoom_positive");
goto do_before_exit;
}
transitions
{
do_before_exit: goto do_before_exit;
}
}
node zoom_negitive // Подскажите, пожалуйста, а что Вас смущает?
{
do
{
$cjm.push("zoom_negitive");
#say("why_reject");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
retry: goto retry on true;
}
}
node when_zoom
{
do
{
$cjm.push("when_zoom");
#say("conference_time");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
zoom_positive: goto zoom_positive on #messageHasSentiment("positive") || #messageHasIntent("accept");
zoom_negitive: goto zoom_negitive on #messageHasSentiment("negative") || #messageHasIntent("decline");
}
}
node is_free_zoom
{
do
{
$cjm.push("is_free_zoom");
#say("zoom_cost");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
retry: goto retry on true;
}
}
node retry // За полчаса мы можем показать вам точки роста вашей карточки.
{
do
{
$cjm.push("retry");
#say("retry");
var result = blockcall SkipMessagesBlock();
wait*;
}
transitions
{
positive: goto zoom_positive on #messageHasSentiment("positive");
negative: goto thanks_bye on #messageHasSentiment("negative");
}
}
node cant_talk_rn //не могу говорить
{
do
{
//благодарю досвидания (в самом начале)
$cjm.push("cant_talk_rn");
#say("thanks_for_time");
goto end_conversation;
}
transitions
{
end_conversation: goto end_conversation;
}
}
node end_conversation
{
do
{
$cjm.push("end_conversation");
goto do_before_exit;
}
transitions
{
do_before_exit: goto do_before_exit;
}
}
node do_before_exit
{
do
{
$cjm.push("do_before_exit");
set $conversation_stop = external time_stamp();
exit;
}
transitions
{
}
}
digression @exit_dig
{
conditions { on true tags: onclosed; }
do
{
$cjm.push("@exit_dig");
set $conversation_status = "broken";
goto do_before_exit;
}
transitions
{
do_before_exit: goto do_before_exit;
}
}
digression conference_time
{
conditions { on #messageHasAnyIntent(digression.conference_time.triggers); }
var triggers = ["when_conference"];
var responses: Phrases[] = ["conference_time"];
do
{
$cjm.push("conference_time");
for (var item in digression.conference_time.responses)
{
#say(item, repeatMode: "ignore");
}
wait*;
}
transitions
{
positive: goto zoom_positive on #messageHasSentiment("positive");
negative: goto zoom_negitive on #messageHasSentiment("negative");
}
}
digression zoom_cost
{
conditions { on #messageHasAnyIntent(digression.zoom_cost.triggers); }
var triggers = ["zoom_cost", "studing_cost"];
var responses: Phrases[] = ["zoom_cost"];
do
{
$cjm.push("zoom_cost");
for (var item in digression.zoom_cost.responses)
{
#say(item, repeatMode: "ignore");
}
goto retry;
}
transitions
{
retry: goto retry;
}
}
digression record
{
conditions { on #messageHasAnyIntent(digression.record.triggers); }
var triggers = ["record"];
var responses: Phrases[] = ["record"];
do
{
$cjm.push("record");
for (var item in digression.record.responses)
{
#say(item, repeatMode: "ignore");
}
#repeat(accuracy: "short");
return;
}
transitions
{
}
}