main.dsl
5.21 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
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 performed_stage(stages: string[], stage: string): string[];
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 part_of_the_day_name = "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();
#say("greeting");
//#say("dont_understand_question");
wait *;
}
transitions
{
//end_conversation: goto end_conversation on true;
canttalkrn: goto cant_talk_rn on #messageHasAnyIntent(["decline", "cant_talk_rn"]);
cantalk: goto can_talk on #messageHasAnyIntent(["accept", "can_talk"]);
}
}
node helpful_pos //pair2
{
do
{
#say("helpful_pos");
wait*;
}
transitions
{
}
}
node helpful_neg //pair2
{
do
{
#say("helpful_neg");
wait*;
}
transitions
{
understood: goto understood on true;
}
}
node understood //pair3
{
do
{
#say("understood");
wait*;
}
transitions
{
positive: goto send_it on #messageHasSentiment("positive") || #messageHasIntent("send_it");
negative: goto dont_need on #messageHasSentiment("negative");
}
}
node send_it
{
do
{
#say("have_whatsapp");
wait*;
}
transitions
{
positive: goto yes_whatsapp on #messageHasSentiment("positive");
negative: goto no_whatsapp on #messageHasSentiment("negative") || #messageHasIntent("no_whatsapp");
}
}
node dont_need
{
do
{
//почему отказываетесь
#say("why_reject");
wait*;
}
transitions
{
negative: goto thanks_bye_2 on #messageHasSentiment("negative") || #messageHasIntent("not_interested");
}
}
node thanks_bye_2
{
do
{
#say("thanks_for_time_2");
goto do_before_exit;
}
transitions
{
do_before_exit: goto do_before_exit;
}
}
node yes_whatsapp
{
do
{
#say("gonna_send_code");
}
transitions
{
end_conversation: goto end_conversation;
}
}
node no_whatsapp
{
do
{
#sayText("give_contacts");
wait*;
}
transitions
{
thanks_bye: goto thanks_bye on true;
}
}
node thanks_bye
{
do
{
#say("thanks_bye");
}
transitions
{
end_conversation: goto end_conversation;
}
}
node can_talk
{
do
{
#say("how_helpful");
wait*;
}
transitions
{
positive: goto helpful_pos on #messageHasSentiment("positive");
negative: goto helpful_neg on #messageHasSentiment("negative");
}
}
node cant_talk_rn //pair1
{
do
{
#say("thanks_for_time");
}
transitions
{
end_conversation: goto end_conversation;
}
}
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;
}
}