@periskope/types 0.6.210 → 0.6.211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rules.types.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/mod_json_type.ps1 +108 -108
- package/mod_json_type.sh +22 -22
- package/package.json +17 -17
- package/src/index.ts +3 -3
- package/src/rules.types.ts +1944 -1944
- package/src/types.ts +980 -980
- package/tsconfig.json +18 -18
- package/update_package.ps1 +21 -21
- package/tsconfig.tsbuildinfo +0 -1
package/src/rules.types.ts
CHANGED
|
@@ -1,1944 +1,1944 @@
|
|
|
1
|
-
import { Merge, OverrideProperties } from 'type-fest';
|
|
2
|
-
import { Tables } from './supabase.types';
|
|
3
|
-
import {
|
|
4
|
-
ChatRuleInfoType,
|
|
5
|
-
MessageRuleInfoType,
|
|
6
|
-
ReactionRuleInfoType,
|
|
7
|
-
SenderRuleInfoType,
|
|
8
|
-
TicketRuleInfoType,
|
|
9
|
-
} from './types';
|
|
10
|
-
|
|
11
|
-
export type AppendTypes<T extends object, O extends string> = {
|
|
12
|
-
[K in keyof T & string as `${K}${O}${keyof T[K] & string}`]: T[K][keyof T[K]];
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type TicketVariablesType = TicketRuleInfoType['ticket'];
|
|
16
|
-
|
|
17
|
-
export type MessageVariablesType = MessageRuleInfoType['message'];
|
|
18
|
-
|
|
19
|
-
export type SenderVariablesType = SenderRuleInfoType;
|
|
20
|
-
|
|
21
|
-
export type ReactionVariablesType = ReactionRuleInfoType['reaction'];
|
|
22
|
-
|
|
23
|
-
export type ChatVariablesType = ChatRuleInfoType;
|
|
24
|
-
|
|
25
|
-
export type MessageRulesInfoType = Merge<
|
|
26
|
-
AppendTypes<
|
|
27
|
-
{
|
|
28
|
-
message: MessageVariablesType;
|
|
29
|
-
sender: SenderVariablesType;
|
|
30
|
-
chat: ChatVariablesType;
|
|
31
|
-
},
|
|
32
|
-
'.'
|
|
33
|
-
>,
|
|
34
|
-
{
|
|
35
|
-
rule: Tables<'tbl_automation_rules'>[];
|
|
36
|
-
id: 'message.message_id';
|
|
37
|
-
type: `message.${'created' | 'updated' | 'flagged'}`;
|
|
38
|
-
org_id: string;
|
|
39
|
-
}
|
|
40
|
-
>;
|
|
41
|
-
|
|
42
|
-
export type TicketRulesInfoType = Merge<
|
|
43
|
-
AppendTypes<
|
|
44
|
-
{
|
|
45
|
-
ticket: TicketVariablesType;
|
|
46
|
-
message: MessageVariablesType;
|
|
47
|
-
sender: SenderVariablesType;
|
|
48
|
-
chat: ChatVariablesType;
|
|
49
|
-
},
|
|
50
|
-
'.'
|
|
51
|
-
>,
|
|
52
|
-
{
|
|
53
|
-
id: 'ticket.ticket_id';
|
|
54
|
-
type: `ticket.${'created' | 'updated'}`;
|
|
55
|
-
org_id: string;
|
|
56
|
-
rule: Tables<'tbl_automation_rules'>[];
|
|
57
|
-
}
|
|
58
|
-
>;
|
|
59
|
-
|
|
60
|
-
export type ReactionRulesInfoType = Merge<
|
|
61
|
-
AppendTypes<
|
|
62
|
-
{
|
|
63
|
-
reaction: ReactionVariablesType;
|
|
64
|
-
message: MessageVariablesType;
|
|
65
|
-
sender: SenderVariablesType;
|
|
66
|
-
chat: ChatVariablesType;
|
|
67
|
-
},
|
|
68
|
-
'.'
|
|
69
|
-
>,
|
|
70
|
-
{
|
|
71
|
-
rule: Tables<'tbl_automation_rules'>[];
|
|
72
|
-
id: 'reaction.reaction_id';
|
|
73
|
-
type: `reaction.added`;
|
|
74
|
-
org_id: string;
|
|
75
|
-
}
|
|
76
|
-
>;
|
|
77
|
-
|
|
78
|
-
export type ChatRulesInfoType = Merge<
|
|
79
|
-
AppendTypes<
|
|
80
|
-
{
|
|
81
|
-
chat: ChatVariablesType;
|
|
82
|
-
},
|
|
83
|
-
'.'
|
|
84
|
-
>,
|
|
85
|
-
{
|
|
86
|
-
rule: Tables<'tbl_automation_rules'>[];
|
|
87
|
-
id: 'chat.chat_id';
|
|
88
|
-
type: 'chat.created' | 'chat.label.updated';
|
|
89
|
-
org_id: string;
|
|
90
|
-
}
|
|
91
|
-
>;
|
|
92
|
-
|
|
93
|
-
export type RuleInfoType =
|
|
94
|
-
| MessageRulesInfoType
|
|
95
|
-
| ChatRulesInfoType
|
|
96
|
-
| TicketRulesInfoType
|
|
97
|
-
| ReactionRulesInfoType;
|
|
98
|
-
|
|
99
|
-
export interface Filter {
|
|
100
|
-
id: string;
|
|
101
|
-
condition:
|
|
102
|
-
| 'CONTAINS'
|
|
103
|
-
| 'NCONTAINS'
|
|
104
|
-
| 'EQ'
|
|
105
|
-
| 'NEQ'
|
|
106
|
-
| 'LT'
|
|
107
|
-
| 'LTE'
|
|
108
|
-
| 'GT'
|
|
109
|
-
| 'GTE'
|
|
110
|
-
| 'KNOWN'
|
|
111
|
-
| 'NKNOWN'
|
|
112
|
-
| 'IS'
|
|
113
|
-
| 'NIS'
|
|
114
|
-
| 'ON'; // Add other condition types as needed
|
|
115
|
-
variable: string;
|
|
116
|
-
value: string | string[];
|
|
117
|
-
variable_type?: 'string' | 'number' | 'boolean' | 'day-time' | 'date' | 'day'; // Optional, like 'Date'
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export const isFilter = (filter: any): filter is Filter => {
|
|
121
|
-
return (
|
|
122
|
-
typeof filter === 'object' &&
|
|
123
|
-
'id' in filter &&
|
|
124
|
-
'condition' in filter &&
|
|
125
|
-
'variable' in filter &&
|
|
126
|
-
'value' in filter
|
|
127
|
-
);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export const FilterNameMap: Record<
|
|
131
|
-
Filter['condition'],
|
|
132
|
-
{
|
|
133
|
-
name: string;
|
|
134
|
-
input: boolean;
|
|
135
|
-
}
|
|
136
|
-
> = {
|
|
137
|
-
EQ: {
|
|
138
|
-
name: 'equals to',
|
|
139
|
-
input: true,
|
|
140
|
-
},
|
|
141
|
-
NEQ: {
|
|
142
|
-
name: 'not equals to',
|
|
143
|
-
input: true,
|
|
144
|
-
},
|
|
145
|
-
CONTAINS: {
|
|
146
|
-
name: 'contains',
|
|
147
|
-
input: true,
|
|
148
|
-
},
|
|
149
|
-
NCONTAINS: {
|
|
150
|
-
name: 'does not contain',
|
|
151
|
-
input: true,
|
|
152
|
-
},
|
|
153
|
-
LT: {
|
|
154
|
-
name: 'less than',
|
|
155
|
-
input: true,
|
|
156
|
-
},
|
|
157
|
-
LTE: {
|
|
158
|
-
name: 'less than or equals to',
|
|
159
|
-
input: true,
|
|
160
|
-
},
|
|
161
|
-
GT: {
|
|
162
|
-
name: 'greater than',
|
|
163
|
-
input: true,
|
|
164
|
-
},
|
|
165
|
-
GTE: {
|
|
166
|
-
name: 'greater than or equals to',
|
|
167
|
-
input: true,
|
|
168
|
-
},
|
|
169
|
-
KNOWN: {
|
|
170
|
-
name: 'is known',
|
|
171
|
-
input: false,
|
|
172
|
-
},
|
|
173
|
-
NKNOWN: {
|
|
174
|
-
name: 'is not known',
|
|
175
|
-
input: false,
|
|
176
|
-
},
|
|
177
|
-
IS: {
|
|
178
|
-
name: 'is',
|
|
179
|
-
input: true,
|
|
180
|
-
},
|
|
181
|
-
NIS: {
|
|
182
|
-
name: 'is not',
|
|
183
|
-
input: true,
|
|
184
|
-
},
|
|
185
|
-
ON: {
|
|
186
|
-
name: 'on',
|
|
187
|
-
input: true,
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
export type VariableNameValueType = {
|
|
192
|
-
text: string;
|
|
193
|
-
type:
|
|
194
|
-
| 'string'
|
|
195
|
-
| 'time'
|
|
196
|
-
| 'boolean'
|
|
197
|
-
| 'dropdown'
|
|
198
|
-
| 'day-time'
|
|
199
|
-
| 'number'
|
|
200
|
-
| 'date';
|
|
201
|
-
variable_type: 'string' | 'number' | 'boolean' | 'day-time' | 'date';
|
|
202
|
-
value?:
|
|
203
|
-
| string
|
|
204
|
-
| {
|
|
205
|
-
id: string;
|
|
206
|
-
value: string | number | boolean;
|
|
207
|
-
label: string;
|
|
208
|
-
}[]
|
|
209
|
-
| null;
|
|
210
|
-
filters:
|
|
211
|
-
| Partial<
|
|
212
|
-
Record<
|
|
213
|
-
Filter['condition'],
|
|
214
|
-
{
|
|
215
|
-
info?: string;
|
|
216
|
-
}
|
|
217
|
-
>
|
|
218
|
-
>
|
|
219
|
-
| Filter['condition'][];
|
|
220
|
-
hidden?: boolean;
|
|
221
|
-
placeholder?: string;
|
|
222
|
-
info?: string;
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
export const MessageVariableNameMap: Record<
|
|
226
|
-
keyof AppendTypes<{ message: MessageVariablesType }, '.'>,
|
|
227
|
-
VariableNameValueType
|
|
228
|
-
> = {
|
|
229
|
-
'message.body': {
|
|
230
|
-
text: 'Message Body',
|
|
231
|
-
type: 'string',
|
|
232
|
-
filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
|
|
233
|
-
placeholder: 'e.g. Test message',
|
|
234
|
-
variable_type: 'string',
|
|
235
|
-
},
|
|
236
|
-
'message.sender_phone': {
|
|
237
|
-
text: 'Message Sender Phone',
|
|
238
|
-
type: 'string',
|
|
239
|
-
filters: ['EQ', 'NEQ'],
|
|
240
|
-
placeholder: 'e.g. 919876543210',
|
|
241
|
-
variable_type: 'string',
|
|
242
|
-
},
|
|
243
|
-
'message.timestamp': {
|
|
244
|
-
text: 'Message Timestamp',
|
|
245
|
-
type: 'day-time',
|
|
246
|
-
filters: {
|
|
247
|
-
LT: {
|
|
248
|
-
info: 'When message is received before mentioned time (UTC)',
|
|
249
|
-
},
|
|
250
|
-
LTE: {
|
|
251
|
-
info: 'When message is received before mentioned time (UTC)',
|
|
252
|
-
},
|
|
253
|
-
GT: {
|
|
254
|
-
info: 'When message is received after mentioned time (UTC)',
|
|
255
|
-
},
|
|
256
|
-
GTE: {
|
|
257
|
-
info: 'When message is received on or after mentioned time (UTC)',
|
|
258
|
-
},
|
|
259
|
-
ON: {
|
|
260
|
-
info: 'When message is received on mentioned days',
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
variable_type: 'day-time',
|
|
264
|
-
info: 'The timestamp when the message was received',
|
|
265
|
-
},
|
|
266
|
-
'message.flag_status': {
|
|
267
|
-
text: 'Message Flag Status',
|
|
268
|
-
filters: ['IS'],
|
|
269
|
-
type: 'boolean',
|
|
270
|
-
variable_type: 'boolean',
|
|
271
|
-
},
|
|
272
|
-
'message.has_quoted_msg': {
|
|
273
|
-
text: 'Has Quoted Message',
|
|
274
|
-
filters: ['IS'],
|
|
275
|
-
type: 'boolean',
|
|
276
|
-
variable_type: 'boolean',
|
|
277
|
-
},
|
|
278
|
-
'message.media': {
|
|
279
|
-
text: 'Has Media',
|
|
280
|
-
type: 'boolean',
|
|
281
|
-
filters: ['KNOWN', 'NKNOWN'],
|
|
282
|
-
variable_type: 'boolean',
|
|
283
|
-
},
|
|
284
|
-
'message.performed_by': {
|
|
285
|
-
text: 'Message Sent By (email)',
|
|
286
|
-
type: 'dropdown',
|
|
287
|
-
value: 'org.members',
|
|
288
|
-
filters: ['EQ', 'NEQ'],
|
|
289
|
-
variable_type: 'string',
|
|
290
|
-
},
|
|
291
|
-
'message.chat_id': {
|
|
292
|
-
text: 'Chat ID',
|
|
293
|
-
type: 'string',
|
|
294
|
-
filters: ['EQ', 'NEQ'],
|
|
295
|
-
hidden: true,
|
|
296
|
-
variable_type: 'string',
|
|
297
|
-
},
|
|
298
|
-
'message.message_ticket_id':{
|
|
299
|
-
text: 'Message Ticket ID',
|
|
300
|
-
type: 'string',
|
|
301
|
-
filters: ['EQ', 'NEQ'],
|
|
302
|
-
hidden: true,
|
|
303
|
-
variable_type: 'string',
|
|
304
|
-
},
|
|
305
|
-
'message.message_id': {
|
|
306
|
-
text: 'Message ID',
|
|
307
|
-
type: 'string',
|
|
308
|
-
filters: ['EQ', 'NEQ'],
|
|
309
|
-
hidden: true,
|
|
310
|
-
variable_type: 'string',
|
|
311
|
-
},
|
|
312
|
-
'message.org_phone': {
|
|
313
|
-
text: 'Org Phone',
|
|
314
|
-
type: 'string',
|
|
315
|
-
filters: ['EQ', 'NEQ'],
|
|
316
|
-
hidden: true,
|
|
317
|
-
variable_type: 'string',
|
|
318
|
-
},
|
|
319
|
-
'message.org_id': {
|
|
320
|
-
text: 'Org ID',
|
|
321
|
-
type: 'string',
|
|
322
|
-
filters: ['EQ', 'NEQ'],
|
|
323
|
-
hidden: true,
|
|
324
|
-
variable_type: 'string',
|
|
325
|
-
},
|
|
326
|
-
'message.message_type': {
|
|
327
|
-
text: 'Message Type',
|
|
328
|
-
type: 'dropdown',
|
|
329
|
-
value: [
|
|
330
|
-
{ id: 'text', value: 'chat', label: 'Text' },
|
|
331
|
-
{ id: 'image', value: 'image', label: 'Image' },
|
|
332
|
-
{ id: 'video', value: 'video', label: 'Video' },
|
|
333
|
-
{ id: 'audio', value: 'audio', label: 'Audio' },
|
|
334
|
-
{ id: 'audio', value: 'ptt', label: 'PTT (Audio voice message)' },
|
|
335
|
-
{ id: 'document', value: 'document', label: 'Document' },
|
|
336
|
-
],
|
|
337
|
-
filters: ['EQ', 'NEQ'],
|
|
338
|
-
variable_type: 'string',
|
|
339
|
-
},
|
|
340
|
-
'message.author': {
|
|
341
|
-
text: 'Message Author',
|
|
342
|
-
type: 'string',
|
|
343
|
-
filters: ['EQ', 'NEQ'],
|
|
344
|
-
hidden: true,
|
|
345
|
-
variable_type: 'string',
|
|
346
|
-
},
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
export const SenderVariableNameMap: Record<
|
|
350
|
-
keyof AppendTypes<{ sender: SenderVariablesType }, '.'>,
|
|
351
|
-
VariableNameValueType
|
|
352
|
-
> = {
|
|
353
|
-
'sender.is_internal': {
|
|
354
|
-
text: 'Sender Is Internal',
|
|
355
|
-
type: 'boolean',
|
|
356
|
-
filters: ['IS'],
|
|
357
|
-
variable_type: 'boolean',
|
|
358
|
-
},
|
|
359
|
-
'sender.contact_name': {
|
|
360
|
-
text: 'Sender Name',
|
|
361
|
-
type: 'string',
|
|
362
|
-
filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
|
|
363
|
-
placeholder: 'e.g. John Doe',
|
|
364
|
-
variable_type: 'string',
|
|
365
|
-
},
|
|
366
|
-
'sender.contact_id': {
|
|
367
|
-
text: 'Sender Phone',
|
|
368
|
-
type: 'string',
|
|
369
|
-
filters: ['EQ', 'NEQ'],
|
|
370
|
-
placeholder: 'e.g. 919876543210',
|
|
371
|
-
variable_type: 'string',
|
|
372
|
-
},
|
|
373
|
-
'sender.labels': {
|
|
374
|
-
text: 'Sender Contact Labels',
|
|
375
|
-
type: 'dropdown',
|
|
376
|
-
value: 'org.labels',
|
|
377
|
-
filters: ['CONTAINS', 'NCONTAINS'],
|
|
378
|
-
variable_type: 'string',
|
|
379
|
-
},
|
|
380
|
-
'sender.org_id': {
|
|
381
|
-
text: 'Org ID',
|
|
382
|
-
type: 'string',
|
|
383
|
-
filters: ['EQ', 'NEQ'],
|
|
384
|
-
hidden: true,
|
|
385
|
-
variable_type: 'string',
|
|
386
|
-
},
|
|
387
|
-
'sender.is_admin': {
|
|
388
|
-
text: 'Sender Is Admin',
|
|
389
|
-
type: 'dropdown',
|
|
390
|
-
filters: ['EQ', 'NEQ'],
|
|
391
|
-
value: [
|
|
392
|
-
{
|
|
393
|
-
id: 'true',
|
|
394
|
-
value: 'true',
|
|
395
|
-
label: 'True',
|
|
396
|
-
},
|
|
397
|
-
{
|
|
398
|
-
id: 'false',
|
|
399
|
-
value: 'false',
|
|
400
|
-
label: 'False',
|
|
401
|
-
},
|
|
402
|
-
],
|
|
403
|
-
variable_type: 'boolean',
|
|
404
|
-
},
|
|
405
|
-
};
|
|
406
|
-
|
|
407
|
-
export const ChatVariableNameMap: Record<
|
|
408
|
-
keyof AppendTypes<{ chat: ChatVariablesType }, '.'>,
|
|
409
|
-
VariableNameValueType
|
|
410
|
-
> = {
|
|
411
|
-
'chat.assigned_to': {
|
|
412
|
-
text: 'Chat Assignee',
|
|
413
|
-
type: 'dropdown',
|
|
414
|
-
value: 'org.members',
|
|
415
|
-
filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
|
|
416
|
-
variable_type: 'string',
|
|
417
|
-
},
|
|
418
|
-
'chat.chat_name': {
|
|
419
|
-
text: 'Chat Name',
|
|
420
|
-
type: 'string',
|
|
421
|
-
filters: ['EQ', 'NEQ', 'CONTAINS', 'NCONTAINS'],
|
|
422
|
-
placeholder: 'e.g. Support Chat',
|
|
423
|
-
variable_type: 'string',
|
|
424
|
-
},
|
|
425
|
-
'chat.org_phone': {
|
|
426
|
-
text: 'Chat Org Phone',
|
|
427
|
-
type: 'dropdown',
|
|
428
|
-
value: 'org.org_phones',
|
|
429
|
-
filters: ['EQ', 'NEQ'],
|
|
430
|
-
variable_type: 'string',
|
|
431
|
-
},
|
|
432
|
-
'chat.chat_type': {
|
|
433
|
-
text: 'Chat Type',
|
|
434
|
-
type: 'dropdown',
|
|
435
|
-
value: [
|
|
436
|
-
{ id: 'user', value: 'user', label: 'User' },
|
|
437
|
-
{ id: 'group', value: 'group', label: 'Group' },
|
|
438
|
-
],
|
|
439
|
-
filters: ['EQ', 'NEQ'],
|
|
440
|
-
variable_type: 'string',
|
|
441
|
-
},
|
|
442
|
-
'chat.members': {
|
|
443
|
-
text: 'Chat Members',
|
|
444
|
-
type: 'string',
|
|
445
|
-
filters: ['CONTAINS', 'NCONTAINS'],
|
|
446
|
-
placeholder: 'e.g. 919876543210',
|
|
447
|
-
variable_type: 'string',
|
|
448
|
-
},
|
|
449
|
-
'chat.labels': {
|
|
450
|
-
text: 'Chat Labels',
|
|
451
|
-
type: 'dropdown',
|
|
452
|
-
value: 'org.labels',
|
|
453
|
-
filters: ['CONTAINS', 'NCONTAINS'],
|
|
454
|
-
variable_type: 'string',
|
|
455
|
-
},
|
|
456
|
-
'chat.chat_id': {
|
|
457
|
-
text: 'Chat ID',
|
|
458
|
-
type: 'string',
|
|
459
|
-
filters: ['EQ', 'NEQ'],
|
|
460
|
-
placeholder: 'e.g. 12027747916749@c.us',
|
|
461
|
-
variable_type: 'string',
|
|
462
|
-
},
|
|
463
|
-
'chat.chat_org_phones': {
|
|
464
|
-
text: 'Chat Org Phones',
|
|
465
|
-
type: 'dropdown',
|
|
466
|
-
filters: ['CONTAINS', 'NCONTAINS'],
|
|
467
|
-
hidden: true,
|
|
468
|
-
variable_type: 'string',
|
|
469
|
-
},
|
|
470
|
-
'chat.org_id': {
|
|
471
|
-
text: 'Org ID',
|
|
472
|
-
type: 'string',
|
|
473
|
-
filters: [],
|
|
474
|
-
hidden: true,
|
|
475
|
-
variable_type: 'string',
|
|
476
|
-
},
|
|
477
|
-
'chat.messages_admins_only': {
|
|
478
|
-
text: 'Messages Admins Only (Chat Settings)',
|
|
479
|
-
type: 'boolean',
|
|
480
|
-
filters: ['EQ', 'NEQ'],
|
|
481
|
-
value: [
|
|
482
|
-
{
|
|
483
|
-
id: 'true',
|
|
484
|
-
value: 'true',
|
|
485
|
-
label: 'True',
|
|
486
|
-
},
|
|
487
|
-
{
|
|
488
|
-
id: 'false',
|
|
489
|
-
value: 'false',
|
|
490
|
-
label: 'False',
|
|
491
|
-
},
|
|
492
|
-
],
|
|
493
|
-
variable_type: 'boolean',
|
|
494
|
-
},
|
|
495
|
-
'chat.info_admins_only': {
|
|
496
|
-
text: 'Info Admins Only (Chat Settings)',
|
|
497
|
-
type: 'boolean',
|
|
498
|
-
filters: ['EQ', 'NEQ'],
|
|
499
|
-
value: [
|
|
500
|
-
{
|
|
501
|
-
id: 'true',
|
|
502
|
-
value: 'true',
|
|
503
|
-
label: 'True',
|
|
504
|
-
},
|
|
505
|
-
{
|
|
506
|
-
id: 'false',
|
|
507
|
-
value: 'false',
|
|
508
|
-
label: 'False',
|
|
509
|
-
},
|
|
510
|
-
],
|
|
511
|
-
variable_type: 'boolean',
|
|
512
|
-
},
|
|
513
|
-
'chat.has_flagged_messages': {
|
|
514
|
-
text: 'Chat Has Flagged Messages',
|
|
515
|
-
type: 'boolean',
|
|
516
|
-
filters: ['EQ', 'NEQ'],
|
|
517
|
-
value: [
|
|
518
|
-
{
|
|
519
|
-
id: 'true',
|
|
520
|
-
value: 'true',
|
|
521
|
-
label: 'True',
|
|
522
|
-
},
|
|
523
|
-
{
|
|
524
|
-
id: 'false',
|
|
525
|
-
value: 'false',
|
|
526
|
-
label: 'False',
|
|
527
|
-
},
|
|
528
|
-
],
|
|
529
|
-
variable_type: 'boolean',
|
|
530
|
-
},
|
|
531
|
-
'chat.group_description': {
|
|
532
|
-
text: 'Group Description',
|
|
533
|
-
type: 'string',
|
|
534
|
-
filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
|
|
535
|
-
placeholder: 'e.g. Group description',
|
|
536
|
-
variable_type: 'string',
|
|
537
|
-
},
|
|
538
|
-
'chat.custom_properties': {
|
|
539
|
-
text: 'Chat Custom Properties',
|
|
540
|
-
type: 'dropdown',
|
|
541
|
-
value: 'org.custom_properties',
|
|
542
|
-
filters: ['EQ', 'NEQ'],
|
|
543
|
-
hidden: true,
|
|
544
|
-
variable_type: 'string',
|
|
545
|
-
},
|
|
546
|
-
'chat.initiated_by': {
|
|
547
|
-
text: 'Chat Initiated By',
|
|
548
|
-
type: 'dropdown',
|
|
549
|
-
value: 'org.members',
|
|
550
|
-
filters: ['EQ', 'NEQ'],
|
|
551
|
-
variable_type: 'string',
|
|
552
|
-
hidden: true,
|
|
553
|
-
},
|
|
554
|
-
'chat.created_at': {
|
|
555
|
-
text: 'Chat Created At',
|
|
556
|
-
type: 'day-time',
|
|
557
|
-
filters: {
|
|
558
|
-
LT: {
|
|
559
|
-
info: 'When chat is created before mentioned time (UTC)',
|
|
560
|
-
},
|
|
561
|
-
LTE: {
|
|
562
|
-
info: 'When chat is created before mentioned time (UTC)',
|
|
563
|
-
},
|
|
564
|
-
GT: {
|
|
565
|
-
info: 'When chat is created after mentioned time (UTC)',
|
|
566
|
-
},
|
|
567
|
-
GTE: {
|
|
568
|
-
info: 'When chat is created on or after mentioned time (UTC)',
|
|
569
|
-
},
|
|
570
|
-
ON: {
|
|
571
|
-
info: 'When chat is created on mentioned days',
|
|
572
|
-
},
|
|
573
|
-
},
|
|
574
|
-
variable_type: 'day-time',
|
|
575
|
-
},
|
|
576
|
-
};
|
|
577
|
-
|
|
578
|
-
export const TicketVariableNameMap: Record<
|
|
579
|
-
keyof AppendTypes<{ ticket: TicketVariablesType }, '.'>,
|
|
580
|
-
VariableNameValueType
|
|
581
|
-
> = {
|
|
582
|
-
'ticket.subject': {
|
|
583
|
-
text: 'Ticket Subject',
|
|
584
|
-
type: 'string',
|
|
585
|
-
filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
|
|
586
|
-
placeholder: 'e.g. Test ticket',
|
|
587
|
-
variable_type: 'string',
|
|
588
|
-
},
|
|
589
|
-
'ticket.status': {
|
|
590
|
-
text: 'Ticket Status',
|
|
591
|
-
type: 'dropdown',
|
|
592
|
-
value: [
|
|
593
|
-
{ id: 'open', value: 'open', label: 'Open' },
|
|
594
|
-
{ id: 'closed', value: 'closed', label: 'Closed' },
|
|
595
|
-
{ id: 'inprogress', value: 'inprogress', label: 'In progress' },
|
|
596
|
-
],
|
|
597
|
-
filters: ['EQ', 'NEQ'],
|
|
598
|
-
variable_type: 'string',
|
|
599
|
-
},
|
|
600
|
-
'ticket.priority': {
|
|
601
|
-
text: 'Ticket Priority',
|
|
602
|
-
type: 'dropdown',
|
|
603
|
-
value: [
|
|
604
|
-
{ id: '0', value: '0', label: 'No Priority' },
|
|
605
|
-
{ id: '1', value: '1', label: 'Low' },
|
|
606
|
-
{ id: '2', value: '2', label: 'Medium' },
|
|
607
|
-
{ id: '3', value: '3', label: 'High' },
|
|
608
|
-
{ id: '4', value: '4', label: 'Urgent' },
|
|
609
|
-
],
|
|
610
|
-
filters: ['EQ', 'NEQ'],
|
|
611
|
-
variable_type: 'string',
|
|
612
|
-
},
|
|
613
|
-
'ticket.assignee': {
|
|
614
|
-
text: 'Ticket Assignee',
|
|
615
|
-
type: 'dropdown',
|
|
616
|
-
value: 'org.members',
|
|
617
|
-
filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
|
|
618
|
-
variable_type: 'string',
|
|
619
|
-
},
|
|
620
|
-
'ticket.labels': {
|
|
621
|
-
text: 'Ticket Labels',
|
|
622
|
-
type: 'dropdown',
|
|
623
|
-
value: 'org.labels',
|
|
624
|
-
filters: ['CONTAINS', 'NCONTAINS'],
|
|
625
|
-
variable_type: 'string',
|
|
626
|
-
},
|
|
627
|
-
'ticket.is_deleted': {
|
|
628
|
-
text: 'Ticket Is Deleted',
|
|
629
|
-
type: 'boolean',
|
|
630
|
-
value: [
|
|
631
|
-
{
|
|
632
|
-
id: 'true',
|
|
633
|
-
value: 'true',
|
|
634
|
-
label: 'True',
|
|
635
|
-
},
|
|
636
|
-
{
|
|
637
|
-
id: 'false',
|
|
638
|
-
value: 'false',
|
|
639
|
-
label: 'False',
|
|
640
|
-
},
|
|
641
|
-
],
|
|
642
|
-
filters: ['IS'],
|
|
643
|
-
variable_type: 'boolean',
|
|
644
|
-
},
|
|
645
|
-
'ticket.raised_by': {
|
|
646
|
-
text: 'Ticket Raised By',
|
|
647
|
-
type: 'dropdown',
|
|
648
|
-
value: 'org.members',
|
|
649
|
-
filters: ['EQ', 'NEQ'],
|
|
650
|
-
variable_type: 'string',
|
|
651
|
-
},
|
|
652
|
-
'ticket.due_date': {
|
|
653
|
-
text: 'Ticket Due Date',
|
|
654
|
-
type: 'date',
|
|
655
|
-
filters: ['KNOWN', 'NKNOWN'],
|
|
656
|
-
variable_type: 'date',
|
|
657
|
-
hidden: true,
|
|
658
|
-
},
|
|
659
|
-
'ticket.ticket_id': {
|
|
660
|
-
text: 'Ticket ID',
|
|
661
|
-
type: 'string',
|
|
662
|
-
filters: ['EQ', 'NEQ'],
|
|
663
|
-
hidden: true,
|
|
664
|
-
variable_type: 'string',
|
|
665
|
-
},
|
|
666
|
-
'ticket.org_id': {
|
|
667
|
-
text: 'Org ID',
|
|
668
|
-
type: 'string',
|
|
669
|
-
filters: ['EQ', 'NEQ'],
|
|
670
|
-
hidden: true,
|
|
671
|
-
variable_type: 'string',
|
|
672
|
-
},
|
|
673
|
-
'ticket.custom_properties': {
|
|
674
|
-
text: 'Ticket Custom Properties',
|
|
675
|
-
type: 'dropdown',
|
|
676
|
-
value: 'org.custom_properties',
|
|
677
|
-
filters: ['EQ', 'NEQ'],
|
|
678
|
-
hidden: true,
|
|
679
|
-
variable_type: 'string',
|
|
680
|
-
},
|
|
681
|
-
'ticket.created_at': {
|
|
682
|
-
text: 'Ticket Created At',
|
|
683
|
-
type: 'day-time',
|
|
684
|
-
filters: {
|
|
685
|
-
LT: {
|
|
686
|
-
info: 'When ticket is created before mentioned time (UTC)',
|
|
687
|
-
},
|
|
688
|
-
LTE: {
|
|
689
|
-
info: 'When ticket is created before mentioned time (UTC)',
|
|
690
|
-
},
|
|
691
|
-
GT: {
|
|
692
|
-
info: 'When ticket is created after mentioned time (UTC)',
|
|
693
|
-
},
|
|
694
|
-
GTE: {
|
|
695
|
-
info: 'When ticket is created on or after mentioned time (UTC)',
|
|
696
|
-
},
|
|
697
|
-
ON: {
|
|
698
|
-
info: 'When ticket is created on mentioned days',
|
|
699
|
-
},
|
|
700
|
-
},
|
|
701
|
-
variable_type: 'day-time',
|
|
702
|
-
},
|
|
703
|
-
'ticket.chat_id': {
|
|
704
|
-
text: 'Chat ID',
|
|
705
|
-
type: 'string',
|
|
706
|
-
filters: ['EQ', 'NEQ'],
|
|
707
|
-
hidden: true,
|
|
708
|
-
variable_type: 'string',
|
|
709
|
-
},
|
|
710
|
-
};
|
|
711
|
-
|
|
712
|
-
export const ReactionVariableNameMap: Record<
|
|
713
|
-
keyof AppendTypes<{ reaction: ReactionVariablesType }, '.'>,
|
|
714
|
-
VariableNameValueType
|
|
715
|
-
> = {
|
|
716
|
-
'reaction.reaction': {
|
|
717
|
-
text: 'Reaction',
|
|
718
|
-
type: 'string',
|
|
719
|
-
filters: ['EQ', 'NEQ'],
|
|
720
|
-
placeholder: 'e.g. 👍',
|
|
721
|
-
variable_type: 'string',
|
|
722
|
-
},
|
|
723
|
-
'reaction.sender_id': {
|
|
724
|
-
text: 'Reaction Sender Phone',
|
|
725
|
-
type: 'string',
|
|
726
|
-
filters: ['EQ', 'NEQ'],
|
|
727
|
-
placeholder: 'e.g. 919876543210',
|
|
728
|
-
variable_type: 'string',
|
|
729
|
-
},
|
|
730
|
-
'reaction.message_id': {
|
|
731
|
-
text: 'Reaction Message ID',
|
|
732
|
-
type: 'string',
|
|
733
|
-
filters: ['EQ', 'NEQ'],
|
|
734
|
-
hidden: true,
|
|
735
|
-
variable_type: 'string',
|
|
736
|
-
},
|
|
737
|
-
'reaction.chat_id': {
|
|
738
|
-
text: 'Chat ID',
|
|
739
|
-
type: 'string',
|
|
740
|
-
filters: ['EQ', 'NEQ'],
|
|
741
|
-
hidden: true,
|
|
742
|
-
variable_type: 'string',
|
|
743
|
-
},
|
|
744
|
-
'reaction.reaction_id': {
|
|
745
|
-
text: 'Reaction ID',
|
|
746
|
-
type: 'string',
|
|
747
|
-
filters: ['EQ', 'NEQ'],
|
|
748
|
-
hidden: true,
|
|
749
|
-
variable_type: 'string',
|
|
750
|
-
},
|
|
751
|
-
};
|
|
752
|
-
|
|
753
|
-
export enum FilterConditionMap {
|
|
754
|
-
'CONTAINS' = 'contains',
|
|
755
|
-
'NCONTAINS' = 'does not contain',
|
|
756
|
-
'EQ' = '=',
|
|
757
|
-
'NEQ' = '<>',
|
|
758
|
-
'LT' = '<',
|
|
759
|
-
'LTE' = '<=',
|
|
760
|
-
'GT' = '>',
|
|
761
|
-
'GTE' = '>=',
|
|
762
|
-
'KNOWN' = 'is known',
|
|
763
|
-
'NKNOWN' = 'is not known',
|
|
764
|
-
'IS' = '=',
|
|
765
|
-
'NIS' = '<>',
|
|
766
|
-
'ON' = 'on',
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
interface FilterGroup {
|
|
770
|
-
filters: Filter[];
|
|
771
|
-
condition: 'allOf' | 'anyOf';
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
export interface Conditions {
|
|
775
|
-
filters: FilterGroup[];
|
|
776
|
-
condition: 'allOf' | 'anyOf';
|
|
777
|
-
variables: string[];
|
|
778
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
779
|
-
org_phones: string[];
|
|
780
|
-
allow_messages_from_org_phones?: boolean;
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
export type SendMessageAction = {
|
|
784
|
-
id: string;
|
|
785
|
-
type: 'send_message';
|
|
786
|
-
metadata: {
|
|
787
|
-
message: string;
|
|
788
|
-
media?: {
|
|
789
|
-
url: string;
|
|
790
|
-
type: 'image' | 'video' | 'audio' | 'document';
|
|
791
|
-
name: string;
|
|
792
|
-
};
|
|
793
|
-
maintain_flag_status: 'true' | 'false';
|
|
794
|
-
debounce_messages: 'true' | 'false';
|
|
795
|
-
debounce_message_time:
|
|
796
|
-
| `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`
|
|
797
|
-
| null
|
|
798
|
-
| undefined;
|
|
799
|
-
};
|
|
800
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
801
|
-
};
|
|
802
|
-
|
|
803
|
-
export type NotifyHttpAction = {
|
|
804
|
-
id: string;
|
|
805
|
-
type: 'notify_http';
|
|
806
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
807
|
-
metadata: {
|
|
808
|
-
url: string;
|
|
809
|
-
};
|
|
810
|
-
};
|
|
811
|
-
|
|
812
|
-
export type CreateTicketAction = {
|
|
813
|
-
id: string;
|
|
814
|
-
type: 'create_ticket';
|
|
815
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
816
|
-
metadata: {
|
|
817
|
-
priority?: '0' | '1' | '2' | '3' | '4';
|
|
818
|
-
label?: string;
|
|
819
|
-
append_to_latest_ticket?: 'true' | 'false';
|
|
820
|
-
round_robin?: 'true' | 'false';
|
|
821
|
-
assignee?: string;
|
|
822
|
-
};
|
|
823
|
-
};
|
|
824
|
-
|
|
825
|
-
export type FlagMessageAction = {
|
|
826
|
-
id: string;
|
|
827
|
-
type: 'flag_message';
|
|
828
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
829
|
-
metadata: {
|
|
830
|
-
flag: 'true' | 'false';
|
|
831
|
-
};
|
|
832
|
-
};
|
|
833
|
-
|
|
834
|
-
export type AssignTicketAction = {
|
|
835
|
-
id: string;
|
|
836
|
-
type: 'assign_ticket';
|
|
837
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
838
|
-
metadata: {
|
|
839
|
-
assignee: string;
|
|
840
|
-
round_robin: 'true' | 'false';
|
|
841
|
-
};
|
|
842
|
-
};
|
|
843
|
-
|
|
844
|
-
export type CloseTicketAction = {
|
|
845
|
-
id: string;
|
|
846
|
-
type: 'close_ticket';
|
|
847
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
848
|
-
metadata: {
|
|
849
|
-
closing_note: string;
|
|
850
|
-
};
|
|
851
|
-
};
|
|
852
|
-
|
|
853
|
-
export type AddChatLabelAction = {
|
|
854
|
-
id: string;
|
|
855
|
-
type: 'add_chat_label';
|
|
856
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
857
|
-
metadata: {
|
|
858
|
-
label: string;
|
|
859
|
-
};
|
|
860
|
-
};
|
|
861
|
-
|
|
862
|
-
export type AddTicketLabelAction = {
|
|
863
|
-
id: string;
|
|
864
|
-
type: 'add_ticket_label';
|
|
865
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
866
|
-
metadata: {
|
|
867
|
-
label: string;
|
|
868
|
-
};
|
|
869
|
-
};
|
|
870
|
-
|
|
871
|
-
export type AssignChatAction = {
|
|
872
|
-
id: string;
|
|
873
|
-
type: 'assign_chat';
|
|
874
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
875
|
-
metadata: {
|
|
876
|
-
assignee: string;
|
|
877
|
-
round_robin: 'true' | 'false';
|
|
878
|
-
};
|
|
879
|
-
};
|
|
880
|
-
|
|
881
|
-
export type ForwardMessageAction = {
|
|
882
|
-
id: string;
|
|
883
|
-
type: 'forward_message';
|
|
884
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
885
|
-
metadata: {
|
|
886
|
-
chat_id: string;
|
|
887
|
-
prefix: string;
|
|
888
|
-
};
|
|
889
|
-
};
|
|
890
|
-
|
|
891
|
-
export type SendEmailAction = {
|
|
892
|
-
id: string;
|
|
893
|
-
type: 'send_email';
|
|
894
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
895
|
-
metadata: {
|
|
896
|
-
email: string;
|
|
897
|
-
subject: string;
|
|
898
|
-
body: string;
|
|
899
|
-
};
|
|
900
|
-
};
|
|
901
|
-
|
|
902
|
-
export type ReplyToMessageAction = {
|
|
903
|
-
id: string;
|
|
904
|
-
type: 'reply_to_message';
|
|
905
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
906
|
-
metadata: {
|
|
907
|
-
message: string;
|
|
908
|
-
media?: {
|
|
909
|
-
url: string;
|
|
910
|
-
type: 'image' | 'video' | 'audio' | 'document';
|
|
911
|
-
name: string;
|
|
912
|
-
};
|
|
913
|
-
maintain_flag_status: 'true' | 'false';
|
|
914
|
-
debounce_messages: 'true' | 'false';
|
|
915
|
-
debounce_message_time:
|
|
916
|
-
| `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`
|
|
917
|
-
| null
|
|
918
|
-
| undefined;
|
|
919
|
-
};
|
|
920
|
-
};
|
|
921
|
-
|
|
922
|
-
export type UpdateCustomPropertyAction = {
|
|
923
|
-
id: string;
|
|
924
|
-
type: 'update_custom_property';
|
|
925
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
926
|
-
metadata: {
|
|
927
|
-
property_id: string;
|
|
928
|
-
value: string;
|
|
929
|
-
};
|
|
930
|
-
};
|
|
931
|
-
|
|
932
|
-
export type DeleteMessageAction = {
|
|
933
|
-
id: string;
|
|
934
|
-
type: 'delete_message';
|
|
935
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
936
|
-
metadata: {};
|
|
937
|
-
};
|
|
938
|
-
|
|
939
|
-
export type SendSlackNotificationAction = {
|
|
940
|
-
id: string;
|
|
941
|
-
type: 'send_slack_notification';
|
|
942
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
943
|
-
metadata: {
|
|
944
|
-
slack_payload: string;
|
|
945
|
-
webhook_url: string;
|
|
946
|
-
};
|
|
947
|
-
};
|
|
948
|
-
|
|
949
|
-
export type AttachMessageToTicketAction = {
|
|
950
|
-
id: string;
|
|
951
|
-
type: 'attach_message_to_ticket';
|
|
952
|
-
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
953
|
-
metadata: {
|
|
954
|
-
status: 'open' | 'inprogress' | 'open_inprogress' | null;
|
|
955
|
-
};
|
|
956
|
-
};
|
|
957
|
-
|
|
958
|
-
export type Action =
|
|
959
|
-
| SendMessageAction
|
|
960
|
-
| NotifyHttpAction
|
|
961
|
-
| CreateTicketAction
|
|
962
|
-
| FlagMessageAction
|
|
963
|
-
| AssignTicketAction
|
|
964
|
-
| CloseTicketAction
|
|
965
|
-
| AddChatLabelAction
|
|
966
|
-
| AddTicketLabelAction
|
|
967
|
-
| AssignChatAction
|
|
968
|
-
| ForwardMessageAction
|
|
969
|
-
| SendEmailAction
|
|
970
|
-
| ReplyToMessageAction
|
|
971
|
-
| UpdateCustomPropertyAction
|
|
972
|
-
| DeleteMessageAction
|
|
973
|
-
| SendSlackNotificationAction
|
|
974
|
-
| AttachMessageToTicketAction;
|
|
975
|
-
|
|
976
|
-
export const isSendMessageOrReplyToMessageAction = (
|
|
977
|
-
action: Action
|
|
978
|
-
): action is SendMessageAction | ReplyToMessageAction => {
|
|
979
|
-
return ['send_message', 'reply_to_message'].includes(action.type);
|
|
980
|
-
};
|
|
981
|
-
|
|
982
|
-
export type Rule = OverrideProperties<
|
|
983
|
-
Tables<'tbl_automation_rules'>,
|
|
984
|
-
{
|
|
985
|
-
actions: Action[];
|
|
986
|
-
conditions: Conditions;
|
|
987
|
-
trigger:
|
|
988
|
-
| 'message.created'
|
|
989
|
-
| 'message.updated'
|
|
990
|
-
| 'chat.created'
|
|
991
|
-
| 'ticket.updated'
|
|
992
|
-
| 'ticket.created'
|
|
993
|
-
| 'reaction.added'
|
|
994
|
-
| 'chat.label.updated'
|
|
995
|
-
| 'message.flagged';
|
|
996
|
-
}
|
|
997
|
-
>;
|
|
998
|
-
|
|
999
|
-
export const RuleNameMap: Record<
|
|
1000
|
-
Rule['trigger'],
|
|
1001
|
-
{
|
|
1002
|
-
title: string;
|
|
1003
|
-
description: string;
|
|
1004
|
-
base_conditions: {
|
|
1005
|
-
org_phone: boolean;
|
|
1006
|
-
};
|
|
1007
|
-
}
|
|
1008
|
-
> = {
|
|
1009
|
-
'message.created': {
|
|
1010
|
-
title: 'New Message Received',
|
|
1011
|
-
description: 'When a new message is received from an external contact',
|
|
1012
|
-
base_conditions: {
|
|
1013
|
-
org_phone: true,
|
|
1014
|
-
},
|
|
1015
|
-
},
|
|
1016
|
-
'chat.created': {
|
|
1017
|
-
title: 'New Chat Created',
|
|
1018
|
-
description: 'When a new chat is created',
|
|
1019
|
-
base_conditions: {
|
|
1020
|
-
org_phone: true,
|
|
1021
|
-
},
|
|
1022
|
-
},
|
|
1023
|
-
'ticket.created': {
|
|
1024
|
-
title: 'New Ticket Created',
|
|
1025
|
-
description: 'When a new ticket is created',
|
|
1026
|
-
base_conditions: {
|
|
1027
|
-
org_phone: false,
|
|
1028
|
-
},
|
|
1029
|
-
},
|
|
1030
|
-
'reaction.added': {
|
|
1031
|
-
title: 'New Reaction Added',
|
|
1032
|
-
description: 'When a reaction is added on a message',
|
|
1033
|
-
base_conditions: {
|
|
1034
|
-
org_phone: true,
|
|
1035
|
-
},
|
|
1036
|
-
},
|
|
1037
|
-
'message.updated': {
|
|
1038
|
-
title: 'Message Updated',
|
|
1039
|
-
description: 'When a message is updated',
|
|
1040
|
-
base_conditions: {
|
|
1041
|
-
org_phone: true,
|
|
1042
|
-
},
|
|
1043
|
-
},
|
|
1044
|
-
'ticket.updated': {
|
|
1045
|
-
title: 'Ticket Updated',
|
|
1046
|
-
description: 'When a ticket is updated',
|
|
1047
|
-
base_conditions: {
|
|
1048
|
-
org_phone: false,
|
|
1049
|
-
},
|
|
1050
|
-
},
|
|
1051
|
-
'chat.label.updated': {
|
|
1052
|
-
title: 'Chat Label Added/Removed',
|
|
1053
|
-
description: 'When labels on chats are updated',
|
|
1054
|
-
base_conditions: {
|
|
1055
|
-
org_phone: false,
|
|
1056
|
-
},
|
|
1057
|
-
},
|
|
1058
|
-
'message.flagged': {
|
|
1059
|
-
title: 'Message Flagged',
|
|
1060
|
-
description: 'When a message is flagged',
|
|
1061
|
-
base_conditions: {
|
|
1062
|
-
org_phone: true,
|
|
1063
|
-
},
|
|
1064
|
-
},
|
|
1065
|
-
};
|
|
1066
|
-
|
|
1067
|
-
export const ActionNameMap: Record<
|
|
1068
|
-
Action['type'],
|
|
1069
|
-
{
|
|
1070
|
-
title: string;
|
|
1071
|
-
description: string;
|
|
1072
|
-
inputs: Record<
|
|
1073
|
-
string,
|
|
1074
|
-
{
|
|
1075
|
-
id: string;
|
|
1076
|
-
type:
|
|
1077
|
-
| 'text'
|
|
1078
|
-
| 'dropdown'
|
|
1079
|
-
| 'editor'
|
|
1080
|
-
| 'date'
|
|
1081
|
-
| 'file'
|
|
1082
|
-
| 'textarea'
|
|
1083
|
-
| 'dynamic'
|
|
1084
|
-
| 'json_editor';
|
|
1085
|
-
value:
|
|
1086
|
-
| 'ticket.labels'
|
|
1087
|
-
| 'org.members'
|
|
1088
|
-
| 'chat.labels'
|
|
1089
|
-
| 'org.chats'
|
|
1090
|
-
| {
|
|
1091
|
-
id: string;
|
|
1092
|
-
value: string;
|
|
1093
|
-
label: string;
|
|
1094
|
-
}[]
|
|
1095
|
-
| null
|
|
1096
|
-
| 'org.custom_properties'
|
|
1097
|
-
| 'custom_property_values'
|
|
1098
|
-
| 'debounce_messages';
|
|
1099
|
-
label: string;
|
|
1100
|
-
placeholder: string;
|
|
1101
|
-
info?: string;
|
|
1102
|
-
required: boolean;
|
|
1103
|
-
description?: string;
|
|
1104
|
-
}
|
|
1105
|
-
>;
|
|
1106
|
-
info?: string;
|
|
1107
|
-
validTriggers: Rule['trigger'][];
|
|
1108
|
-
}
|
|
1109
|
-
> = {
|
|
1110
|
-
send_message: {
|
|
1111
|
-
title: 'Send Message',
|
|
1112
|
-
description: 'Send a message',
|
|
1113
|
-
inputs: {
|
|
1114
|
-
message: {
|
|
1115
|
-
id: 'message',
|
|
1116
|
-
type: 'editor',
|
|
1117
|
-
label: 'Message',
|
|
1118
|
-
placeholder: 'Enter message',
|
|
1119
|
-
value: null,
|
|
1120
|
-
required: true,
|
|
1121
|
-
},
|
|
1122
|
-
media: {
|
|
1123
|
-
id: 'media',
|
|
1124
|
-
type: 'file',
|
|
1125
|
-
label: 'Media',
|
|
1126
|
-
placeholder: 'Upload media',
|
|
1127
|
-
value: null,
|
|
1128
|
-
required: false,
|
|
1129
|
-
},
|
|
1130
|
-
maintain_flag_status: {
|
|
1131
|
-
id: 'maintain_flag_status',
|
|
1132
|
-
type: 'dropdown',
|
|
1133
|
-
label: 'Maintain Flag Status',
|
|
1134
|
-
placeholder: 'Select...',
|
|
1135
|
-
value: [
|
|
1136
|
-
{ id: 'true', value: 'true', label: 'True' },
|
|
1137
|
-
{ id: 'false', value: 'false', label: 'False' },
|
|
1138
|
-
],
|
|
1139
|
-
required: true,
|
|
1140
|
-
},
|
|
1141
|
-
debounce_messages: {
|
|
1142
|
-
id: 'debounce_messages',
|
|
1143
|
-
type: 'dropdown',
|
|
1144
|
-
label: 'Enable Cooldown Period',
|
|
1145
|
-
placeholder: 'Select...',
|
|
1146
|
-
value: [
|
|
1147
|
-
{ id: 'true', value: 'true', label: 'True' },
|
|
1148
|
-
{ id: 'false', value: 'false', label: 'False' },
|
|
1149
|
-
],
|
|
1150
|
-
info: 'If enabled, only one message per chat will be sent in the specified cooldown period',
|
|
1151
|
-
required: false,
|
|
1152
|
-
},
|
|
1153
|
-
debounce_message_time: {
|
|
1154
|
-
id: 'debounce_message_time',
|
|
1155
|
-
type: 'dynamic',
|
|
1156
|
-
label: 'Cooldown Period',
|
|
1157
|
-
placeholder: 'Enter time',
|
|
1158
|
-
value: 'debounce_messages',
|
|
1159
|
-
required: false,
|
|
1160
|
-
},
|
|
1161
|
-
},
|
|
1162
|
-
validTriggers: [
|
|
1163
|
-
'message.created',
|
|
1164
|
-
'message.updated',
|
|
1165
|
-
'chat.created',
|
|
1166
|
-
'ticket.updated',
|
|
1167
|
-
'ticket.created',
|
|
1168
|
-
'reaction.added',
|
|
1169
|
-
'message.flagged',
|
|
1170
|
-
'chat.label.updated',
|
|
1171
|
-
],
|
|
1172
|
-
},
|
|
1173
|
-
reply_to_message: {
|
|
1174
|
-
title: 'Reply to message',
|
|
1175
|
-
description: 'Send a message with the quoted message',
|
|
1176
|
-
inputs: {
|
|
1177
|
-
message: {
|
|
1178
|
-
id: 'message',
|
|
1179
|
-
type: 'editor',
|
|
1180
|
-
label: 'Message',
|
|
1181
|
-
placeholder: 'Enter message',
|
|
1182
|
-
value: null,
|
|
1183
|
-
required: true,
|
|
1184
|
-
},
|
|
1185
|
-
media: {
|
|
1186
|
-
id: 'media',
|
|
1187
|
-
type: 'file',
|
|
1188
|
-
label: 'Media',
|
|
1189
|
-
placeholder: 'Upload media',
|
|
1190
|
-
value: null,
|
|
1191
|
-
required: false,
|
|
1192
|
-
},
|
|
1193
|
-
maintain_flag_status: {
|
|
1194
|
-
id: 'maintain_flag_status',
|
|
1195
|
-
type: 'dropdown',
|
|
1196
|
-
label: 'Maintain Flag Status',
|
|
1197
|
-
placeholder: 'Select...',
|
|
1198
|
-
value: [
|
|
1199
|
-
{ id: 'true', value: 'true', label: 'True' },
|
|
1200
|
-
{ id: 'false', value: 'false', label: 'False' },
|
|
1201
|
-
],
|
|
1202
|
-
required: true,
|
|
1203
|
-
},
|
|
1204
|
-
debounce_messages: {
|
|
1205
|
-
id: 'debounce_messages',
|
|
1206
|
-
type: 'dropdown',
|
|
1207
|
-
label: 'Enable Cooldown Period',
|
|
1208
|
-
placeholder: 'Select...',
|
|
1209
|
-
value: [
|
|
1210
|
-
{ id: 'true', value: 'true', label: 'True' },
|
|
1211
|
-
{ id: 'false', value: 'false', label: 'False' },
|
|
1212
|
-
],
|
|
1213
|
-
info: 'If enabled, only one message per chat will be sent in the specified cooldown period',
|
|
1214
|
-
required: false,
|
|
1215
|
-
},
|
|
1216
|
-
debounce_message_time: {
|
|
1217
|
-
id: 'debounce_message_time',
|
|
1218
|
-
type: 'dynamic',
|
|
1219
|
-
label: 'Cooldown Period',
|
|
1220
|
-
placeholder: 'Enter time',
|
|
1221
|
-
value: 'debounce_messages',
|
|
1222
|
-
required: false,
|
|
1223
|
-
},
|
|
1224
|
-
},
|
|
1225
|
-
validTriggers: [
|
|
1226
|
-
'message.created',
|
|
1227
|
-
'message.updated',
|
|
1228
|
-
'reaction.added',
|
|
1229
|
-
'message.flagged',
|
|
1230
|
-
'ticket.created',
|
|
1231
|
-
'ticket.updated',
|
|
1232
|
-
],
|
|
1233
|
-
},
|
|
1234
|
-
delete_message: {
|
|
1235
|
-
title: 'Delete Message',
|
|
1236
|
-
description: 'Delete a message',
|
|
1237
|
-
inputs: {},
|
|
1238
|
-
validTriggers: [
|
|
1239
|
-
'message.created',
|
|
1240
|
-
'message.updated',
|
|
1241
|
-
'reaction.added',
|
|
1242
|
-
'message.flagged',
|
|
1243
|
-
'ticket.created',
|
|
1244
|
-
'ticket.updated',
|
|
1245
|
-
],
|
|
1246
|
-
},
|
|
1247
|
-
attach_message_to_ticket: {
|
|
1248
|
-
title: 'Attach Message To Latest Ticket',
|
|
1249
|
-
description: 'Attach message to latest ticket based on statuses',
|
|
1250
|
-
inputs: {
|
|
1251
|
-
status: {
|
|
1252
|
-
id: 'status',
|
|
1253
|
-
type: 'dropdown',
|
|
1254
|
-
value: [
|
|
1255
|
-
{
|
|
1256
|
-
id: 'open_inprogress',
|
|
1257
|
-
value: 'open_inprogress',
|
|
1258
|
-
label: 'Open/In Progress',
|
|
1259
|
-
},
|
|
1260
|
-
{ id: 'open', value: 'open', label: 'Open' },
|
|
1261
|
-
{ id: 'inprogress', value: 'inprogress', label: 'In Progress' },
|
|
1262
|
-
],
|
|
1263
|
-
label: 'Ticket Status',
|
|
1264
|
-
placeholder: 'Select...',
|
|
1265
|
-
required: true,
|
|
1266
|
-
info: 'Select the ticket status of ticket to attach the message to (only applicable for open or inprogress tickets)',
|
|
1267
|
-
},
|
|
1268
|
-
},
|
|
1269
|
-
validTriggers: [
|
|
1270
|
-
'message.created',
|
|
1271
|
-
'message.updated',
|
|
1272
|
-
'reaction.added',
|
|
1273
|
-
'message.flagged',
|
|
1274
|
-
],
|
|
1275
|
-
},
|
|
1276
|
-
notify_http: {
|
|
1277
|
-
title: 'Notify HTTP',
|
|
1278
|
-
description: 'Notify an HTTP endpoint',
|
|
1279
|
-
inputs: {
|
|
1280
|
-
url: {
|
|
1281
|
-
id: 'url',
|
|
1282
|
-
type: 'text',
|
|
1283
|
-
label: 'URL',
|
|
1284
|
-
placeholder: 'Enter URL',
|
|
1285
|
-
value: null,
|
|
1286
|
-
required: true,
|
|
1287
|
-
description:
|
|
1288
|
-
'Enter the Webhook URL here. The endpoint added here should be a **POST HTTP / Endpoint** with no open auth.',
|
|
1289
|
-
},
|
|
1290
|
-
},
|
|
1291
|
-
validTriggers: [
|
|
1292
|
-
'message.created',
|
|
1293
|
-
'message.updated',
|
|
1294
|
-
'chat.created',
|
|
1295
|
-
'ticket.updated',
|
|
1296
|
-
'ticket.created',
|
|
1297
|
-
'reaction.added',
|
|
1298
|
-
'message.flagged',
|
|
1299
|
-
'chat.label.updated',
|
|
1300
|
-
],
|
|
1301
|
-
},
|
|
1302
|
-
create_ticket: {
|
|
1303
|
-
title: 'Create Ticket or Attach Message To Latest Ticket',
|
|
1304
|
-
description: 'Create a ticket or attach message to latest ticket',
|
|
1305
|
-
inputs: {
|
|
1306
|
-
append_to_latest_ticket: {
|
|
1307
|
-
id: 'append_to_latest_ticket',
|
|
1308
|
-
type: 'dropdown',
|
|
1309
|
-
value: [
|
|
1310
|
-
{ id: 'true', value: 'true', label: 'True' },
|
|
1311
|
-
{ id: 'false', value: 'false', label: 'False' },
|
|
1312
|
-
],
|
|
1313
|
-
label: 'Attach message to latest ticket (if available)',
|
|
1314
|
-
placeholder: 'Select...',
|
|
1315
|
-
info: 'If enabled, the message will be appended to the latest open ticket (if available) else a new ticket will be created',
|
|
1316
|
-
required: false,
|
|
1317
|
-
},
|
|
1318
|
-
priority: {
|
|
1319
|
-
id: 'priority',
|
|
1320
|
-
type: 'dropdown',
|
|
1321
|
-
value: [
|
|
1322
|
-
{ id: '0', value: '0', label: 'No Priority' },
|
|
1323
|
-
{ id: '1', value: '1', label: 'Low' },
|
|
1324
|
-
{ id: '2', value: '2', label: 'Medium' },
|
|
1325
|
-
{ id: '3', value: '3', label: 'High' },
|
|
1326
|
-
{ id: '4', value: '4', label: 'Urgent' },
|
|
1327
|
-
],
|
|
1328
|
-
label: 'Priority (New Ticket)',
|
|
1329
|
-
placeholder: 'Select priority',
|
|
1330
|
-
info: 'Only applicable for create ticket. If no priority is selected, the ticket will have no priority.',
|
|
1331
|
-
required: false,
|
|
1332
|
-
},
|
|
1333
|
-
label: {
|
|
1334
|
-
id: 'label',
|
|
1335
|
-
type: 'dropdown',
|
|
1336
|
-
value: 'ticket.labels',
|
|
1337
|
-
label: 'Label (New Ticket)',
|
|
1338
|
-
placeholder: 'Select label',
|
|
1339
|
-
info: 'Only applicable for create ticket. If no label is selected, the ticket will have no label.',
|
|
1340
|
-
required: false,
|
|
1341
|
-
},
|
|
1342
|
-
round_robin: {
|
|
1343
|
-
id: 'round_robin',
|
|
1344
|
-
type: 'dropdown',
|
|
1345
|
-
value: [
|
|
1346
|
-
{ id: 'true', value: 'true', label: 'True' },
|
|
1347
|
-
{ id: 'false', value: 'false', label: 'False' },
|
|
1348
|
-
],
|
|
1349
|
-
label: 'Enable Round Robin (New Ticket: Assignee)',
|
|
1350
|
-
placeholder: 'Select...',
|
|
1351
|
-
info: 'If enabled, the ticket will be assigned to the next available agent in the list',
|
|
1352
|
-
required: false,
|
|
1353
|
-
},
|
|
1354
|
-
assignee: {
|
|
1355
|
-
id: 'assignee',
|
|
1356
|
-
type: 'dynamic',
|
|
1357
|
-
value: 'org.members',
|
|
1358
|
-
label: 'Assignee (New Ticket)',
|
|
1359
|
-
placeholder: 'Select assignee',
|
|
1360
|
-
info: "If round robin is enabled, the ticket will be assigned to the next available agent in the list else it'll be assigned to the selected agent",
|
|
1361
|
-
required: false,
|
|
1362
|
-
},
|
|
1363
|
-
},
|
|
1364
|
-
validTriggers: [
|
|
1365
|
-
'message.created',
|
|
1366
|
-
'message.updated',
|
|
1367
|
-
'reaction.added',
|
|
1368
|
-
'message.flagged',
|
|
1369
|
-
],
|
|
1370
|
-
},
|
|
1371
|
-
flag_message: {
|
|
1372
|
-
title: 'Update flag status',
|
|
1373
|
-
description: 'Flag/Unflag a message',
|
|
1374
|
-
inputs: {
|
|
1375
|
-
flag: {
|
|
1376
|
-
id: 'flag',
|
|
1377
|
-
type: 'dropdown',
|
|
1378
|
-
value: [
|
|
1379
|
-
{ id: 'flag', value: 'true', label: 'True' },
|
|
1380
|
-
{ id: 'unflag', value: 'false', label: 'False' },
|
|
1381
|
-
],
|
|
1382
|
-
label: 'Flag status',
|
|
1383
|
-
placeholder: 'Select flag',
|
|
1384
|
-
required: true,
|
|
1385
|
-
},
|
|
1386
|
-
},
|
|
1387
|
-
validTriggers: [
|
|
1388
|
-
'message.created',
|
|
1389
|
-
'message.updated',
|
|
1390
|
-
'reaction.added',
|
|
1391
|
-
'message.flagged',
|
|
1392
|
-
'ticket.created',
|
|
1393
|
-
'ticket.updated',
|
|
1394
|
-
],
|
|
1395
|
-
},
|
|
1396
|
-
assign_ticket: {
|
|
1397
|
-
title: 'Assign Ticket',
|
|
1398
|
-
description: 'Assign a ticket',
|
|
1399
|
-
inputs: {
|
|
1400
|
-
round_robin: {
|
|
1401
|
-
id: 'round_robin',
|
|
1402
|
-
type: 'dropdown',
|
|
1403
|
-
value: [
|
|
1404
|
-
{ id: 'true', value: 'true', label: 'True' },
|
|
1405
|
-
{ id: 'false', value: 'false', label: 'False' },
|
|
1406
|
-
],
|
|
1407
|
-
label: 'Enable Round Robin',
|
|
1408
|
-
placeholder: 'Select...',
|
|
1409
|
-
info: 'If enabled, the ticket will be assigned to the next available agent in the list',
|
|
1410
|
-
required: false,
|
|
1411
|
-
},
|
|
1412
|
-
assignee: {
|
|
1413
|
-
id: 'assignee',
|
|
1414
|
-
type: 'dynamic',
|
|
1415
|
-
value: 'org.members',
|
|
1416
|
-
label: 'Assignee',
|
|
1417
|
-
placeholder: 'Select assignee',
|
|
1418
|
-
info: "If round robin is enabled, the ticket will be assigned to the next available agent in the list else it'll be assigned to the selected agent",
|
|
1419
|
-
required: true,
|
|
1420
|
-
},
|
|
1421
|
-
},
|
|
1422
|
-
validTriggers: ['ticket.updated', 'ticket.created'],
|
|
1423
|
-
},
|
|
1424
|
-
close_ticket: {
|
|
1425
|
-
title: 'Close Ticket',
|
|
1426
|
-
description: 'Close a ticket',
|
|
1427
|
-
info: "This action will close the ticket. This doesn't check for mandatory ticket custom properties.",
|
|
1428
|
-
inputs: {
|
|
1429
|
-
closing_note: {
|
|
1430
|
-
id: 'closing_note',
|
|
1431
|
-
type: 'textarea',
|
|
1432
|
-
label: 'Closing Note',
|
|
1433
|
-
placeholder: 'Enter closing note',
|
|
1434
|
-
value: null,
|
|
1435
|
-
required: false,
|
|
1436
|
-
},
|
|
1437
|
-
},
|
|
1438
|
-
validTriggers: ['ticket.updated', 'ticket.created', 'reaction.added'],
|
|
1439
|
-
},
|
|
1440
|
-
add_chat_label: {
|
|
1441
|
-
title: 'Add Chat Label',
|
|
1442
|
-
description: 'Add a label to referred chat',
|
|
1443
|
-
inputs: {
|
|
1444
|
-
label: {
|
|
1445
|
-
id: 'label',
|
|
1446
|
-
type: 'dropdown',
|
|
1447
|
-
value: 'chat.labels',
|
|
1448
|
-
label: 'Label',
|
|
1449
|
-
placeholder: 'Select label',
|
|
1450
|
-
required: true,
|
|
1451
|
-
},
|
|
1452
|
-
},
|
|
1453
|
-
validTriggers: [
|
|
1454
|
-
'message.created',
|
|
1455
|
-
'message.updated',
|
|
1456
|
-
'chat.created',
|
|
1457
|
-
'ticket.updated',
|
|
1458
|
-
'ticket.created',
|
|
1459
|
-
'reaction.added',
|
|
1460
|
-
'chat.label.updated',
|
|
1461
|
-
'message.flagged',
|
|
1462
|
-
],
|
|
1463
|
-
},
|
|
1464
|
-
add_ticket_label: {
|
|
1465
|
-
title: 'Add Ticket Label',
|
|
1466
|
-
description: 'Add a label to referred ticket',
|
|
1467
|
-
inputs: {
|
|
1468
|
-
label: {
|
|
1469
|
-
id: 'label',
|
|
1470
|
-
type: 'dropdown',
|
|
1471
|
-
value: 'ticket.labels',
|
|
1472
|
-
label: 'Label',
|
|
1473
|
-
placeholder: 'Select label',
|
|
1474
|
-
required: true,
|
|
1475
|
-
},
|
|
1476
|
-
},
|
|
1477
|
-
validTriggers: ['ticket.updated', 'ticket.created'],
|
|
1478
|
-
},
|
|
1479
|
-
update_custom_property: {
|
|
1480
|
-
description: 'Update a chat custom property',
|
|
1481
|
-
title: 'Update Chat Custom Property',
|
|
1482
|
-
validTriggers: [
|
|
1483
|
-
'message.created',
|
|
1484
|
-
'message.updated',
|
|
1485
|
-
'chat.created',
|
|
1486
|
-
'ticket.updated',
|
|
1487
|
-
'ticket.created',
|
|
1488
|
-
'reaction.added',
|
|
1489
|
-
'message.flagged',
|
|
1490
|
-
'chat.label.updated',
|
|
1491
|
-
],
|
|
1492
|
-
inputs: {
|
|
1493
|
-
property_id: {
|
|
1494
|
-
id: 'property_id',
|
|
1495
|
-
type: 'dropdown',
|
|
1496
|
-
value: 'org.custom_properties',
|
|
1497
|
-
label: 'Property',
|
|
1498
|
-
placeholder: 'Select property',
|
|
1499
|
-
required: true,
|
|
1500
|
-
},
|
|
1501
|
-
value: {
|
|
1502
|
-
id: 'property_id',
|
|
1503
|
-
type: 'dynamic',
|
|
1504
|
-
label: 'Value',
|
|
1505
|
-
placeholder: 'Enter value',
|
|
1506
|
-
value: 'custom_property_values',
|
|
1507
|
-
required: true,
|
|
1508
|
-
},
|
|
1509
|
-
},
|
|
1510
|
-
},
|
|
1511
|
-
assign_chat: {
|
|
1512
|
-
title: 'Assign Chat',
|
|
1513
|
-
description: 'Assign a chat',
|
|
1514
|
-
inputs: {
|
|
1515
|
-
round_robin: {
|
|
1516
|
-
id: 'round_robin',
|
|
1517
|
-
type: 'dropdown',
|
|
1518
|
-
value: [
|
|
1519
|
-
{ id: 'true', value: 'true', label: 'True' },
|
|
1520
|
-
{ id: 'false', value: 'false', label: 'False' },
|
|
1521
|
-
],
|
|
1522
|
-
label: 'Enable Round Robin',
|
|
1523
|
-
placeholder: 'Select...',
|
|
1524
|
-
info: 'If enabled, the chat will be assigned to the next available agent in the list',
|
|
1525
|
-
required: false,
|
|
1526
|
-
},
|
|
1527
|
-
assignee: {
|
|
1528
|
-
id: 'assignee',
|
|
1529
|
-
type: 'dynamic',
|
|
1530
|
-
value: 'org.members',
|
|
1531
|
-
label: 'Assignee',
|
|
1532
|
-
placeholder: 'Select assignee',
|
|
1533
|
-
required: true,
|
|
1534
|
-
},
|
|
1535
|
-
},
|
|
1536
|
-
validTriggers: [
|
|
1537
|
-
'message.created',
|
|
1538
|
-
'message.updated',
|
|
1539
|
-
'chat.created',
|
|
1540
|
-
'ticket.updated',
|
|
1541
|
-
'ticket.created',
|
|
1542
|
-
'reaction.added',
|
|
1543
|
-
'chat.label.updated',
|
|
1544
|
-
'message.flagged',
|
|
1545
|
-
],
|
|
1546
|
-
},
|
|
1547
|
-
forward_message: {
|
|
1548
|
-
title: 'Forward Message',
|
|
1549
|
-
description: 'Forward a message',
|
|
1550
|
-
inputs: {
|
|
1551
|
-
chat_id: {
|
|
1552
|
-
id: 'chat_id',
|
|
1553
|
-
type: 'dropdown',
|
|
1554
|
-
value: 'org.chats',
|
|
1555
|
-
label: 'Chat',
|
|
1556
|
-
placeholder: 'Select chat',
|
|
1557
|
-
required: true,
|
|
1558
|
-
},
|
|
1559
|
-
},
|
|
1560
|
-
validTriggers: [
|
|
1561
|
-
'message.created',
|
|
1562
|
-
'message.updated',
|
|
1563
|
-
'ticket.updated',
|
|
1564
|
-
'ticket.created',
|
|
1565
|
-
'reaction.added',
|
|
1566
|
-
'message.flagged',
|
|
1567
|
-
],
|
|
1568
|
-
},
|
|
1569
|
-
send_email: {
|
|
1570
|
-
title: 'Send Email',
|
|
1571
|
-
description: 'Send an email',
|
|
1572
|
-
inputs: {
|
|
1573
|
-
email: {
|
|
1574
|
-
id: 'email',
|
|
1575
|
-
type: 'text',
|
|
1576
|
-
label: 'Email',
|
|
1577
|
-
placeholder: 'Enter email',
|
|
1578
|
-
value: null,
|
|
1579
|
-
required: true,
|
|
1580
|
-
},
|
|
1581
|
-
subject: {
|
|
1582
|
-
id: 'subject',
|
|
1583
|
-
type: 'editor',
|
|
1584
|
-
label: 'Subject',
|
|
1585
|
-
placeholder: 'Enter subject',
|
|
1586
|
-
value: null,
|
|
1587
|
-
required: true,
|
|
1588
|
-
},
|
|
1589
|
-
body: {
|
|
1590
|
-
id: 'body',
|
|
1591
|
-
type: 'editor',
|
|
1592
|
-
label: 'Body',
|
|
1593
|
-
placeholder: 'Enter body',
|
|
1594
|
-
value: null,
|
|
1595
|
-
required: true,
|
|
1596
|
-
},
|
|
1597
|
-
},
|
|
1598
|
-
validTriggers: [
|
|
1599
|
-
'message.created',
|
|
1600
|
-
'message.updated',
|
|
1601
|
-
'chat.created',
|
|
1602
|
-
'ticket.updated',
|
|
1603
|
-
'ticket.created',
|
|
1604
|
-
'reaction.added',
|
|
1605
|
-
'message.flagged',
|
|
1606
|
-
'chat.label.updated',
|
|
1607
|
-
],
|
|
1608
|
-
},
|
|
1609
|
-
send_slack_notification: {
|
|
1610
|
-
title: 'Send Slack Webhook Notification',
|
|
1611
|
-
description: 'Send a slack webhook notification to a channel',
|
|
1612
|
-
validTriggers: [
|
|
1613
|
-
'message.created',
|
|
1614
|
-
'message.updated',
|
|
1615
|
-
'chat.created',
|
|
1616
|
-
'ticket.updated',
|
|
1617
|
-
'ticket.created',
|
|
1618
|
-
'reaction.added',
|
|
1619
|
-
'message.flagged',
|
|
1620
|
-
'chat.label.updated',
|
|
1621
|
-
],
|
|
1622
|
-
inputs: {
|
|
1623
|
-
webhook_url: {
|
|
1624
|
-
type: 'text',
|
|
1625
|
-
id: 'webhook_url',
|
|
1626
|
-
label: 'Webhook URL',
|
|
1627
|
-
placeholder: 'Enter webhook URL',
|
|
1628
|
-
value: null,
|
|
1629
|
-
required: true,
|
|
1630
|
-
description:
|
|
1631
|
-
'Enter the webhook URL to send the notification, to create a slack incoming webhook to start receiving notification check [here](https://api.slack.com/messaging/webhooks)',
|
|
1632
|
-
},
|
|
1633
|
-
slack_payload: {
|
|
1634
|
-
type: 'json_editor',
|
|
1635
|
-
id: 'slack_payload',
|
|
1636
|
-
label: 'Slack Notification Payload',
|
|
1637
|
-
placeholder: 'Enter payload',
|
|
1638
|
-
value: null,
|
|
1639
|
-
required: true,
|
|
1640
|
-
description:
|
|
1641
|
-
'You can send slack blocks as notifications to the provided hook URL.\n\nIn order to **build a slack notification block**, you can visit [here](https://api.slack.com/block-kit/building)',
|
|
1642
|
-
},
|
|
1643
|
-
},
|
|
1644
|
-
},
|
|
1645
|
-
};
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
type editorVariablesList =
|
|
1649
|
-
| 'chat.assigned_to'
|
|
1650
|
-
| 'chat.chat_id'
|
|
1651
|
-
| 'chat.chat_name'
|
|
1652
|
-
| 'chat.chat_type'
|
|
1653
|
-
| 'chat.org_phone'
|
|
1654
|
-
| 'chat.org_id'
|
|
1655
|
-
| 'chat.group_description'
|
|
1656
|
-
| 'ticket.assignee'
|
|
1657
|
-
| 'ticket.due_date'
|
|
1658
|
-
| 'ticket.priority'
|
|
1659
|
-
| 'ticket.status'
|
|
1660
|
-
| 'ticket.subject'
|
|
1661
|
-
| 'ticket.ticket_id'
|
|
1662
|
-
| 'ticket.raised_by'
|
|
1663
|
-
| 'ticket.created_at'
|
|
1664
|
-
| 'sender.is_internal'
|
|
1665
|
-
| 'sender.is_admin'
|
|
1666
|
-
| 'sender.contact_name'
|
|
1667
|
-
| 'sender.contact_id'
|
|
1668
|
-
| 'reaction.sender_id'
|
|
1669
|
-
| 'reaction.reaction'
|
|
1670
|
-
| 'message.message_id'
|
|
1671
|
-
| 'message.timestamp'
|
|
1672
|
-
| 'message.sender_phone'
|
|
1673
|
-
| 'message.message_type'
|
|
1674
|
-
| 'message.media'
|
|
1675
|
-
| 'message.body';
|
|
1676
|
-
|
|
1677
|
-
export const editorVariables: Array<{
|
|
1678
|
-
label: string;
|
|
1679
|
-
value: editorVariablesList;
|
|
1680
|
-
validTriggers: Rule['trigger'][];
|
|
1681
|
-
}> = [
|
|
1682
|
-
{
|
|
1683
|
-
label: 'Ticket ID',
|
|
1684
|
-
value: 'ticket.ticket_id',
|
|
1685
|
-
validTriggers: ['ticket.updated', 'ticket.created'],
|
|
1686
|
-
},
|
|
1687
|
-
{
|
|
1688
|
-
value: 'ticket.assignee',
|
|
1689
|
-
label: 'Ticket Assignee',
|
|
1690
|
-
validTriggers: ['ticket.updated', 'ticket.created'],
|
|
1691
|
-
},
|
|
1692
|
-
{
|
|
1693
|
-
value: 'ticket.due_date',
|
|
1694
|
-
label: 'Ticket Due Date',
|
|
1695
|
-
validTriggers: ['ticket.updated', 'ticket.created'],
|
|
1696
|
-
},
|
|
1697
|
-
{
|
|
1698
|
-
value: 'ticket.priority',
|
|
1699
|
-
label: 'Ticket Priority',
|
|
1700
|
-
validTriggers: ['ticket.updated', 'ticket.created'],
|
|
1701
|
-
},
|
|
1702
|
-
{
|
|
1703
|
-
value: 'ticket.status',
|
|
1704
|
-
label: 'Ticket Status',
|
|
1705
|
-
validTriggers: ['ticket.updated', 'ticket.created'],
|
|
1706
|
-
},
|
|
1707
|
-
{
|
|
1708
|
-
value: 'ticket.subject',
|
|
1709
|
-
label: 'Ticket Subject',
|
|
1710
|
-
validTriggers: ['ticket.updated', 'ticket.created'],
|
|
1711
|
-
},
|
|
1712
|
-
{
|
|
1713
|
-
label: 'Message Body',
|
|
1714
|
-
value: 'message.body',
|
|
1715
|
-
validTriggers: [
|
|
1716
|
-
'message.created',
|
|
1717
|
-
'message.updated',
|
|
1718
|
-
'reaction.added',
|
|
1719
|
-
'message.flagged',
|
|
1720
|
-
'ticket.created',
|
|
1721
|
-
'ticket.updated',
|
|
1722
|
-
],
|
|
1723
|
-
},
|
|
1724
|
-
{
|
|
1725
|
-
value: 'message.media',
|
|
1726
|
-
label: 'Message Media',
|
|
1727
|
-
validTriggers: [
|
|
1728
|
-
'message.created',
|
|
1729
|
-
'message.updated',
|
|
1730
|
-
'reaction.added',
|
|
1731
|
-
'message.flagged',
|
|
1732
|
-
'ticket.created',
|
|
1733
|
-
'ticket.updated',
|
|
1734
|
-
],
|
|
1735
|
-
},
|
|
1736
|
-
{
|
|
1737
|
-
value: 'message.message_id',
|
|
1738
|
-
label: 'Message ID',
|
|
1739
|
-
validTriggers: [
|
|
1740
|
-
'message.created',
|
|
1741
|
-
'message.updated',
|
|
1742
|
-
'reaction.added',
|
|
1743
|
-
'message.flagged',
|
|
1744
|
-
'ticket.created',
|
|
1745
|
-
'ticket.updated',
|
|
1746
|
-
],
|
|
1747
|
-
},
|
|
1748
|
-
{
|
|
1749
|
-
value: 'message.message_type',
|
|
1750
|
-
label: 'Message Type',
|
|
1751
|
-
validTriggers: [
|
|
1752
|
-
'message.created',
|
|
1753
|
-
'message.updated',
|
|
1754
|
-
'reaction.added',
|
|
1755
|
-
'message.flagged',
|
|
1756
|
-
'ticket.created',
|
|
1757
|
-
'ticket.updated',
|
|
1758
|
-
],
|
|
1759
|
-
},
|
|
1760
|
-
{
|
|
1761
|
-
value: 'message.sender_phone',
|
|
1762
|
-
label: 'Sender Phone',
|
|
1763
|
-
validTriggers: [
|
|
1764
|
-
'message.created',
|
|
1765
|
-
'message.updated',
|
|
1766
|
-
'reaction.added',
|
|
1767
|
-
'message.flagged',
|
|
1768
|
-
'ticket.created',
|
|
1769
|
-
'ticket.updated',
|
|
1770
|
-
],
|
|
1771
|
-
},
|
|
1772
|
-
{
|
|
1773
|
-
value: 'message.timestamp',
|
|
1774
|
-
label: 'Message Timestamp',
|
|
1775
|
-
validTriggers: [
|
|
1776
|
-
'message.created',
|
|
1777
|
-
'message.updated',
|
|
1778
|
-
'reaction.added',
|
|
1779
|
-
'message.flagged',
|
|
1780
|
-
'ticket.created',
|
|
1781
|
-
'ticket.updated',
|
|
1782
|
-
],
|
|
1783
|
-
},
|
|
1784
|
-
{
|
|
1785
|
-
label: 'Sender Name',
|
|
1786
|
-
value: 'sender.contact_name',
|
|
1787
|
-
validTriggers: [
|
|
1788
|
-
'message.created',
|
|
1789
|
-
'message.updated',
|
|
1790
|
-
'reaction.added',
|
|
1791
|
-
'message.flagged',
|
|
1792
|
-
'ticket.created',
|
|
1793
|
-
'ticket.updated',
|
|
1794
|
-
],
|
|
1795
|
-
},
|
|
1796
|
-
{
|
|
1797
|
-
value: 'sender.is_admin',
|
|
1798
|
-
label: 'Sender Is Admin',
|
|
1799
|
-
validTriggers: [
|
|
1800
|
-
'message.created',
|
|
1801
|
-
'message.updated',
|
|
1802
|
-
'reaction.added',
|
|
1803
|
-
'message.flagged',
|
|
1804
|
-
'ticket.created',
|
|
1805
|
-
'ticket.updated',
|
|
1806
|
-
],
|
|
1807
|
-
},
|
|
1808
|
-
{
|
|
1809
|
-
value: 'sender.is_internal',
|
|
1810
|
-
label: 'Sender Is Internal',
|
|
1811
|
-
validTriggers: [
|
|
1812
|
-
'message.created',
|
|
1813
|
-
'message.updated',
|
|
1814
|
-
'reaction.added',
|
|
1815
|
-
'message.flagged',
|
|
1816
|
-
'ticket.created',
|
|
1817
|
-
'ticket.updated',
|
|
1818
|
-
],
|
|
1819
|
-
},
|
|
1820
|
-
{
|
|
1821
|
-
label: 'Reaction',
|
|
1822
|
-
value: 'reaction.reaction',
|
|
1823
|
-
validTriggers: ['reaction.added'],
|
|
1824
|
-
},
|
|
1825
|
-
{
|
|
1826
|
-
value: 'reaction.sender_id',
|
|
1827
|
-
label: 'Reaction Sender Phone',
|
|
1828
|
-
validTriggers: ['reaction.added'],
|
|
1829
|
-
},
|
|
1830
|
-
{
|
|
1831
|
-
label: 'Chat Name',
|
|
1832
|
-
value: 'chat.chat_name',
|
|
1833
|
-
validTriggers: [
|
|
1834
|
-
'message.created',
|
|
1835
|
-
'message.updated',
|
|
1836
|
-
'reaction.added',
|
|
1837
|
-
'message.flagged',
|
|
1838
|
-
'chat.created',
|
|
1839
|
-
'chat.label.updated',
|
|
1840
|
-
'ticket.created',
|
|
1841
|
-
'ticket.updated',
|
|
1842
|
-
],
|
|
1843
|
-
},
|
|
1844
|
-
{
|
|
1845
|
-
value: 'chat.assigned_to',
|
|
1846
|
-
label: 'Chat Assigned To',
|
|
1847
|
-
validTriggers: [
|
|
1848
|
-
'message.created',
|
|
1849
|
-
'message.updated',
|
|
1850
|
-
'reaction.added',
|
|
1851
|
-
'message.flagged',
|
|
1852
|
-
'chat.created',
|
|
1853
|
-
'chat.label.updated',
|
|
1854
|
-
'ticket.created',
|
|
1855
|
-
'ticket.updated',
|
|
1856
|
-
],
|
|
1857
|
-
},
|
|
1858
|
-
{
|
|
1859
|
-
value: 'chat.chat_id',
|
|
1860
|
-
label: 'Chat ID',
|
|
1861
|
-
validTriggers: [
|
|
1862
|
-
'message.created',
|
|
1863
|
-
'message.updated',
|
|
1864
|
-
'reaction.added',
|
|
1865
|
-
'message.flagged',
|
|
1866
|
-
'chat.created',
|
|
1867
|
-
'chat.label.updated',
|
|
1868
|
-
'ticket.created',
|
|
1869
|
-
'ticket.updated',
|
|
1870
|
-
],
|
|
1871
|
-
},
|
|
1872
|
-
{
|
|
1873
|
-
value: 'chat.chat_type',
|
|
1874
|
-
label: 'Chat Type',
|
|
1875
|
-
validTriggers: [
|
|
1876
|
-
'message.created',
|
|
1877
|
-
'message.updated',
|
|
1878
|
-
'reaction.added',
|
|
1879
|
-
'message.flagged',
|
|
1880
|
-
'chat.created',
|
|
1881
|
-
'chat.label.updated',
|
|
1882
|
-
'ticket.created',
|
|
1883
|
-
'ticket.updated',
|
|
1884
|
-
],
|
|
1885
|
-
},
|
|
1886
|
-
{
|
|
1887
|
-
value: 'chat.org_id',
|
|
1888
|
-
label: 'Chat Org ID',
|
|
1889
|
-
validTriggers: [
|
|
1890
|
-
'message.created',
|
|
1891
|
-
'message.updated',
|
|
1892
|
-
'reaction.added',
|
|
1893
|
-
'message.flagged',
|
|
1894
|
-
'chat.created',
|
|
1895
|
-
'chat.label.updated',
|
|
1896
|
-
'ticket.created',
|
|
1897
|
-
'ticket.updated',
|
|
1898
|
-
],
|
|
1899
|
-
},
|
|
1900
|
-
{
|
|
1901
|
-
value: 'chat.org_phone',
|
|
1902
|
-
label: 'Chat Org Phone',
|
|
1903
|
-
validTriggers: [
|
|
1904
|
-
'message.created',
|
|
1905
|
-
'message.updated',
|
|
1906
|
-
'reaction.added',
|
|
1907
|
-
'message.flagged',
|
|
1908
|
-
'chat.created',
|
|
1909
|
-
'chat.label.updated',
|
|
1910
|
-
'ticket.created',
|
|
1911
|
-
'ticket.updated',
|
|
1912
|
-
],
|
|
1913
|
-
},
|
|
1914
|
-
];
|
|
1915
|
-
|
|
1916
|
-
export const variablesExclusionList: Record<
|
|
1917
|
-
Rule['trigger'],
|
|
1918
|
-
Array<
|
|
1919
|
-
| keyof AppendTypes<{ message: MessageVariablesType }, '.'>
|
|
1920
|
-
| keyof AppendTypes<{ sender: SenderVariablesType }, '.'>
|
|
1921
|
-
| keyof AppendTypes<{ chat: ChatVariablesType }, '.'>
|
|
1922
|
-
| keyof AppendTypes<{ ticket: TicketVariablesType }, '.'>
|
|
1923
|
-
| keyof AppendTypes<{ reaction: ReactionVariablesType }, '.'>
|
|
1924
|
-
>
|
|
1925
|
-
> = {
|
|
1926
|
-
'ticket.created': ['ticket.is_deleted'],
|
|
1927
|
-
'chat.created': [
|
|
1928
|
-
'chat.chat_id',
|
|
1929
|
-
'chat.labels',
|
|
1930
|
-
'chat.has_flagged_messages',
|
|
1931
|
-
'chat.assigned_to',
|
|
1932
|
-
],
|
|
1933
|
-
'message.created': [
|
|
1934
|
-
'message.author',
|
|
1935
|
-
'message.performed_by',
|
|
1936
|
-
'message.flag_status',
|
|
1937
|
-
'sender.is_internal',
|
|
1938
|
-
],
|
|
1939
|
-
'ticket.updated': ['ticket.is_deleted'],
|
|
1940
|
-
'reaction.added': [],
|
|
1941
|
-
'message.updated': [],
|
|
1942
|
-
'message.flagged': [],
|
|
1943
|
-
'chat.label.updated': [],
|
|
1944
|
-
};
|
|
1
|
+
import { Merge, OverrideProperties } from 'type-fest';
|
|
2
|
+
import { Tables } from './supabase.types';
|
|
3
|
+
import {
|
|
4
|
+
ChatRuleInfoType,
|
|
5
|
+
MessageRuleInfoType,
|
|
6
|
+
ReactionRuleInfoType,
|
|
7
|
+
SenderRuleInfoType,
|
|
8
|
+
TicketRuleInfoType,
|
|
9
|
+
} from './types';
|
|
10
|
+
|
|
11
|
+
export type AppendTypes<T extends object, O extends string> = {
|
|
12
|
+
[K in keyof T & string as `${K}${O}${keyof T[K] & string}`]: T[K][keyof T[K]];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type TicketVariablesType = TicketRuleInfoType['ticket'];
|
|
16
|
+
|
|
17
|
+
export type MessageVariablesType = MessageRuleInfoType['message'];
|
|
18
|
+
|
|
19
|
+
export type SenderVariablesType = SenderRuleInfoType;
|
|
20
|
+
|
|
21
|
+
export type ReactionVariablesType = ReactionRuleInfoType['reaction'];
|
|
22
|
+
|
|
23
|
+
export type ChatVariablesType = ChatRuleInfoType;
|
|
24
|
+
|
|
25
|
+
export type MessageRulesInfoType = Merge<
|
|
26
|
+
AppendTypes<
|
|
27
|
+
{
|
|
28
|
+
message: MessageVariablesType;
|
|
29
|
+
sender: SenderVariablesType;
|
|
30
|
+
chat: ChatVariablesType;
|
|
31
|
+
},
|
|
32
|
+
'.'
|
|
33
|
+
>,
|
|
34
|
+
{
|
|
35
|
+
rule: Tables<'tbl_automation_rules'>[];
|
|
36
|
+
id: 'message.message_id';
|
|
37
|
+
type: `message.${'created' | 'updated' | 'flagged'}`;
|
|
38
|
+
org_id: string;
|
|
39
|
+
}
|
|
40
|
+
>;
|
|
41
|
+
|
|
42
|
+
export type TicketRulesInfoType = Merge<
|
|
43
|
+
AppendTypes<
|
|
44
|
+
{
|
|
45
|
+
ticket: TicketVariablesType;
|
|
46
|
+
message: MessageVariablesType;
|
|
47
|
+
sender: SenderVariablesType;
|
|
48
|
+
chat: ChatVariablesType;
|
|
49
|
+
},
|
|
50
|
+
'.'
|
|
51
|
+
>,
|
|
52
|
+
{
|
|
53
|
+
id: 'ticket.ticket_id';
|
|
54
|
+
type: `ticket.${'created' | 'updated'}`;
|
|
55
|
+
org_id: string;
|
|
56
|
+
rule: Tables<'tbl_automation_rules'>[];
|
|
57
|
+
}
|
|
58
|
+
>;
|
|
59
|
+
|
|
60
|
+
export type ReactionRulesInfoType = Merge<
|
|
61
|
+
AppendTypes<
|
|
62
|
+
{
|
|
63
|
+
reaction: ReactionVariablesType;
|
|
64
|
+
message: MessageVariablesType;
|
|
65
|
+
sender: SenderVariablesType;
|
|
66
|
+
chat: ChatVariablesType;
|
|
67
|
+
},
|
|
68
|
+
'.'
|
|
69
|
+
>,
|
|
70
|
+
{
|
|
71
|
+
rule: Tables<'tbl_automation_rules'>[];
|
|
72
|
+
id: 'reaction.reaction_id';
|
|
73
|
+
type: `reaction.added`;
|
|
74
|
+
org_id: string;
|
|
75
|
+
}
|
|
76
|
+
>;
|
|
77
|
+
|
|
78
|
+
export type ChatRulesInfoType = Merge<
|
|
79
|
+
AppendTypes<
|
|
80
|
+
{
|
|
81
|
+
chat: ChatVariablesType;
|
|
82
|
+
},
|
|
83
|
+
'.'
|
|
84
|
+
>,
|
|
85
|
+
{
|
|
86
|
+
rule: Tables<'tbl_automation_rules'>[];
|
|
87
|
+
id: 'chat.chat_id';
|
|
88
|
+
type: 'chat.created' | 'chat.label.updated';
|
|
89
|
+
org_id: string;
|
|
90
|
+
}
|
|
91
|
+
>;
|
|
92
|
+
|
|
93
|
+
export type RuleInfoType =
|
|
94
|
+
| MessageRulesInfoType
|
|
95
|
+
| ChatRulesInfoType
|
|
96
|
+
| TicketRulesInfoType
|
|
97
|
+
| ReactionRulesInfoType;
|
|
98
|
+
|
|
99
|
+
export interface Filter {
|
|
100
|
+
id: string;
|
|
101
|
+
condition:
|
|
102
|
+
| 'CONTAINS'
|
|
103
|
+
| 'NCONTAINS'
|
|
104
|
+
| 'EQ'
|
|
105
|
+
| 'NEQ'
|
|
106
|
+
| 'LT'
|
|
107
|
+
| 'LTE'
|
|
108
|
+
| 'GT'
|
|
109
|
+
| 'GTE'
|
|
110
|
+
| 'KNOWN'
|
|
111
|
+
| 'NKNOWN'
|
|
112
|
+
| 'IS'
|
|
113
|
+
| 'NIS'
|
|
114
|
+
| 'ON'; // Add other condition types as needed
|
|
115
|
+
variable: string;
|
|
116
|
+
value: string | string[];
|
|
117
|
+
variable_type?: 'string' | 'number' | 'boolean' | 'day-time' | 'date' | 'day'; // Optional, like 'Date'
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export const isFilter = (filter: any): filter is Filter => {
|
|
121
|
+
return (
|
|
122
|
+
typeof filter === 'object' &&
|
|
123
|
+
'id' in filter &&
|
|
124
|
+
'condition' in filter &&
|
|
125
|
+
'variable' in filter &&
|
|
126
|
+
'value' in filter
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const FilterNameMap: Record<
|
|
131
|
+
Filter['condition'],
|
|
132
|
+
{
|
|
133
|
+
name: string;
|
|
134
|
+
input: boolean;
|
|
135
|
+
}
|
|
136
|
+
> = {
|
|
137
|
+
EQ: {
|
|
138
|
+
name: 'equals to',
|
|
139
|
+
input: true,
|
|
140
|
+
},
|
|
141
|
+
NEQ: {
|
|
142
|
+
name: 'not equals to',
|
|
143
|
+
input: true,
|
|
144
|
+
},
|
|
145
|
+
CONTAINS: {
|
|
146
|
+
name: 'contains',
|
|
147
|
+
input: true,
|
|
148
|
+
},
|
|
149
|
+
NCONTAINS: {
|
|
150
|
+
name: 'does not contain',
|
|
151
|
+
input: true,
|
|
152
|
+
},
|
|
153
|
+
LT: {
|
|
154
|
+
name: 'less than',
|
|
155
|
+
input: true,
|
|
156
|
+
},
|
|
157
|
+
LTE: {
|
|
158
|
+
name: 'less than or equals to',
|
|
159
|
+
input: true,
|
|
160
|
+
},
|
|
161
|
+
GT: {
|
|
162
|
+
name: 'greater than',
|
|
163
|
+
input: true,
|
|
164
|
+
},
|
|
165
|
+
GTE: {
|
|
166
|
+
name: 'greater than or equals to',
|
|
167
|
+
input: true,
|
|
168
|
+
},
|
|
169
|
+
KNOWN: {
|
|
170
|
+
name: 'is known',
|
|
171
|
+
input: false,
|
|
172
|
+
},
|
|
173
|
+
NKNOWN: {
|
|
174
|
+
name: 'is not known',
|
|
175
|
+
input: false,
|
|
176
|
+
},
|
|
177
|
+
IS: {
|
|
178
|
+
name: 'is',
|
|
179
|
+
input: true,
|
|
180
|
+
},
|
|
181
|
+
NIS: {
|
|
182
|
+
name: 'is not',
|
|
183
|
+
input: true,
|
|
184
|
+
},
|
|
185
|
+
ON: {
|
|
186
|
+
name: 'on',
|
|
187
|
+
input: true,
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export type VariableNameValueType = {
|
|
192
|
+
text: string;
|
|
193
|
+
type:
|
|
194
|
+
| 'string'
|
|
195
|
+
| 'time'
|
|
196
|
+
| 'boolean'
|
|
197
|
+
| 'dropdown'
|
|
198
|
+
| 'day-time'
|
|
199
|
+
| 'number'
|
|
200
|
+
| 'date';
|
|
201
|
+
variable_type: 'string' | 'number' | 'boolean' | 'day-time' | 'date';
|
|
202
|
+
value?:
|
|
203
|
+
| string
|
|
204
|
+
| {
|
|
205
|
+
id: string;
|
|
206
|
+
value: string | number | boolean;
|
|
207
|
+
label: string;
|
|
208
|
+
}[]
|
|
209
|
+
| null;
|
|
210
|
+
filters:
|
|
211
|
+
| Partial<
|
|
212
|
+
Record<
|
|
213
|
+
Filter['condition'],
|
|
214
|
+
{
|
|
215
|
+
info?: string;
|
|
216
|
+
}
|
|
217
|
+
>
|
|
218
|
+
>
|
|
219
|
+
| Filter['condition'][];
|
|
220
|
+
hidden?: boolean;
|
|
221
|
+
placeholder?: string;
|
|
222
|
+
info?: string;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export const MessageVariableNameMap: Record<
|
|
226
|
+
keyof AppendTypes<{ message: MessageVariablesType }, '.'>,
|
|
227
|
+
VariableNameValueType
|
|
228
|
+
> = {
|
|
229
|
+
'message.body': {
|
|
230
|
+
text: 'Message Body',
|
|
231
|
+
type: 'string',
|
|
232
|
+
filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
|
|
233
|
+
placeholder: 'e.g. Test message',
|
|
234
|
+
variable_type: 'string',
|
|
235
|
+
},
|
|
236
|
+
'message.sender_phone': {
|
|
237
|
+
text: 'Message Sender Phone',
|
|
238
|
+
type: 'string',
|
|
239
|
+
filters: ['EQ', 'NEQ'],
|
|
240
|
+
placeholder: 'e.g. 919876543210',
|
|
241
|
+
variable_type: 'string',
|
|
242
|
+
},
|
|
243
|
+
'message.timestamp': {
|
|
244
|
+
text: 'Message Timestamp',
|
|
245
|
+
type: 'day-time',
|
|
246
|
+
filters: {
|
|
247
|
+
LT: {
|
|
248
|
+
info: 'When message is received before mentioned time (UTC)',
|
|
249
|
+
},
|
|
250
|
+
LTE: {
|
|
251
|
+
info: 'When message is received before mentioned time (UTC)',
|
|
252
|
+
},
|
|
253
|
+
GT: {
|
|
254
|
+
info: 'When message is received after mentioned time (UTC)',
|
|
255
|
+
},
|
|
256
|
+
GTE: {
|
|
257
|
+
info: 'When message is received on or after mentioned time (UTC)',
|
|
258
|
+
},
|
|
259
|
+
ON: {
|
|
260
|
+
info: 'When message is received on mentioned days',
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
variable_type: 'day-time',
|
|
264
|
+
info: 'The timestamp when the message was received',
|
|
265
|
+
},
|
|
266
|
+
'message.flag_status': {
|
|
267
|
+
text: 'Message Flag Status',
|
|
268
|
+
filters: ['IS'],
|
|
269
|
+
type: 'boolean',
|
|
270
|
+
variable_type: 'boolean',
|
|
271
|
+
},
|
|
272
|
+
'message.has_quoted_msg': {
|
|
273
|
+
text: 'Has Quoted Message',
|
|
274
|
+
filters: ['IS'],
|
|
275
|
+
type: 'boolean',
|
|
276
|
+
variable_type: 'boolean',
|
|
277
|
+
},
|
|
278
|
+
'message.media': {
|
|
279
|
+
text: 'Has Media',
|
|
280
|
+
type: 'boolean',
|
|
281
|
+
filters: ['KNOWN', 'NKNOWN'],
|
|
282
|
+
variable_type: 'boolean',
|
|
283
|
+
},
|
|
284
|
+
'message.performed_by': {
|
|
285
|
+
text: 'Message Sent By (email)',
|
|
286
|
+
type: 'dropdown',
|
|
287
|
+
value: 'org.members',
|
|
288
|
+
filters: ['EQ', 'NEQ'],
|
|
289
|
+
variable_type: 'string',
|
|
290
|
+
},
|
|
291
|
+
'message.chat_id': {
|
|
292
|
+
text: 'Chat ID',
|
|
293
|
+
type: 'string',
|
|
294
|
+
filters: ['EQ', 'NEQ'],
|
|
295
|
+
hidden: true,
|
|
296
|
+
variable_type: 'string',
|
|
297
|
+
},
|
|
298
|
+
'message.message_ticket_id':{
|
|
299
|
+
text: 'Message Ticket ID',
|
|
300
|
+
type: 'string',
|
|
301
|
+
filters: ['EQ', 'NEQ'],
|
|
302
|
+
hidden: true,
|
|
303
|
+
variable_type: 'string',
|
|
304
|
+
},
|
|
305
|
+
'message.message_id': {
|
|
306
|
+
text: 'Message ID',
|
|
307
|
+
type: 'string',
|
|
308
|
+
filters: ['EQ', 'NEQ'],
|
|
309
|
+
hidden: true,
|
|
310
|
+
variable_type: 'string',
|
|
311
|
+
},
|
|
312
|
+
'message.org_phone': {
|
|
313
|
+
text: 'Org Phone',
|
|
314
|
+
type: 'string',
|
|
315
|
+
filters: ['EQ', 'NEQ'],
|
|
316
|
+
hidden: true,
|
|
317
|
+
variable_type: 'string',
|
|
318
|
+
},
|
|
319
|
+
'message.org_id': {
|
|
320
|
+
text: 'Org ID',
|
|
321
|
+
type: 'string',
|
|
322
|
+
filters: ['EQ', 'NEQ'],
|
|
323
|
+
hidden: true,
|
|
324
|
+
variable_type: 'string',
|
|
325
|
+
},
|
|
326
|
+
'message.message_type': {
|
|
327
|
+
text: 'Message Type',
|
|
328
|
+
type: 'dropdown',
|
|
329
|
+
value: [
|
|
330
|
+
{ id: 'text', value: 'chat', label: 'Text' },
|
|
331
|
+
{ id: 'image', value: 'image', label: 'Image' },
|
|
332
|
+
{ id: 'video', value: 'video', label: 'Video' },
|
|
333
|
+
{ id: 'audio', value: 'audio', label: 'Audio' },
|
|
334
|
+
{ id: 'audio', value: 'ptt', label: 'PTT (Audio voice message)' },
|
|
335
|
+
{ id: 'document', value: 'document', label: 'Document' },
|
|
336
|
+
],
|
|
337
|
+
filters: ['EQ', 'NEQ'],
|
|
338
|
+
variable_type: 'string',
|
|
339
|
+
},
|
|
340
|
+
'message.author': {
|
|
341
|
+
text: 'Message Author',
|
|
342
|
+
type: 'string',
|
|
343
|
+
filters: ['EQ', 'NEQ'],
|
|
344
|
+
hidden: true,
|
|
345
|
+
variable_type: 'string',
|
|
346
|
+
},
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
export const SenderVariableNameMap: Record<
|
|
350
|
+
keyof AppendTypes<{ sender: SenderVariablesType }, '.'>,
|
|
351
|
+
VariableNameValueType
|
|
352
|
+
> = {
|
|
353
|
+
'sender.is_internal': {
|
|
354
|
+
text: 'Sender Is Internal',
|
|
355
|
+
type: 'boolean',
|
|
356
|
+
filters: ['IS'],
|
|
357
|
+
variable_type: 'boolean',
|
|
358
|
+
},
|
|
359
|
+
'sender.contact_name': {
|
|
360
|
+
text: 'Sender Name',
|
|
361
|
+
type: 'string',
|
|
362
|
+
filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
|
|
363
|
+
placeholder: 'e.g. John Doe',
|
|
364
|
+
variable_type: 'string',
|
|
365
|
+
},
|
|
366
|
+
'sender.contact_id': {
|
|
367
|
+
text: 'Sender Phone',
|
|
368
|
+
type: 'string',
|
|
369
|
+
filters: ['EQ', 'NEQ'],
|
|
370
|
+
placeholder: 'e.g. 919876543210',
|
|
371
|
+
variable_type: 'string',
|
|
372
|
+
},
|
|
373
|
+
'sender.labels': {
|
|
374
|
+
text: 'Sender Contact Labels',
|
|
375
|
+
type: 'dropdown',
|
|
376
|
+
value: 'org.labels',
|
|
377
|
+
filters: ['CONTAINS', 'NCONTAINS'],
|
|
378
|
+
variable_type: 'string',
|
|
379
|
+
},
|
|
380
|
+
'sender.org_id': {
|
|
381
|
+
text: 'Org ID',
|
|
382
|
+
type: 'string',
|
|
383
|
+
filters: ['EQ', 'NEQ'],
|
|
384
|
+
hidden: true,
|
|
385
|
+
variable_type: 'string',
|
|
386
|
+
},
|
|
387
|
+
'sender.is_admin': {
|
|
388
|
+
text: 'Sender Is Admin',
|
|
389
|
+
type: 'dropdown',
|
|
390
|
+
filters: ['EQ', 'NEQ'],
|
|
391
|
+
value: [
|
|
392
|
+
{
|
|
393
|
+
id: 'true',
|
|
394
|
+
value: 'true',
|
|
395
|
+
label: 'True',
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
id: 'false',
|
|
399
|
+
value: 'false',
|
|
400
|
+
label: 'False',
|
|
401
|
+
},
|
|
402
|
+
],
|
|
403
|
+
variable_type: 'boolean',
|
|
404
|
+
},
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
export const ChatVariableNameMap: Record<
|
|
408
|
+
keyof AppendTypes<{ chat: ChatVariablesType }, '.'>,
|
|
409
|
+
VariableNameValueType
|
|
410
|
+
> = {
|
|
411
|
+
'chat.assigned_to': {
|
|
412
|
+
text: 'Chat Assignee',
|
|
413
|
+
type: 'dropdown',
|
|
414
|
+
value: 'org.members',
|
|
415
|
+
filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
|
|
416
|
+
variable_type: 'string',
|
|
417
|
+
},
|
|
418
|
+
'chat.chat_name': {
|
|
419
|
+
text: 'Chat Name',
|
|
420
|
+
type: 'string',
|
|
421
|
+
filters: ['EQ', 'NEQ', 'CONTAINS', 'NCONTAINS'],
|
|
422
|
+
placeholder: 'e.g. Support Chat',
|
|
423
|
+
variable_type: 'string',
|
|
424
|
+
},
|
|
425
|
+
'chat.org_phone': {
|
|
426
|
+
text: 'Chat Org Phone',
|
|
427
|
+
type: 'dropdown',
|
|
428
|
+
value: 'org.org_phones',
|
|
429
|
+
filters: ['EQ', 'NEQ'],
|
|
430
|
+
variable_type: 'string',
|
|
431
|
+
},
|
|
432
|
+
'chat.chat_type': {
|
|
433
|
+
text: 'Chat Type',
|
|
434
|
+
type: 'dropdown',
|
|
435
|
+
value: [
|
|
436
|
+
{ id: 'user', value: 'user', label: 'User' },
|
|
437
|
+
{ id: 'group', value: 'group', label: 'Group' },
|
|
438
|
+
],
|
|
439
|
+
filters: ['EQ', 'NEQ'],
|
|
440
|
+
variable_type: 'string',
|
|
441
|
+
},
|
|
442
|
+
'chat.members': {
|
|
443
|
+
text: 'Chat Members',
|
|
444
|
+
type: 'string',
|
|
445
|
+
filters: ['CONTAINS', 'NCONTAINS'],
|
|
446
|
+
placeholder: 'e.g. 919876543210',
|
|
447
|
+
variable_type: 'string',
|
|
448
|
+
},
|
|
449
|
+
'chat.labels': {
|
|
450
|
+
text: 'Chat Labels',
|
|
451
|
+
type: 'dropdown',
|
|
452
|
+
value: 'org.labels',
|
|
453
|
+
filters: ['CONTAINS', 'NCONTAINS'],
|
|
454
|
+
variable_type: 'string',
|
|
455
|
+
},
|
|
456
|
+
'chat.chat_id': {
|
|
457
|
+
text: 'Chat ID',
|
|
458
|
+
type: 'string',
|
|
459
|
+
filters: ['EQ', 'NEQ'],
|
|
460
|
+
placeholder: 'e.g. 12027747916749@c.us',
|
|
461
|
+
variable_type: 'string',
|
|
462
|
+
},
|
|
463
|
+
'chat.chat_org_phones': {
|
|
464
|
+
text: 'Chat Org Phones',
|
|
465
|
+
type: 'dropdown',
|
|
466
|
+
filters: ['CONTAINS', 'NCONTAINS'],
|
|
467
|
+
hidden: true,
|
|
468
|
+
variable_type: 'string',
|
|
469
|
+
},
|
|
470
|
+
'chat.org_id': {
|
|
471
|
+
text: 'Org ID',
|
|
472
|
+
type: 'string',
|
|
473
|
+
filters: [],
|
|
474
|
+
hidden: true,
|
|
475
|
+
variable_type: 'string',
|
|
476
|
+
},
|
|
477
|
+
'chat.messages_admins_only': {
|
|
478
|
+
text: 'Messages Admins Only (Chat Settings)',
|
|
479
|
+
type: 'boolean',
|
|
480
|
+
filters: ['EQ', 'NEQ'],
|
|
481
|
+
value: [
|
|
482
|
+
{
|
|
483
|
+
id: 'true',
|
|
484
|
+
value: 'true',
|
|
485
|
+
label: 'True',
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
id: 'false',
|
|
489
|
+
value: 'false',
|
|
490
|
+
label: 'False',
|
|
491
|
+
},
|
|
492
|
+
],
|
|
493
|
+
variable_type: 'boolean',
|
|
494
|
+
},
|
|
495
|
+
'chat.info_admins_only': {
|
|
496
|
+
text: 'Info Admins Only (Chat Settings)',
|
|
497
|
+
type: 'boolean',
|
|
498
|
+
filters: ['EQ', 'NEQ'],
|
|
499
|
+
value: [
|
|
500
|
+
{
|
|
501
|
+
id: 'true',
|
|
502
|
+
value: 'true',
|
|
503
|
+
label: 'True',
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
id: 'false',
|
|
507
|
+
value: 'false',
|
|
508
|
+
label: 'False',
|
|
509
|
+
},
|
|
510
|
+
],
|
|
511
|
+
variable_type: 'boolean',
|
|
512
|
+
},
|
|
513
|
+
'chat.has_flagged_messages': {
|
|
514
|
+
text: 'Chat Has Flagged Messages',
|
|
515
|
+
type: 'boolean',
|
|
516
|
+
filters: ['EQ', 'NEQ'],
|
|
517
|
+
value: [
|
|
518
|
+
{
|
|
519
|
+
id: 'true',
|
|
520
|
+
value: 'true',
|
|
521
|
+
label: 'True',
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
id: 'false',
|
|
525
|
+
value: 'false',
|
|
526
|
+
label: 'False',
|
|
527
|
+
},
|
|
528
|
+
],
|
|
529
|
+
variable_type: 'boolean',
|
|
530
|
+
},
|
|
531
|
+
'chat.group_description': {
|
|
532
|
+
text: 'Group Description',
|
|
533
|
+
type: 'string',
|
|
534
|
+
filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
|
|
535
|
+
placeholder: 'e.g. Group description',
|
|
536
|
+
variable_type: 'string',
|
|
537
|
+
},
|
|
538
|
+
'chat.custom_properties': {
|
|
539
|
+
text: 'Chat Custom Properties',
|
|
540
|
+
type: 'dropdown',
|
|
541
|
+
value: 'org.custom_properties',
|
|
542
|
+
filters: ['EQ', 'NEQ'],
|
|
543
|
+
hidden: true,
|
|
544
|
+
variable_type: 'string',
|
|
545
|
+
},
|
|
546
|
+
'chat.initiated_by': {
|
|
547
|
+
text: 'Chat Initiated By',
|
|
548
|
+
type: 'dropdown',
|
|
549
|
+
value: 'org.members',
|
|
550
|
+
filters: ['EQ', 'NEQ'],
|
|
551
|
+
variable_type: 'string',
|
|
552
|
+
hidden: true,
|
|
553
|
+
},
|
|
554
|
+
'chat.created_at': {
|
|
555
|
+
text: 'Chat Created At',
|
|
556
|
+
type: 'day-time',
|
|
557
|
+
filters: {
|
|
558
|
+
LT: {
|
|
559
|
+
info: 'When chat is created before mentioned time (UTC)',
|
|
560
|
+
},
|
|
561
|
+
LTE: {
|
|
562
|
+
info: 'When chat is created before mentioned time (UTC)',
|
|
563
|
+
},
|
|
564
|
+
GT: {
|
|
565
|
+
info: 'When chat is created after mentioned time (UTC)',
|
|
566
|
+
},
|
|
567
|
+
GTE: {
|
|
568
|
+
info: 'When chat is created on or after mentioned time (UTC)',
|
|
569
|
+
},
|
|
570
|
+
ON: {
|
|
571
|
+
info: 'When chat is created on mentioned days',
|
|
572
|
+
},
|
|
573
|
+
},
|
|
574
|
+
variable_type: 'day-time',
|
|
575
|
+
},
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
export const TicketVariableNameMap: Record<
|
|
579
|
+
keyof AppendTypes<{ ticket: TicketVariablesType }, '.'>,
|
|
580
|
+
VariableNameValueType
|
|
581
|
+
> = {
|
|
582
|
+
'ticket.subject': {
|
|
583
|
+
text: 'Ticket Subject',
|
|
584
|
+
type: 'string',
|
|
585
|
+
filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
|
|
586
|
+
placeholder: 'e.g. Test ticket',
|
|
587
|
+
variable_type: 'string',
|
|
588
|
+
},
|
|
589
|
+
'ticket.status': {
|
|
590
|
+
text: 'Ticket Status',
|
|
591
|
+
type: 'dropdown',
|
|
592
|
+
value: [
|
|
593
|
+
{ id: 'open', value: 'open', label: 'Open' },
|
|
594
|
+
{ id: 'closed', value: 'closed', label: 'Closed' },
|
|
595
|
+
{ id: 'inprogress', value: 'inprogress', label: 'In progress' },
|
|
596
|
+
],
|
|
597
|
+
filters: ['EQ', 'NEQ'],
|
|
598
|
+
variable_type: 'string',
|
|
599
|
+
},
|
|
600
|
+
'ticket.priority': {
|
|
601
|
+
text: 'Ticket Priority',
|
|
602
|
+
type: 'dropdown',
|
|
603
|
+
value: [
|
|
604
|
+
{ id: '0', value: '0', label: 'No Priority' },
|
|
605
|
+
{ id: '1', value: '1', label: 'Low' },
|
|
606
|
+
{ id: '2', value: '2', label: 'Medium' },
|
|
607
|
+
{ id: '3', value: '3', label: 'High' },
|
|
608
|
+
{ id: '4', value: '4', label: 'Urgent' },
|
|
609
|
+
],
|
|
610
|
+
filters: ['EQ', 'NEQ'],
|
|
611
|
+
variable_type: 'string',
|
|
612
|
+
},
|
|
613
|
+
'ticket.assignee': {
|
|
614
|
+
text: 'Ticket Assignee',
|
|
615
|
+
type: 'dropdown',
|
|
616
|
+
value: 'org.members',
|
|
617
|
+
filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
|
|
618
|
+
variable_type: 'string',
|
|
619
|
+
},
|
|
620
|
+
'ticket.labels': {
|
|
621
|
+
text: 'Ticket Labels',
|
|
622
|
+
type: 'dropdown',
|
|
623
|
+
value: 'org.labels',
|
|
624
|
+
filters: ['CONTAINS', 'NCONTAINS'],
|
|
625
|
+
variable_type: 'string',
|
|
626
|
+
},
|
|
627
|
+
'ticket.is_deleted': {
|
|
628
|
+
text: 'Ticket Is Deleted',
|
|
629
|
+
type: 'boolean',
|
|
630
|
+
value: [
|
|
631
|
+
{
|
|
632
|
+
id: 'true',
|
|
633
|
+
value: 'true',
|
|
634
|
+
label: 'True',
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
id: 'false',
|
|
638
|
+
value: 'false',
|
|
639
|
+
label: 'False',
|
|
640
|
+
},
|
|
641
|
+
],
|
|
642
|
+
filters: ['IS'],
|
|
643
|
+
variable_type: 'boolean',
|
|
644
|
+
},
|
|
645
|
+
'ticket.raised_by': {
|
|
646
|
+
text: 'Ticket Raised By',
|
|
647
|
+
type: 'dropdown',
|
|
648
|
+
value: 'org.members',
|
|
649
|
+
filters: ['EQ', 'NEQ'],
|
|
650
|
+
variable_type: 'string',
|
|
651
|
+
},
|
|
652
|
+
'ticket.due_date': {
|
|
653
|
+
text: 'Ticket Due Date',
|
|
654
|
+
type: 'date',
|
|
655
|
+
filters: ['KNOWN', 'NKNOWN'],
|
|
656
|
+
variable_type: 'date',
|
|
657
|
+
hidden: true,
|
|
658
|
+
},
|
|
659
|
+
'ticket.ticket_id': {
|
|
660
|
+
text: 'Ticket ID',
|
|
661
|
+
type: 'string',
|
|
662
|
+
filters: ['EQ', 'NEQ'],
|
|
663
|
+
hidden: true,
|
|
664
|
+
variable_type: 'string',
|
|
665
|
+
},
|
|
666
|
+
'ticket.org_id': {
|
|
667
|
+
text: 'Org ID',
|
|
668
|
+
type: 'string',
|
|
669
|
+
filters: ['EQ', 'NEQ'],
|
|
670
|
+
hidden: true,
|
|
671
|
+
variable_type: 'string',
|
|
672
|
+
},
|
|
673
|
+
'ticket.custom_properties': {
|
|
674
|
+
text: 'Ticket Custom Properties',
|
|
675
|
+
type: 'dropdown',
|
|
676
|
+
value: 'org.custom_properties',
|
|
677
|
+
filters: ['EQ', 'NEQ'],
|
|
678
|
+
hidden: true,
|
|
679
|
+
variable_type: 'string',
|
|
680
|
+
},
|
|
681
|
+
'ticket.created_at': {
|
|
682
|
+
text: 'Ticket Created At',
|
|
683
|
+
type: 'day-time',
|
|
684
|
+
filters: {
|
|
685
|
+
LT: {
|
|
686
|
+
info: 'When ticket is created before mentioned time (UTC)',
|
|
687
|
+
},
|
|
688
|
+
LTE: {
|
|
689
|
+
info: 'When ticket is created before mentioned time (UTC)',
|
|
690
|
+
},
|
|
691
|
+
GT: {
|
|
692
|
+
info: 'When ticket is created after mentioned time (UTC)',
|
|
693
|
+
},
|
|
694
|
+
GTE: {
|
|
695
|
+
info: 'When ticket is created on or after mentioned time (UTC)',
|
|
696
|
+
},
|
|
697
|
+
ON: {
|
|
698
|
+
info: 'When ticket is created on mentioned days',
|
|
699
|
+
},
|
|
700
|
+
},
|
|
701
|
+
variable_type: 'day-time',
|
|
702
|
+
},
|
|
703
|
+
'ticket.chat_id': {
|
|
704
|
+
text: 'Chat ID',
|
|
705
|
+
type: 'string',
|
|
706
|
+
filters: ['EQ', 'NEQ'],
|
|
707
|
+
hidden: true,
|
|
708
|
+
variable_type: 'string',
|
|
709
|
+
},
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
export const ReactionVariableNameMap: Record<
|
|
713
|
+
keyof AppendTypes<{ reaction: ReactionVariablesType }, '.'>,
|
|
714
|
+
VariableNameValueType
|
|
715
|
+
> = {
|
|
716
|
+
'reaction.reaction': {
|
|
717
|
+
text: 'Reaction',
|
|
718
|
+
type: 'string',
|
|
719
|
+
filters: ['EQ', 'NEQ'],
|
|
720
|
+
placeholder: 'e.g. 👍',
|
|
721
|
+
variable_type: 'string',
|
|
722
|
+
},
|
|
723
|
+
'reaction.sender_id': {
|
|
724
|
+
text: 'Reaction Sender Phone',
|
|
725
|
+
type: 'string',
|
|
726
|
+
filters: ['EQ', 'NEQ'],
|
|
727
|
+
placeholder: 'e.g. 919876543210',
|
|
728
|
+
variable_type: 'string',
|
|
729
|
+
},
|
|
730
|
+
'reaction.message_id': {
|
|
731
|
+
text: 'Reaction Message ID',
|
|
732
|
+
type: 'string',
|
|
733
|
+
filters: ['EQ', 'NEQ'],
|
|
734
|
+
hidden: true,
|
|
735
|
+
variable_type: 'string',
|
|
736
|
+
},
|
|
737
|
+
'reaction.chat_id': {
|
|
738
|
+
text: 'Chat ID',
|
|
739
|
+
type: 'string',
|
|
740
|
+
filters: ['EQ', 'NEQ'],
|
|
741
|
+
hidden: true,
|
|
742
|
+
variable_type: 'string',
|
|
743
|
+
},
|
|
744
|
+
'reaction.reaction_id': {
|
|
745
|
+
text: 'Reaction ID',
|
|
746
|
+
type: 'string',
|
|
747
|
+
filters: ['EQ', 'NEQ'],
|
|
748
|
+
hidden: true,
|
|
749
|
+
variable_type: 'string',
|
|
750
|
+
},
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
export enum FilterConditionMap {
|
|
754
|
+
'CONTAINS' = 'contains',
|
|
755
|
+
'NCONTAINS' = 'does not contain',
|
|
756
|
+
'EQ' = '=',
|
|
757
|
+
'NEQ' = '<>',
|
|
758
|
+
'LT' = '<',
|
|
759
|
+
'LTE' = '<=',
|
|
760
|
+
'GT' = '>',
|
|
761
|
+
'GTE' = '>=',
|
|
762
|
+
'KNOWN' = 'is known',
|
|
763
|
+
'NKNOWN' = 'is not known',
|
|
764
|
+
'IS' = '=',
|
|
765
|
+
'NIS' = '<>',
|
|
766
|
+
'ON' = 'on',
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
interface FilterGroup {
|
|
770
|
+
filters: Filter[];
|
|
771
|
+
condition: 'allOf' | 'anyOf';
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
export interface Conditions {
|
|
775
|
+
filters: FilterGroup[];
|
|
776
|
+
condition: 'allOf' | 'anyOf';
|
|
777
|
+
variables: string[];
|
|
778
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
779
|
+
org_phones: string[];
|
|
780
|
+
allow_messages_from_org_phones?: boolean;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
export type SendMessageAction = {
|
|
784
|
+
id: string;
|
|
785
|
+
type: 'send_message';
|
|
786
|
+
metadata: {
|
|
787
|
+
message: string;
|
|
788
|
+
media?: {
|
|
789
|
+
url: string;
|
|
790
|
+
type: 'image' | 'video' | 'audio' | 'document';
|
|
791
|
+
name: string;
|
|
792
|
+
};
|
|
793
|
+
maintain_flag_status: 'true' | 'false';
|
|
794
|
+
debounce_messages: 'true' | 'false';
|
|
795
|
+
debounce_message_time:
|
|
796
|
+
| `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`
|
|
797
|
+
| null
|
|
798
|
+
| undefined;
|
|
799
|
+
};
|
|
800
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
801
|
+
};
|
|
802
|
+
|
|
803
|
+
export type NotifyHttpAction = {
|
|
804
|
+
id: string;
|
|
805
|
+
type: 'notify_http';
|
|
806
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
807
|
+
metadata: {
|
|
808
|
+
url: string;
|
|
809
|
+
};
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
export type CreateTicketAction = {
|
|
813
|
+
id: string;
|
|
814
|
+
type: 'create_ticket';
|
|
815
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
816
|
+
metadata: {
|
|
817
|
+
priority?: '0' | '1' | '2' | '3' | '4';
|
|
818
|
+
label?: string;
|
|
819
|
+
append_to_latest_ticket?: 'true' | 'false';
|
|
820
|
+
round_robin?: 'true' | 'false';
|
|
821
|
+
assignee?: string;
|
|
822
|
+
};
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
export type FlagMessageAction = {
|
|
826
|
+
id: string;
|
|
827
|
+
type: 'flag_message';
|
|
828
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
829
|
+
metadata: {
|
|
830
|
+
flag: 'true' | 'false';
|
|
831
|
+
};
|
|
832
|
+
};
|
|
833
|
+
|
|
834
|
+
export type AssignTicketAction = {
|
|
835
|
+
id: string;
|
|
836
|
+
type: 'assign_ticket';
|
|
837
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
838
|
+
metadata: {
|
|
839
|
+
assignee: string;
|
|
840
|
+
round_robin: 'true' | 'false';
|
|
841
|
+
};
|
|
842
|
+
};
|
|
843
|
+
|
|
844
|
+
export type CloseTicketAction = {
|
|
845
|
+
id: string;
|
|
846
|
+
type: 'close_ticket';
|
|
847
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
848
|
+
metadata: {
|
|
849
|
+
closing_note: string;
|
|
850
|
+
};
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
export type AddChatLabelAction = {
|
|
854
|
+
id: string;
|
|
855
|
+
type: 'add_chat_label';
|
|
856
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
857
|
+
metadata: {
|
|
858
|
+
label: string;
|
|
859
|
+
};
|
|
860
|
+
};
|
|
861
|
+
|
|
862
|
+
export type AddTicketLabelAction = {
|
|
863
|
+
id: string;
|
|
864
|
+
type: 'add_ticket_label';
|
|
865
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
866
|
+
metadata: {
|
|
867
|
+
label: string;
|
|
868
|
+
};
|
|
869
|
+
};
|
|
870
|
+
|
|
871
|
+
export type AssignChatAction = {
|
|
872
|
+
id: string;
|
|
873
|
+
type: 'assign_chat';
|
|
874
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
875
|
+
metadata: {
|
|
876
|
+
assignee: string;
|
|
877
|
+
round_robin: 'true' | 'false';
|
|
878
|
+
};
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
export type ForwardMessageAction = {
|
|
882
|
+
id: string;
|
|
883
|
+
type: 'forward_message';
|
|
884
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
885
|
+
metadata: {
|
|
886
|
+
chat_id: string;
|
|
887
|
+
prefix: string;
|
|
888
|
+
};
|
|
889
|
+
};
|
|
890
|
+
|
|
891
|
+
export type SendEmailAction = {
|
|
892
|
+
id: string;
|
|
893
|
+
type: 'send_email';
|
|
894
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
895
|
+
metadata: {
|
|
896
|
+
email: string;
|
|
897
|
+
subject: string;
|
|
898
|
+
body: string;
|
|
899
|
+
};
|
|
900
|
+
};
|
|
901
|
+
|
|
902
|
+
export type ReplyToMessageAction = {
|
|
903
|
+
id: string;
|
|
904
|
+
type: 'reply_to_message';
|
|
905
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
906
|
+
metadata: {
|
|
907
|
+
message: string;
|
|
908
|
+
media?: {
|
|
909
|
+
url: string;
|
|
910
|
+
type: 'image' | 'video' | 'audio' | 'document';
|
|
911
|
+
name: string;
|
|
912
|
+
};
|
|
913
|
+
maintain_flag_status: 'true' | 'false';
|
|
914
|
+
debounce_messages: 'true' | 'false';
|
|
915
|
+
debounce_message_time:
|
|
916
|
+
| `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`
|
|
917
|
+
| null
|
|
918
|
+
| undefined;
|
|
919
|
+
};
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
export type UpdateCustomPropertyAction = {
|
|
923
|
+
id: string;
|
|
924
|
+
type: 'update_custom_property';
|
|
925
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
926
|
+
metadata: {
|
|
927
|
+
property_id: string;
|
|
928
|
+
value: string;
|
|
929
|
+
};
|
|
930
|
+
};
|
|
931
|
+
|
|
932
|
+
export type DeleteMessageAction = {
|
|
933
|
+
id: string;
|
|
934
|
+
type: 'delete_message';
|
|
935
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
936
|
+
metadata: {};
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
export type SendSlackNotificationAction = {
|
|
940
|
+
id: string;
|
|
941
|
+
type: 'send_slack_notification';
|
|
942
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
943
|
+
metadata: {
|
|
944
|
+
slack_payload: string;
|
|
945
|
+
webhook_url: string;
|
|
946
|
+
};
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
export type AttachMessageToTicketAction = {
|
|
950
|
+
id: string;
|
|
951
|
+
type: 'attach_message_to_ticket';
|
|
952
|
+
delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
|
|
953
|
+
metadata: {
|
|
954
|
+
status: 'open' | 'inprogress' | 'open_inprogress' | null;
|
|
955
|
+
};
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
export type Action =
|
|
959
|
+
| SendMessageAction
|
|
960
|
+
| NotifyHttpAction
|
|
961
|
+
| CreateTicketAction
|
|
962
|
+
| FlagMessageAction
|
|
963
|
+
| AssignTicketAction
|
|
964
|
+
| CloseTicketAction
|
|
965
|
+
| AddChatLabelAction
|
|
966
|
+
| AddTicketLabelAction
|
|
967
|
+
| AssignChatAction
|
|
968
|
+
| ForwardMessageAction
|
|
969
|
+
| SendEmailAction
|
|
970
|
+
| ReplyToMessageAction
|
|
971
|
+
| UpdateCustomPropertyAction
|
|
972
|
+
| DeleteMessageAction
|
|
973
|
+
| SendSlackNotificationAction
|
|
974
|
+
| AttachMessageToTicketAction;
|
|
975
|
+
|
|
976
|
+
export const isSendMessageOrReplyToMessageAction = (
|
|
977
|
+
action: Action
|
|
978
|
+
): action is SendMessageAction | ReplyToMessageAction => {
|
|
979
|
+
return ['send_message', 'reply_to_message'].includes(action.type);
|
|
980
|
+
};
|
|
981
|
+
|
|
982
|
+
export type Rule = OverrideProperties<
|
|
983
|
+
Tables<'tbl_automation_rules'>,
|
|
984
|
+
{
|
|
985
|
+
actions: Action[];
|
|
986
|
+
conditions: Conditions;
|
|
987
|
+
trigger:
|
|
988
|
+
| 'message.created'
|
|
989
|
+
| 'message.updated'
|
|
990
|
+
| 'chat.created'
|
|
991
|
+
| 'ticket.updated'
|
|
992
|
+
| 'ticket.created'
|
|
993
|
+
| 'reaction.added'
|
|
994
|
+
| 'chat.label.updated'
|
|
995
|
+
| 'message.flagged';
|
|
996
|
+
}
|
|
997
|
+
>;
|
|
998
|
+
|
|
999
|
+
export const RuleNameMap: Record<
|
|
1000
|
+
Rule['trigger'],
|
|
1001
|
+
{
|
|
1002
|
+
title: string;
|
|
1003
|
+
description: string;
|
|
1004
|
+
base_conditions: {
|
|
1005
|
+
org_phone: boolean;
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
> = {
|
|
1009
|
+
'message.created': {
|
|
1010
|
+
title: 'New Message Received',
|
|
1011
|
+
description: 'When a new message is received from an external contact',
|
|
1012
|
+
base_conditions: {
|
|
1013
|
+
org_phone: true,
|
|
1014
|
+
},
|
|
1015
|
+
},
|
|
1016
|
+
'chat.created': {
|
|
1017
|
+
title: 'New Chat Created',
|
|
1018
|
+
description: 'When a new chat is created',
|
|
1019
|
+
base_conditions: {
|
|
1020
|
+
org_phone: true,
|
|
1021
|
+
},
|
|
1022
|
+
},
|
|
1023
|
+
'ticket.created': {
|
|
1024
|
+
title: 'New Ticket Created',
|
|
1025
|
+
description: 'When a new ticket is created',
|
|
1026
|
+
base_conditions: {
|
|
1027
|
+
org_phone: false,
|
|
1028
|
+
},
|
|
1029
|
+
},
|
|
1030
|
+
'reaction.added': {
|
|
1031
|
+
title: 'New Reaction Added',
|
|
1032
|
+
description: 'When a reaction is added on a message',
|
|
1033
|
+
base_conditions: {
|
|
1034
|
+
org_phone: true,
|
|
1035
|
+
},
|
|
1036
|
+
},
|
|
1037
|
+
'message.updated': {
|
|
1038
|
+
title: 'Message Updated',
|
|
1039
|
+
description: 'When a message is updated',
|
|
1040
|
+
base_conditions: {
|
|
1041
|
+
org_phone: true,
|
|
1042
|
+
},
|
|
1043
|
+
},
|
|
1044
|
+
'ticket.updated': {
|
|
1045
|
+
title: 'Ticket Updated',
|
|
1046
|
+
description: 'When a ticket is updated',
|
|
1047
|
+
base_conditions: {
|
|
1048
|
+
org_phone: false,
|
|
1049
|
+
},
|
|
1050
|
+
},
|
|
1051
|
+
'chat.label.updated': {
|
|
1052
|
+
title: 'Chat Label Added/Removed',
|
|
1053
|
+
description: 'When labels on chats are updated',
|
|
1054
|
+
base_conditions: {
|
|
1055
|
+
org_phone: false,
|
|
1056
|
+
},
|
|
1057
|
+
},
|
|
1058
|
+
'message.flagged': {
|
|
1059
|
+
title: 'Message Flagged',
|
|
1060
|
+
description: 'When a message is flagged',
|
|
1061
|
+
base_conditions: {
|
|
1062
|
+
org_phone: true,
|
|
1063
|
+
},
|
|
1064
|
+
},
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
export const ActionNameMap: Record<
|
|
1068
|
+
Action['type'],
|
|
1069
|
+
{
|
|
1070
|
+
title: string;
|
|
1071
|
+
description: string;
|
|
1072
|
+
inputs: Record<
|
|
1073
|
+
string,
|
|
1074
|
+
{
|
|
1075
|
+
id: string;
|
|
1076
|
+
type:
|
|
1077
|
+
| 'text'
|
|
1078
|
+
| 'dropdown'
|
|
1079
|
+
| 'editor'
|
|
1080
|
+
| 'date'
|
|
1081
|
+
| 'file'
|
|
1082
|
+
| 'textarea'
|
|
1083
|
+
| 'dynamic'
|
|
1084
|
+
| 'json_editor';
|
|
1085
|
+
value:
|
|
1086
|
+
| 'ticket.labels'
|
|
1087
|
+
| 'org.members'
|
|
1088
|
+
| 'chat.labels'
|
|
1089
|
+
| 'org.chats'
|
|
1090
|
+
| {
|
|
1091
|
+
id: string;
|
|
1092
|
+
value: string;
|
|
1093
|
+
label: string;
|
|
1094
|
+
}[]
|
|
1095
|
+
| null
|
|
1096
|
+
| 'org.custom_properties'
|
|
1097
|
+
| 'custom_property_values'
|
|
1098
|
+
| 'debounce_messages';
|
|
1099
|
+
label: string;
|
|
1100
|
+
placeholder: string;
|
|
1101
|
+
info?: string;
|
|
1102
|
+
required: boolean;
|
|
1103
|
+
description?: string;
|
|
1104
|
+
}
|
|
1105
|
+
>;
|
|
1106
|
+
info?: string;
|
|
1107
|
+
validTriggers: Rule['trigger'][];
|
|
1108
|
+
}
|
|
1109
|
+
> = {
|
|
1110
|
+
send_message: {
|
|
1111
|
+
title: 'Send Message',
|
|
1112
|
+
description: 'Send a message',
|
|
1113
|
+
inputs: {
|
|
1114
|
+
message: {
|
|
1115
|
+
id: 'message',
|
|
1116
|
+
type: 'editor',
|
|
1117
|
+
label: 'Message',
|
|
1118
|
+
placeholder: 'Enter message',
|
|
1119
|
+
value: null,
|
|
1120
|
+
required: true,
|
|
1121
|
+
},
|
|
1122
|
+
media: {
|
|
1123
|
+
id: 'media',
|
|
1124
|
+
type: 'file',
|
|
1125
|
+
label: 'Media',
|
|
1126
|
+
placeholder: 'Upload media',
|
|
1127
|
+
value: null,
|
|
1128
|
+
required: false,
|
|
1129
|
+
},
|
|
1130
|
+
maintain_flag_status: {
|
|
1131
|
+
id: 'maintain_flag_status',
|
|
1132
|
+
type: 'dropdown',
|
|
1133
|
+
label: 'Maintain Flag Status',
|
|
1134
|
+
placeholder: 'Select...',
|
|
1135
|
+
value: [
|
|
1136
|
+
{ id: 'true', value: 'true', label: 'True' },
|
|
1137
|
+
{ id: 'false', value: 'false', label: 'False' },
|
|
1138
|
+
],
|
|
1139
|
+
required: true,
|
|
1140
|
+
},
|
|
1141
|
+
debounce_messages: {
|
|
1142
|
+
id: 'debounce_messages',
|
|
1143
|
+
type: 'dropdown',
|
|
1144
|
+
label: 'Enable Cooldown Period',
|
|
1145
|
+
placeholder: 'Select...',
|
|
1146
|
+
value: [
|
|
1147
|
+
{ id: 'true', value: 'true', label: 'True' },
|
|
1148
|
+
{ id: 'false', value: 'false', label: 'False' },
|
|
1149
|
+
],
|
|
1150
|
+
info: 'If enabled, only one message per chat will be sent in the specified cooldown period',
|
|
1151
|
+
required: false,
|
|
1152
|
+
},
|
|
1153
|
+
debounce_message_time: {
|
|
1154
|
+
id: 'debounce_message_time',
|
|
1155
|
+
type: 'dynamic',
|
|
1156
|
+
label: 'Cooldown Period',
|
|
1157
|
+
placeholder: 'Enter time',
|
|
1158
|
+
value: 'debounce_messages',
|
|
1159
|
+
required: false,
|
|
1160
|
+
},
|
|
1161
|
+
},
|
|
1162
|
+
validTriggers: [
|
|
1163
|
+
'message.created',
|
|
1164
|
+
'message.updated',
|
|
1165
|
+
'chat.created',
|
|
1166
|
+
'ticket.updated',
|
|
1167
|
+
'ticket.created',
|
|
1168
|
+
'reaction.added',
|
|
1169
|
+
'message.flagged',
|
|
1170
|
+
'chat.label.updated',
|
|
1171
|
+
],
|
|
1172
|
+
},
|
|
1173
|
+
reply_to_message: {
|
|
1174
|
+
title: 'Reply to message',
|
|
1175
|
+
description: 'Send a message with the quoted message',
|
|
1176
|
+
inputs: {
|
|
1177
|
+
message: {
|
|
1178
|
+
id: 'message',
|
|
1179
|
+
type: 'editor',
|
|
1180
|
+
label: 'Message',
|
|
1181
|
+
placeholder: 'Enter message',
|
|
1182
|
+
value: null,
|
|
1183
|
+
required: true,
|
|
1184
|
+
},
|
|
1185
|
+
media: {
|
|
1186
|
+
id: 'media',
|
|
1187
|
+
type: 'file',
|
|
1188
|
+
label: 'Media',
|
|
1189
|
+
placeholder: 'Upload media',
|
|
1190
|
+
value: null,
|
|
1191
|
+
required: false,
|
|
1192
|
+
},
|
|
1193
|
+
maintain_flag_status: {
|
|
1194
|
+
id: 'maintain_flag_status',
|
|
1195
|
+
type: 'dropdown',
|
|
1196
|
+
label: 'Maintain Flag Status',
|
|
1197
|
+
placeholder: 'Select...',
|
|
1198
|
+
value: [
|
|
1199
|
+
{ id: 'true', value: 'true', label: 'True' },
|
|
1200
|
+
{ id: 'false', value: 'false', label: 'False' },
|
|
1201
|
+
],
|
|
1202
|
+
required: true,
|
|
1203
|
+
},
|
|
1204
|
+
debounce_messages: {
|
|
1205
|
+
id: 'debounce_messages',
|
|
1206
|
+
type: 'dropdown',
|
|
1207
|
+
label: 'Enable Cooldown Period',
|
|
1208
|
+
placeholder: 'Select...',
|
|
1209
|
+
value: [
|
|
1210
|
+
{ id: 'true', value: 'true', label: 'True' },
|
|
1211
|
+
{ id: 'false', value: 'false', label: 'False' },
|
|
1212
|
+
],
|
|
1213
|
+
info: 'If enabled, only one message per chat will be sent in the specified cooldown period',
|
|
1214
|
+
required: false,
|
|
1215
|
+
},
|
|
1216
|
+
debounce_message_time: {
|
|
1217
|
+
id: 'debounce_message_time',
|
|
1218
|
+
type: 'dynamic',
|
|
1219
|
+
label: 'Cooldown Period',
|
|
1220
|
+
placeholder: 'Enter time',
|
|
1221
|
+
value: 'debounce_messages',
|
|
1222
|
+
required: false,
|
|
1223
|
+
},
|
|
1224
|
+
},
|
|
1225
|
+
validTriggers: [
|
|
1226
|
+
'message.created',
|
|
1227
|
+
'message.updated',
|
|
1228
|
+
'reaction.added',
|
|
1229
|
+
'message.flagged',
|
|
1230
|
+
'ticket.created',
|
|
1231
|
+
'ticket.updated',
|
|
1232
|
+
],
|
|
1233
|
+
},
|
|
1234
|
+
delete_message: {
|
|
1235
|
+
title: 'Delete Message',
|
|
1236
|
+
description: 'Delete a message',
|
|
1237
|
+
inputs: {},
|
|
1238
|
+
validTriggers: [
|
|
1239
|
+
'message.created',
|
|
1240
|
+
'message.updated',
|
|
1241
|
+
'reaction.added',
|
|
1242
|
+
'message.flagged',
|
|
1243
|
+
'ticket.created',
|
|
1244
|
+
'ticket.updated',
|
|
1245
|
+
],
|
|
1246
|
+
},
|
|
1247
|
+
attach_message_to_ticket: {
|
|
1248
|
+
title: 'Attach Message To Latest Ticket',
|
|
1249
|
+
description: 'Attach message to latest ticket based on statuses',
|
|
1250
|
+
inputs: {
|
|
1251
|
+
status: {
|
|
1252
|
+
id: 'status',
|
|
1253
|
+
type: 'dropdown',
|
|
1254
|
+
value: [
|
|
1255
|
+
{
|
|
1256
|
+
id: 'open_inprogress',
|
|
1257
|
+
value: 'open_inprogress',
|
|
1258
|
+
label: 'Open/In Progress',
|
|
1259
|
+
},
|
|
1260
|
+
{ id: 'open', value: 'open', label: 'Open' },
|
|
1261
|
+
{ id: 'inprogress', value: 'inprogress', label: 'In Progress' },
|
|
1262
|
+
],
|
|
1263
|
+
label: 'Ticket Status',
|
|
1264
|
+
placeholder: 'Select...',
|
|
1265
|
+
required: true,
|
|
1266
|
+
info: 'Select the ticket status of ticket to attach the message to (only applicable for open or inprogress tickets)',
|
|
1267
|
+
},
|
|
1268
|
+
},
|
|
1269
|
+
validTriggers: [
|
|
1270
|
+
'message.created',
|
|
1271
|
+
'message.updated',
|
|
1272
|
+
'reaction.added',
|
|
1273
|
+
'message.flagged',
|
|
1274
|
+
],
|
|
1275
|
+
},
|
|
1276
|
+
notify_http: {
|
|
1277
|
+
title: 'Notify HTTP',
|
|
1278
|
+
description: 'Notify an HTTP endpoint',
|
|
1279
|
+
inputs: {
|
|
1280
|
+
url: {
|
|
1281
|
+
id: 'url',
|
|
1282
|
+
type: 'text',
|
|
1283
|
+
label: 'URL',
|
|
1284
|
+
placeholder: 'Enter URL',
|
|
1285
|
+
value: null,
|
|
1286
|
+
required: true,
|
|
1287
|
+
description:
|
|
1288
|
+
'Enter the Webhook URL here. The endpoint added here should be a **POST HTTP / Endpoint** with no open auth.',
|
|
1289
|
+
},
|
|
1290
|
+
},
|
|
1291
|
+
validTriggers: [
|
|
1292
|
+
'message.created',
|
|
1293
|
+
'message.updated',
|
|
1294
|
+
'chat.created',
|
|
1295
|
+
'ticket.updated',
|
|
1296
|
+
'ticket.created',
|
|
1297
|
+
'reaction.added',
|
|
1298
|
+
'message.flagged',
|
|
1299
|
+
'chat.label.updated',
|
|
1300
|
+
],
|
|
1301
|
+
},
|
|
1302
|
+
create_ticket: {
|
|
1303
|
+
title: 'Create Ticket or Attach Message To Latest Ticket',
|
|
1304
|
+
description: 'Create a ticket or attach message to latest ticket',
|
|
1305
|
+
inputs: {
|
|
1306
|
+
append_to_latest_ticket: {
|
|
1307
|
+
id: 'append_to_latest_ticket',
|
|
1308
|
+
type: 'dropdown',
|
|
1309
|
+
value: [
|
|
1310
|
+
{ id: 'true', value: 'true', label: 'True' },
|
|
1311
|
+
{ id: 'false', value: 'false', label: 'False' },
|
|
1312
|
+
],
|
|
1313
|
+
label: 'Attach message to latest ticket (if available)',
|
|
1314
|
+
placeholder: 'Select...',
|
|
1315
|
+
info: 'If enabled, the message will be appended to the latest open ticket (if available) else a new ticket will be created',
|
|
1316
|
+
required: false,
|
|
1317
|
+
},
|
|
1318
|
+
priority: {
|
|
1319
|
+
id: 'priority',
|
|
1320
|
+
type: 'dropdown',
|
|
1321
|
+
value: [
|
|
1322
|
+
{ id: '0', value: '0', label: 'No Priority' },
|
|
1323
|
+
{ id: '1', value: '1', label: 'Low' },
|
|
1324
|
+
{ id: '2', value: '2', label: 'Medium' },
|
|
1325
|
+
{ id: '3', value: '3', label: 'High' },
|
|
1326
|
+
{ id: '4', value: '4', label: 'Urgent' },
|
|
1327
|
+
],
|
|
1328
|
+
label: 'Priority (New Ticket)',
|
|
1329
|
+
placeholder: 'Select priority',
|
|
1330
|
+
info: 'Only applicable for create ticket. If no priority is selected, the ticket will have no priority.',
|
|
1331
|
+
required: false,
|
|
1332
|
+
},
|
|
1333
|
+
label: {
|
|
1334
|
+
id: 'label',
|
|
1335
|
+
type: 'dropdown',
|
|
1336
|
+
value: 'ticket.labels',
|
|
1337
|
+
label: 'Label (New Ticket)',
|
|
1338
|
+
placeholder: 'Select label',
|
|
1339
|
+
info: 'Only applicable for create ticket. If no label is selected, the ticket will have no label.',
|
|
1340
|
+
required: false,
|
|
1341
|
+
},
|
|
1342
|
+
round_robin: {
|
|
1343
|
+
id: 'round_robin',
|
|
1344
|
+
type: 'dropdown',
|
|
1345
|
+
value: [
|
|
1346
|
+
{ id: 'true', value: 'true', label: 'True' },
|
|
1347
|
+
{ id: 'false', value: 'false', label: 'False' },
|
|
1348
|
+
],
|
|
1349
|
+
label: 'Enable Round Robin (New Ticket: Assignee)',
|
|
1350
|
+
placeholder: 'Select...',
|
|
1351
|
+
info: 'If enabled, the ticket will be assigned to the next available agent in the list',
|
|
1352
|
+
required: false,
|
|
1353
|
+
},
|
|
1354
|
+
assignee: {
|
|
1355
|
+
id: 'assignee',
|
|
1356
|
+
type: 'dynamic',
|
|
1357
|
+
value: 'org.members',
|
|
1358
|
+
label: 'Assignee (New Ticket)',
|
|
1359
|
+
placeholder: 'Select assignee',
|
|
1360
|
+
info: "If round robin is enabled, the ticket will be assigned to the next available agent in the list else it'll be assigned to the selected agent",
|
|
1361
|
+
required: false,
|
|
1362
|
+
},
|
|
1363
|
+
},
|
|
1364
|
+
validTriggers: [
|
|
1365
|
+
'message.created',
|
|
1366
|
+
'message.updated',
|
|
1367
|
+
'reaction.added',
|
|
1368
|
+
'message.flagged',
|
|
1369
|
+
],
|
|
1370
|
+
},
|
|
1371
|
+
flag_message: {
|
|
1372
|
+
title: 'Update flag status',
|
|
1373
|
+
description: 'Flag/Unflag a message',
|
|
1374
|
+
inputs: {
|
|
1375
|
+
flag: {
|
|
1376
|
+
id: 'flag',
|
|
1377
|
+
type: 'dropdown',
|
|
1378
|
+
value: [
|
|
1379
|
+
{ id: 'flag', value: 'true', label: 'True' },
|
|
1380
|
+
{ id: 'unflag', value: 'false', label: 'False' },
|
|
1381
|
+
],
|
|
1382
|
+
label: 'Flag status',
|
|
1383
|
+
placeholder: 'Select flag',
|
|
1384
|
+
required: true,
|
|
1385
|
+
},
|
|
1386
|
+
},
|
|
1387
|
+
validTriggers: [
|
|
1388
|
+
'message.created',
|
|
1389
|
+
'message.updated',
|
|
1390
|
+
'reaction.added',
|
|
1391
|
+
'message.flagged',
|
|
1392
|
+
'ticket.created',
|
|
1393
|
+
'ticket.updated',
|
|
1394
|
+
],
|
|
1395
|
+
},
|
|
1396
|
+
assign_ticket: {
|
|
1397
|
+
title: 'Assign Ticket',
|
|
1398
|
+
description: 'Assign a ticket',
|
|
1399
|
+
inputs: {
|
|
1400
|
+
round_robin: {
|
|
1401
|
+
id: 'round_robin',
|
|
1402
|
+
type: 'dropdown',
|
|
1403
|
+
value: [
|
|
1404
|
+
{ id: 'true', value: 'true', label: 'True' },
|
|
1405
|
+
{ id: 'false', value: 'false', label: 'False' },
|
|
1406
|
+
],
|
|
1407
|
+
label: 'Enable Round Robin',
|
|
1408
|
+
placeholder: 'Select...',
|
|
1409
|
+
info: 'If enabled, the ticket will be assigned to the next available agent in the list',
|
|
1410
|
+
required: false,
|
|
1411
|
+
},
|
|
1412
|
+
assignee: {
|
|
1413
|
+
id: 'assignee',
|
|
1414
|
+
type: 'dynamic',
|
|
1415
|
+
value: 'org.members',
|
|
1416
|
+
label: 'Assignee',
|
|
1417
|
+
placeholder: 'Select assignee',
|
|
1418
|
+
info: "If round robin is enabled, the ticket will be assigned to the next available agent in the list else it'll be assigned to the selected agent",
|
|
1419
|
+
required: true,
|
|
1420
|
+
},
|
|
1421
|
+
},
|
|
1422
|
+
validTriggers: ['ticket.updated', 'ticket.created'],
|
|
1423
|
+
},
|
|
1424
|
+
close_ticket: {
|
|
1425
|
+
title: 'Close Ticket',
|
|
1426
|
+
description: 'Close a ticket',
|
|
1427
|
+
info: "This action will close the ticket. This doesn't check for mandatory ticket custom properties.",
|
|
1428
|
+
inputs: {
|
|
1429
|
+
closing_note: {
|
|
1430
|
+
id: 'closing_note',
|
|
1431
|
+
type: 'textarea',
|
|
1432
|
+
label: 'Closing Note',
|
|
1433
|
+
placeholder: 'Enter closing note',
|
|
1434
|
+
value: null,
|
|
1435
|
+
required: false,
|
|
1436
|
+
},
|
|
1437
|
+
},
|
|
1438
|
+
validTriggers: ['ticket.updated', 'ticket.created', 'reaction.added'],
|
|
1439
|
+
},
|
|
1440
|
+
add_chat_label: {
|
|
1441
|
+
title: 'Add Chat Label',
|
|
1442
|
+
description: 'Add a label to referred chat',
|
|
1443
|
+
inputs: {
|
|
1444
|
+
label: {
|
|
1445
|
+
id: 'label',
|
|
1446
|
+
type: 'dropdown',
|
|
1447
|
+
value: 'chat.labels',
|
|
1448
|
+
label: 'Label',
|
|
1449
|
+
placeholder: 'Select label',
|
|
1450
|
+
required: true,
|
|
1451
|
+
},
|
|
1452
|
+
},
|
|
1453
|
+
validTriggers: [
|
|
1454
|
+
'message.created',
|
|
1455
|
+
'message.updated',
|
|
1456
|
+
'chat.created',
|
|
1457
|
+
'ticket.updated',
|
|
1458
|
+
'ticket.created',
|
|
1459
|
+
'reaction.added',
|
|
1460
|
+
'chat.label.updated',
|
|
1461
|
+
'message.flagged',
|
|
1462
|
+
],
|
|
1463
|
+
},
|
|
1464
|
+
add_ticket_label: {
|
|
1465
|
+
title: 'Add Ticket Label',
|
|
1466
|
+
description: 'Add a label to referred ticket',
|
|
1467
|
+
inputs: {
|
|
1468
|
+
label: {
|
|
1469
|
+
id: 'label',
|
|
1470
|
+
type: 'dropdown',
|
|
1471
|
+
value: 'ticket.labels',
|
|
1472
|
+
label: 'Label',
|
|
1473
|
+
placeholder: 'Select label',
|
|
1474
|
+
required: true,
|
|
1475
|
+
},
|
|
1476
|
+
},
|
|
1477
|
+
validTriggers: ['ticket.updated', 'ticket.created'],
|
|
1478
|
+
},
|
|
1479
|
+
update_custom_property: {
|
|
1480
|
+
description: 'Update a chat custom property',
|
|
1481
|
+
title: 'Update Chat Custom Property',
|
|
1482
|
+
validTriggers: [
|
|
1483
|
+
'message.created',
|
|
1484
|
+
'message.updated',
|
|
1485
|
+
'chat.created',
|
|
1486
|
+
'ticket.updated',
|
|
1487
|
+
'ticket.created',
|
|
1488
|
+
'reaction.added',
|
|
1489
|
+
'message.flagged',
|
|
1490
|
+
'chat.label.updated',
|
|
1491
|
+
],
|
|
1492
|
+
inputs: {
|
|
1493
|
+
property_id: {
|
|
1494
|
+
id: 'property_id',
|
|
1495
|
+
type: 'dropdown',
|
|
1496
|
+
value: 'org.custom_properties',
|
|
1497
|
+
label: 'Property',
|
|
1498
|
+
placeholder: 'Select property',
|
|
1499
|
+
required: true,
|
|
1500
|
+
},
|
|
1501
|
+
value: {
|
|
1502
|
+
id: 'property_id',
|
|
1503
|
+
type: 'dynamic',
|
|
1504
|
+
label: 'Value',
|
|
1505
|
+
placeholder: 'Enter value',
|
|
1506
|
+
value: 'custom_property_values',
|
|
1507
|
+
required: true,
|
|
1508
|
+
},
|
|
1509
|
+
},
|
|
1510
|
+
},
|
|
1511
|
+
assign_chat: {
|
|
1512
|
+
title: 'Assign Chat',
|
|
1513
|
+
description: 'Assign a chat',
|
|
1514
|
+
inputs: {
|
|
1515
|
+
round_robin: {
|
|
1516
|
+
id: 'round_robin',
|
|
1517
|
+
type: 'dropdown',
|
|
1518
|
+
value: [
|
|
1519
|
+
{ id: 'true', value: 'true', label: 'True' },
|
|
1520
|
+
{ id: 'false', value: 'false', label: 'False' },
|
|
1521
|
+
],
|
|
1522
|
+
label: 'Enable Round Robin',
|
|
1523
|
+
placeholder: 'Select...',
|
|
1524
|
+
info: 'If enabled, the chat will be assigned to the next available agent in the list',
|
|
1525
|
+
required: false,
|
|
1526
|
+
},
|
|
1527
|
+
assignee: {
|
|
1528
|
+
id: 'assignee',
|
|
1529
|
+
type: 'dynamic',
|
|
1530
|
+
value: 'org.members',
|
|
1531
|
+
label: 'Assignee',
|
|
1532
|
+
placeholder: 'Select assignee',
|
|
1533
|
+
required: true,
|
|
1534
|
+
},
|
|
1535
|
+
},
|
|
1536
|
+
validTriggers: [
|
|
1537
|
+
'message.created',
|
|
1538
|
+
'message.updated',
|
|
1539
|
+
'chat.created',
|
|
1540
|
+
'ticket.updated',
|
|
1541
|
+
'ticket.created',
|
|
1542
|
+
'reaction.added',
|
|
1543
|
+
'chat.label.updated',
|
|
1544
|
+
'message.flagged',
|
|
1545
|
+
],
|
|
1546
|
+
},
|
|
1547
|
+
forward_message: {
|
|
1548
|
+
title: 'Forward Message',
|
|
1549
|
+
description: 'Forward a message',
|
|
1550
|
+
inputs: {
|
|
1551
|
+
chat_id: {
|
|
1552
|
+
id: 'chat_id',
|
|
1553
|
+
type: 'dropdown',
|
|
1554
|
+
value: 'org.chats',
|
|
1555
|
+
label: 'Chat',
|
|
1556
|
+
placeholder: 'Select chat',
|
|
1557
|
+
required: true,
|
|
1558
|
+
},
|
|
1559
|
+
},
|
|
1560
|
+
validTriggers: [
|
|
1561
|
+
'message.created',
|
|
1562
|
+
'message.updated',
|
|
1563
|
+
'ticket.updated',
|
|
1564
|
+
'ticket.created',
|
|
1565
|
+
'reaction.added',
|
|
1566
|
+
'message.flagged',
|
|
1567
|
+
],
|
|
1568
|
+
},
|
|
1569
|
+
send_email: {
|
|
1570
|
+
title: 'Send Email',
|
|
1571
|
+
description: 'Send an email',
|
|
1572
|
+
inputs: {
|
|
1573
|
+
email: {
|
|
1574
|
+
id: 'email',
|
|
1575
|
+
type: 'text',
|
|
1576
|
+
label: 'Email',
|
|
1577
|
+
placeholder: 'Enter email',
|
|
1578
|
+
value: null,
|
|
1579
|
+
required: true,
|
|
1580
|
+
},
|
|
1581
|
+
subject: {
|
|
1582
|
+
id: 'subject',
|
|
1583
|
+
type: 'editor',
|
|
1584
|
+
label: 'Subject',
|
|
1585
|
+
placeholder: 'Enter subject',
|
|
1586
|
+
value: null,
|
|
1587
|
+
required: true,
|
|
1588
|
+
},
|
|
1589
|
+
body: {
|
|
1590
|
+
id: 'body',
|
|
1591
|
+
type: 'editor',
|
|
1592
|
+
label: 'Body',
|
|
1593
|
+
placeholder: 'Enter body',
|
|
1594
|
+
value: null,
|
|
1595
|
+
required: true,
|
|
1596
|
+
},
|
|
1597
|
+
},
|
|
1598
|
+
validTriggers: [
|
|
1599
|
+
'message.created',
|
|
1600
|
+
'message.updated',
|
|
1601
|
+
'chat.created',
|
|
1602
|
+
'ticket.updated',
|
|
1603
|
+
'ticket.created',
|
|
1604
|
+
'reaction.added',
|
|
1605
|
+
'message.flagged',
|
|
1606
|
+
'chat.label.updated',
|
|
1607
|
+
],
|
|
1608
|
+
},
|
|
1609
|
+
send_slack_notification: {
|
|
1610
|
+
title: 'Send Slack Webhook Notification',
|
|
1611
|
+
description: 'Send a slack webhook notification to a channel',
|
|
1612
|
+
validTriggers: [
|
|
1613
|
+
'message.created',
|
|
1614
|
+
'message.updated',
|
|
1615
|
+
'chat.created',
|
|
1616
|
+
'ticket.updated',
|
|
1617
|
+
'ticket.created',
|
|
1618
|
+
'reaction.added',
|
|
1619
|
+
'message.flagged',
|
|
1620
|
+
'chat.label.updated',
|
|
1621
|
+
],
|
|
1622
|
+
inputs: {
|
|
1623
|
+
webhook_url: {
|
|
1624
|
+
type: 'text',
|
|
1625
|
+
id: 'webhook_url',
|
|
1626
|
+
label: 'Webhook URL',
|
|
1627
|
+
placeholder: 'Enter webhook URL',
|
|
1628
|
+
value: null,
|
|
1629
|
+
required: true,
|
|
1630
|
+
description:
|
|
1631
|
+
'Enter the webhook URL to send the notification, to create a slack incoming webhook to start receiving notification check [here](https://api.slack.com/messaging/webhooks)',
|
|
1632
|
+
},
|
|
1633
|
+
slack_payload: {
|
|
1634
|
+
type: 'json_editor',
|
|
1635
|
+
id: 'slack_payload',
|
|
1636
|
+
label: 'Slack Notification Payload',
|
|
1637
|
+
placeholder: 'Enter payload',
|
|
1638
|
+
value: null,
|
|
1639
|
+
required: true,
|
|
1640
|
+
description:
|
|
1641
|
+
'You can send slack blocks as notifications to the provided hook URL.\n\nIn order to **build a slack notification block**, you can visit [here](https://api.slack.com/block-kit/building)',
|
|
1642
|
+
},
|
|
1643
|
+
},
|
|
1644
|
+
},
|
|
1645
|
+
};
|
|
1646
|
+
|
|
1647
|
+
|
|
1648
|
+
type editorVariablesList =
|
|
1649
|
+
| 'chat.assigned_to'
|
|
1650
|
+
| 'chat.chat_id'
|
|
1651
|
+
| 'chat.chat_name'
|
|
1652
|
+
| 'chat.chat_type'
|
|
1653
|
+
| 'chat.org_phone'
|
|
1654
|
+
| 'chat.org_id'
|
|
1655
|
+
| 'chat.group_description'
|
|
1656
|
+
| 'ticket.assignee'
|
|
1657
|
+
| 'ticket.due_date'
|
|
1658
|
+
| 'ticket.priority'
|
|
1659
|
+
| 'ticket.status'
|
|
1660
|
+
| 'ticket.subject'
|
|
1661
|
+
| 'ticket.ticket_id'
|
|
1662
|
+
| 'ticket.raised_by'
|
|
1663
|
+
| 'ticket.created_at'
|
|
1664
|
+
| 'sender.is_internal'
|
|
1665
|
+
| 'sender.is_admin'
|
|
1666
|
+
| 'sender.contact_name'
|
|
1667
|
+
| 'sender.contact_id'
|
|
1668
|
+
| 'reaction.sender_id'
|
|
1669
|
+
| 'reaction.reaction'
|
|
1670
|
+
| 'message.message_id'
|
|
1671
|
+
| 'message.timestamp'
|
|
1672
|
+
| 'message.sender_phone'
|
|
1673
|
+
| 'message.message_type'
|
|
1674
|
+
| 'message.media'
|
|
1675
|
+
| 'message.body';
|
|
1676
|
+
|
|
1677
|
+
export const editorVariables: Array<{
|
|
1678
|
+
label: string;
|
|
1679
|
+
value: editorVariablesList;
|
|
1680
|
+
validTriggers: Rule['trigger'][];
|
|
1681
|
+
}> = [
|
|
1682
|
+
{
|
|
1683
|
+
label: 'Ticket ID',
|
|
1684
|
+
value: 'ticket.ticket_id',
|
|
1685
|
+
validTriggers: ['ticket.updated', 'ticket.created'],
|
|
1686
|
+
},
|
|
1687
|
+
{
|
|
1688
|
+
value: 'ticket.assignee',
|
|
1689
|
+
label: 'Ticket Assignee',
|
|
1690
|
+
validTriggers: ['ticket.updated', 'ticket.created'],
|
|
1691
|
+
},
|
|
1692
|
+
{
|
|
1693
|
+
value: 'ticket.due_date',
|
|
1694
|
+
label: 'Ticket Due Date',
|
|
1695
|
+
validTriggers: ['ticket.updated', 'ticket.created'],
|
|
1696
|
+
},
|
|
1697
|
+
{
|
|
1698
|
+
value: 'ticket.priority',
|
|
1699
|
+
label: 'Ticket Priority',
|
|
1700
|
+
validTriggers: ['ticket.updated', 'ticket.created'],
|
|
1701
|
+
},
|
|
1702
|
+
{
|
|
1703
|
+
value: 'ticket.status',
|
|
1704
|
+
label: 'Ticket Status',
|
|
1705
|
+
validTriggers: ['ticket.updated', 'ticket.created'],
|
|
1706
|
+
},
|
|
1707
|
+
{
|
|
1708
|
+
value: 'ticket.subject',
|
|
1709
|
+
label: 'Ticket Subject',
|
|
1710
|
+
validTriggers: ['ticket.updated', 'ticket.created'],
|
|
1711
|
+
},
|
|
1712
|
+
{
|
|
1713
|
+
label: 'Message Body',
|
|
1714
|
+
value: 'message.body',
|
|
1715
|
+
validTriggers: [
|
|
1716
|
+
'message.created',
|
|
1717
|
+
'message.updated',
|
|
1718
|
+
'reaction.added',
|
|
1719
|
+
'message.flagged',
|
|
1720
|
+
'ticket.created',
|
|
1721
|
+
'ticket.updated',
|
|
1722
|
+
],
|
|
1723
|
+
},
|
|
1724
|
+
{
|
|
1725
|
+
value: 'message.media',
|
|
1726
|
+
label: 'Message Media',
|
|
1727
|
+
validTriggers: [
|
|
1728
|
+
'message.created',
|
|
1729
|
+
'message.updated',
|
|
1730
|
+
'reaction.added',
|
|
1731
|
+
'message.flagged',
|
|
1732
|
+
'ticket.created',
|
|
1733
|
+
'ticket.updated',
|
|
1734
|
+
],
|
|
1735
|
+
},
|
|
1736
|
+
{
|
|
1737
|
+
value: 'message.message_id',
|
|
1738
|
+
label: 'Message ID',
|
|
1739
|
+
validTriggers: [
|
|
1740
|
+
'message.created',
|
|
1741
|
+
'message.updated',
|
|
1742
|
+
'reaction.added',
|
|
1743
|
+
'message.flagged',
|
|
1744
|
+
'ticket.created',
|
|
1745
|
+
'ticket.updated',
|
|
1746
|
+
],
|
|
1747
|
+
},
|
|
1748
|
+
{
|
|
1749
|
+
value: 'message.message_type',
|
|
1750
|
+
label: 'Message Type',
|
|
1751
|
+
validTriggers: [
|
|
1752
|
+
'message.created',
|
|
1753
|
+
'message.updated',
|
|
1754
|
+
'reaction.added',
|
|
1755
|
+
'message.flagged',
|
|
1756
|
+
'ticket.created',
|
|
1757
|
+
'ticket.updated',
|
|
1758
|
+
],
|
|
1759
|
+
},
|
|
1760
|
+
{
|
|
1761
|
+
value: 'message.sender_phone',
|
|
1762
|
+
label: 'Sender Phone',
|
|
1763
|
+
validTriggers: [
|
|
1764
|
+
'message.created',
|
|
1765
|
+
'message.updated',
|
|
1766
|
+
'reaction.added',
|
|
1767
|
+
'message.flagged',
|
|
1768
|
+
'ticket.created',
|
|
1769
|
+
'ticket.updated',
|
|
1770
|
+
],
|
|
1771
|
+
},
|
|
1772
|
+
{
|
|
1773
|
+
value: 'message.timestamp',
|
|
1774
|
+
label: 'Message Timestamp',
|
|
1775
|
+
validTriggers: [
|
|
1776
|
+
'message.created',
|
|
1777
|
+
'message.updated',
|
|
1778
|
+
'reaction.added',
|
|
1779
|
+
'message.flagged',
|
|
1780
|
+
'ticket.created',
|
|
1781
|
+
'ticket.updated',
|
|
1782
|
+
],
|
|
1783
|
+
},
|
|
1784
|
+
{
|
|
1785
|
+
label: 'Sender Name',
|
|
1786
|
+
value: 'sender.contact_name',
|
|
1787
|
+
validTriggers: [
|
|
1788
|
+
'message.created',
|
|
1789
|
+
'message.updated',
|
|
1790
|
+
'reaction.added',
|
|
1791
|
+
'message.flagged',
|
|
1792
|
+
'ticket.created',
|
|
1793
|
+
'ticket.updated',
|
|
1794
|
+
],
|
|
1795
|
+
},
|
|
1796
|
+
{
|
|
1797
|
+
value: 'sender.is_admin',
|
|
1798
|
+
label: 'Sender Is Admin',
|
|
1799
|
+
validTriggers: [
|
|
1800
|
+
'message.created',
|
|
1801
|
+
'message.updated',
|
|
1802
|
+
'reaction.added',
|
|
1803
|
+
'message.flagged',
|
|
1804
|
+
'ticket.created',
|
|
1805
|
+
'ticket.updated',
|
|
1806
|
+
],
|
|
1807
|
+
},
|
|
1808
|
+
{
|
|
1809
|
+
value: 'sender.is_internal',
|
|
1810
|
+
label: 'Sender Is Internal',
|
|
1811
|
+
validTriggers: [
|
|
1812
|
+
'message.created',
|
|
1813
|
+
'message.updated',
|
|
1814
|
+
'reaction.added',
|
|
1815
|
+
'message.flagged',
|
|
1816
|
+
'ticket.created',
|
|
1817
|
+
'ticket.updated',
|
|
1818
|
+
],
|
|
1819
|
+
},
|
|
1820
|
+
{
|
|
1821
|
+
label: 'Reaction',
|
|
1822
|
+
value: 'reaction.reaction',
|
|
1823
|
+
validTriggers: ['reaction.added'],
|
|
1824
|
+
},
|
|
1825
|
+
{
|
|
1826
|
+
value: 'reaction.sender_id',
|
|
1827
|
+
label: 'Reaction Sender Phone',
|
|
1828
|
+
validTriggers: ['reaction.added'],
|
|
1829
|
+
},
|
|
1830
|
+
{
|
|
1831
|
+
label: 'Chat Name',
|
|
1832
|
+
value: 'chat.chat_name',
|
|
1833
|
+
validTriggers: [
|
|
1834
|
+
'message.created',
|
|
1835
|
+
'message.updated',
|
|
1836
|
+
'reaction.added',
|
|
1837
|
+
'message.flagged',
|
|
1838
|
+
'chat.created',
|
|
1839
|
+
'chat.label.updated',
|
|
1840
|
+
'ticket.created',
|
|
1841
|
+
'ticket.updated',
|
|
1842
|
+
],
|
|
1843
|
+
},
|
|
1844
|
+
{
|
|
1845
|
+
value: 'chat.assigned_to',
|
|
1846
|
+
label: 'Chat Assigned To',
|
|
1847
|
+
validTriggers: [
|
|
1848
|
+
'message.created',
|
|
1849
|
+
'message.updated',
|
|
1850
|
+
'reaction.added',
|
|
1851
|
+
'message.flagged',
|
|
1852
|
+
'chat.created',
|
|
1853
|
+
'chat.label.updated',
|
|
1854
|
+
'ticket.created',
|
|
1855
|
+
'ticket.updated',
|
|
1856
|
+
],
|
|
1857
|
+
},
|
|
1858
|
+
{
|
|
1859
|
+
value: 'chat.chat_id',
|
|
1860
|
+
label: 'Chat ID',
|
|
1861
|
+
validTriggers: [
|
|
1862
|
+
'message.created',
|
|
1863
|
+
'message.updated',
|
|
1864
|
+
'reaction.added',
|
|
1865
|
+
'message.flagged',
|
|
1866
|
+
'chat.created',
|
|
1867
|
+
'chat.label.updated',
|
|
1868
|
+
'ticket.created',
|
|
1869
|
+
'ticket.updated',
|
|
1870
|
+
],
|
|
1871
|
+
},
|
|
1872
|
+
{
|
|
1873
|
+
value: 'chat.chat_type',
|
|
1874
|
+
label: 'Chat Type',
|
|
1875
|
+
validTriggers: [
|
|
1876
|
+
'message.created',
|
|
1877
|
+
'message.updated',
|
|
1878
|
+
'reaction.added',
|
|
1879
|
+
'message.flagged',
|
|
1880
|
+
'chat.created',
|
|
1881
|
+
'chat.label.updated',
|
|
1882
|
+
'ticket.created',
|
|
1883
|
+
'ticket.updated',
|
|
1884
|
+
],
|
|
1885
|
+
},
|
|
1886
|
+
{
|
|
1887
|
+
value: 'chat.org_id',
|
|
1888
|
+
label: 'Chat Org ID',
|
|
1889
|
+
validTriggers: [
|
|
1890
|
+
'message.created',
|
|
1891
|
+
'message.updated',
|
|
1892
|
+
'reaction.added',
|
|
1893
|
+
'message.flagged',
|
|
1894
|
+
'chat.created',
|
|
1895
|
+
'chat.label.updated',
|
|
1896
|
+
'ticket.created',
|
|
1897
|
+
'ticket.updated',
|
|
1898
|
+
],
|
|
1899
|
+
},
|
|
1900
|
+
{
|
|
1901
|
+
value: 'chat.org_phone',
|
|
1902
|
+
label: 'Chat Org Phone',
|
|
1903
|
+
validTriggers: [
|
|
1904
|
+
'message.created',
|
|
1905
|
+
'message.updated',
|
|
1906
|
+
'reaction.added',
|
|
1907
|
+
'message.flagged',
|
|
1908
|
+
'chat.created',
|
|
1909
|
+
'chat.label.updated',
|
|
1910
|
+
'ticket.created',
|
|
1911
|
+
'ticket.updated',
|
|
1912
|
+
],
|
|
1913
|
+
},
|
|
1914
|
+
];
|
|
1915
|
+
|
|
1916
|
+
export const variablesExclusionList: Record<
|
|
1917
|
+
Rule['trigger'],
|
|
1918
|
+
Array<
|
|
1919
|
+
| keyof AppendTypes<{ message: MessageVariablesType }, '.'>
|
|
1920
|
+
| keyof AppendTypes<{ sender: SenderVariablesType }, '.'>
|
|
1921
|
+
| keyof AppendTypes<{ chat: ChatVariablesType }, '.'>
|
|
1922
|
+
| keyof AppendTypes<{ ticket: TicketVariablesType }, '.'>
|
|
1923
|
+
| keyof AppendTypes<{ reaction: ReactionVariablesType }, '.'>
|
|
1924
|
+
>
|
|
1925
|
+
> = {
|
|
1926
|
+
'ticket.created': ['ticket.is_deleted'],
|
|
1927
|
+
'chat.created': [
|
|
1928
|
+
'chat.chat_id',
|
|
1929
|
+
'chat.labels',
|
|
1930
|
+
'chat.has_flagged_messages',
|
|
1931
|
+
'chat.assigned_to',
|
|
1932
|
+
],
|
|
1933
|
+
'message.created': [
|
|
1934
|
+
'message.author',
|
|
1935
|
+
'message.performed_by',
|
|
1936
|
+
'message.flag_status',
|
|
1937
|
+
'sender.is_internal',
|
|
1938
|
+
],
|
|
1939
|
+
'ticket.updated': ['ticket.is_deleted'],
|
|
1940
|
+
'reaction.added': [],
|
|
1941
|
+
'message.updated': [],
|
|
1942
|
+
'message.flagged': [],
|
|
1943
|
+
'chat.label.updated': [],
|
|
1944
|
+
};
|