main.dsl
4.04 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
import "commonReactions/all.dsl";
context {
input phone: string;
input caller: string;
output cjm: string[] = [];
output need_ask_name: boolean = true;
output template_id: number = 3;
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_phone_number: string = "";
output abonent_name: string = "";
output company_name: string = "";
output phone_suffix: 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 array_size(arr: unknown): number;
external function string_trim(one_line: string): string;
external function is_empty(check: unknown): boolean;
external function performed_stage(stages: string[], stage: string): string[];
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;
start node root
{
do
{
set $cjm = external performed_stage($cjm, "root");
set $conversation_start = external time_stamp();
goto caller_id;
}
transitions
{
caller_id: goto caller_id;
}
}
node caller_id
{
do
{
set $cjm = external performed_stage($cjm, "caller_id");
#connectSafe($phone);
#waitForSpeech(1000);
// Строим приветствие, зависящее от времени суток
var part_of_the_day_name = external part_of_the_day();
var abonent_greeting = "Здравствуйте";
if (part_of_the_day_name == "night")
{
set abonent_greeting = "Доброй ночи";
}
if (part_of_the_day_name == "morning")
{
set abonent_greeting = "Доброе утро";
}
if (part_of_the_day_name == "day")
{
set abonent_greeting = "Добрый день";
}
if (part_of_the_day_name == "evening")
{
set abonent_greeting = "Добрый вечер";
}
// Запоминаем временной штамп перед самой первой репликой
set $conversation_begin = external time_stamp();
#sayText(abonent_greeting, options: {speed: 1.15});
#say("dont_understand_question");
wait *;
}
transitions
{
end_conversation: goto end_conversation on true;
}
onexit
{
end_conversation: do
{
var abonent_say = #getMessageText();
set $abonent_request = external performed_stage($abonent_request, abonent_say);
}
}
}
node end_conversation
{
do
{
set $cjm = external performed_stage($cjm, "end_conversation");
#say("end_conversation");
goto do_before_exit;
}
transitions
{
do_before_exit: goto do_before_exit;
}
}
node do_before_exit
{
do
{
set $cjm = external performed_stage($cjm, "do_before_exit");
set $conversation_stop = external time_stamp();
exit;
}
transitions
{
}
}
digression @exit_dig
{
conditions { on true tags: onclosed; }
do
{
set $cjm = external performed_stage($cjm, "@exit_dig");
set $conversation_status = "broken";
goto do_before_exit;
}
transitions
{
do_before_exit: goto do_before_exit;
}
}