@periskope/types 0.6.366 → 0.6.368

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.
@@ -1,2625 +1,2625 @@
1
- import { Merge, OverrideProperties } from 'type-fest';
2
- import { Tables } from './supabase.types';
3
- import {
4
- ChatRuleInfoType,
5
- MessageRuleInfoType,
6
- OrgType,
7
- ReactionRuleInfoType,
8
- SenderRuleInfoType,
9
- TaskRuleInfoType,
10
- TicketRuleInfoType,
11
- } from './types';
12
-
13
- export type AppendTypes<T extends object, O extends string> = {
14
- [K in keyof T & string as `${K}${O}${keyof T[K] & string}`]: T[K][keyof T[K]];
15
- };
16
-
17
- export type TicketVariablesType = TicketRuleInfoType['ticket'];
18
-
19
- export type MessageVariablesType = MessageRuleInfoType['message'];
20
-
21
- export type SenderVariablesType = SenderRuleInfoType;
22
-
23
- export type ReactionVariablesType = ReactionRuleInfoType['reaction'];
24
-
25
- export type ChatVariablesType = ChatRuleInfoType['chat'];
26
-
27
- export type TaskVariablesType = TaskRuleInfoType['task'];
28
-
29
- export type MessageRulesInfoType = Merge<
30
- AppendTypes<
31
- {
32
- message: MessageVariablesType;
33
- sender: SenderVariablesType;
34
- chat: ChatVariablesType;
35
- },
36
- '.'
37
- >,
38
- {
39
- rule: Tables<'tbl_automation_rules'>[];
40
- id: 'message.message_id';
41
- type: `message.${'created' | 'updated' | 'flagged' | 'deleted' | 'unflagged'}`;
42
- org_id: string;
43
- }
44
- >;
45
-
46
- export type TicketRulesInfoType = Merge<
47
- AppendTypes<
48
- {
49
- ticket: TicketVariablesType;
50
- message: MessageVariablesType;
51
- sender: SenderVariablesType;
52
- chat: ChatVariablesType;
53
- },
54
- '.'
55
- >,
56
- {
57
- id: 'ticket.ticket_id';
58
- type: `ticket.${'created' | 'updated' | 'closed'}` | 'ticket.label.updated';
59
- org_id: string;
60
- rule: Tables<'tbl_automation_rules'>[];
61
- }
62
- >;
63
-
64
- export type TaskRulesInfoType<
65
- T extends 'ticket' | 'chat' | 'message' | 'todo' = 'todo',
66
- > = Merge<
67
- AppendTypes<
68
- T extends 'message'
69
- ? {
70
- task: TaskVariablesType;
71
- message: MessageVariablesType;
72
- sender: SenderVariablesType;
73
- chat: ChatVariablesType;
74
- }
75
- : T extends 'chat'
76
- ? {
77
- task: TaskVariablesType;
78
- chat: ChatVariablesType;
79
- }
80
- : T extends 'ticket'
81
- ? {
82
- task: TaskVariablesType;
83
- ticket: TicketVariablesType;
84
- message: MessageVariablesType;
85
- sender: SenderVariablesType;
86
- chat: ChatVariablesType;
87
- }
88
- : {
89
- task: TaskVariablesType;
90
- },
91
- '.'
92
- >,
93
- {
94
- id: 'task.task_id';
95
- type: `task.${'created' | 'assignee.updated'}`;
96
- org_id: string;
97
- rule: Tables<'tbl_automation_rules'>[];
98
- }
99
- >;
100
-
101
- export type ReactionRulesInfoType = Merge<
102
- AppendTypes<
103
- {
104
- reaction: ReactionVariablesType;
105
- message: MessageVariablesType;
106
- sender: SenderVariablesType;
107
- chat: ChatVariablesType;
108
- },
109
- '.'
110
- >,
111
- {
112
- rule: Tables<'tbl_automation_rules'>[];
113
- id: 'reaction.reaction_id';
114
- type: `reaction.added`;
115
- org_id: string;
116
- }
117
- >;
118
-
119
- export type ChatRulesInfoType = Merge<
120
- AppendTypes<
121
- {
122
- chat: ChatVariablesType;
123
- },
124
- '.'
125
- >,
126
- {
127
- rule: Tables<'tbl_automation_rules'>[];
128
- id: 'chat.chat_id';
129
- type: 'chat.created' | 'chat.label.updated';
130
- org_id: string;
131
- }
132
- >;
133
-
134
- export type RuleInfoType =
135
- | MessageRulesInfoType
136
- | ChatRulesInfoType
137
- | TicketRulesInfoType
138
- | ReactionRulesInfoType
139
- | TaskRulesInfoType;
140
-
141
- export interface Filter {
142
- id: string;
143
- condition:
144
- | 'CONTAINS'
145
- | 'NCONTAINS'
146
- | 'EQ'
147
- | 'NEQ'
148
- | 'LT'
149
- | 'LTE'
150
- | 'GT'
151
- | 'GTE'
152
- | 'KNOWN'
153
- | 'NKNOWN'
154
- | 'IS'
155
- | 'NIS'
156
- | 'ON'
157
- | 'STARTS_WITH'
158
- | 'ENDS_WITH'; // Add other condition types as needed
159
- variable: string;
160
- value: string | string[];
161
- variable_type?: 'string' | 'number' | 'boolean' | 'day-time' | 'date' | 'day'; // Optional, like 'Date'
162
- }
163
-
164
- export const isFilter = (filter: any): filter is Filter => {
165
- return (
166
- typeof filter === 'object' &&
167
- 'id' in filter &&
168
- 'condition' in filter &&
169
- 'variable' in filter &&
170
- 'value' in filter
171
- );
172
- };
173
-
174
- export const FilterNameMap: Record<
175
- Filter['condition'],
176
- {
177
- name: string;
178
- input: boolean;
179
- }
180
- > = {
181
- EQ: {
182
- name: 'equals to',
183
- input: true,
184
- },
185
- NEQ: {
186
- name: 'not equals to',
187
- input: true,
188
- },
189
- CONTAINS: {
190
- name: 'contains',
191
- input: true,
192
- },
193
- NCONTAINS: {
194
- name: 'does not contain',
195
- input: true,
196
- },
197
- LT: {
198
- name: 'less than',
199
- input: true,
200
- },
201
- LTE: {
202
- name: 'less than or equals to',
203
- input: true,
204
- },
205
- GT: {
206
- name: 'greater than',
207
- input: true,
208
- },
209
- GTE: {
210
- name: 'greater than or equals to',
211
- input: true,
212
- },
213
- KNOWN: {
214
- name: 'is known',
215
- input: false,
216
- },
217
- NKNOWN: {
218
- name: 'is not known',
219
- input: false,
220
- },
221
- IS: {
222
- name: 'is',
223
- input: true,
224
- },
225
- NIS: {
226
- name: 'is not',
227
- input: true,
228
- },
229
- ON: {
230
- name: 'on',
231
- input: true,
232
- },
233
- STARTS_WITH: {
234
- name: 'starts with',
235
- input: true,
236
- },
237
- ENDS_WITH: {
238
- name: 'ends with',
239
- input: true,
240
- },
241
- };
242
-
243
- export type VariableNameValueType = {
244
- text: string;
245
- type:
246
- | 'string'
247
- | 'time'
248
- | 'boolean'
249
- | 'dropdown'
250
- | 'day-time'
251
- | 'number'
252
- | 'date';
253
- variable_type: 'string' | 'number' | 'boolean' | 'day-time' | 'date';
254
- value?:
255
- | string
256
- | {
257
- id: string;
258
- value: string | number | boolean;
259
- label: string;
260
- }[]
261
- | null;
262
- filters:
263
- | Partial<
264
- Record<
265
- Filter['condition'],
266
- {
267
- info?: string;
268
- }
269
- >
270
- >
271
- | Filter['condition'][];
272
- hidden?: boolean;
273
- placeholder?: string;
274
- info?: string;
275
- };
276
-
277
- export const MessageVariableNameMap: Record<
278
- keyof AppendTypes<{ message: MessageVariablesType }, '.'>,
279
- VariableNameValueType
280
- > = {
281
- 'message.body': {
282
- text: 'Message Body',
283
- type: 'string',
284
- filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
285
- placeholder: 'e.g. Test message',
286
- variable_type: 'string',
287
- },
288
- 'message.sender_phone': {
289
- text: 'Message Sender Phone',
290
- type: 'string',
291
- filters: ['EQ', 'NEQ'],
292
- placeholder: 'e.g. 919876543210',
293
- variable_type: 'string',
294
- },
295
- 'message.timestamp': {
296
- text: 'Message Timestamp',
297
- type: 'day-time',
298
- filters: {
299
- LT: {
300
- info: 'When message is received before mentioned time (UTC)',
301
- },
302
- LTE: {
303
- info: 'When message is received before mentioned time (UTC)',
304
- },
305
- GT: {
306
- info: 'When message is received after mentioned time (UTC)',
307
- },
308
- GTE: {
309
- info: 'When message is received on or after mentioned time (UTC)',
310
- },
311
- ON: {
312
- info: 'When message is received on mentioned days',
313
- },
314
- },
315
- variable_type: 'day-time',
316
- info: 'The timestamp when the message was received',
317
- },
318
- 'message.flag_status': {
319
- text: 'Message Flag Status',
320
- filters: ['IS'],
321
- type: 'boolean',
322
- variable_type: 'boolean',
323
- },
324
- 'message.has_quoted_msg': {
325
- text: 'Has Quoted Message',
326
- filters: ['IS'],
327
- type: 'boolean',
328
- variable_type: 'boolean',
329
- },
330
- 'message.media': {
331
- text: 'Has Media',
332
- type: 'boolean',
333
- filters: ['KNOWN', 'NKNOWN'],
334
- variable_type: 'boolean',
335
- },
336
- 'message.performed_by': {
337
- text: 'Message Sent By (email)',
338
- type: 'dropdown',
339
- value: 'org.members',
340
- filters: ['EQ', 'NEQ'],
341
- variable_type: 'string',
342
- },
343
- 'message.chat_id': {
344
- text: 'Chat ID',
345
- type: 'string',
346
- filters: ['EQ', 'NEQ', 'STARTS_WITH', 'ENDS_WITH'],
347
- hidden: true,
348
- variable_type: 'string',
349
- },
350
- 'message.message_ticket_id': {
351
- text: 'Message Ticket ID',
352
- type: 'string',
353
- filters: ['EQ', 'NEQ'],
354
- hidden: true,
355
- variable_type: 'string',
356
- },
357
- 'message.message_id': {
358
- text: 'Message ID',
359
- type: 'string',
360
- filters: ['EQ', 'NEQ'],
361
- hidden: true,
362
- variable_type: 'string',
363
- },
364
- 'message.org_phone': {
365
- text: 'Org Phone',
366
- type: 'string',
367
- filters: ['EQ', 'NEQ'],
368
- hidden: true,
369
- variable_type: 'string',
370
- },
371
- 'message.org_id': {
372
- text: 'Org ID',
373
- type: 'string',
374
- filters: ['EQ', 'NEQ'],
375
- hidden: true,
376
- variable_type: 'string',
377
- },
378
- 'message.message_type': {
379
- text: 'Message Type',
380
- type: 'dropdown',
381
- value: [
382
- { id: 'text', value: 'chat', label: 'Text' },
383
- { id: 'image', value: 'image', label: 'Image' },
384
- { id: 'video', value: 'video', label: 'Video' },
385
- { id: 'audio', value: 'audio', label: 'Audio' },
386
- { id: 'audio', value: 'ptt', label: 'PTT (Audio voice message)' },
387
- { id: 'document', value: 'document', label: 'Document' },
388
- ],
389
- filters: ['EQ', 'NEQ'],
390
- variable_type: 'string',
391
- },
392
- 'message.author': {
393
- text: 'Message Author',
394
- type: 'string',
395
- filters: ['EQ', 'NEQ'],
396
- hidden: true,
397
- variable_type: 'string',
398
- },
399
- };
400
-
401
- export const SenderVariableNameMap: Record<
402
- keyof AppendTypes<{ sender: SenderVariablesType }, '.'>,
403
- VariableNameValueType
404
- > = {
405
- 'sender.is_internal': {
406
- text: 'Sender Is Internal',
407
- type: 'boolean',
408
- filters: ['IS'],
409
- variable_type: 'boolean',
410
- },
411
- 'sender.contact_name': {
412
- text: 'Sender Name',
413
- type: 'string',
414
- filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
415
- placeholder: 'e.g. John Doe',
416
- variable_type: 'string',
417
- },
418
- 'sender.contact_id': {
419
- text: 'Sender Phone',
420
- type: 'string',
421
- filters: ['EQ', 'NEQ'],
422
- placeholder: 'e.g. 919876543210',
423
- variable_type: 'string',
424
- },
425
- 'sender.org_id': {
426
- text: 'Org ID',
427
- type: 'string',
428
- filters: ['EQ', 'NEQ'],
429
- hidden: true,
430
- variable_type: 'string',
431
- },
432
- 'sender.labels': {
433
- text: 'Sender Contact Labels',
434
- type: 'dropdown',
435
- value: 'org.labels',
436
- filters: ['CONTAINS', 'NCONTAINS'],
437
- variable_type: 'string',
438
- },
439
- 'sender.is_admin': {
440
- text: 'Sender Is Admin',
441
- type: 'dropdown',
442
- filters: ['EQ', 'NEQ'],
443
- value: [
444
- {
445
- id: 'true',
446
- value: 'true',
447
- label: 'True',
448
- },
449
- {
450
- id: 'false',
451
- value: 'false',
452
- label: 'False',
453
- },
454
- ],
455
- variable_type: 'boolean',
456
- },
457
- };
458
-
459
- export const ChatVariableNameMap: Record<
460
- keyof AppendTypes<{ chat: ChatVariablesType }, '.'>,
461
- VariableNameValueType
462
- > = {
463
- 'chat.assigned_to': {
464
- text: 'Chat Assignee',
465
- type: 'dropdown',
466
- value: 'org.members',
467
- filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
468
- variable_type: 'string',
469
- },
470
- 'chat.chat_name': {
471
- text: 'Chat Name',
472
- type: 'string',
473
- filters: ['EQ', 'NEQ', 'CONTAINS', 'NCONTAINS'],
474
- placeholder: 'e.g. Support Chat',
475
- variable_type: 'string',
476
- },
477
- 'chat.org_phone': {
478
- text: 'Chat Org Phone',
479
- type: 'dropdown',
480
- value: 'org.org_phones',
481
- filters: ['EQ', 'NEQ'],
482
- variable_type: 'string',
483
- },
484
- 'chat.chat_type': {
485
- text: 'Chat Type',
486
- type: 'dropdown',
487
- value: [
488
- { id: 'user', value: 'user', label: 'User' },
489
- { id: 'group', value: 'group', label: 'Group' },
490
- ],
491
- filters: ['EQ', 'NEQ'],
492
- variable_type: 'string',
493
- },
494
- 'chat.members': {
495
- text: 'Chat Members',
496
- type: 'string',
497
- filters: ['CONTAINS', 'NCONTAINS'],
498
- placeholder: 'e.g. 919876543210',
499
- variable_type: 'string',
500
- },
501
- 'chat.labels': {
502
- text: 'Chat Labels',
503
- type: 'dropdown',
504
- value: 'org.labels',
505
- filters: ['CONTAINS', 'NCONTAINS'],
506
- variable_type: 'string',
507
- },
508
- 'chat.chat_id': {
509
- text: 'Chat ID',
510
- type: 'string',
511
- filters: ['EQ', 'NEQ', 'STARTS_WITH', 'ENDS_WITH'],
512
- placeholder: 'e.g. 12027747916749@g.us',
513
- variable_type: 'string',
514
- },
515
- 'chat.chat_org_phones': {
516
- text: 'Chat Org Phones',
517
- type: 'dropdown',
518
- filters: ['CONTAINS', 'NCONTAINS'],
519
- hidden: true,
520
- variable_type: 'string',
521
- },
522
- 'chat.org_id': {
523
- text: 'Org ID',
524
- type: 'string',
525
- filters: [],
526
- hidden: true,
527
- variable_type: 'string',
528
- },
529
- 'chat.messages_admins_only': {
530
- text: 'Messages Admins Only (Chat Settings)',
531
- type: 'boolean',
532
- filters: ['EQ', 'NEQ'],
533
- value: [
534
- {
535
- id: 'true',
536
- value: 'true',
537
- label: 'True',
538
- },
539
- {
540
- id: 'false',
541
- value: 'false',
542
- label: 'False',
543
- },
544
- ],
545
- variable_type: 'boolean',
546
- },
547
- 'chat.info_admins_only': {
548
- text: 'Info Admins Only (Chat Settings)',
549
- type: 'boolean',
550
- filters: ['EQ', 'NEQ'],
551
- value: [
552
- {
553
- id: 'true',
554
- value: 'true',
555
- label: 'True',
556
- },
557
- {
558
- id: 'false',
559
- value: 'false',
560
- label: 'False',
561
- },
562
- ],
563
- variable_type: 'boolean',
564
- },
565
- 'chat.has_flagged_messages': {
566
- text: 'Chat Has Flagged Messages',
567
- type: 'boolean',
568
- filters: ['EQ', 'NEQ'],
569
- value: [
570
- {
571
- id: 'true',
572
- value: 'true',
573
- label: 'True',
574
- },
575
- {
576
- id: 'false',
577
- value: 'false',
578
- label: 'False',
579
- },
580
- ],
581
- variable_type: 'boolean',
582
- },
583
- 'chat.group_description': {
584
- text: 'Group Description',
585
- type: 'string',
586
- filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
587
- placeholder: 'e.g. Group description',
588
- variable_type: 'string',
589
- },
590
- 'chat.custom_properties': {
591
- text: 'Chat Custom Properties',
592
- type: 'dropdown',
593
- value: 'org.custom_properties',
594
- filters: ['EQ', 'NEQ'],
595
- hidden: true,
596
- variable_type: 'string',
597
- },
598
- 'chat.initiated_by': {
599
- text: 'Chat Initiated By',
600
- type: 'dropdown',
601
- value: 'org.members',
602
- filters: ['EQ', 'NEQ'],
603
- variable_type: 'string',
604
- hidden: true,
605
- },
606
- 'chat.created_at': {
607
- text: 'Chat Created At',
608
- type: 'day-time',
609
- filters: {
610
- LT: {
611
- info: 'When chat is created before mentioned time (UTC)',
612
- },
613
- LTE: {
614
- info: 'When chat is created before mentioned time (UTC)',
615
- },
616
- GT: {
617
- info: 'When chat is created after mentioned time (UTC)',
618
- },
619
- GTE: {
620
- info: 'When chat is created on or after mentioned time (UTC)',
621
- },
622
- ON: {
623
- info: 'When chat is created on mentioned days',
624
- },
625
- },
626
- variable_type: 'day-time',
627
- },
628
- };
629
-
630
- export const TicketVariableNameMap: Record<
631
- keyof AppendTypes<{ ticket: TicketVariablesType }, '.'>,
632
- VariableNameValueType
633
- > = {
634
- 'ticket.subject': {
635
- text: 'Ticket Subject',
636
- type: 'string',
637
- filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
638
- placeholder: 'e.g. Test ticket',
639
- variable_type: 'string',
640
- },
641
- 'ticket.status': {
642
- text: 'Ticket Status',
643
- type: 'dropdown',
644
- value: [
645
- { id: 'open', value: 'open', label: 'Open' },
646
- { id: 'closed', value: 'closed', label: 'Closed' },
647
- { id: 'inprogress', value: 'inprogress', label: 'In progress' },
648
- ],
649
- filters: ['EQ', 'NEQ'],
650
- variable_type: 'string',
651
- },
652
- 'ticket.priority': {
653
- text: 'Ticket Priority',
654
- type: 'dropdown',
655
- value: [
656
- { id: '0', value: '0', label: 'No Priority' },
657
- { id: '1', value: '1', label: 'Low' },
658
- { id: '2', value: '2', label: 'Medium' },
659
- { id: '3', value: '3', label: 'High' },
660
- { id: '4', value: '4', label: 'Urgent' },
661
- ],
662
- filters: ['EQ', 'NEQ'],
663
- variable_type: 'string',
664
- },
665
- 'ticket.assignee': {
666
- text: 'Ticket Assignee',
667
- type: 'dropdown',
668
- value: 'org.members',
669
- filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
670
- variable_type: 'string',
671
- },
672
- 'ticket.labels': {
673
- text: 'Ticket Labels',
674
- type: 'dropdown',
675
- value: 'org.labels',
676
- filters: ['CONTAINS', 'NCONTAINS'],
677
- variable_type: 'string',
678
- },
679
- 'ticket.is_deleted': {
680
- text: 'Ticket Is Deleted',
681
- type: 'boolean',
682
- value: [
683
- {
684
- id: 'true',
685
- value: 'true',
686
- label: 'True',
687
- },
688
- {
689
- id: 'false',
690
- value: 'false',
691
- label: 'False',
692
- },
693
- ],
694
- filters: ['IS'],
695
- variable_type: 'boolean',
696
- },
697
- 'ticket.raised_by': {
698
- text: 'Ticket Raised By',
699
- type: 'dropdown',
700
- value: 'org.members',
701
- filters: ['EQ', 'NEQ'],
702
- variable_type: 'string',
703
- },
704
- 'ticket.due_date': {
705
- text: 'Ticket Due Date',
706
- type: 'date',
707
- filters: ['KNOWN', 'NKNOWN'],
708
- variable_type: 'date',
709
- hidden: true,
710
- },
711
- 'ticket.ticket_id': {
712
- text: 'Ticket ID',
713
- type: 'string',
714
- filters: ['EQ', 'NEQ'],
715
- hidden: true,
716
- variable_type: 'string',
717
- },
718
- 'ticket.org_id': {
719
- text: 'Org ID',
720
- type: 'string',
721
- filters: ['EQ', 'NEQ'],
722
- hidden: true,
723
- variable_type: 'string',
724
- },
725
- 'ticket.custom_properties': {
726
- text: 'Ticket Custom Properties',
727
- type: 'dropdown',
728
- value: 'org.custom_properties',
729
- filters: ['EQ', 'NEQ'],
730
- hidden: true,
731
- variable_type: 'string',
732
- },
733
- 'ticket.created_at': {
734
- text: 'Ticket Created At',
735
- type: 'day-time',
736
- filters: {
737
- LT: {
738
- info: 'When ticket is created before mentioned time (UTC)',
739
- },
740
- LTE: {
741
- info: 'When ticket is created before mentioned time (UTC)',
742
- },
743
- GT: {
744
- info: 'When ticket is created after mentioned time (UTC)',
745
- },
746
- GTE: {
747
- info: 'When ticket is created on or after mentioned time (UTC)',
748
- },
749
- ON: {
750
- info: 'When ticket is created on mentioned days',
751
- },
752
- },
753
- variable_type: 'day-time',
754
- },
755
- 'ticket.chat_id': {
756
- text: 'Chat ID',
757
- type: 'string',
758
- filters: ['EQ', 'NEQ', 'STARTS_WITH', 'ENDS_WITH'],
759
- hidden: true,
760
- variable_type: 'string',
761
- },
762
- };
763
-
764
- export const TaskVariableNameMap: Record<
765
- keyof AppendTypes<{ task: TaskVariablesType }, '.'>,
766
- VariableNameValueType
767
- > = {
768
- 'task.title': {
769
- text: 'Task Title',
770
- type: 'string',
771
- filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
772
- placeholder: 'e.g. Test task',
773
- variable_type: 'string',
774
- },
775
- 'task.assignee': {
776
- text: 'Task Assignee',
777
- type: 'dropdown',
778
- value: 'org.members',
779
- filters: ['EQ', 'NEQ'],
780
- variable_type: 'string',
781
- },
782
- 'task.priority': {
783
- text: 'Task Priority',
784
- type: 'dropdown',
785
- value: [
786
- { id: '0', value: '0', label: 'No Priority' },
787
- { id: '1', value: '1', label: 'Low' },
788
- { id: '2', value: '2', label: 'Medium' },
789
- { id: '3', value: '3', label: 'High' },
790
- { id: '4', value: '4', label: 'Urgent' },
791
- ],
792
- filters: ['EQ', 'NEQ'],
793
- variable_type: 'string',
794
- },
795
- 'task.due_date': {
796
- text: 'Task Due Date',
797
- type: 'day-time',
798
- filters: {
799
- LT: {
800
- info: 'When task is created before mentioned time (UTC)',
801
- },
802
- LTE: {
803
- info: 'When task is created before mentioned time (UTC)',
804
- },
805
- GT: {
806
- info: 'When task is created after mentioned time (UTC)',
807
- },
808
- GTE: {
809
- info: 'When task is created on or after mentioned time (UTC)',
810
- },
811
- ON: {
812
- info: 'When task is created on mentioned days',
813
- },
814
- },
815
- variable_type: 'day-time',
816
- },
817
- 'task.task_id': {
818
- text: 'Task ID',
819
- type: 'string',
820
- filters: ['EQ', 'NEQ'],
821
- hidden: true,
822
- variable_type: 'string',
823
- },
824
- 'task.org_id': {
825
- text: 'Org ID',
826
- type: 'string',
827
- filters: ['EQ', 'NEQ'],
828
- hidden: true,
829
- variable_type: 'string',
830
- },
831
- 'task.created_at': {
832
- text: 'Task Created At',
833
- type: 'day-time',
834
- filters: {
835
- LT: {
836
- info: 'When task is created before mentioned time (UTC)',
837
- },
838
- LTE: {
839
- info: 'When task is created before mentioned time (UTC)',
840
- },
841
- GT: {
842
- info: 'When task is created after mentioned time (UTC)',
843
- },
844
- GTE: {
845
- info: 'When task is created on or after mentioned time (UTC)',
846
- },
847
- ON: {
848
- info: 'When task is created on mentioned days',
849
- },
850
- },
851
- variable_type: 'day-time',
852
- },
853
- 'task.notes': {
854
- text: 'Task Notes',
855
- type: 'string',
856
- filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
857
- placeholder: 'e.g. Test task',
858
- variable_type: 'string',
859
- },
860
- 'task.status': {
861
- text: 'Task Status',
862
- type: 'dropdown',
863
- value: [
864
- { id: 'open', value: 'open', label: 'Open' },
865
- { id: 'closed', value: 'closed', label: 'Closed' },
866
- { id: 'inprogress', value: 'inprogress', label: 'In progress' },
867
- ],
868
- filters: ['EQ', 'NEQ'],
869
- variable_type: 'string',
870
- },
871
- };
872
- export const ReactionVariableNameMap: Record<
873
- keyof AppendTypes<{ reaction: ReactionVariablesType }, '.'>,
874
- VariableNameValueType
875
- > = {
876
- 'reaction.reaction': {
877
- text: 'Reaction',
878
- type: 'string',
879
- filters: ['EQ', 'NEQ'],
880
- placeholder: 'e.g. 👍',
881
- variable_type: 'string',
882
- },
883
- 'reaction.sender_id': {
884
- text: 'Reaction Sender Phone',
885
- type: 'string',
886
- filters: ['EQ', 'NEQ'],
887
- placeholder: 'e.g. 919876543210',
888
- variable_type: 'string',
889
- },
890
- 'reaction.message_id': {
891
- text: 'Reaction Message ID',
892
- type: 'string',
893
- filters: ['EQ', 'NEQ'],
894
- hidden: true,
895
- variable_type: 'string',
896
- },
897
- 'reaction.chat_id': {
898
- text: 'Chat ID',
899
- type: 'string',
900
- filters: ['EQ', 'NEQ', 'STARTS_WITH', 'ENDS_WITH'],
901
- hidden: true,
902
- variable_type: 'string',
903
- },
904
- 'reaction.reaction_id': {
905
- text: 'Reaction ID',
906
- type: 'string',
907
- filters: ['EQ', 'NEQ'],
908
- hidden: true,
909
- variable_type: 'string',
910
- },
911
- };
912
-
913
- export enum FilterConditionMap {
914
- 'CONTAINS' = 'contains',
915
- 'NCONTAINS' = 'does not contain',
916
- 'EQ' = '=',
917
- 'NEQ' = '<>',
918
- 'LT' = '<',
919
- 'LTE' = '<=',
920
- 'GT' = '>',
921
- 'GTE' = '>=',
922
- 'KNOWN' = 'is known',
923
- 'NKNOWN' = 'is not known',
924
- 'IS' = '=',
925
- 'NIS' = '<>',
926
- 'ON' = 'on',
927
- 'STARTS_WITH' = 'starts with',
928
- 'ENDS_WITH' = 'ends with',
929
- }
930
-
931
- interface FilterGroup {
932
- filters: Filter[];
933
- condition: 'allOf' | 'anyOf';
934
- }
935
-
936
- export interface Conditions {
937
- filters: FilterGroup[];
938
- condition: 'allOf' | 'anyOf';
939
- variables: string[];
940
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
941
- org_phones: string[];
942
- allow_messages_from_org_phones?: boolean;
943
- }
944
-
945
- export type SendMessageAction = {
946
- id: string;
947
- type: 'send_message';
948
- metadata: {
949
- message: string;
950
- media?: {
951
- url: string;
952
- type: 'image' | 'video' | 'audio' | 'document';
953
- name: string;
954
- };
955
- maintain_flag_status: 'true' | 'false';
956
- debounce_messages: 'true' | 'false';
957
- debounce_message_time:
958
- | `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`
959
- | null
960
- | undefined;
961
- };
962
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
963
- };
964
-
965
- export type NotifyHttpAction = {
966
- id: string;
967
- type: 'notify_http';
968
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
969
- metadata: {
970
- url: string;
971
- };
972
- };
973
-
974
- export type CreateTicketAction = {
975
- id: string;
976
- type: 'create_ticket';
977
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
978
- metadata: {
979
- priority?: '0' | '1' | '2' | '3' | '4';
980
- label?: string;
981
- append_to_latest_ticket?: 'true' | 'false';
982
- round_robin?: 'true' | 'false';
983
- assignee?: string;
984
- rr_check_for?: 'shift_time' | 'user_status' | 'shift_time user_status';
985
- };
986
- };
987
-
988
- export type FlagMessageAction = {
989
- id: string;
990
- type: 'flag_message';
991
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
992
- metadata: {
993
- flag: 'true' | 'false';
994
- };
995
- };
996
-
997
- export type AssignTicketAction = {
998
- id: string;
999
- type: 'assign_ticket';
1000
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1001
- metadata: {
1002
- assignee: string;
1003
- round_robin: 'true' | 'false';
1004
- rr_check_for?: 'shift_time' | 'user_status' | 'shift_time user_status';
1005
- };
1006
- };
1007
-
1008
- export type CloseTicketAction = {
1009
- id: string;
1010
- type: 'close_ticket';
1011
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1012
- metadata: {
1013
- closing_note: string;
1014
- };
1015
- };
1016
-
1017
- export type AddChatLabelAction = {
1018
- id: string;
1019
- type: 'add_chat_label';
1020
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1021
- metadata: {
1022
- label: string;
1023
- };
1024
- };
1025
-
1026
- export type AddTicketLabelAction = {
1027
- id: string;
1028
- type: 'add_ticket_label';
1029
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1030
- metadata: {
1031
- label: string;
1032
- };
1033
- };
1034
-
1035
- export type SetTicketDueDateAction = {
1036
- id: string;
1037
- type: 'set_ticket_due_date';
1038
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1039
- metadata: {
1040
- due_date_option_time: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1041
- };
1042
- };
1043
-
1044
- export type AssignChatAction = {
1045
- id: string;
1046
- type: 'assign_chat';
1047
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1048
- metadata: {
1049
- assignee: string;
1050
- round_robin: 'true' | 'false';
1051
- rr_check_for?: 'shift_time' | 'user_status' | 'shift_time user_status';
1052
- };
1053
- };
1054
-
1055
- export type ForwardMessageAction = {
1056
- id: string;
1057
- type: 'forward_message';
1058
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1059
- metadata: {
1060
- chat_id: string;
1061
- prefix: string;
1062
- };
1063
- };
1064
-
1065
- export type SendEmailAction = {
1066
- id: string;
1067
- type: 'send_email';
1068
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1069
- metadata: {
1070
- email: string;
1071
- subject: string;
1072
- body: string;
1073
- };
1074
- };
1075
-
1076
- export type ReplyToMessageAction = {
1077
- id: string;
1078
- type: 'reply_to_message';
1079
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1080
- metadata: {
1081
- message: string;
1082
- media?: {
1083
- url: string;
1084
- type: 'image' | 'video' | 'audio' | 'document';
1085
- name: string;
1086
- };
1087
- maintain_flag_status: 'true' | 'false';
1088
- debounce_messages: 'true' | 'false';
1089
- debounce_message_time:
1090
- | `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`
1091
- | null
1092
- | undefined;
1093
- };
1094
- };
1095
-
1096
- export type UpdateCustomPropertyAction = {
1097
- id: string;
1098
- type: 'update_custom_property';
1099
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1100
- metadata: {
1101
- property_id: string;
1102
- value: string;
1103
- };
1104
- };
1105
-
1106
- export type DeleteMessageAction = {
1107
- id: string;
1108
- type: 'delete_message';
1109
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1110
- metadata: {};
1111
- };
1112
-
1113
- export type SendSlackNotificationAction = {
1114
- id: string;
1115
- type: 'send_slack_notification';
1116
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1117
- metadata: {
1118
- slack_payload: string;
1119
- webhook_url: string;
1120
- };
1121
- };
1122
-
1123
- export type AttachMessageToTicketAction = {
1124
- id: string;
1125
- type: 'attach_message_to_ticket';
1126
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1127
- metadata: {
1128
- status: 'open' | 'inprogress' | 'open_inprogress' | null;
1129
- };
1130
- };
1131
-
1132
- export type CloseChatAction = {
1133
- id: string;
1134
- type: 'close_chat';
1135
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1136
- metadata: {};
1137
- };
1138
-
1139
- export type SendMessageToChatAction = {
1140
- id: string;
1141
- type: 'send_message_to_chat';
1142
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1143
- metadata: {
1144
- chat_id: string;
1145
- message: string;
1146
- media?: {
1147
- url: string;
1148
- type: 'image' | 'video' | 'audio' | 'document';
1149
- name: string;
1150
- };
1151
- };
1152
- };
1153
-
1154
- export type FreshdeskCreateTicketAction = {
1155
- id: string;
1156
- type: 'create_ticket_on_freshdesk';
1157
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1158
- metadata: {};
1159
- };
1160
-
1161
- export type HubspotCreateTicketAction = {
1162
- id: string;
1163
- type: 'create_ticket_on_hubspot';
1164
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1165
- metadata: {};
1166
- };
1167
-
1168
- export type ZohodeskCreateTicketAction = {
1169
- id: string;
1170
- type: 'create_ticket_on_zohodesk';
1171
- delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1172
- metadata: {};
1173
- };
1174
-
1175
- export type Action =
1176
- | SendMessageAction
1177
- | NotifyHttpAction
1178
- | CreateTicketAction
1179
- | FlagMessageAction
1180
- | AssignTicketAction
1181
- | CloseTicketAction
1182
- | AddChatLabelAction
1183
- | AddTicketLabelAction
1184
- | SetTicketDueDateAction
1185
- | AssignChatAction
1186
- | ForwardMessageAction
1187
- | SendEmailAction
1188
- | ReplyToMessageAction
1189
- | UpdateCustomPropertyAction
1190
- | DeleteMessageAction
1191
- | SendSlackNotificationAction
1192
- | AttachMessageToTicketAction
1193
- | CloseChatAction
1194
- | SendMessageToChatAction
1195
- | FreshdeskCreateTicketAction
1196
- | HubspotCreateTicketAction
1197
- | ZohodeskCreateTicketAction;
1198
-
1199
- export const isSendMessageOrReplyToMessageAction = (
1200
- action: Action
1201
- ): action is SendMessageAction | ReplyToMessageAction => {
1202
- return ['send_message', 'reply_to_message'].includes(action.type);
1203
- };
1204
-
1205
- export type Rule = OverrideProperties<
1206
- Tables<'tbl_automation_rules'>,
1207
- {
1208
- actions: Action[];
1209
- conditions: Conditions;
1210
- trigger:
1211
- | 'message.created'
1212
- | 'message.updated'
1213
- | 'chat.created'
1214
- | 'ticket.updated'
1215
- | 'ticket.created'
1216
- | 'reaction.added'
1217
- | 'chat.label.updated'
1218
- | 'message.flagged'
1219
- | 'message.unflagged'
1220
- | 'message.deleted'
1221
- | 'ticket.closed'
1222
- | 'ticket.label.updated'
1223
- | 'task.created'
1224
- | 'task.assignee.updated';
1225
- }
1226
- >;
1227
-
1228
- export const RuleNameMap: Record<
1229
- Rule['trigger'],
1230
- {
1231
- title: string;
1232
- description: string;
1233
- base_conditions: {
1234
- org_phone: boolean;
1235
- };
1236
- }
1237
- > = {
1238
- 'message.created': {
1239
- title: 'New Message Received',
1240
- description: 'When a new message is received from an external contact',
1241
- base_conditions: {
1242
- org_phone: true,
1243
- },
1244
- },
1245
- 'chat.created': {
1246
- title: 'New Chat Created',
1247
- description: 'When a new chat is created',
1248
- base_conditions: {
1249
- org_phone: true,
1250
- },
1251
- },
1252
- 'ticket.created': {
1253
- title: 'New Ticket Created',
1254
- description: 'When a new ticket is created',
1255
- base_conditions: {
1256
- org_phone: false,
1257
- },
1258
- },
1259
- 'reaction.added': {
1260
- title: 'New Reaction Added',
1261
- description: 'When a reaction is added on a message',
1262
- base_conditions: {
1263
- org_phone: true,
1264
- },
1265
- },
1266
- 'message.updated': {
1267
- title: 'Message Updated',
1268
- description: 'When a message is updated',
1269
- base_conditions: {
1270
- org_phone: true,
1271
- },
1272
- },
1273
- 'ticket.updated': {
1274
- title: 'Ticket Updated',
1275
- description: 'When a ticket is updated',
1276
- base_conditions: {
1277
- org_phone: false,
1278
- },
1279
- },
1280
- 'ticket.label.updated': {
1281
- title: 'Ticket Label Added/Removed',
1282
- description: 'When labels on tickets are updated',
1283
- base_conditions: {
1284
- org_phone: false,
1285
- },
1286
- },
1287
- 'chat.label.updated': {
1288
- title: 'Chat Label Added/Removed',
1289
- description: 'When labels on chats are updated',
1290
- base_conditions: {
1291
- org_phone: false,
1292
- },
1293
- },
1294
- 'message.flagged': {
1295
- title: 'Message Flagged',
1296
- description: 'When a message is flagged',
1297
- base_conditions: {
1298
- org_phone: true,
1299
- },
1300
- },
1301
- 'message.unflagged': {
1302
- title: 'Message Unflagged',
1303
- description: 'When a message is unflagged',
1304
- base_conditions: {
1305
- org_phone: true,
1306
- },
1307
- },
1308
- 'message.deleted': {
1309
- title: 'Message Deleted',
1310
- description: 'When a message is Deleted',
1311
- base_conditions: {
1312
- org_phone: true,
1313
- },
1314
- },
1315
- 'ticket.closed': {
1316
- title: 'Ticket Closed',
1317
- description: 'When a Ticket is Closed',
1318
- base_conditions: {
1319
- org_phone: false,
1320
- },
1321
- },
1322
- 'task.created': {
1323
- title: 'New Task Created',
1324
- description: 'When a Task is Created',
1325
- base_conditions: {
1326
- org_phone: false,
1327
- },
1328
- },
1329
- 'task.assignee.updated': {
1330
- title: 'Task Assigned',
1331
- description: 'When a Task is Assigned',
1332
- base_conditions: {
1333
- org_phone: false,
1334
- },
1335
- },
1336
- };
1337
-
1338
- export type ValidateFunction<T extends any[] = any[]> = (...args: T) => boolean;
1339
-
1340
- type ValidateArgsMap = {
1341
- create_ticket_on_freshdesk: [OrgType, Rule];
1342
- create_ticket_on_hubspot: [OrgType, Rule];
1343
- create_ticket_on_zohodesk: [OrgType, Rule];
1344
- };
1345
-
1346
- type ActionNameMapType = {
1347
- [K in Action['type']]: {
1348
- title: string;
1349
- description: string;
1350
- inputs: Record<
1351
- string,
1352
- {
1353
- id: string;
1354
- type:
1355
- | 'text'
1356
- | 'dropdown'
1357
- | 'editor'
1358
- | 'date'
1359
- | 'file'
1360
- | 'textarea'
1361
- | 'dynamic'
1362
- | 'json_editor';
1363
- value:
1364
- | 'ticket.labels'
1365
- | 'org.members'
1366
- | 'chat.labels'
1367
- | 'org.chats'
1368
- | {
1369
- id: string;
1370
- value: string;
1371
- label: string;
1372
- }[]
1373
- | null
1374
- | 'org.custom_properties'
1375
- | 'custom_property_values'
1376
- | 'custom_duration';
1377
- label: string;
1378
- placeholder: string;
1379
- info?: string;
1380
- required: boolean;
1381
- description?: string;
1382
- }
1383
- >;
1384
- validate: K extends keyof ValidateArgsMap
1385
- ? ValidateFunction<ValidateArgsMap[K]>
1386
- : ValidateFunction<never[]>;
1387
- info?: string;
1388
- validTriggers: Rule['trigger'][];
1389
- };
1390
- };
1391
-
1392
- export const ActionNameMap: ActionNameMapType = {
1393
- send_message: {
1394
- title: 'Send Message',
1395
- description: 'Send a message',
1396
- inputs: {
1397
- message: {
1398
- id: 'message',
1399
- type: 'editor',
1400
- label: 'Message',
1401
- placeholder: 'Enter message',
1402
- value: null,
1403
- required: true,
1404
- },
1405
- media: {
1406
- id: 'media',
1407
- type: 'file',
1408
- label: 'Media',
1409
- placeholder: 'Upload media',
1410
- value: null,
1411
- required: false,
1412
- },
1413
- maintain_flag_status: {
1414
- id: 'maintain_flag_status',
1415
- type: 'dropdown',
1416
- label: 'Maintain Flag Status',
1417
- placeholder: 'Select...',
1418
- value: [
1419
- { id: 'true', value: 'true', label: 'True' },
1420
- { id: 'false', value: 'false', label: 'False' },
1421
- ],
1422
- required: true,
1423
- },
1424
- debounce_messages: {
1425
- id: 'debounce_messages',
1426
- type: 'dropdown',
1427
- label: 'Enable Cooldown Period',
1428
- placeholder: 'Select...',
1429
- value: [
1430
- { id: 'true', value: 'true', label: 'True' },
1431
- { id: 'false', value: 'false', label: 'False' },
1432
- ],
1433
- info: 'If enabled, only one message per chat will be sent in the specified cooldown period',
1434
- required: false,
1435
- },
1436
- debounce_message_time: {
1437
- id: 'debounce_message_time',
1438
- type: 'dynamic',
1439
- label: 'Cooldown Period',
1440
- placeholder: 'Enter time',
1441
- value: 'custom_duration',
1442
- required: false,
1443
- },
1444
- },
1445
- validTriggers: [
1446
- 'message.created',
1447
- 'message.updated',
1448
- 'chat.created',
1449
- 'ticket.updated',
1450
- 'ticket.created',
1451
- 'reaction.added',
1452
- 'message.flagged',
1453
- 'message.unflagged',
1454
- 'chat.label.updated',
1455
- 'message.deleted',
1456
- 'ticket.closed',
1457
- 'task.created',
1458
- 'task.assignee.updated',
1459
- 'ticket.label.updated'
1460
- ],
1461
- validate: () => true,
1462
- },
1463
- reply_to_message: {
1464
- title: 'Reply to message',
1465
- description: 'Send a message with the quoted message',
1466
- inputs: {
1467
- message: {
1468
- id: 'message',
1469
- type: 'editor',
1470
- label: 'Message',
1471
- placeholder: 'Enter message',
1472
- value: null,
1473
- required: true,
1474
- },
1475
- media: {
1476
- id: 'media',
1477
- type: 'file',
1478
- label: 'Media',
1479
- placeholder: 'Upload media',
1480
- value: null,
1481
- required: false,
1482
- },
1483
- maintain_flag_status: {
1484
- id: 'maintain_flag_status',
1485
- type: 'dropdown',
1486
- label: 'Maintain Flag Status',
1487
- placeholder: 'Select...',
1488
- value: [
1489
- { id: 'true', value: 'true', label: 'True' },
1490
- { id: 'false', value: 'false', label: 'False' },
1491
- ],
1492
- required: true,
1493
- },
1494
- debounce_messages: {
1495
- id: 'debounce_messages',
1496
- type: 'dropdown',
1497
- label: 'Enable Cooldown Period',
1498
- placeholder: 'Select...',
1499
- value: [
1500
- { id: 'true', value: 'true', label: 'True' },
1501
- { id: 'false', value: 'false', label: 'False' },
1502
- ],
1503
- info: 'If enabled, only one message per chat will be sent in the specified cooldown period',
1504
- required: false,
1505
- },
1506
- debounce_message_time: {
1507
- id: 'debounce_message_time',
1508
- type: 'dynamic',
1509
- label: 'Cooldown Period',
1510
- placeholder: 'Enter time',
1511
- value: 'custom_duration',
1512
- required: false,
1513
- },
1514
- },
1515
- validTriggers: [
1516
- 'message.created',
1517
- 'message.updated',
1518
- 'reaction.added',
1519
- 'message.flagged',
1520
- 'ticket.created',
1521
- 'ticket.updated',
1522
- 'ticket.closed',
1523
- 'message.unflagged',
1524
- 'task.created',
1525
- 'task.assignee.updated',
1526
- 'ticket.label.updated'
1527
- ],
1528
- validate: () => true,
1529
- },
1530
- delete_message: {
1531
- title: 'Delete Message',
1532
- description: 'Delete a message',
1533
- inputs: {},
1534
- validTriggers: [
1535
- 'message.created',
1536
- 'message.updated',
1537
- 'reaction.added',
1538
- 'message.flagged',
1539
- 'ticket.created',
1540
- 'ticket.updated',
1541
- 'ticket.closed',
1542
- 'message.unflagged',
1543
- 'ticket.label.updated'
1544
- ],
1545
- validate: () => true,
1546
- },
1547
- attach_message_to_ticket: {
1548
- title: 'Attach Message To Latest Ticket',
1549
- description: 'Attach message to latest ticket based on statuses',
1550
- inputs: {
1551
- status: {
1552
- id: 'status',
1553
- type: 'dropdown',
1554
- value: [
1555
- {
1556
- id: 'open_inprogress',
1557
- value: 'open_inprogress',
1558
- label: 'Open/In Progress',
1559
- },
1560
- { id: 'open', value: 'open', label: 'Open' },
1561
- { id: 'inprogress', value: 'inprogress', label: 'In Progress' },
1562
- ],
1563
- label: 'Ticket Status',
1564
- placeholder: 'Select...',
1565
- required: true,
1566
- info: 'Select the ticket status of ticket to attach the message to (only applicable for open or inprogress tickets)',
1567
- },
1568
- },
1569
- validTriggers: [
1570
- 'message.created',
1571
- 'message.updated',
1572
- 'reaction.added',
1573
- 'message.flagged',
1574
- ],
1575
- validate: () => true,
1576
- },
1577
- notify_http: {
1578
- title: 'Notify HTTP',
1579
- description: 'Notify an HTTP endpoint',
1580
- inputs: {
1581
- url: {
1582
- id: 'url',
1583
- type: 'text',
1584
- label: 'URL',
1585
- placeholder: 'Enter URL',
1586
- value: null,
1587
- required: true,
1588
- description:
1589
- 'Enter the Webhook URL here. The endpoint added here should be a **POST HTTP / Endpoint** with no open auth.',
1590
- },
1591
- },
1592
- validTriggers: [
1593
- 'message.created',
1594
- 'message.updated',
1595
- 'chat.created',
1596
- 'ticket.updated',
1597
- 'ticket.created',
1598
- 'reaction.added',
1599
- 'message.flagged',
1600
- 'chat.label.updated',
1601
- 'message.deleted',
1602
- 'ticket.closed',
1603
- 'message.unflagged',
1604
- 'task.created',
1605
- 'task.assignee.updated',
1606
- 'ticket.label.updated'
1607
- ],
1608
- validate: () => true,
1609
- },
1610
- create_ticket: {
1611
- title: 'Create Ticket or Attach Message To Latest Ticket',
1612
- description: 'Create a ticket or attach message to latest ticket',
1613
- inputs: {
1614
- append_to_latest_ticket: {
1615
- id: 'append_to_latest_ticket',
1616
- type: 'dropdown',
1617
- value: [
1618
- { id: 'true', value: 'true', label: 'True' },
1619
- { id: 'false', value: 'false', label: 'False' },
1620
- ],
1621
- label: 'Attach message to latest ticket (if available)',
1622
- placeholder: 'Select...',
1623
- info: 'If enabled, the message will be appended to the latest open ticket (if available) else a new ticket will be created',
1624
- required: false,
1625
- },
1626
- priority: {
1627
- id: 'priority',
1628
- type: 'dropdown',
1629
- value: [
1630
- { id: '0', value: '0', label: 'No Priority' },
1631
- { id: '1', value: '1', label: 'Low' },
1632
- { id: '2', value: '2', label: 'Medium' },
1633
- { id: '3', value: '3', label: 'High' },
1634
- { id: '4', value: '4', label: 'Urgent' },
1635
- ],
1636
- label: 'Priority (New Ticket)',
1637
- placeholder: 'Select priority',
1638
- info: 'Only applicable for create ticket. If no priority is selected, the ticket will have no priority.',
1639
- required: false,
1640
- },
1641
- label: {
1642
- id: 'label',
1643
- type: 'dropdown',
1644
- value: 'ticket.labels',
1645
- label: 'Label (New Ticket)',
1646
- placeholder: 'Select label',
1647
- info: 'Only applicable for create ticket. If no label is selected, the ticket will have no label.',
1648
- required: false,
1649
- },
1650
- round_robin: {
1651
- id: 'round_robin',
1652
- type: 'dropdown',
1653
- value: [
1654
- { id: 'true', value: 'true', label: 'True' },
1655
- { id: 'false', value: 'false', label: 'False' },
1656
- ],
1657
- label: 'Enable Round Robin (New Ticket: Assignee)',
1658
- placeholder: 'Select...',
1659
- info: 'If enabled, the ticket will be assigned to the next available agent in the list',
1660
- required: false,
1661
- },
1662
- rr_check_for: {
1663
- id: 'rr_check_for',
1664
- type: 'dropdown',
1665
- value: [
1666
- {
1667
- id: 'shift_time',
1668
- value: 'shift_time',
1669
- label: 'Consider shift timings',
1670
- },
1671
- {
1672
- id: 'user_status',
1673
- value: 'user_status',
1674
- label: 'Exclude users manually marked as offline',
1675
- },
1676
- {
1677
- id: 'user_status_offline',
1678
- value: 'user_status_offline',
1679
- label: 'Exclude users marked as offline or away',
1680
- },
1681
- {
1682
- id: 'shift_time user_status',
1683
- value: 'shift_time user_status',
1684
- label:
1685
- 'Consider both shift timings and user status (excludes only manually marked offline users)',
1686
- },
1687
- ],
1688
- label: 'Check Assignee status for (Round Robin)',
1689
- placeholder: 'Select...',
1690
- info: 'Criteria for assigning the next available agent',
1691
- required: false,
1692
- },
1693
- assignee: {
1694
- id: 'assignee',
1695
- type: 'dynamic',
1696
- value: 'org.members',
1697
- label: 'Assignee (New Ticket)',
1698
- placeholder: 'Select assignee',
1699
- 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",
1700
- required: false,
1701
- },
1702
- },
1703
- validTriggers: [
1704
- 'message.created',
1705
- 'message.updated',
1706
- 'reaction.added',
1707
- 'message.flagged',
1708
- 'message.unflagged',
1709
- 'task.created',
1710
- 'task.assignee.updated',
1711
- ],
1712
- validate: () => true,
1713
- },
1714
- flag_message: {
1715
- title: 'Update flag status',
1716
- description: 'Flag/Unflag a message',
1717
- inputs: {
1718
- flag: {
1719
- id: 'flag',
1720
- type: 'dropdown',
1721
- value: [
1722
- { id: 'flag', value: 'true', label: 'True' },
1723
- { id: 'unflag', value: 'false', label: 'False' },
1724
- ],
1725
- label: 'Flag status',
1726
- placeholder: 'Select flag',
1727
- required: true,
1728
- },
1729
- },
1730
- validTriggers: [
1731
- 'message.created',
1732
- 'message.updated',
1733
- 'reaction.added',
1734
- 'message.flagged',
1735
- 'message.unflagged',
1736
- 'ticket.created',
1737
- 'ticket.updated',
1738
- 'ticket.closed',
1739
- 'task.created',
1740
- 'task.assignee.updated',
1741
- 'ticket.label.updated'
1742
- ],
1743
- validate: () => true,
1744
- },
1745
- assign_ticket: {
1746
- title: 'Assign Ticket',
1747
- description: 'Assign a ticket',
1748
- inputs: {
1749
- round_robin: {
1750
- id: 'round_robin',
1751
- type: 'dropdown',
1752
- value: [
1753
- { id: 'true', value: 'true', label: 'True' },
1754
- { id: 'false', value: 'false', label: 'False' },
1755
- ],
1756
- label: 'Enable Round Robin',
1757
- placeholder: 'Select...',
1758
- info: 'If enabled, the ticket will be assigned to the next available agent in the list',
1759
- required: false,
1760
- },
1761
- rr_check_for: {
1762
- id: 'rr_check_for',
1763
- type: 'dropdown',
1764
- value: [
1765
- {
1766
- id: 'shift_time',
1767
- value: 'shift_time',
1768
- label: 'Consider shift timings',
1769
- },
1770
- {
1771
- id: 'user_status',
1772
- value: 'user_status',
1773
- label: 'Exclude users manually marked as offline',
1774
- },
1775
- {
1776
- id: 'user_status_offline',
1777
- value: 'user_status_offline',
1778
- label: 'Exclude users marked as offline or away',
1779
- },
1780
- {
1781
- id: 'shift_time user_status',
1782
- value: 'shift_time user_status',
1783
- label:
1784
- 'Consider both shift timings and user status (excludes only manually marked offline users)',
1785
- },
1786
- ],
1787
- label: 'Check Assignee status for (Round Robin)',
1788
- placeholder: 'Select...',
1789
- info: 'Criteria for assigning the next available agent',
1790
- required: false,
1791
- },
1792
- assignee: {
1793
- id: 'assignee',
1794
- type: 'dynamic',
1795
- value: 'org.members',
1796
- label: 'Assignee',
1797
- placeholder: 'Select assignee',
1798
- 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",
1799
- required: true,
1800
- },
1801
- },
1802
- validTriggers: [
1803
- 'ticket.updated',
1804
- 'ticket.created',
1805
- 'task.created',
1806
- 'task.assignee.updated',
1807
- 'ticket.label.updated'
1808
- ],
1809
- validate: () => true,
1810
- },
1811
- close_ticket: {
1812
- title: 'Close Ticket',
1813
- description: 'Close a ticket',
1814
- info: "This action will close the ticket. This doesn't check for mandatory ticket custom properties.",
1815
- inputs: {
1816
- closing_note: {
1817
- id: 'closing_note',
1818
- type: 'textarea',
1819
- label: 'Closing Note',
1820
- placeholder: 'Enter closing note',
1821
- value: null,
1822
- required: false,
1823
- },
1824
- },
1825
- validTriggers: [
1826
- 'ticket.updated',
1827
- 'ticket.created',
1828
- 'reaction.added',
1829
- 'message.unflagged',
1830
- 'message.deleted',
1831
- 'ticket.label.updated',
1832
- ],
1833
- validate: () => true,
1834
- },
1835
- add_chat_label: {
1836
- title: 'Add Chat Label',
1837
- description: 'Add a label to referred chat',
1838
- inputs: {
1839
- label: {
1840
- id: 'label',
1841
- type: 'dropdown',
1842
- value: 'chat.labels',
1843
- label: 'Label',
1844
- placeholder: 'Select label',
1845
- required: true,
1846
- },
1847
- },
1848
- validTriggers: [
1849
- 'message.created',
1850
- 'message.updated',
1851
- 'chat.created',
1852
- 'ticket.updated',
1853
- 'ticket.created',
1854
- 'reaction.added',
1855
- 'chat.label.updated',
1856
- 'message.flagged',
1857
- 'message.deleted',
1858
- 'message.unflagged',
1859
- 'ticket.closed',
1860
- ],
1861
- validate: () => true,
1862
- },
1863
- add_ticket_label: {
1864
- title: 'Add Ticket Label',
1865
- description: 'Add a label to referred ticket',
1866
- inputs: {
1867
- label: {
1868
- id: 'label',
1869
- type: 'dropdown',
1870
- value: 'ticket.labels',
1871
- label: 'Label',
1872
- placeholder: 'Select label',
1873
- required: true,
1874
- },
1875
- },
1876
- validTriggers: ['ticket.updated', 'ticket.created', 'ticket.label.updated'],
1877
- validate: () => true,
1878
- },
1879
- set_ticket_due_date: {
1880
- title: 'Set Ticket Due Date',
1881
- description: 'Set a due date for the ticket',
1882
- info: 'This action will set a due date for the ticket. The due date will be set after the specified time from the current date and time of rule execution.',
1883
- inputs: {
1884
- due_date_option_time: {
1885
- id: 'due_date_option_time',
1886
- type: 'dynamic',
1887
- label: 'Due After',
1888
- placeholder: 'Enter time',
1889
- value: 'custom_duration',
1890
- required: true,
1891
- },
1892
- },
1893
- validTriggers: [
1894
- 'ticket.created',
1895
- 'reaction.added',
1896
- 'ticket.label.updated',
1897
- 'ticket.closed',
1898
- ],
1899
- validate: () => true,
1900
- },
1901
- update_custom_property: {
1902
- description: 'Update a chat custom property',
1903
- title: 'Update Chat Custom Property',
1904
- validTriggers: [
1905
- 'message.created',
1906
- 'message.updated',
1907
- 'chat.created',
1908
- 'ticket.updated',
1909
- 'ticket.created',
1910
- 'reaction.added',
1911
- 'message.flagged',
1912
- 'chat.label.updated',
1913
- 'message.deleted',
1914
- 'message.unflagged',
1915
- 'ticket.closed',
1916
- 'ticket.label.updated'
1917
- ],
1918
- inputs: {
1919
- property_id: {
1920
- id: 'property_id',
1921
- type: 'dropdown',
1922
- value: 'org.custom_properties',
1923
- label: 'Property',
1924
- placeholder: 'Select property',
1925
- required: true,
1926
- },
1927
- value: {
1928
- id: 'property_id',
1929
- type: 'dynamic',
1930
- label: 'Value',
1931
- placeholder: 'Enter value',
1932
- value: 'custom_property_values',
1933
- required: true,
1934
- },
1935
- },
1936
- validate: () => true,
1937
- },
1938
- assign_chat: {
1939
- title: 'Assign Chat',
1940
- description: 'Assign a chat',
1941
- inputs: {
1942
- round_robin: {
1943
- id: 'round_robin',
1944
- type: 'dropdown',
1945
- value: [
1946
- { id: 'true', value: 'true', label: 'True' },
1947
- { id: 'false', value: 'false', label: 'False' },
1948
- ],
1949
- label: 'Enable Round Robin',
1950
- placeholder: 'Select...',
1951
- info: 'If enabled, the chat will be assigned to the next available agent in the list',
1952
- required: false,
1953
- },
1954
- rr_check_for: {
1955
- id: 'rr_check_for',
1956
- type: 'dropdown',
1957
- value: [
1958
- {
1959
- id: 'shift_time',
1960
- value: 'shift_time',
1961
- label: 'Consider shift timings',
1962
- },
1963
- {
1964
- id: 'user_status',
1965
- value: 'user_status',
1966
- label: 'Exclude users manually marked as offline',
1967
- },
1968
- {
1969
- id: 'user_status_offline',
1970
- value: 'user_status_offline',
1971
- label: 'Exclude users marked as offline or away',
1972
- },
1973
- {
1974
- id: 'shift_time user_status',
1975
- value: 'shift_time user_status',
1976
- label:
1977
- 'Consider both shift timings and user status (excludes only manually marked offline users)',
1978
- },
1979
- ],
1980
- label: 'Check Assignee status for (Round Robin)',
1981
- placeholder: 'Select...',
1982
- info: 'Criteria for assigning the next available agent',
1983
- required: false,
1984
- },
1985
- assignee: {
1986
- id: 'assignee',
1987
- type: 'dynamic',
1988
- value: 'org.members',
1989
- label: 'Assignee',
1990
- placeholder: 'Select assignee',
1991
- required: true,
1992
- },
1993
- },
1994
- validTriggers: [
1995
- 'message.created',
1996
- 'message.updated',
1997
- 'chat.created',
1998
- 'ticket.updated',
1999
- 'ticket.created',
2000
- 'reaction.added',
2001
- 'chat.label.updated',
2002
- 'message.flagged',
2003
- 'message.deleted',
2004
- 'message.unflagged',
2005
- 'ticket.closed',
2006
- 'task.created',
2007
- 'task.assignee.updated',
2008
- 'ticket.label.updated'
2009
- ],
2010
- validate: () => true,
2011
- },
2012
- close_chat: {
2013
- title: 'Close Chat',
2014
- description: 'Close a chat conversation',
2015
- inputs: {},
2016
- validTriggers: [
2017
- 'message.created',
2018
- 'message.updated',
2019
- 'chat.created',
2020
- 'ticket.updated',
2021
- 'ticket.created',
2022
- 'reaction.added',
2023
- 'chat.label.updated',
2024
- 'message.flagged',
2025
- 'message.unflagged',
2026
- 'message.deleted',
2027
- 'ticket.closed',
2028
- 'ticket.label.updated'
2029
- ],
2030
- validate: () => true,
2031
- },
2032
- forward_message: {
2033
- title: 'Forward Message',
2034
- description: 'Forward a message',
2035
- inputs: {
2036
- chat_id: {
2037
- id: 'chat_id',
2038
- type: 'dropdown',
2039
- value: 'org.chats',
2040
- label: 'Chat',
2041
- placeholder: 'Select chat',
2042
- required: true,
2043
- },
2044
- },
2045
- info: 'Forward a message to a specified chat. Only applicable if message is present.',
2046
- validTriggers: [
2047
- 'message.created',
2048
- 'message.updated',
2049
- 'ticket.updated',
2050
- 'ticket.created',
2051
- 'reaction.added',
2052
- 'message.unflagged',
2053
- 'message.flagged',
2054
- 'ticket.closed',
2055
- 'ticket.label.updated',
2056
- 'task.created',
2057
- 'task.assignee.updated',
2058
- ],
2059
- validate: () => true,
2060
- },
2061
- send_email: {
2062
- title: 'Send Email',
2063
- description: 'Send an email',
2064
- inputs: {
2065
- email: {
2066
- id: 'email',
2067
- type: 'text',
2068
- label: 'Email',
2069
- placeholder: 'Enter email',
2070
- value: null,
2071
- required: true,
2072
- },
2073
- subject: {
2074
- id: 'subject',
2075
- type: 'editor',
2076
- label: 'Subject',
2077
- placeholder: 'Enter subject',
2078
- value: null,
2079
- required: true,
2080
- },
2081
- body: {
2082
- id: 'body',
2083
- type: 'editor',
2084
- label: 'Body',
2085
- placeholder: 'Enter body',
2086
- value: null,
2087
- required: true,
2088
- },
2089
- },
2090
- validTriggers: [
2091
- 'message.created',
2092
- 'message.updated',
2093
- 'chat.created',
2094
- 'ticket.updated',
2095
- 'ticket.created',
2096
- 'reaction.added',
2097
- 'message.flagged',
2098
- 'message.unflagged',
2099
- 'chat.label.updated',
2100
- 'message.deleted',
2101
- 'ticket.closed',
2102
- 'task.created',
2103
- 'task.assignee.updated',
2104
- 'ticket.label.updated',
2105
- ],
2106
- validate: () => true,
2107
- },
2108
- send_slack_notification: {
2109
- title: 'Send Slack Webhook Notification',
2110
- description: 'Send a slack webhook notification to a channel',
2111
- validTriggers: [
2112
- 'message.created',
2113
- 'message.updated',
2114
- 'chat.created',
2115
- 'ticket.updated',
2116
- 'ticket.created',
2117
- 'reaction.added',
2118
- 'message.flagged',
2119
- 'message.unflagged',
2120
- 'chat.label.updated',
2121
- 'message.deleted',
2122
- 'ticket.closed',
2123
- 'ticket.label.updated',
2124
- 'task.created',
2125
- 'task.assignee.updated',
2126
- ],
2127
- inputs: {
2128
- webhook_url: {
2129
- type: 'text',
2130
- id: 'webhook_url',
2131
- label: 'Webhook URL',
2132
- placeholder: 'Enter webhook URL',
2133
- value: null,
2134
- required: true,
2135
- description:
2136
- '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)',
2137
- },
2138
- slack_payload: {
2139
- type: 'json_editor',
2140
- id: 'slack_payload',
2141
- label: 'Slack Notification Payload',
2142
- placeholder: 'Enter payload',
2143
- value: null,
2144
- required: true,
2145
- description:
2146
- '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)',
2147
- },
2148
- },
2149
- validate: () => true,
2150
- },
2151
- send_message_to_chat: {
2152
- title: 'Send Message To Chat',
2153
- description: 'Send a message to a specified chat',
2154
- inputs: {
2155
- chat_id: {
2156
- id: 'chat_id',
2157
- type: 'dropdown',
2158
- value: 'org.chats',
2159
- label: 'Chat',
2160
- placeholder: 'Select chat',
2161
- required: true,
2162
- },
2163
- message: {
2164
- id: 'message',
2165
- type: 'editor',
2166
- label: 'Message',
2167
- placeholder: 'Enter message',
2168
- value: null,
2169
- required: true,
2170
- },
2171
- media: {
2172
- id: 'media',
2173
- type: 'file',
2174
- label: 'Media',
2175
- placeholder: 'Upload media',
2176
- value: null,
2177
- required: false,
2178
- },
2179
- },
2180
- validTriggers: [
2181
- 'message.created',
2182
- 'message.updated',
2183
- 'chat.created',
2184
- 'ticket.updated',
2185
- 'ticket.created',
2186
- 'reaction.added',
2187
- 'message.flagged',
2188
- 'message.unflagged',
2189
- 'chat.label.updated',
2190
- 'message.deleted',
2191
- 'ticket.closed',
2192
- 'ticket.label.updated',
2193
- 'task.created',
2194
- 'task.assignee.updated',
2195
- ],
2196
- validate: () => true,
2197
- },
2198
- create_ticket_on_freshdesk: {
2199
- title: 'Create Ticket On Freshdesk',
2200
- description: 'Create a ticket on Freshdesk',
2201
- info: 'This action will create a ticket on Freshdesk. Please make sure you have a Freshdesk integration setup.',
2202
- inputs: {},
2203
- validTriggers: ['ticket.created'],
2204
- validate: (org, rule) => {
2205
- return (
2206
- org.is_freshdesk_connected ||
2207
- rule.actions.some((a) => a.type === 'create_ticket_on_freshdesk')
2208
- );
2209
- },
2210
- },
2211
- create_ticket_on_hubspot: {
2212
- title: 'Create Ticket On Hubspot',
2213
- description: 'Create a ticket on Hubspot',
2214
- info: 'This action will create a ticket on Hubspot. Please make sure you have a Hubspot integration setup.',
2215
- inputs: {},
2216
- validTriggers: ['ticket.created'],
2217
- validate: (org, rule) => {
2218
- return (
2219
- org.is_hubspot_connected ||
2220
- rule.actions.some((a) => a.type === 'create_ticket_on_hubspot')
2221
- );
2222
- },
2223
- },
2224
- create_ticket_on_zohodesk: {
2225
- title: 'Create Ticket On Zohodesk',
2226
- description: 'Create a ticket on Zohodesk',
2227
- info: 'This action will create a ticket on Zohodesk. Please make sure you have a Zohodesk integration setup.',
2228
- inputs: {},
2229
- validTriggers: ['ticket.created'],
2230
- validate: (org, rule) => {
2231
- return (
2232
- org.is_zohodesk_connected ||
2233
- rule.actions.some((a) => a.type === 'create_ticket_on_zohodesk')
2234
- );
2235
- },
2236
- },
2237
- };
2238
-
2239
- type editorVariablesList =
2240
- | 'chat.assigned_to'
2241
- | 'chat.chat_id'
2242
- | 'chat.chat_name'
2243
- | 'chat.chat_type'
2244
- | 'chat.org_phone'
2245
- | 'chat.org_id'
2246
- | 'chat.group_description'
2247
- | 'ticket.assignee'
2248
- | 'ticket.due_date'
2249
- | 'ticket.priority'
2250
- | 'ticket.status'
2251
- | 'ticket.subject'
2252
- | 'ticket.ticket_id'
2253
- | 'ticket.raised_by'
2254
- | 'ticket.created_at'
2255
- | 'sender.is_internal'
2256
- | 'sender.is_admin'
2257
- | 'sender.contact_name'
2258
- | 'sender.contact_id'
2259
- | 'reaction.sender_id'
2260
- | 'reaction.reaction'
2261
- | 'message.message_id'
2262
- | 'message.timestamp'
2263
- | 'message.sender_phone'
2264
- | 'message.message_type'
2265
- | 'message.media'
2266
- | 'message.body'
2267
- | 'task.title'
2268
- | 'task.assignee'
2269
- | 'task.due_date'
2270
- | 'task.task_id'
2271
- | 'task.notes';
2272
-
2273
- export const editorVariables: Array<{
2274
- label: string;
2275
- value: editorVariablesList;
2276
- validTriggers: Rule['trigger'][];
2277
- }> = [
2278
- {
2279
- label: 'Ticket ID',
2280
- value: 'ticket.ticket_id',
2281
- validTriggers: ['ticket.updated', 'ticket.created', 'ticket.closed'],
2282
- },
2283
- {
2284
- value: 'ticket.assignee',
2285
- label: 'Ticket Assignee',
2286
- validTriggers: ['ticket.updated', 'ticket.created', 'ticket.closed'],
2287
- },
2288
- {
2289
- value: 'ticket.due_date',
2290
- label: 'Ticket Due Date',
2291
- validTriggers: ['ticket.updated', 'ticket.created', 'ticket.closed'],
2292
- },
2293
- {
2294
- value: 'ticket.priority',
2295
- label: 'Ticket Priority',
2296
- validTriggers: ['ticket.updated', 'ticket.created', 'ticket.closed'],
2297
- },
2298
- {
2299
- value: 'ticket.status',
2300
- label: 'Ticket Status',
2301
- validTriggers: ['ticket.updated', 'ticket.created', 'ticket.closed'],
2302
- },
2303
- {
2304
- value: 'ticket.subject',
2305
- label: 'Ticket Subject',
2306
- validTriggers: ['ticket.updated', 'ticket.created', 'ticket.closed'],
2307
- },
2308
- {
2309
- label: 'Message Body',
2310
- value: 'message.body',
2311
- validTriggers: [
2312
- 'message.created',
2313
- 'message.updated',
2314
- 'reaction.added',
2315
- 'message.flagged',
2316
- 'ticket.created',
2317
- 'ticket.updated',
2318
- 'ticket.closed',
2319
- 'message.deleted',
2320
- 'task.created',
2321
- 'task.assignee.updated',
2322
- ],
2323
- },
2324
- {
2325
- value: 'message.media',
2326
- label: 'Message Media',
2327
- validTriggers: [
2328
- 'message.created',
2329
- 'message.updated',
2330
- 'reaction.added',
2331
- 'message.flagged',
2332
- 'ticket.created',
2333
- 'ticket.updated',
2334
- 'ticket.closed',
2335
- 'message.deleted',
2336
- ],
2337
- },
2338
- {
2339
- value: 'message.message_id',
2340
- label: 'Message ID',
2341
- validTriggers: [
2342
- 'message.created',
2343
- 'message.updated',
2344
- 'reaction.added',
2345
- 'message.flagged',
2346
- 'ticket.created',
2347
- 'ticket.updated',
2348
- 'ticket.closed',
2349
- 'message.deleted',
2350
- ],
2351
- },
2352
- {
2353
- value: 'message.message_type',
2354
- label: 'Message Type',
2355
- validTriggers: [
2356
- 'message.created',
2357
- 'message.updated',
2358
- 'reaction.added',
2359
- 'message.flagged',
2360
- 'ticket.created',
2361
- 'ticket.updated',
2362
- 'ticket.closed',
2363
- 'message.deleted',
2364
- 'task.created',
2365
- 'task.assignee.updated',
2366
- ],
2367
- },
2368
- {
2369
- value: 'message.sender_phone',
2370
- label: 'Sender Phone',
2371
- validTriggers: [
2372
- 'message.created',
2373
- 'message.updated',
2374
- 'reaction.added',
2375
- 'message.flagged',
2376
- 'ticket.created',
2377
- 'ticket.updated',
2378
- 'ticket.closed',
2379
- 'message.deleted',
2380
- ],
2381
- },
2382
- {
2383
- value: 'message.timestamp',
2384
- label: 'Message Timestamp',
2385
- validTriggers: [
2386
- 'message.created',
2387
- 'message.updated',
2388
- 'reaction.added',
2389
- 'message.flagged',
2390
- 'ticket.created',
2391
- 'ticket.updated',
2392
- 'ticket.closed',
2393
- 'message.deleted',
2394
- 'task.created',
2395
- 'task.assignee.updated',
2396
- ],
2397
- },
2398
- {
2399
- value: 'sender.contact_name',
2400
- label: 'Sender Name',
2401
- validTriggers: [
2402
- 'message.created',
2403
- 'message.updated',
2404
- 'reaction.added',
2405
- 'message.flagged',
2406
- 'ticket.created',
2407
- 'ticket.updated',
2408
- 'ticket.closed',
2409
- 'message.deleted',
2410
- 'task.created',
2411
- 'task.assignee.updated',
2412
- ],
2413
- },
2414
- {
2415
- value: 'sender.is_admin',
2416
- label: 'Sender Is Admin',
2417
- validTriggers: [
2418
- 'message.created',
2419
- 'message.updated',
2420
- 'reaction.added',
2421
- 'message.flagged',
2422
- 'ticket.created',
2423
- 'ticket.updated',
2424
- 'ticket.closed',
2425
- 'message.deleted',
2426
- 'task.created',
2427
- 'task.assignee.updated',
2428
- ],
2429
- },
2430
- {
2431
- value: 'sender.is_internal',
2432
- label: 'Sender Is Internal',
2433
- validTriggers: [
2434
- 'message.created',
2435
- 'message.updated',
2436
- 'reaction.added',
2437
- 'message.flagged',
2438
- 'ticket.created',
2439
- 'ticket.updated',
2440
- 'ticket.closed',
2441
- 'message.deleted',
2442
- 'task.created',
2443
- 'task.assignee.updated',
2444
- ],
2445
- },
2446
- {
2447
- value: 'reaction.reaction',
2448
- label: 'Reaction',
2449
- validTriggers: ['reaction.added'],
2450
- },
2451
- {
2452
- value: 'reaction.sender_id',
2453
- label: 'Reaction Sender Phone',
2454
- validTriggers: ['reaction.added'],
2455
- },
2456
- {
2457
- label: 'Chat Name',
2458
- value: 'chat.chat_name',
2459
- validTriggers: [
2460
- 'message.created',
2461
- 'message.updated',
2462
- 'reaction.added',
2463
- 'message.flagged',
2464
- 'chat.created',
2465
- 'chat.label.updated',
2466
- 'ticket.created',
2467
- 'ticket.updated',
2468
- 'ticket.closed',
2469
- 'message.deleted',
2470
- 'task.created',
2471
- 'task.assignee.updated',
2472
- ],
2473
- },
2474
- {
2475
- value: 'chat.assigned_to',
2476
- label: 'Chat Assigned To',
2477
- validTriggers: [
2478
- 'message.created',
2479
- 'message.updated',
2480
- 'reaction.added',
2481
- 'message.flagged',
2482
- 'chat.created',
2483
- 'chat.label.updated',
2484
- 'ticket.created',
2485
- 'ticket.updated',
2486
- 'ticket.closed',
2487
- 'message.deleted',
2488
- 'task.created',
2489
- 'task.assignee.updated',
2490
- ],
2491
- },
2492
- {
2493
- value: 'chat.chat_id',
2494
- label: 'Chat ID',
2495
- validTriggers: [
2496
- 'message.created',
2497
- 'message.updated',
2498
- 'reaction.added',
2499
- 'message.flagged',
2500
- 'chat.created',
2501
- 'chat.label.updated',
2502
- 'ticket.created',
2503
- 'ticket.updated',
2504
- 'ticket.closed',
2505
- 'message.deleted',
2506
- 'task.created',
2507
- 'task.assignee.updated',
2508
- ],
2509
- },
2510
- {
2511
- value: 'chat.chat_type',
2512
- label: 'Chat Type',
2513
- validTriggers: [
2514
- 'message.created',
2515
- 'message.updated',
2516
- 'reaction.added',
2517
- 'message.flagged',
2518
- 'chat.created',
2519
- 'chat.label.updated',
2520
- 'ticket.created',
2521
- 'ticket.updated',
2522
- 'ticket.closed',
2523
- 'message.deleted',
2524
- 'task.created',
2525
- 'task.assignee.updated',
2526
- ],
2527
- },
2528
- {
2529
- value: 'chat.org_id',
2530
- label: 'Chat Org ID',
2531
- validTriggers: [
2532
- 'message.created',
2533
- 'message.updated',
2534
- 'reaction.added',
2535
- 'message.flagged',
2536
- 'chat.created',
2537
- 'chat.label.updated',
2538
- 'ticket.created',
2539
- 'ticket.updated',
2540
- 'ticket.closed',
2541
- 'message.deleted',
2542
- 'task.created',
2543
- 'task.assignee.updated',
2544
- ],
2545
- },
2546
- {
2547
- value: 'chat.org_phone',
2548
- label: 'Chat Org Phone',
2549
- validTriggers: [
2550
- 'message.created',
2551
- 'message.updated',
2552
- 'reaction.added',
2553
- 'message.flagged',
2554
- 'chat.created',
2555
- 'chat.label.updated',
2556
- 'ticket.created',
2557
- 'ticket.updated',
2558
- 'ticket.closed',
2559
- 'message.deleted',
2560
- 'task.created',
2561
- 'task.assignee.updated',
2562
- ],
2563
- },
2564
- {
2565
- value: 'task.title',
2566
- label: 'Task Title',
2567
- validTriggers: ['task.created', 'task.assignee.updated'],
2568
- },
2569
- {
2570
- value: 'task.assignee',
2571
- label: 'Task Assignee',
2572
- validTriggers: ['task.created', 'task.assignee.updated'],
2573
- },
2574
- {
2575
- value: 'task.due_date',
2576
- label: 'Task Due Date',
2577
- validTriggers: ['task.created', 'task.assignee.updated'],
2578
- },
2579
- {
2580
- value: 'task.task_id',
2581
- label: 'Task ID',
2582
- validTriggers: ['task.created', 'task.assignee.updated'],
2583
- },
2584
- {
2585
- value: 'task.notes',
2586
- label: 'Task Notes',
2587
- validTriggers: ['task.created', 'task.assignee.updated'],
2588
- },
2589
- ];
2590
-
2591
- export const variablesExclusionList: Record<
2592
- Rule['trigger'],
2593
- Array<
2594
- | keyof AppendTypes<{ message: MessageVariablesType }, '.'>
2595
- | keyof AppendTypes<{ sender: SenderVariablesType }, '.'>
2596
- | keyof AppendTypes<{ chat: ChatVariablesType }, '.'>
2597
- | keyof AppendTypes<{ ticket: TicketVariablesType }, '.'>
2598
- | keyof AppendTypes<{ reaction: ReactionVariablesType }, '.'>
2599
- | keyof AppendTypes<{ task: TaskVariablesType }, '.'>
2600
- >
2601
- > = {
2602
- 'ticket.created': ['ticket.is_deleted'],
2603
- 'chat.created': [
2604
- 'chat.labels',
2605
- 'chat.has_flagged_messages',
2606
- 'chat.assigned_to',
2607
- ],
2608
- 'message.created': [
2609
- 'message.author',
2610
- 'message.performed_by',
2611
- 'message.flag_status',
2612
- 'sender.is_internal',
2613
- ],
2614
- 'ticket.updated': ['ticket.is_deleted'],
2615
- "ticket.label.updated": ['ticket.is_deleted'],
2616
- 'reaction.added': [],
2617
- 'message.updated': [],
2618
- 'message.flagged': [],
2619
- 'message.unflagged': [],
2620
- 'message.deleted': [],
2621
- 'ticket.closed': ['ticket.is_deleted'],
2622
- 'chat.label.updated': [],
2623
- 'task.created': [],
2624
- 'task.assignee.updated': [],
2625
- };
1
+ import { Merge, OverrideProperties } from 'type-fest';
2
+ import { Tables } from './supabase.types';
3
+ import {
4
+ ChatRuleInfoType,
5
+ MessageRuleInfoType,
6
+ OrgType,
7
+ ReactionRuleInfoType,
8
+ SenderRuleInfoType,
9
+ TaskRuleInfoType,
10
+ TicketRuleInfoType,
11
+ } from './types';
12
+
13
+ export type AppendTypes<T extends object, O extends string> = {
14
+ [K in keyof T & string as `${K}${O}${keyof T[K] & string}`]: T[K][keyof T[K]];
15
+ };
16
+
17
+ export type TicketVariablesType = TicketRuleInfoType['ticket'];
18
+
19
+ export type MessageVariablesType = MessageRuleInfoType['message'];
20
+
21
+ export type SenderVariablesType = SenderRuleInfoType;
22
+
23
+ export type ReactionVariablesType = ReactionRuleInfoType['reaction'];
24
+
25
+ export type ChatVariablesType = ChatRuleInfoType['chat'];
26
+
27
+ export type TaskVariablesType = TaskRuleInfoType['task'];
28
+
29
+ export type MessageRulesInfoType = Merge<
30
+ AppendTypes<
31
+ {
32
+ message: MessageVariablesType;
33
+ sender: SenderVariablesType;
34
+ chat: ChatVariablesType;
35
+ },
36
+ '.'
37
+ >,
38
+ {
39
+ rule: Tables<'tbl_automation_rules'>[];
40
+ id: 'message.message_id';
41
+ type: `message.${'created' | 'updated' | 'flagged' | 'deleted' | 'unflagged'}`;
42
+ org_id: string;
43
+ }
44
+ >;
45
+
46
+ export type TicketRulesInfoType = Merge<
47
+ AppendTypes<
48
+ {
49
+ ticket: TicketVariablesType;
50
+ message: MessageVariablesType;
51
+ sender: SenderVariablesType;
52
+ chat: ChatVariablesType;
53
+ },
54
+ '.'
55
+ >,
56
+ {
57
+ id: 'ticket.ticket_id';
58
+ type: `ticket.${'created' | 'updated' | 'closed'}` | 'ticket.label.updated';
59
+ org_id: string;
60
+ rule: Tables<'tbl_automation_rules'>[];
61
+ }
62
+ >;
63
+
64
+ export type TaskRulesInfoType<
65
+ T extends 'ticket' | 'chat' | 'message' | 'todo' = 'todo',
66
+ > = Merge<
67
+ AppendTypes<
68
+ T extends 'message'
69
+ ? {
70
+ task: TaskVariablesType;
71
+ message: MessageVariablesType;
72
+ sender: SenderVariablesType;
73
+ chat: ChatVariablesType;
74
+ }
75
+ : T extends 'chat'
76
+ ? {
77
+ task: TaskVariablesType;
78
+ chat: ChatVariablesType;
79
+ }
80
+ : T extends 'ticket'
81
+ ? {
82
+ task: TaskVariablesType;
83
+ ticket: TicketVariablesType;
84
+ message: MessageVariablesType;
85
+ sender: SenderVariablesType;
86
+ chat: ChatVariablesType;
87
+ }
88
+ : {
89
+ task: TaskVariablesType;
90
+ },
91
+ '.'
92
+ >,
93
+ {
94
+ id: 'task.task_id';
95
+ type: `task.${'created' | 'assignee.updated'}`;
96
+ org_id: string;
97
+ rule: Tables<'tbl_automation_rules'>[];
98
+ }
99
+ >;
100
+
101
+ export type ReactionRulesInfoType = Merge<
102
+ AppendTypes<
103
+ {
104
+ reaction: ReactionVariablesType;
105
+ message: MessageVariablesType;
106
+ sender: SenderVariablesType;
107
+ chat: ChatVariablesType;
108
+ },
109
+ '.'
110
+ >,
111
+ {
112
+ rule: Tables<'tbl_automation_rules'>[];
113
+ id: 'reaction.reaction_id';
114
+ type: `reaction.added`;
115
+ org_id: string;
116
+ }
117
+ >;
118
+
119
+ export type ChatRulesInfoType = Merge<
120
+ AppendTypes<
121
+ {
122
+ chat: ChatVariablesType;
123
+ },
124
+ '.'
125
+ >,
126
+ {
127
+ rule: Tables<'tbl_automation_rules'>[];
128
+ id: 'chat.chat_id';
129
+ type: 'chat.created' | 'chat.label.updated';
130
+ org_id: string;
131
+ }
132
+ >;
133
+
134
+ export type RuleInfoType =
135
+ | MessageRulesInfoType
136
+ | ChatRulesInfoType
137
+ | TicketRulesInfoType
138
+ | ReactionRulesInfoType
139
+ | TaskRulesInfoType;
140
+
141
+ export interface Filter {
142
+ id: string;
143
+ condition:
144
+ | 'CONTAINS'
145
+ | 'NCONTAINS'
146
+ | 'EQ'
147
+ | 'NEQ'
148
+ | 'LT'
149
+ | 'LTE'
150
+ | 'GT'
151
+ | 'GTE'
152
+ | 'KNOWN'
153
+ | 'NKNOWN'
154
+ | 'IS'
155
+ | 'NIS'
156
+ | 'ON'
157
+ | 'STARTS_WITH'
158
+ | 'ENDS_WITH'; // Add other condition types as needed
159
+ variable: string;
160
+ value: string | string[];
161
+ variable_type?: 'string' | 'number' | 'boolean' | 'day-time' | 'date' | 'day'; // Optional, like 'Date'
162
+ }
163
+
164
+ export const isFilter = (filter: any): filter is Filter => {
165
+ return (
166
+ typeof filter === 'object' &&
167
+ 'id' in filter &&
168
+ 'condition' in filter &&
169
+ 'variable' in filter &&
170
+ 'value' in filter
171
+ );
172
+ };
173
+
174
+ export const FilterNameMap: Record<
175
+ Filter['condition'],
176
+ {
177
+ name: string;
178
+ input: boolean;
179
+ }
180
+ > = {
181
+ EQ: {
182
+ name: 'equals to',
183
+ input: true,
184
+ },
185
+ NEQ: {
186
+ name: 'not equals to',
187
+ input: true,
188
+ },
189
+ CONTAINS: {
190
+ name: 'contains',
191
+ input: true,
192
+ },
193
+ NCONTAINS: {
194
+ name: 'does not contain',
195
+ input: true,
196
+ },
197
+ LT: {
198
+ name: 'less than',
199
+ input: true,
200
+ },
201
+ LTE: {
202
+ name: 'less than or equals to',
203
+ input: true,
204
+ },
205
+ GT: {
206
+ name: 'greater than',
207
+ input: true,
208
+ },
209
+ GTE: {
210
+ name: 'greater than or equals to',
211
+ input: true,
212
+ },
213
+ KNOWN: {
214
+ name: 'is known',
215
+ input: false,
216
+ },
217
+ NKNOWN: {
218
+ name: 'is not known',
219
+ input: false,
220
+ },
221
+ IS: {
222
+ name: 'is',
223
+ input: true,
224
+ },
225
+ NIS: {
226
+ name: 'is not',
227
+ input: true,
228
+ },
229
+ ON: {
230
+ name: 'on',
231
+ input: true,
232
+ },
233
+ STARTS_WITH: {
234
+ name: 'starts with',
235
+ input: true,
236
+ },
237
+ ENDS_WITH: {
238
+ name: 'ends with',
239
+ input: true,
240
+ },
241
+ };
242
+
243
+ export type VariableNameValueType = {
244
+ text: string;
245
+ type:
246
+ | 'string'
247
+ | 'time'
248
+ | 'boolean'
249
+ | 'dropdown'
250
+ | 'day-time'
251
+ | 'number'
252
+ | 'date';
253
+ variable_type: 'string' | 'number' | 'boolean' | 'day-time' | 'date';
254
+ value?:
255
+ | string
256
+ | {
257
+ id: string;
258
+ value: string | number | boolean;
259
+ label: string;
260
+ }[]
261
+ | null;
262
+ filters:
263
+ | Partial<
264
+ Record<
265
+ Filter['condition'],
266
+ {
267
+ info?: string;
268
+ }
269
+ >
270
+ >
271
+ | Filter['condition'][];
272
+ hidden?: boolean;
273
+ placeholder?: string;
274
+ info?: string;
275
+ };
276
+
277
+ export const MessageVariableNameMap: Record<
278
+ keyof AppendTypes<{ message: MessageVariablesType }, '.'>,
279
+ VariableNameValueType
280
+ > = {
281
+ 'message.body': {
282
+ text: 'Message Body',
283
+ type: 'string',
284
+ filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
285
+ placeholder: 'e.g. Test message',
286
+ variable_type: 'string',
287
+ },
288
+ 'message.sender_phone': {
289
+ text: 'Message Sender Phone',
290
+ type: 'string',
291
+ filters: ['EQ', 'NEQ'],
292
+ placeholder: 'e.g. 919876543210',
293
+ variable_type: 'string',
294
+ },
295
+ 'message.timestamp': {
296
+ text: 'Message Timestamp',
297
+ type: 'day-time',
298
+ filters: {
299
+ LT: {
300
+ info: 'When message is received before mentioned time (UTC)',
301
+ },
302
+ LTE: {
303
+ info: 'When message is received before mentioned time (UTC)',
304
+ },
305
+ GT: {
306
+ info: 'When message is received after mentioned time (UTC)',
307
+ },
308
+ GTE: {
309
+ info: 'When message is received on or after mentioned time (UTC)',
310
+ },
311
+ ON: {
312
+ info: 'When message is received on mentioned days',
313
+ },
314
+ },
315
+ variable_type: 'day-time',
316
+ info: 'The timestamp when the message was received',
317
+ },
318
+ 'message.flag_status': {
319
+ text: 'Message Flag Status',
320
+ filters: ['IS'],
321
+ type: 'boolean',
322
+ variable_type: 'boolean',
323
+ },
324
+ 'message.has_quoted_msg': {
325
+ text: 'Has Quoted Message',
326
+ filters: ['IS'],
327
+ type: 'boolean',
328
+ variable_type: 'boolean',
329
+ },
330
+ 'message.media': {
331
+ text: 'Has Media',
332
+ type: 'boolean',
333
+ filters: ['KNOWN', 'NKNOWN'],
334
+ variable_type: 'boolean',
335
+ },
336
+ 'message.performed_by': {
337
+ text: 'Message Sent By (email)',
338
+ type: 'dropdown',
339
+ value: 'org.members',
340
+ filters: ['EQ', 'NEQ'],
341
+ variable_type: 'string',
342
+ },
343
+ 'message.chat_id': {
344
+ text: 'Chat ID',
345
+ type: 'string',
346
+ filters: ['EQ', 'NEQ', 'STARTS_WITH', 'ENDS_WITH'],
347
+ hidden: true,
348
+ variable_type: 'string',
349
+ },
350
+ 'message.message_ticket_id': {
351
+ text: 'Message Ticket ID',
352
+ type: 'string',
353
+ filters: ['EQ', 'NEQ'],
354
+ hidden: true,
355
+ variable_type: 'string',
356
+ },
357
+ 'message.message_id': {
358
+ text: 'Message ID',
359
+ type: 'string',
360
+ filters: ['EQ', 'NEQ'],
361
+ hidden: true,
362
+ variable_type: 'string',
363
+ },
364
+ 'message.org_phone': {
365
+ text: 'Org Phone',
366
+ type: 'string',
367
+ filters: ['EQ', 'NEQ'],
368
+ hidden: true,
369
+ variable_type: 'string',
370
+ },
371
+ 'message.org_id': {
372
+ text: 'Org ID',
373
+ type: 'string',
374
+ filters: ['EQ', 'NEQ'],
375
+ hidden: true,
376
+ variable_type: 'string',
377
+ },
378
+ 'message.message_type': {
379
+ text: 'Message Type',
380
+ type: 'dropdown',
381
+ value: [
382
+ { id: 'text', value: 'chat', label: 'Text' },
383
+ { id: 'image', value: 'image', label: 'Image' },
384
+ { id: 'video', value: 'video', label: 'Video' },
385
+ { id: 'audio', value: 'audio', label: 'Audio' },
386
+ { id: 'audio', value: 'ptt', label: 'PTT (Audio voice message)' },
387
+ { id: 'document', value: 'document', label: 'Document' },
388
+ ],
389
+ filters: ['EQ', 'NEQ'],
390
+ variable_type: 'string',
391
+ },
392
+ 'message.author': {
393
+ text: 'Message Author',
394
+ type: 'string',
395
+ filters: ['EQ', 'NEQ'],
396
+ hidden: true,
397
+ variable_type: 'string',
398
+ },
399
+ };
400
+
401
+ export const SenderVariableNameMap: Record<
402
+ keyof AppendTypes<{ sender: SenderVariablesType }, '.'>,
403
+ VariableNameValueType
404
+ > = {
405
+ 'sender.is_internal': {
406
+ text: 'Sender Is Internal',
407
+ type: 'boolean',
408
+ filters: ['IS'],
409
+ variable_type: 'boolean',
410
+ },
411
+ 'sender.contact_name': {
412
+ text: 'Sender Name',
413
+ type: 'string',
414
+ filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
415
+ placeholder: 'e.g. John Doe',
416
+ variable_type: 'string',
417
+ },
418
+ 'sender.contact_id': {
419
+ text: 'Sender Phone',
420
+ type: 'string',
421
+ filters: ['EQ', 'NEQ'],
422
+ placeholder: 'e.g. 919876543210',
423
+ variable_type: 'string',
424
+ },
425
+ 'sender.org_id': {
426
+ text: 'Org ID',
427
+ type: 'string',
428
+ filters: ['EQ', 'NEQ'],
429
+ hidden: true,
430
+ variable_type: 'string',
431
+ },
432
+ 'sender.labels': {
433
+ text: 'Sender Contact Labels',
434
+ type: 'dropdown',
435
+ value: 'org.labels',
436
+ filters: ['CONTAINS', 'NCONTAINS'],
437
+ variable_type: 'string',
438
+ },
439
+ 'sender.is_admin': {
440
+ text: 'Sender Is Admin',
441
+ type: 'dropdown',
442
+ filters: ['EQ', 'NEQ'],
443
+ value: [
444
+ {
445
+ id: 'true',
446
+ value: 'true',
447
+ label: 'True',
448
+ },
449
+ {
450
+ id: 'false',
451
+ value: 'false',
452
+ label: 'False',
453
+ },
454
+ ],
455
+ variable_type: 'boolean',
456
+ },
457
+ };
458
+
459
+ export const ChatVariableNameMap: Record<
460
+ keyof AppendTypes<{ chat: ChatVariablesType }, '.'>,
461
+ VariableNameValueType
462
+ > = {
463
+ 'chat.assigned_to': {
464
+ text: 'Chat Assignee',
465
+ type: 'dropdown',
466
+ value: 'org.members',
467
+ filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
468
+ variable_type: 'string',
469
+ },
470
+ 'chat.chat_name': {
471
+ text: 'Chat Name',
472
+ type: 'string',
473
+ filters: ['EQ', 'NEQ', 'CONTAINS', 'NCONTAINS'],
474
+ placeholder: 'e.g. Support Chat',
475
+ variable_type: 'string',
476
+ },
477
+ 'chat.org_phone': {
478
+ text: 'Chat Org Phone',
479
+ type: 'dropdown',
480
+ value: 'org.org_phones',
481
+ filters: ['EQ', 'NEQ'],
482
+ variable_type: 'string',
483
+ },
484
+ 'chat.chat_type': {
485
+ text: 'Chat Type',
486
+ type: 'dropdown',
487
+ value: [
488
+ { id: 'user', value: 'user', label: 'User' },
489
+ { id: 'group', value: 'group', label: 'Group' },
490
+ ],
491
+ filters: ['EQ', 'NEQ'],
492
+ variable_type: 'string',
493
+ },
494
+ 'chat.members': {
495
+ text: 'Chat Members',
496
+ type: 'string',
497
+ filters: ['CONTAINS', 'NCONTAINS'],
498
+ placeholder: 'e.g. 919876543210',
499
+ variable_type: 'string',
500
+ },
501
+ 'chat.labels': {
502
+ text: 'Chat Labels',
503
+ type: 'dropdown',
504
+ value: 'org.labels',
505
+ filters: ['CONTAINS', 'NCONTAINS'],
506
+ variable_type: 'string',
507
+ },
508
+ 'chat.chat_id': {
509
+ text: 'Chat ID',
510
+ type: 'string',
511
+ filters: ['EQ', 'NEQ', 'STARTS_WITH', 'ENDS_WITH'],
512
+ placeholder: 'e.g. 12027747916749@g.us',
513
+ variable_type: 'string',
514
+ },
515
+ 'chat.chat_org_phones': {
516
+ text: 'Chat Org Phones',
517
+ type: 'dropdown',
518
+ filters: ['CONTAINS', 'NCONTAINS'],
519
+ hidden: true,
520
+ variable_type: 'string',
521
+ },
522
+ 'chat.org_id': {
523
+ text: 'Org ID',
524
+ type: 'string',
525
+ filters: [],
526
+ hidden: true,
527
+ variable_type: 'string',
528
+ },
529
+ 'chat.messages_admins_only': {
530
+ text: 'Messages Admins Only (Chat Settings)',
531
+ type: 'boolean',
532
+ filters: ['EQ', 'NEQ'],
533
+ value: [
534
+ {
535
+ id: 'true',
536
+ value: 'true',
537
+ label: 'True',
538
+ },
539
+ {
540
+ id: 'false',
541
+ value: 'false',
542
+ label: 'False',
543
+ },
544
+ ],
545
+ variable_type: 'boolean',
546
+ },
547
+ 'chat.info_admins_only': {
548
+ text: 'Info Admins Only (Chat Settings)',
549
+ type: 'boolean',
550
+ filters: ['EQ', 'NEQ'],
551
+ value: [
552
+ {
553
+ id: 'true',
554
+ value: 'true',
555
+ label: 'True',
556
+ },
557
+ {
558
+ id: 'false',
559
+ value: 'false',
560
+ label: 'False',
561
+ },
562
+ ],
563
+ variable_type: 'boolean',
564
+ },
565
+ 'chat.has_flagged_messages': {
566
+ text: 'Chat Has Flagged Messages',
567
+ type: 'boolean',
568
+ filters: ['EQ', 'NEQ'],
569
+ value: [
570
+ {
571
+ id: 'true',
572
+ value: 'true',
573
+ label: 'True',
574
+ },
575
+ {
576
+ id: 'false',
577
+ value: 'false',
578
+ label: 'False',
579
+ },
580
+ ],
581
+ variable_type: 'boolean',
582
+ },
583
+ 'chat.group_description': {
584
+ text: 'Group Description',
585
+ type: 'string',
586
+ filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
587
+ placeholder: 'e.g. Group description',
588
+ variable_type: 'string',
589
+ },
590
+ 'chat.custom_properties': {
591
+ text: 'Chat Custom Properties',
592
+ type: 'dropdown',
593
+ value: 'org.custom_properties',
594
+ filters: ['EQ', 'NEQ'],
595
+ hidden: true,
596
+ variable_type: 'string',
597
+ },
598
+ 'chat.initiated_by': {
599
+ text: 'Chat Initiated By',
600
+ type: 'dropdown',
601
+ value: 'org.members',
602
+ filters: ['EQ', 'NEQ'],
603
+ variable_type: 'string',
604
+ hidden: true,
605
+ },
606
+ 'chat.created_at': {
607
+ text: 'Chat Created At',
608
+ type: 'day-time',
609
+ filters: {
610
+ LT: {
611
+ info: 'When chat is created before mentioned time (UTC)',
612
+ },
613
+ LTE: {
614
+ info: 'When chat is created before mentioned time (UTC)',
615
+ },
616
+ GT: {
617
+ info: 'When chat is created after mentioned time (UTC)',
618
+ },
619
+ GTE: {
620
+ info: 'When chat is created on or after mentioned time (UTC)',
621
+ },
622
+ ON: {
623
+ info: 'When chat is created on mentioned days',
624
+ },
625
+ },
626
+ variable_type: 'day-time',
627
+ },
628
+ };
629
+
630
+ export const TicketVariableNameMap: Record<
631
+ keyof AppendTypes<{ ticket: TicketVariablesType }, '.'>,
632
+ VariableNameValueType
633
+ > = {
634
+ 'ticket.subject': {
635
+ text: 'Ticket Subject',
636
+ type: 'string',
637
+ filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
638
+ placeholder: 'e.g. Test ticket',
639
+ variable_type: 'string',
640
+ },
641
+ 'ticket.status': {
642
+ text: 'Ticket Status',
643
+ type: 'dropdown',
644
+ value: [
645
+ { id: 'open', value: 'open', label: 'Open' },
646
+ { id: 'closed', value: 'closed', label: 'Closed' },
647
+ { id: 'inprogress', value: 'inprogress', label: 'In progress' },
648
+ ],
649
+ filters: ['EQ', 'NEQ'],
650
+ variable_type: 'string',
651
+ },
652
+ 'ticket.priority': {
653
+ text: 'Ticket Priority',
654
+ type: 'dropdown',
655
+ value: [
656
+ { id: '0', value: '0', label: 'No Priority' },
657
+ { id: '1', value: '1', label: 'Low' },
658
+ { id: '2', value: '2', label: 'Medium' },
659
+ { id: '3', value: '3', label: 'High' },
660
+ { id: '4', value: '4', label: 'Urgent' },
661
+ ],
662
+ filters: ['EQ', 'NEQ'],
663
+ variable_type: 'string',
664
+ },
665
+ 'ticket.assignee': {
666
+ text: 'Ticket Assignee',
667
+ type: 'dropdown',
668
+ value: 'org.members',
669
+ filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
670
+ variable_type: 'string',
671
+ },
672
+ 'ticket.labels': {
673
+ text: 'Ticket Labels',
674
+ type: 'dropdown',
675
+ value: 'org.labels',
676
+ filters: ['CONTAINS', 'NCONTAINS'],
677
+ variable_type: 'string',
678
+ },
679
+ 'ticket.is_deleted': {
680
+ text: 'Ticket Is Deleted',
681
+ type: 'boolean',
682
+ value: [
683
+ {
684
+ id: 'true',
685
+ value: 'true',
686
+ label: 'True',
687
+ },
688
+ {
689
+ id: 'false',
690
+ value: 'false',
691
+ label: 'False',
692
+ },
693
+ ],
694
+ filters: ['IS'],
695
+ variable_type: 'boolean',
696
+ },
697
+ 'ticket.raised_by': {
698
+ text: 'Ticket Raised By',
699
+ type: 'dropdown',
700
+ value: 'org.members',
701
+ filters: ['EQ', 'NEQ'],
702
+ variable_type: 'string',
703
+ },
704
+ 'ticket.due_date': {
705
+ text: 'Ticket Due Date',
706
+ type: 'date',
707
+ filters: ['KNOWN', 'NKNOWN'],
708
+ variable_type: 'date',
709
+ hidden: true,
710
+ },
711
+ 'ticket.ticket_id': {
712
+ text: 'Ticket ID',
713
+ type: 'string',
714
+ filters: ['EQ', 'NEQ'],
715
+ hidden: true,
716
+ variable_type: 'string',
717
+ },
718
+ 'ticket.org_id': {
719
+ text: 'Org ID',
720
+ type: 'string',
721
+ filters: ['EQ', 'NEQ'],
722
+ hidden: true,
723
+ variable_type: 'string',
724
+ },
725
+ 'ticket.custom_properties': {
726
+ text: 'Ticket Custom Properties',
727
+ type: 'dropdown',
728
+ value: 'org.custom_properties',
729
+ filters: ['EQ', 'NEQ'],
730
+ hidden: true,
731
+ variable_type: 'string',
732
+ },
733
+ 'ticket.created_at': {
734
+ text: 'Ticket Created At',
735
+ type: 'day-time',
736
+ filters: {
737
+ LT: {
738
+ info: 'When ticket is created before mentioned time (UTC)',
739
+ },
740
+ LTE: {
741
+ info: 'When ticket is created before mentioned time (UTC)',
742
+ },
743
+ GT: {
744
+ info: 'When ticket is created after mentioned time (UTC)',
745
+ },
746
+ GTE: {
747
+ info: 'When ticket is created on or after mentioned time (UTC)',
748
+ },
749
+ ON: {
750
+ info: 'When ticket is created on mentioned days',
751
+ },
752
+ },
753
+ variable_type: 'day-time',
754
+ },
755
+ 'ticket.chat_id': {
756
+ text: 'Chat ID',
757
+ type: 'string',
758
+ filters: ['EQ', 'NEQ', 'STARTS_WITH', 'ENDS_WITH'],
759
+ hidden: true,
760
+ variable_type: 'string',
761
+ },
762
+ };
763
+
764
+ export const TaskVariableNameMap: Record<
765
+ keyof AppendTypes<{ task: TaskVariablesType }, '.'>,
766
+ VariableNameValueType
767
+ > = {
768
+ 'task.title': {
769
+ text: 'Task Title',
770
+ type: 'string',
771
+ filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
772
+ placeholder: 'e.g. Test task',
773
+ variable_type: 'string',
774
+ },
775
+ 'task.assignee': {
776
+ text: 'Task Assignee',
777
+ type: 'dropdown',
778
+ value: 'org.members',
779
+ filters: ['EQ', 'NEQ'],
780
+ variable_type: 'string',
781
+ },
782
+ 'task.priority': {
783
+ text: 'Task Priority',
784
+ type: 'dropdown',
785
+ value: [
786
+ { id: '0', value: '0', label: 'No Priority' },
787
+ { id: '1', value: '1', label: 'Low' },
788
+ { id: '2', value: '2', label: 'Medium' },
789
+ { id: '3', value: '3', label: 'High' },
790
+ { id: '4', value: '4', label: 'Urgent' },
791
+ ],
792
+ filters: ['EQ', 'NEQ'],
793
+ variable_type: 'string',
794
+ },
795
+ 'task.due_date': {
796
+ text: 'Task Due Date',
797
+ type: 'day-time',
798
+ filters: {
799
+ LT: {
800
+ info: 'When task is created before mentioned time (UTC)',
801
+ },
802
+ LTE: {
803
+ info: 'When task is created before mentioned time (UTC)',
804
+ },
805
+ GT: {
806
+ info: 'When task is created after mentioned time (UTC)',
807
+ },
808
+ GTE: {
809
+ info: 'When task is created on or after mentioned time (UTC)',
810
+ },
811
+ ON: {
812
+ info: 'When task is created on mentioned days',
813
+ },
814
+ },
815
+ variable_type: 'day-time',
816
+ },
817
+ 'task.task_id': {
818
+ text: 'Task ID',
819
+ type: 'string',
820
+ filters: ['EQ', 'NEQ'],
821
+ hidden: true,
822
+ variable_type: 'string',
823
+ },
824
+ 'task.org_id': {
825
+ text: 'Org ID',
826
+ type: 'string',
827
+ filters: ['EQ', 'NEQ'],
828
+ hidden: true,
829
+ variable_type: 'string',
830
+ },
831
+ 'task.created_at': {
832
+ text: 'Task Created At',
833
+ type: 'day-time',
834
+ filters: {
835
+ LT: {
836
+ info: 'When task is created before mentioned time (UTC)',
837
+ },
838
+ LTE: {
839
+ info: 'When task is created before mentioned time (UTC)',
840
+ },
841
+ GT: {
842
+ info: 'When task is created after mentioned time (UTC)',
843
+ },
844
+ GTE: {
845
+ info: 'When task is created on or after mentioned time (UTC)',
846
+ },
847
+ ON: {
848
+ info: 'When task is created on mentioned days',
849
+ },
850
+ },
851
+ variable_type: 'day-time',
852
+ },
853
+ 'task.notes': {
854
+ text: 'Task Notes',
855
+ type: 'string',
856
+ filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
857
+ placeholder: 'e.g. Test task',
858
+ variable_type: 'string',
859
+ },
860
+ 'task.status': {
861
+ text: 'Task Status',
862
+ type: 'dropdown',
863
+ value: [
864
+ { id: 'open', value: 'open', label: 'Open' },
865
+ { id: 'closed', value: 'closed', label: 'Closed' },
866
+ { id: 'inprogress', value: 'inprogress', label: 'In progress' },
867
+ ],
868
+ filters: ['EQ', 'NEQ'],
869
+ variable_type: 'string',
870
+ },
871
+ };
872
+ export const ReactionVariableNameMap: Record<
873
+ keyof AppendTypes<{ reaction: ReactionVariablesType }, '.'>,
874
+ VariableNameValueType
875
+ > = {
876
+ 'reaction.reaction': {
877
+ text: 'Reaction',
878
+ type: 'string',
879
+ filters: ['EQ', 'NEQ'],
880
+ placeholder: 'e.g. 👍',
881
+ variable_type: 'string',
882
+ },
883
+ 'reaction.sender_id': {
884
+ text: 'Reaction Sender Phone',
885
+ type: 'string',
886
+ filters: ['EQ', 'NEQ'],
887
+ placeholder: 'e.g. 919876543210',
888
+ variable_type: 'string',
889
+ },
890
+ 'reaction.message_id': {
891
+ text: 'Reaction Message ID',
892
+ type: 'string',
893
+ filters: ['EQ', 'NEQ'],
894
+ hidden: true,
895
+ variable_type: 'string',
896
+ },
897
+ 'reaction.chat_id': {
898
+ text: 'Chat ID',
899
+ type: 'string',
900
+ filters: ['EQ', 'NEQ', 'STARTS_WITH', 'ENDS_WITH'],
901
+ hidden: true,
902
+ variable_type: 'string',
903
+ },
904
+ 'reaction.reaction_id': {
905
+ text: 'Reaction ID',
906
+ type: 'string',
907
+ filters: ['EQ', 'NEQ'],
908
+ hidden: true,
909
+ variable_type: 'string',
910
+ },
911
+ };
912
+
913
+ export enum FilterConditionMap {
914
+ 'CONTAINS' = 'contains',
915
+ 'NCONTAINS' = 'does not contain',
916
+ 'EQ' = '=',
917
+ 'NEQ' = '<>',
918
+ 'LT' = '<',
919
+ 'LTE' = '<=',
920
+ 'GT' = '>',
921
+ 'GTE' = '>=',
922
+ 'KNOWN' = 'is known',
923
+ 'NKNOWN' = 'is not known',
924
+ 'IS' = '=',
925
+ 'NIS' = '<>',
926
+ 'ON' = 'on',
927
+ 'STARTS_WITH' = 'starts with',
928
+ 'ENDS_WITH' = 'ends with',
929
+ }
930
+
931
+ interface FilterGroup {
932
+ filters: Filter[];
933
+ condition: 'allOf' | 'anyOf';
934
+ }
935
+
936
+ export interface Conditions {
937
+ filters: FilterGroup[];
938
+ condition: 'allOf' | 'anyOf';
939
+ variables: string[];
940
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
941
+ org_phones: string[];
942
+ allow_messages_from_org_phones?: boolean;
943
+ }
944
+
945
+ export type SendMessageAction = {
946
+ id: string;
947
+ type: 'send_message';
948
+ metadata: {
949
+ message: string;
950
+ media?: {
951
+ url: string;
952
+ type: 'image' | 'video' | 'audio' | 'document';
953
+ name: string;
954
+ };
955
+ maintain_flag_status: 'true' | 'false';
956
+ debounce_messages: 'true' | 'false';
957
+ debounce_message_time:
958
+ | `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`
959
+ | null
960
+ | undefined;
961
+ };
962
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
963
+ };
964
+
965
+ export type NotifyHttpAction = {
966
+ id: string;
967
+ type: 'notify_http';
968
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
969
+ metadata: {
970
+ url: string;
971
+ };
972
+ };
973
+
974
+ export type CreateTicketAction = {
975
+ id: string;
976
+ type: 'create_ticket';
977
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
978
+ metadata: {
979
+ priority?: '0' | '1' | '2' | '3' | '4';
980
+ label?: string;
981
+ append_to_latest_ticket?: 'true' | 'false';
982
+ round_robin?: 'true' | 'false';
983
+ assignee?: string;
984
+ rr_check_for?: 'shift_time' | 'user_status' | 'shift_time user_status';
985
+ };
986
+ };
987
+
988
+ export type FlagMessageAction = {
989
+ id: string;
990
+ type: 'flag_message';
991
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
992
+ metadata: {
993
+ flag: 'true' | 'false';
994
+ };
995
+ };
996
+
997
+ export type AssignTicketAction = {
998
+ id: string;
999
+ type: 'assign_ticket';
1000
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1001
+ metadata: {
1002
+ assignee: string;
1003
+ round_robin: 'true' | 'false';
1004
+ rr_check_for?: 'shift_time' | 'user_status' | 'shift_time user_status';
1005
+ };
1006
+ };
1007
+
1008
+ export type CloseTicketAction = {
1009
+ id: string;
1010
+ type: 'close_ticket';
1011
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1012
+ metadata: {
1013
+ closing_note: string;
1014
+ };
1015
+ };
1016
+
1017
+ export type AddChatLabelAction = {
1018
+ id: string;
1019
+ type: 'add_chat_label';
1020
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1021
+ metadata: {
1022
+ label: string;
1023
+ };
1024
+ };
1025
+
1026
+ export type AddTicketLabelAction = {
1027
+ id: string;
1028
+ type: 'add_ticket_label';
1029
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1030
+ metadata: {
1031
+ label: string;
1032
+ };
1033
+ };
1034
+
1035
+ export type SetTicketDueDateAction = {
1036
+ id: string;
1037
+ type: 'set_ticket_due_date';
1038
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1039
+ metadata: {
1040
+ due_date_option_time: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1041
+ };
1042
+ };
1043
+
1044
+ export type AssignChatAction = {
1045
+ id: string;
1046
+ type: 'assign_chat';
1047
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1048
+ metadata: {
1049
+ assignee: string;
1050
+ round_robin: 'true' | 'false';
1051
+ rr_check_for?: 'shift_time' | 'user_status' | 'shift_time user_status';
1052
+ };
1053
+ };
1054
+
1055
+ export type ForwardMessageAction = {
1056
+ id: string;
1057
+ type: 'forward_message';
1058
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1059
+ metadata: {
1060
+ chat_id: string;
1061
+ prefix: string;
1062
+ };
1063
+ };
1064
+
1065
+ export type SendEmailAction = {
1066
+ id: string;
1067
+ type: 'send_email';
1068
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1069
+ metadata: {
1070
+ email: string;
1071
+ subject: string;
1072
+ body: string;
1073
+ };
1074
+ };
1075
+
1076
+ export type ReplyToMessageAction = {
1077
+ id: string;
1078
+ type: 'reply_to_message';
1079
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1080
+ metadata: {
1081
+ message: string;
1082
+ media?: {
1083
+ url: string;
1084
+ type: 'image' | 'video' | 'audio' | 'document';
1085
+ name: string;
1086
+ };
1087
+ maintain_flag_status: 'true' | 'false';
1088
+ debounce_messages: 'true' | 'false';
1089
+ debounce_message_time:
1090
+ | `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`
1091
+ | null
1092
+ | undefined;
1093
+ };
1094
+ };
1095
+
1096
+ export type UpdateCustomPropertyAction = {
1097
+ id: string;
1098
+ type: 'update_custom_property';
1099
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1100
+ metadata: {
1101
+ property_id: string;
1102
+ value: string;
1103
+ };
1104
+ };
1105
+
1106
+ export type DeleteMessageAction = {
1107
+ id: string;
1108
+ type: 'delete_message';
1109
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1110
+ metadata: {};
1111
+ };
1112
+
1113
+ export type SendSlackNotificationAction = {
1114
+ id: string;
1115
+ type: 'send_slack_notification';
1116
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1117
+ metadata: {
1118
+ slack_payload: string;
1119
+ webhook_url: string;
1120
+ };
1121
+ };
1122
+
1123
+ export type AttachMessageToTicketAction = {
1124
+ id: string;
1125
+ type: 'attach_message_to_ticket';
1126
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1127
+ metadata: {
1128
+ status: 'open' | 'inprogress' | 'open_inprogress' | null;
1129
+ };
1130
+ };
1131
+
1132
+ export type CloseChatAction = {
1133
+ id: string;
1134
+ type: 'close_chat';
1135
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1136
+ metadata: {};
1137
+ };
1138
+
1139
+ export type SendMessageToChatAction = {
1140
+ id: string;
1141
+ type: 'send_message_to_chat';
1142
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1143
+ metadata: {
1144
+ chat_id: string;
1145
+ message: string;
1146
+ media?: {
1147
+ url: string;
1148
+ type: 'image' | 'video' | 'audio' | 'document';
1149
+ name: string;
1150
+ };
1151
+ };
1152
+ };
1153
+
1154
+ export type FreshdeskCreateTicketAction = {
1155
+ id: string;
1156
+ type: 'create_ticket_on_freshdesk';
1157
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1158
+ metadata: {};
1159
+ };
1160
+
1161
+ export type HubspotCreateTicketAction = {
1162
+ id: string;
1163
+ type: 'create_ticket_on_hubspot';
1164
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1165
+ metadata: {};
1166
+ };
1167
+
1168
+ export type ZohodeskCreateTicketAction = {
1169
+ id: string;
1170
+ type: 'create_ticket_on_zohodesk';
1171
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
1172
+ metadata: {};
1173
+ };
1174
+
1175
+ export type Action =
1176
+ | SendMessageAction
1177
+ | NotifyHttpAction
1178
+ | CreateTicketAction
1179
+ | FlagMessageAction
1180
+ | AssignTicketAction
1181
+ | CloseTicketAction
1182
+ | AddChatLabelAction
1183
+ | AddTicketLabelAction
1184
+ | SetTicketDueDateAction
1185
+ | AssignChatAction
1186
+ | ForwardMessageAction
1187
+ | SendEmailAction
1188
+ | ReplyToMessageAction
1189
+ | UpdateCustomPropertyAction
1190
+ | DeleteMessageAction
1191
+ | SendSlackNotificationAction
1192
+ | AttachMessageToTicketAction
1193
+ | CloseChatAction
1194
+ | SendMessageToChatAction
1195
+ | FreshdeskCreateTicketAction
1196
+ | HubspotCreateTicketAction
1197
+ | ZohodeskCreateTicketAction;
1198
+
1199
+ export const isSendMessageOrReplyToMessageAction = (
1200
+ action: Action
1201
+ ): action is SendMessageAction | ReplyToMessageAction => {
1202
+ return ['send_message', 'reply_to_message'].includes(action.type);
1203
+ };
1204
+
1205
+ export type Rule = OverrideProperties<
1206
+ Tables<'tbl_automation_rules'>,
1207
+ {
1208
+ actions: Action[];
1209
+ conditions: Conditions;
1210
+ trigger:
1211
+ | 'message.created'
1212
+ | 'message.updated'
1213
+ | 'chat.created'
1214
+ | 'ticket.updated'
1215
+ | 'ticket.created'
1216
+ | 'reaction.added'
1217
+ | 'chat.label.updated'
1218
+ | 'message.flagged'
1219
+ | 'message.unflagged'
1220
+ | 'message.deleted'
1221
+ | 'ticket.closed'
1222
+ | 'ticket.label.updated'
1223
+ | 'task.created'
1224
+ | 'task.assignee.updated';
1225
+ }
1226
+ >;
1227
+
1228
+ export const RuleNameMap: Record<
1229
+ Rule['trigger'],
1230
+ {
1231
+ title: string;
1232
+ description: string;
1233
+ base_conditions: {
1234
+ org_phone: boolean;
1235
+ };
1236
+ }
1237
+ > = {
1238
+ 'message.created': {
1239
+ title: 'New Message Received',
1240
+ description: 'When a new message is received from an external contact',
1241
+ base_conditions: {
1242
+ org_phone: true,
1243
+ },
1244
+ },
1245
+ 'chat.created': {
1246
+ title: 'New Chat Created',
1247
+ description: 'When a new chat is created',
1248
+ base_conditions: {
1249
+ org_phone: true,
1250
+ },
1251
+ },
1252
+ 'ticket.created': {
1253
+ title: 'New Ticket Created',
1254
+ description: 'When a new ticket is created',
1255
+ base_conditions: {
1256
+ org_phone: false,
1257
+ },
1258
+ },
1259
+ 'reaction.added': {
1260
+ title: 'New Reaction Added',
1261
+ description: 'When a reaction is added on a message',
1262
+ base_conditions: {
1263
+ org_phone: true,
1264
+ },
1265
+ },
1266
+ 'message.updated': {
1267
+ title: 'Message Updated',
1268
+ description: 'When a message is updated',
1269
+ base_conditions: {
1270
+ org_phone: true,
1271
+ },
1272
+ },
1273
+ 'ticket.updated': {
1274
+ title: 'Ticket Updated',
1275
+ description: 'When a ticket is updated',
1276
+ base_conditions: {
1277
+ org_phone: false,
1278
+ },
1279
+ },
1280
+ 'ticket.label.updated': {
1281
+ title: 'Ticket Label Added/Removed',
1282
+ description: 'When labels on tickets are updated',
1283
+ base_conditions: {
1284
+ org_phone: false,
1285
+ },
1286
+ },
1287
+ 'chat.label.updated': {
1288
+ title: 'Chat Label Added/Removed',
1289
+ description: 'When labels on chats are updated',
1290
+ base_conditions: {
1291
+ org_phone: false,
1292
+ },
1293
+ },
1294
+ 'message.flagged': {
1295
+ title: 'Message Flagged',
1296
+ description: 'When a message is flagged',
1297
+ base_conditions: {
1298
+ org_phone: true,
1299
+ },
1300
+ },
1301
+ 'message.unflagged': {
1302
+ title: 'Message Unflagged',
1303
+ description: 'When a message is unflagged',
1304
+ base_conditions: {
1305
+ org_phone: true,
1306
+ },
1307
+ },
1308
+ 'message.deleted': {
1309
+ title: 'Message Deleted',
1310
+ description: 'When a message is Deleted',
1311
+ base_conditions: {
1312
+ org_phone: true,
1313
+ },
1314
+ },
1315
+ 'ticket.closed': {
1316
+ title: 'Ticket Closed',
1317
+ description: 'When a Ticket is Closed',
1318
+ base_conditions: {
1319
+ org_phone: false,
1320
+ },
1321
+ },
1322
+ 'task.created': {
1323
+ title: 'New Task Created',
1324
+ description: 'When a Task is Created',
1325
+ base_conditions: {
1326
+ org_phone: false,
1327
+ },
1328
+ },
1329
+ 'task.assignee.updated': {
1330
+ title: 'Task Assigned',
1331
+ description: 'When a Task is Assigned',
1332
+ base_conditions: {
1333
+ org_phone: false,
1334
+ },
1335
+ },
1336
+ };
1337
+
1338
+ export type ValidateFunction<T extends any[] = any[]> = (...args: T) => boolean;
1339
+
1340
+ type ValidateArgsMap = {
1341
+ create_ticket_on_freshdesk: [OrgType, Rule];
1342
+ create_ticket_on_hubspot: [OrgType, Rule];
1343
+ create_ticket_on_zohodesk: [OrgType, Rule];
1344
+ };
1345
+
1346
+ type ActionNameMapType = {
1347
+ [K in Action['type']]: {
1348
+ title: string;
1349
+ description: string;
1350
+ inputs: Record<
1351
+ string,
1352
+ {
1353
+ id: string;
1354
+ type:
1355
+ | 'text'
1356
+ | 'dropdown'
1357
+ | 'editor'
1358
+ | 'date'
1359
+ | 'file'
1360
+ | 'textarea'
1361
+ | 'dynamic'
1362
+ | 'json_editor';
1363
+ value:
1364
+ | 'ticket.labels'
1365
+ | 'org.members'
1366
+ | 'chat.labels'
1367
+ | 'org.chats'
1368
+ | {
1369
+ id: string;
1370
+ value: string;
1371
+ label: string;
1372
+ }[]
1373
+ | null
1374
+ | 'org.custom_properties'
1375
+ | 'custom_property_values'
1376
+ | 'custom_duration';
1377
+ label: string;
1378
+ placeholder: string;
1379
+ info?: string;
1380
+ required: boolean;
1381
+ description?: string;
1382
+ }
1383
+ >;
1384
+ validate: K extends keyof ValidateArgsMap
1385
+ ? ValidateFunction<ValidateArgsMap[K]>
1386
+ : ValidateFunction<never[]>;
1387
+ info?: string;
1388
+ validTriggers: Rule['trigger'][];
1389
+ };
1390
+ };
1391
+
1392
+ export const ActionNameMap: ActionNameMapType = {
1393
+ send_message: {
1394
+ title: 'Send Message',
1395
+ description: 'Send a message',
1396
+ inputs: {
1397
+ message: {
1398
+ id: 'message',
1399
+ type: 'editor',
1400
+ label: 'Message',
1401
+ placeholder: 'Enter message',
1402
+ value: null,
1403
+ required: true,
1404
+ },
1405
+ media: {
1406
+ id: 'media',
1407
+ type: 'file',
1408
+ label: 'Media',
1409
+ placeholder: 'Upload media',
1410
+ value: null,
1411
+ required: false,
1412
+ },
1413
+ maintain_flag_status: {
1414
+ id: 'maintain_flag_status',
1415
+ type: 'dropdown',
1416
+ label: 'Maintain Flag Status',
1417
+ placeholder: 'Select...',
1418
+ value: [
1419
+ { id: 'true', value: 'true', label: 'True' },
1420
+ { id: 'false', value: 'false', label: 'False' },
1421
+ ],
1422
+ required: true,
1423
+ },
1424
+ debounce_messages: {
1425
+ id: 'debounce_messages',
1426
+ type: 'dropdown',
1427
+ label: 'Enable Cooldown Period',
1428
+ placeholder: 'Select...',
1429
+ value: [
1430
+ { id: 'true', value: 'true', label: 'True' },
1431
+ { id: 'false', value: 'false', label: 'False' },
1432
+ ],
1433
+ info: 'If enabled, only one message per chat will be sent in the specified cooldown period',
1434
+ required: false,
1435
+ },
1436
+ debounce_message_time: {
1437
+ id: 'debounce_message_time',
1438
+ type: 'dynamic',
1439
+ label: 'Cooldown Period',
1440
+ placeholder: 'Enter time',
1441
+ value: 'custom_duration',
1442
+ required: false,
1443
+ },
1444
+ },
1445
+ validTriggers: [
1446
+ 'message.created',
1447
+ 'message.updated',
1448
+ 'chat.created',
1449
+ 'ticket.updated',
1450
+ 'ticket.created',
1451
+ 'reaction.added',
1452
+ 'message.flagged',
1453
+ 'message.unflagged',
1454
+ 'chat.label.updated',
1455
+ 'message.deleted',
1456
+ 'ticket.closed',
1457
+ 'task.created',
1458
+ 'task.assignee.updated',
1459
+ 'ticket.label.updated'
1460
+ ],
1461
+ validate: () => true,
1462
+ },
1463
+ reply_to_message: {
1464
+ title: 'Reply to message',
1465
+ description: 'Send a message with the quoted message',
1466
+ inputs: {
1467
+ message: {
1468
+ id: 'message',
1469
+ type: 'editor',
1470
+ label: 'Message',
1471
+ placeholder: 'Enter message',
1472
+ value: null,
1473
+ required: true,
1474
+ },
1475
+ media: {
1476
+ id: 'media',
1477
+ type: 'file',
1478
+ label: 'Media',
1479
+ placeholder: 'Upload media',
1480
+ value: null,
1481
+ required: false,
1482
+ },
1483
+ maintain_flag_status: {
1484
+ id: 'maintain_flag_status',
1485
+ type: 'dropdown',
1486
+ label: 'Maintain Flag Status',
1487
+ placeholder: 'Select...',
1488
+ value: [
1489
+ { id: 'true', value: 'true', label: 'True' },
1490
+ { id: 'false', value: 'false', label: 'False' },
1491
+ ],
1492
+ required: true,
1493
+ },
1494
+ debounce_messages: {
1495
+ id: 'debounce_messages',
1496
+ type: 'dropdown',
1497
+ label: 'Enable Cooldown Period',
1498
+ placeholder: 'Select...',
1499
+ value: [
1500
+ { id: 'true', value: 'true', label: 'True' },
1501
+ { id: 'false', value: 'false', label: 'False' },
1502
+ ],
1503
+ info: 'If enabled, only one message per chat will be sent in the specified cooldown period',
1504
+ required: false,
1505
+ },
1506
+ debounce_message_time: {
1507
+ id: 'debounce_message_time',
1508
+ type: 'dynamic',
1509
+ label: 'Cooldown Period',
1510
+ placeholder: 'Enter time',
1511
+ value: 'custom_duration',
1512
+ required: false,
1513
+ },
1514
+ },
1515
+ validTriggers: [
1516
+ 'message.created',
1517
+ 'message.updated',
1518
+ 'reaction.added',
1519
+ 'message.flagged',
1520
+ 'ticket.created',
1521
+ 'ticket.updated',
1522
+ 'ticket.closed',
1523
+ 'message.unflagged',
1524
+ 'task.created',
1525
+ 'task.assignee.updated',
1526
+ 'ticket.label.updated'
1527
+ ],
1528
+ validate: () => true,
1529
+ },
1530
+ delete_message: {
1531
+ title: 'Delete Message',
1532
+ description: 'Delete a message',
1533
+ inputs: {},
1534
+ validTriggers: [
1535
+ 'message.created',
1536
+ 'message.updated',
1537
+ 'reaction.added',
1538
+ 'message.flagged',
1539
+ 'ticket.created',
1540
+ 'ticket.updated',
1541
+ 'ticket.closed',
1542
+ 'message.unflagged',
1543
+ 'ticket.label.updated'
1544
+ ],
1545
+ validate: () => true,
1546
+ },
1547
+ attach_message_to_ticket: {
1548
+ title: 'Attach Message To Latest Ticket',
1549
+ description: 'Attach message to latest ticket based on statuses',
1550
+ inputs: {
1551
+ status: {
1552
+ id: 'status',
1553
+ type: 'dropdown',
1554
+ value: [
1555
+ {
1556
+ id: 'open_inprogress',
1557
+ value: 'open_inprogress',
1558
+ label: 'Open/In Progress',
1559
+ },
1560
+ { id: 'open', value: 'open', label: 'Open' },
1561
+ { id: 'inprogress', value: 'inprogress', label: 'In Progress' },
1562
+ ],
1563
+ label: 'Ticket Status',
1564
+ placeholder: 'Select...',
1565
+ required: true,
1566
+ info: 'Select the ticket status of ticket to attach the message to (only applicable for open or inprogress tickets)',
1567
+ },
1568
+ },
1569
+ validTriggers: [
1570
+ 'message.created',
1571
+ 'message.updated',
1572
+ 'reaction.added',
1573
+ 'message.flagged',
1574
+ ],
1575
+ validate: () => true,
1576
+ },
1577
+ notify_http: {
1578
+ title: 'Notify HTTP',
1579
+ description: 'Notify an HTTP endpoint',
1580
+ inputs: {
1581
+ url: {
1582
+ id: 'url',
1583
+ type: 'text',
1584
+ label: 'URL',
1585
+ placeholder: 'Enter URL',
1586
+ value: null,
1587
+ required: true,
1588
+ description:
1589
+ 'Enter the Webhook URL here. The endpoint added here should be a **POST HTTP / Endpoint** with no open auth.',
1590
+ },
1591
+ },
1592
+ validTriggers: [
1593
+ 'message.created',
1594
+ 'message.updated',
1595
+ 'chat.created',
1596
+ 'ticket.updated',
1597
+ 'ticket.created',
1598
+ 'reaction.added',
1599
+ 'message.flagged',
1600
+ 'chat.label.updated',
1601
+ 'message.deleted',
1602
+ 'ticket.closed',
1603
+ 'message.unflagged',
1604
+ 'task.created',
1605
+ 'task.assignee.updated',
1606
+ 'ticket.label.updated'
1607
+ ],
1608
+ validate: () => true,
1609
+ },
1610
+ create_ticket: {
1611
+ title: 'Create Ticket or Attach Message To Latest Ticket',
1612
+ description: 'Create a ticket or attach message to latest ticket',
1613
+ inputs: {
1614
+ append_to_latest_ticket: {
1615
+ id: 'append_to_latest_ticket',
1616
+ type: 'dropdown',
1617
+ value: [
1618
+ { id: 'true', value: 'true', label: 'True' },
1619
+ { id: 'false', value: 'false', label: 'False' },
1620
+ ],
1621
+ label: 'Attach message to latest ticket (if available)',
1622
+ placeholder: 'Select...',
1623
+ info: 'If enabled, the message will be appended to the latest open ticket (if available) else a new ticket will be created',
1624
+ required: false,
1625
+ },
1626
+ priority: {
1627
+ id: 'priority',
1628
+ type: 'dropdown',
1629
+ value: [
1630
+ { id: '0', value: '0', label: 'No Priority' },
1631
+ { id: '1', value: '1', label: 'Low' },
1632
+ { id: '2', value: '2', label: 'Medium' },
1633
+ { id: '3', value: '3', label: 'High' },
1634
+ { id: '4', value: '4', label: 'Urgent' },
1635
+ ],
1636
+ label: 'Priority (New Ticket)',
1637
+ placeholder: 'Select priority',
1638
+ info: 'Only applicable for create ticket. If no priority is selected, the ticket will have no priority.',
1639
+ required: false,
1640
+ },
1641
+ label: {
1642
+ id: 'label',
1643
+ type: 'dropdown',
1644
+ value: 'ticket.labels',
1645
+ label: 'Label (New Ticket)',
1646
+ placeholder: 'Select label',
1647
+ info: 'Only applicable for create ticket. If no label is selected, the ticket will have no label.',
1648
+ required: false,
1649
+ },
1650
+ round_robin: {
1651
+ id: 'round_robin',
1652
+ type: 'dropdown',
1653
+ value: [
1654
+ { id: 'true', value: 'true', label: 'True' },
1655
+ { id: 'false', value: 'false', label: 'False' },
1656
+ ],
1657
+ label: 'Enable Round Robin (New Ticket: Assignee)',
1658
+ placeholder: 'Select...',
1659
+ info: 'If enabled, the ticket will be assigned to the next available agent in the list',
1660
+ required: false,
1661
+ },
1662
+ rr_check_for: {
1663
+ id: 'rr_check_for',
1664
+ type: 'dropdown',
1665
+ value: [
1666
+ {
1667
+ id: 'shift_time',
1668
+ value: 'shift_time',
1669
+ label: 'Consider shift timings',
1670
+ },
1671
+ {
1672
+ id: 'user_status',
1673
+ value: 'user_status',
1674
+ label: 'Exclude users manually marked as offline',
1675
+ },
1676
+ {
1677
+ id: 'user_status_offline',
1678
+ value: 'user_status_offline',
1679
+ label: 'Exclude users marked as offline or away',
1680
+ },
1681
+ {
1682
+ id: 'shift_time user_status',
1683
+ value: 'shift_time user_status',
1684
+ label:
1685
+ 'Consider both shift timings and user status (excludes only manually marked offline users)',
1686
+ },
1687
+ ],
1688
+ label: 'Check Assignee status for (Round Robin)',
1689
+ placeholder: 'Select...',
1690
+ info: 'Criteria for assigning the next available agent',
1691
+ required: false,
1692
+ },
1693
+ assignee: {
1694
+ id: 'assignee',
1695
+ type: 'dynamic',
1696
+ value: 'org.members',
1697
+ label: 'Assignee (New Ticket)',
1698
+ placeholder: 'Select assignee',
1699
+ 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",
1700
+ required: false,
1701
+ },
1702
+ },
1703
+ validTriggers: [
1704
+ 'message.created',
1705
+ 'message.updated',
1706
+ 'reaction.added',
1707
+ 'message.flagged',
1708
+ 'message.unflagged',
1709
+ 'task.created',
1710
+ 'task.assignee.updated',
1711
+ ],
1712
+ validate: () => true,
1713
+ },
1714
+ flag_message: {
1715
+ title: 'Update flag status',
1716
+ description: 'Flag/Unflag a message',
1717
+ inputs: {
1718
+ flag: {
1719
+ id: 'flag',
1720
+ type: 'dropdown',
1721
+ value: [
1722
+ { id: 'flag', value: 'true', label: 'True' },
1723
+ { id: 'unflag', value: 'false', label: 'False' },
1724
+ ],
1725
+ label: 'Flag status',
1726
+ placeholder: 'Select flag',
1727
+ required: true,
1728
+ },
1729
+ },
1730
+ validTriggers: [
1731
+ 'message.created',
1732
+ 'message.updated',
1733
+ 'reaction.added',
1734
+ 'message.flagged',
1735
+ 'message.unflagged',
1736
+ 'ticket.created',
1737
+ 'ticket.updated',
1738
+ 'ticket.closed',
1739
+ 'task.created',
1740
+ 'task.assignee.updated',
1741
+ 'ticket.label.updated'
1742
+ ],
1743
+ validate: () => true,
1744
+ },
1745
+ assign_ticket: {
1746
+ title: 'Assign Ticket',
1747
+ description: 'Assign a ticket',
1748
+ inputs: {
1749
+ round_robin: {
1750
+ id: 'round_robin',
1751
+ type: 'dropdown',
1752
+ value: [
1753
+ { id: 'true', value: 'true', label: 'True' },
1754
+ { id: 'false', value: 'false', label: 'False' },
1755
+ ],
1756
+ label: 'Enable Round Robin',
1757
+ placeholder: 'Select...',
1758
+ info: 'If enabled, the ticket will be assigned to the next available agent in the list',
1759
+ required: false,
1760
+ },
1761
+ rr_check_for: {
1762
+ id: 'rr_check_for',
1763
+ type: 'dropdown',
1764
+ value: [
1765
+ {
1766
+ id: 'shift_time',
1767
+ value: 'shift_time',
1768
+ label: 'Consider shift timings',
1769
+ },
1770
+ {
1771
+ id: 'user_status',
1772
+ value: 'user_status',
1773
+ label: 'Exclude users manually marked as offline',
1774
+ },
1775
+ {
1776
+ id: 'user_status_offline',
1777
+ value: 'user_status_offline',
1778
+ label: 'Exclude users marked as offline or away',
1779
+ },
1780
+ {
1781
+ id: 'shift_time user_status',
1782
+ value: 'shift_time user_status',
1783
+ label:
1784
+ 'Consider both shift timings and user status (excludes only manually marked offline users)',
1785
+ },
1786
+ ],
1787
+ label: 'Check Assignee status for (Round Robin)',
1788
+ placeholder: 'Select...',
1789
+ info: 'Criteria for assigning the next available agent',
1790
+ required: false,
1791
+ },
1792
+ assignee: {
1793
+ id: 'assignee',
1794
+ type: 'dynamic',
1795
+ value: 'org.members',
1796
+ label: 'Assignee',
1797
+ placeholder: 'Select assignee',
1798
+ 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",
1799
+ required: true,
1800
+ },
1801
+ },
1802
+ validTriggers: [
1803
+ 'ticket.updated',
1804
+ 'ticket.created',
1805
+ 'task.created',
1806
+ 'task.assignee.updated',
1807
+ 'ticket.label.updated'
1808
+ ],
1809
+ validate: () => true,
1810
+ },
1811
+ close_ticket: {
1812
+ title: 'Close Ticket',
1813
+ description: 'Close a ticket',
1814
+ info: "This action will close the ticket. This doesn't check for mandatory ticket custom properties.",
1815
+ inputs: {
1816
+ closing_note: {
1817
+ id: 'closing_note',
1818
+ type: 'textarea',
1819
+ label: 'Closing Note',
1820
+ placeholder: 'Enter closing note',
1821
+ value: null,
1822
+ required: false,
1823
+ },
1824
+ },
1825
+ validTriggers: [
1826
+ 'ticket.updated',
1827
+ 'ticket.created',
1828
+ 'reaction.added',
1829
+ 'message.unflagged',
1830
+ 'message.deleted',
1831
+ 'ticket.label.updated',
1832
+ ],
1833
+ validate: () => true,
1834
+ },
1835
+ add_chat_label: {
1836
+ title: 'Add Chat Label',
1837
+ description: 'Add a label to referred chat',
1838
+ inputs: {
1839
+ label: {
1840
+ id: 'label',
1841
+ type: 'dropdown',
1842
+ value: 'chat.labels',
1843
+ label: 'Label',
1844
+ placeholder: 'Select label',
1845
+ required: true,
1846
+ },
1847
+ },
1848
+ validTriggers: [
1849
+ 'message.created',
1850
+ 'message.updated',
1851
+ 'chat.created',
1852
+ 'ticket.updated',
1853
+ 'ticket.created',
1854
+ 'reaction.added',
1855
+ 'chat.label.updated',
1856
+ 'message.flagged',
1857
+ 'message.deleted',
1858
+ 'message.unflagged',
1859
+ 'ticket.closed',
1860
+ ],
1861
+ validate: () => true,
1862
+ },
1863
+ add_ticket_label: {
1864
+ title: 'Add Ticket Label',
1865
+ description: 'Add a label to referred ticket',
1866
+ inputs: {
1867
+ label: {
1868
+ id: 'label',
1869
+ type: 'dropdown',
1870
+ value: 'ticket.labels',
1871
+ label: 'Label',
1872
+ placeholder: 'Select label',
1873
+ required: true,
1874
+ },
1875
+ },
1876
+ validTriggers: ['ticket.updated', 'ticket.created', 'ticket.label.updated'],
1877
+ validate: () => true,
1878
+ },
1879
+ set_ticket_due_date: {
1880
+ title: 'Set Ticket Due Date',
1881
+ description: 'Set a due date for the ticket',
1882
+ info: 'This action will set a due date for the ticket. The due date will be set after the specified time from the current date and time of rule execution.',
1883
+ inputs: {
1884
+ due_date_option_time: {
1885
+ id: 'due_date_option_time',
1886
+ type: 'dynamic',
1887
+ label: 'Due After',
1888
+ placeholder: 'Enter time',
1889
+ value: 'custom_duration',
1890
+ required: true,
1891
+ },
1892
+ },
1893
+ validTriggers: [
1894
+ 'ticket.created',
1895
+ 'reaction.added',
1896
+ 'ticket.label.updated',
1897
+ 'ticket.closed',
1898
+ ],
1899
+ validate: () => true,
1900
+ },
1901
+ update_custom_property: {
1902
+ description: 'Update a chat custom property',
1903
+ title: 'Update Chat Custom Property',
1904
+ validTriggers: [
1905
+ 'message.created',
1906
+ 'message.updated',
1907
+ 'chat.created',
1908
+ 'ticket.updated',
1909
+ 'ticket.created',
1910
+ 'reaction.added',
1911
+ 'message.flagged',
1912
+ 'chat.label.updated',
1913
+ 'message.deleted',
1914
+ 'message.unflagged',
1915
+ 'ticket.closed',
1916
+ 'ticket.label.updated'
1917
+ ],
1918
+ inputs: {
1919
+ property_id: {
1920
+ id: 'property_id',
1921
+ type: 'dropdown',
1922
+ value: 'org.custom_properties',
1923
+ label: 'Property',
1924
+ placeholder: 'Select property',
1925
+ required: true,
1926
+ },
1927
+ value: {
1928
+ id: 'property_id',
1929
+ type: 'dynamic',
1930
+ label: 'Value',
1931
+ placeholder: 'Enter value',
1932
+ value: 'custom_property_values',
1933
+ required: true,
1934
+ },
1935
+ },
1936
+ validate: () => true,
1937
+ },
1938
+ assign_chat: {
1939
+ title: 'Assign Chat',
1940
+ description: 'Assign a chat',
1941
+ inputs: {
1942
+ round_robin: {
1943
+ id: 'round_robin',
1944
+ type: 'dropdown',
1945
+ value: [
1946
+ { id: 'true', value: 'true', label: 'True' },
1947
+ { id: 'false', value: 'false', label: 'False' },
1948
+ ],
1949
+ label: 'Enable Round Robin',
1950
+ placeholder: 'Select...',
1951
+ info: 'If enabled, the chat will be assigned to the next available agent in the list',
1952
+ required: false,
1953
+ },
1954
+ rr_check_for: {
1955
+ id: 'rr_check_for',
1956
+ type: 'dropdown',
1957
+ value: [
1958
+ {
1959
+ id: 'shift_time',
1960
+ value: 'shift_time',
1961
+ label: 'Consider shift timings',
1962
+ },
1963
+ {
1964
+ id: 'user_status',
1965
+ value: 'user_status',
1966
+ label: 'Exclude users manually marked as offline',
1967
+ },
1968
+ {
1969
+ id: 'user_status_offline',
1970
+ value: 'user_status_offline',
1971
+ label: 'Exclude users marked as offline or away',
1972
+ },
1973
+ {
1974
+ id: 'shift_time user_status',
1975
+ value: 'shift_time user_status',
1976
+ label:
1977
+ 'Consider both shift timings and user status (excludes only manually marked offline users)',
1978
+ },
1979
+ ],
1980
+ label: 'Check Assignee status for (Round Robin)',
1981
+ placeholder: 'Select...',
1982
+ info: 'Criteria for assigning the next available agent',
1983
+ required: false,
1984
+ },
1985
+ assignee: {
1986
+ id: 'assignee',
1987
+ type: 'dynamic',
1988
+ value: 'org.members',
1989
+ label: 'Assignee',
1990
+ placeholder: 'Select assignee',
1991
+ required: true,
1992
+ },
1993
+ },
1994
+ validTriggers: [
1995
+ 'message.created',
1996
+ 'message.updated',
1997
+ 'chat.created',
1998
+ 'ticket.updated',
1999
+ 'ticket.created',
2000
+ 'reaction.added',
2001
+ 'chat.label.updated',
2002
+ 'message.flagged',
2003
+ 'message.deleted',
2004
+ 'message.unflagged',
2005
+ 'ticket.closed',
2006
+ 'task.created',
2007
+ 'task.assignee.updated',
2008
+ 'ticket.label.updated'
2009
+ ],
2010
+ validate: () => true,
2011
+ },
2012
+ close_chat: {
2013
+ title: 'Close Chat',
2014
+ description: 'Close a chat conversation',
2015
+ inputs: {},
2016
+ validTriggers: [
2017
+ 'message.created',
2018
+ 'message.updated',
2019
+ 'chat.created',
2020
+ 'ticket.updated',
2021
+ 'ticket.created',
2022
+ 'reaction.added',
2023
+ 'chat.label.updated',
2024
+ 'message.flagged',
2025
+ 'message.unflagged',
2026
+ 'message.deleted',
2027
+ 'ticket.closed',
2028
+ 'ticket.label.updated'
2029
+ ],
2030
+ validate: () => true,
2031
+ },
2032
+ forward_message: {
2033
+ title: 'Forward Message',
2034
+ description: 'Forward a message',
2035
+ inputs: {
2036
+ chat_id: {
2037
+ id: 'chat_id',
2038
+ type: 'dropdown',
2039
+ value: 'org.chats',
2040
+ label: 'Chat',
2041
+ placeholder: 'Select chat',
2042
+ required: true,
2043
+ },
2044
+ },
2045
+ info: 'Forward a message to a specified chat. Only applicable if message is present.',
2046
+ validTriggers: [
2047
+ 'message.created',
2048
+ 'message.updated',
2049
+ 'ticket.updated',
2050
+ 'ticket.created',
2051
+ 'reaction.added',
2052
+ 'message.unflagged',
2053
+ 'message.flagged',
2054
+ 'ticket.closed',
2055
+ 'ticket.label.updated',
2056
+ 'task.created',
2057
+ 'task.assignee.updated',
2058
+ ],
2059
+ validate: () => true,
2060
+ },
2061
+ send_email: {
2062
+ title: 'Send Email',
2063
+ description: 'Send an email',
2064
+ inputs: {
2065
+ email: {
2066
+ id: 'email',
2067
+ type: 'text',
2068
+ label: 'Email',
2069
+ placeholder: 'Enter email',
2070
+ value: null,
2071
+ required: true,
2072
+ },
2073
+ subject: {
2074
+ id: 'subject',
2075
+ type: 'editor',
2076
+ label: 'Subject',
2077
+ placeholder: 'Enter subject',
2078
+ value: null,
2079
+ required: true,
2080
+ },
2081
+ body: {
2082
+ id: 'body',
2083
+ type: 'editor',
2084
+ label: 'Body',
2085
+ placeholder: 'Enter body',
2086
+ value: null,
2087
+ required: true,
2088
+ },
2089
+ },
2090
+ validTriggers: [
2091
+ 'message.created',
2092
+ 'message.updated',
2093
+ 'chat.created',
2094
+ 'ticket.updated',
2095
+ 'ticket.created',
2096
+ 'reaction.added',
2097
+ 'message.flagged',
2098
+ 'message.unflagged',
2099
+ 'chat.label.updated',
2100
+ 'message.deleted',
2101
+ 'ticket.closed',
2102
+ 'task.created',
2103
+ 'task.assignee.updated',
2104
+ 'ticket.label.updated',
2105
+ ],
2106
+ validate: () => true,
2107
+ },
2108
+ send_slack_notification: {
2109
+ title: 'Send Slack Webhook Notification',
2110
+ description: 'Send a slack webhook notification to a channel',
2111
+ validTriggers: [
2112
+ 'message.created',
2113
+ 'message.updated',
2114
+ 'chat.created',
2115
+ 'ticket.updated',
2116
+ 'ticket.created',
2117
+ 'reaction.added',
2118
+ 'message.flagged',
2119
+ 'message.unflagged',
2120
+ 'chat.label.updated',
2121
+ 'message.deleted',
2122
+ 'ticket.closed',
2123
+ 'ticket.label.updated',
2124
+ 'task.created',
2125
+ 'task.assignee.updated',
2126
+ ],
2127
+ inputs: {
2128
+ webhook_url: {
2129
+ type: 'text',
2130
+ id: 'webhook_url',
2131
+ label: 'Webhook URL',
2132
+ placeholder: 'Enter webhook URL',
2133
+ value: null,
2134
+ required: true,
2135
+ description:
2136
+ '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)',
2137
+ },
2138
+ slack_payload: {
2139
+ type: 'json_editor',
2140
+ id: 'slack_payload',
2141
+ label: 'Slack Notification Payload',
2142
+ placeholder: 'Enter payload',
2143
+ value: null,
2144
+ required: true,
2145
+ description:
2146
+ '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)',
2147
+ },
2148
+ },
2149
+ validate: () => true,
2150
+ },
2151
+ send_message_to_chat: {
2152
+ title: 'Send Message To Chat',
2153
+ description: 'Send a message to a specified chat',
2154
+ inputs: {
2155
+ chat_id: {
2156
+ id: 'chat_id',
2157
+ type: 'dropdown',
2158
+ value: 'org.chats',
2159
+ label: 'Chat',
2160
+ placeholder: 'Select chat',
2161
+ required: true,
2162
+ },
2163
+ message: {
2164
+ id: 'message',
2165
+ type: 'editor',
2166
+ label: 'Message',
2167
+ placeholder: 'Enter message',
2168
+ value: null,
2169
+ required: true,
2170
+ },
2171
+ media: {
2172
+ id: 'media',
2173
+ type: 'file',
2174
+ label: 'Media',
2175
+ placeholder: 'Upload media',
2176
+ value: null,
2177
+ required: false,
2178
+ },
2179
+ },
2180
+ validTriggers: [
2181
+ 'message.created',
2182
+ 'message.updated',
2183
+ 'chat.created',
2184
+ 'ticket.updated',
2185
+ 'ticket.created',
2186
+ 'reaction.added',
2187
+ 'message.flagged',
2188
+ 'message.unflagged',
2189
+ 'chat.label.updated',
2190
+ 'message.deleted',
2191
+ 'ticket.closed',
2192
+ 'ticket.label.updated',
2193
+ 'task.created',
2194
+ 'task.assignee.updated',
2195
+ ],
2196
+ validate: () => true,
2197
+ },
2198
+ create_ticket_on_freshdesk: {
2199
+ title: 'Create Ticket On Freshdesk',
2200
+ description: 'Create a ticket on Freshdesk',
2201
+ info: 'This action will create a ticket on Freshdesk. Please make sure you have a Freshdesk integration setup.',
2202
+ inputs: {},
2203
+ validTriggers: ['ticket.created'],
2204
+ validate: (org, rule) => {
2205
+ return (
2206
+ org.is_freshdesk_connected ||
2207
+ rule.actions.some((a) => a.type === 'create_ticket_on_freshdesk')
2208
+ );
2209
+ },
2210
+ },
2211
+ create_ticket_on_hubspot: {
2212
+ title: 'Create Ticket On Hubspot',
2213
+ description: 'Create a ticket on Hubspot',
2214
+ info: 'This action will create a ticket on Hubspot. Please make sure you have a Hubspot integration setup.',
2215
+ inputs: {},
2216
+ validTriggers: ['ticket.created'],
2217
+ validate: (org, rule) => {
2218
+ return (
2219
+ org.is_hubspot_connected ||
2220
+ rule.actions.some((a) => a.type === 'create_ticket_on_hubspot')
2221
+ );
2222
+ },
2223
+ },
2224
+ create_ticket_on_zohodesk: {
2225
+ title: 'Create Ticket On Zohodesk',
2226
+ description: 'Create a ticket on Zohodesk',
2227
+ info: 'This action will create a ticket on Zohodesk. Please make sure you have a Zohodesk integration setup.',
2228
+ inputs: {},
2229
+ validTriggers: ['ticket.created'],
2230
+ validate: (org, rule) => {
2231
+ return (
2232
+ org.is_zohodesk_connected ||
2233
+ rule.actions.some((a) => a.type === 'create_ticket_on_zohodesk')
2234
+ );
2235
+ },
2236
+ },
2237
+ };
2238
+
2239
+ type editorVariablesList =
2240
+ | 'chat.assigned_to'
2241
+ | 'chat.chat_id'
2242
+ | 'chat.chat_name'
2243
+ | 'chat.chat_type'
2244
+ | 'chat.org_phone'
2245
+ | 'chat.org_id'
2246
+ | 'chat.group_description'
2247
+ | 'ticket.assignee'
2248
+ | 'ticket.due_date'
2249
+ | 'ticket.priority'
2250
+ | 'ticket.status'
2251
+ | 'ticket.subject'
2252
+ | 'ticket.ticket_id'
2253
+ | 'ticket.raised_by'
2254
+ | 'ticket.created_at'
2255
+ | 'sender.is_internal'
2256
+ | 'sender.is_admin'
2257
+ | 'sender.contact_name'
2258
+ | 'sender.contact_id'
2259
+ | 'reaction.sender_id'
2260
+ | 'reaction.reaction'
2261
+ | 'message.message_id'
2262
+ | 'message.timestamp'
2263
+ | 'message.sender_phone'
2264
+ | 'message.message_type'
2265
+ | 'message.media'
2266
+ | 'message.body'
2267
+ | 'task.title'
2268
+ | 'task.assignee'
2269
+ | 'task.due_date'
2270
+ | 'task.task_id'
2271
+ | 'task.notes';
2272
+
2273
+ export const editorVariables: Array<{
2274
+ label: string;
2275
+ value: editorVariablesList;
2276
+ validTriggers: Rule['trigger'][];
2277
+ }> = [
2278
+ {
2279
+ label: 'Ticket ID',
2280
+ value: 'ticket.ticket_id',
2281
+ validTriggers: ['ticket.updated', 'ticket.created', 'ticket.closed'],
2282
+ },
2283
+ {
2284
+ value: 'ticket.assignee',
2285
+ label: 'Ticket Assignee',
2286
+ validTriggers: ['ticket.updated', 'ticket.created', 'ticket.closed'],
2287
+ },
2288
+ {
2289
+ value: 'ticket.due_date',
2290
+ label: 'Ticket Due Date',
2291
+ validTriggers: ['ticket.updated', 'ticket.created', 'ticket.closed'],
2292
+ },
2293
+ {
2294
+ value: 'ticket.priority',
2295
+ label: 'Ticket Priority',
2296
+ validTriggers: ['ticket.updated', 'ticket.created', 'ticket.closed'],
2297
+ },
2298
+ {
2299
+ value: 'ticket.status',
2300
+ label: 'Ticket Status',
2301
+ validTriggers: ['ticket.updated', 'ticket.created', 'ticket.closed'],
2302
+ },
2303
+ {
2304
+ value: 'ticket.subject',
2305
+ label: 'Ticket Subject',
2306
+ validTriggers: ['ticket.updated', 'ticket.created', 'ticket.closed'],
2307
+ },
2308
+ {
2309
+ label: 'Message Body',
2310
+ value: 'message.body',
2311
+ validTriggers: [
2312
+ 'message.created',
2313
+ 'message.updated',
2314
+ 'reaction.added',
2315
+ 'message.flagged',
2316
+ 'ticket.created',
2317
+ 'ticket.updated',
2318
+ 'ticket.closed',
2319
+ 'message.deleted',
2320
+ 'task.created',
2321
+ 'task.assignee.updated',
2322
+ ],
2323
+ },
2324
+ {
2325
+ value: 'message.media',
2326
+ label: 'Message Media',
2327
+ validTriggers: [
2328
+ 'message.created',
2329
+ 'message.updated',
2330
+ 'reaction.added',
2331
+ 'message.flagged',
2332
+ 'ticket.created',
2333
+ 'ticket.updated',
2334
+ 'ticket.closed',
2335
+ 'message.deleted',
2336
+ ],
2337
+ },
2338
+ {
2339
+ value: 'message.message_id',
2340
+ label: 'Message ID',
2341
+ validTriggers: [
2342
+ 'message.created',
2343
+ 'message.updated',
2344
+ 'reaction.added',
2345
+ 'message.flagged',
2346
+ 'ticket.created',
2347
+ 'ticket.updated',
2348
+ 'ticket.closed',
2349
+ 'message.deleted',
2350
+ ],
2351
+ },
2352
+ {
2353
+ value: 'message.message_type',
2354
+ label: 'Message Type',
2355
+ validTriggers: [
2356
+ 'message.created',
2357
+ 'message.updated',
2358
+ 'reaction.added',
2359
+ 'message.flagged',
2360
+ 'ticket.created',
2361
+ 'ticket.updated',
2362
+ 'ticket.closed',
2363
+ 'message.deleted',
2364
+ 'task.created',
2365
+ 'task.assignee.updated',
2366
+ ],
2367
+ },
2368
+ {
2369
+ value: 'message.sender_phone',
2370
+ label: 'Sender Phone',
2371
+ validTriggers: [
2372
+ 'message.created',
2373
+ 'message.updated',
2374
+ 'reaction.added',
2375
+ 'message.flagged',
2376
+ 'ticket.created',
2377
+ 'ticket.updated',
2378
+ 'ticket.closed',
2379
+ 'message.deleted',
2380
+ ],
2381
+ },
2382
+ {
2383
+ value: 'message.timestamp',
2384
+ label: 'Message Timestamp',
2385
+ validTriggers: [
2386
+ 'message.created',
2387
+ 'message.updated',
2388
+ 'reaction.added',
2389
+ 'message.flagged',
2390
+ 'ticket.created',
2391
+ 'ticket.updated',
2392
+ 'ticket.closed',
2393
+ 'message.deleted',
2394
+ 'task.created',
2395
+ 'task.assignee.updated',
2396
+ ],
2397
+ },
2398
+ {
2399
+ value: 'sender.contact_name',
2400
+ label: 'Sender Name',
2401
+ validTriggers: [
2402
+ 'message.created',
2403
+ 'message.updated',
2404
+ 'reaction.added',
2405
+ 'message.flagged',
2406
+ 'ticket.created',
2407
+ 'ticket.updated',
2408
+ 'ticket.closed',
2409
+ 'message.deleted',
2410
+ 'task.created',
2411
+ 'task.assignee.updated',
2412
+ ],
2413
+ },
2414
+ {
2415
+ value: 'sender.is_admin',
2416
+ label: 'Sender Is Admin',
2417
+ validTriggers: [
2418
+ 'message.created',
2419
+ 'message.updated',
2420
+ 'reaction.added',
2421
+ 'message.flagged',
2422
+ 'ticket.created',
2423
+ 'ticket.updated',
2424
+ 'ticket.closed',
2425
+ 'message.deleted',
2426
+ 'task.created',
2427
+ 'task.assignee.updated',
2428
+ ],
2429
+ },
2430
+ {
2431
+ value: 'sender.is_internal',
2432
+ label: 'Sender Is Internal',
2433
+ validTriggers: [
2434
+ 'message.created',
2435
+ 'message.updated',
2436
+ 'reaction.added',
2437
+ 'message.flagged',
2438
+ 'ticket.created',
2439
+ 'ticket.updated',
2440
+ 'ticket.closed',
2441
+ 'message.deleted',
2442
+ 'task.created',
2443
+ 'task.assignee.updated',
2444
+ ],
2445
+ },
2446
+ {
2447
+ value: 'reaction.reaction',
2448
+ label: 'Reaction',
2449
+ validTriggers: ['reaction.added'],
2450
+ },
2451
+ {
2452
+ value: 'reaction.sender_id',
2453
+ label: 'Reaction Sender Phone',
2454
+ validTriggers: ['reaction.added'],
2455
+ },
2456
+ {
2457
+ label: 'Chat Name',
2458
+ value: 'chat.chat_name',
2459
+ validTriggers: [
2460
+ 'message.created',
2461
+ 'message.updated',
2462
+ 'reaction.added',
2463
+ 'message.flagged',
2464
+ 'chat.created',
2465
+ 'chat.label.updated',
2466
+ 'ticket.created',
2467
+ 'ticket.updated',
2468
+ 'ticket.closed',
2469
+ 'message.deleted',
2470
+ 'task.created',
2471
+ 'task.assignee.updated',
2472
+ ],
2473
+ },
2474
+ {
2475
+ value: 'chat.assigned_to',
2476
+ label: 'Chat Assigned To',
2477
+ validTriggers: [
2478
+ 'message.created',
2479
+ 'message.updated',
2480
+ 'reaction.added',
2481
+ 'message.flagged',
2482
+ 'chat.created',
2483
+ 'chat.label.updated',
2484
+ 'ticket.created',
2485
+ 'ticket.updated',
2486
+ 'ticket.closed',
2487
+ 'message.deleted',
2488
+ 'task.created',
2489
+ 'task.assignee.updated',
2490
+ ],
2491
+ },
2492
+ {
2493
+ value: 'chat.chat_id',
2494
+ label: 'Chat ID',
2495
+ validTriggers: [
2496
+ 'message.created',
2497
+ 'message.updated',
2498
+ 'reaction.added',
2499
+ 'message.flagged',
2500
+ 'chat.created',
2501
+ 'chat.label.updated',
2502
+ 'ticket.created',
2503
+ 'ticket.updated',
2504
+ 'ticket.closed',
2505
+ 'message.deleted',
2506
+ 'task.created',
2507
+ 'task.assignee.updated',
2508
+ ],
2509
+ },
2510
+ {
2511
+ value: 'chat.chat_type',
2512
+ label: 'Chat Type',
2513
+ validTriggers: [
2514
+ 'message.created',
2515
+ 'message.updated',
2516
+ 'reaction.added',
2517
+ 'message.flagged',
2518
+ 'chat.created',
2519
+ 'chat.label.updated',
2520
+ 'ticket.created',
2521
+ 'ticket.updated',
2522
+ 'ticket.closed',
2523
+ 'message.deleted',
2524
+ 'task.created',
2525
+ 'task.assignee.updated',
2526
+ ],
2527
+ },
2528
+ {
2529
+ value: 'chat.org_id',
2530
+ label: 'Chat Org ID',
2531
+ validTriggers: [
2532
+ 'message.created',
2533
+ 'message.updated',
2534
+ 'reaction.added',
2535
+ 'message.flagged',
2536
+ 'chat.created',
2537
+ 'chat.label.updated',
2538
+ 'ticket.created',
2539
+ 'ticket.updated',
2540
+ 'ticket.closed',
2541
+ 'message.deleted',
2542
+ 'task.created',
2543
+ 'task.assignee.updated',
2544
+ ],
2545
+ },
2546
+ {
2547
+ value: 'chat.org_phone',
2548
+ label: 'Chat Org Phone',
2549
+ validTriggers: [
2550
+ 'message.created',
2551
+ 'message.updated',
2552
+ 'reaction.added',
2553
+ 'message.flagged',
2554
+ 'chat.created',
2555
+ 'chat.label.updated',
2556
+ 'ticket.created',
2557
+ 'ticket.updated',
2558
+ 'ticket.closed',
2559
+ 'message.deleted',
2560
+ 'task.created',
2561
+ 'task.assignee.updated',
2562
+ ],
2563
+ },
2564
+ {
2565
+ value: 'task.title',
2566
+ label: 'Task Title',
2567
+ validTriggers: ['task.created', 'task.assignee.updated'],
2568
+ },
2569
+ {
2570
+ value: 'task.assignee',
2571
+ label: 'Task Assignee',
2572
+ validTriggers: ['task.created', 'task.assignee.updated'],
2573
+ },
2574
+ {
2575
+ value: 'task.due_date',
2576
+ label: 'Task Due Date',
2577
+ validTriggers: ['task.created', 'task.assignee.updated'],
2578
+ },
2579
+ {
2580
+ value: 'task.task_id',
2581
+ label: 'Task ID',
2582
+ validTriggers: ['task.created', 'task.assignee.updated'],
2583
+ },
2584
+ {
2585
+ value: 'task.notes',
2586
+ label: 'Task Notes',
2587
+ validTriggers: ['task.created', 'task.assignee.updated'],
2588
+ },
2589
+ ];
2590
+
2591
+ export const variablesExclusionList: Record<
2592
+ Rule['trigger'],
2593
+ Array<
2594
+ | keyof AppendTypes<{ message: MessageVariablesType }, '.'>
2595
+ | keyof AppendTypes<{ sender: SenderVariablesType }, '.'>
2596
+ | keyof AppendTypes<{ chat: ChatVariablesType }, '.'>
2597
+ | keyof AppendTypes<{ ticket: TicketVariablesType }, '.'>
2598
+ | keyof AppendTypes<{ reaction: ReactionVariablesType }, '.'>
2599
+ | keyof AppendTypes<{ task: TaskVariablesType }, '.'>
2600
+ >
2601
+ > = {
2602
+ 'ticket.created': ['ticket.is_deleted'],
2603
+ 'chat.created': [
2604
+ 'chat.labels',
2605
+ 'chat.has_flagged_messages',
2606
+ 'chat.assigned_to',
2607
+ ],
2608
+ 'message.created': [
2609
+ 'message.author',
2610
+ 'message.performed_by',
2611
+ 'message.flag_status',
2612
+ 'sender.is_internal',
2613
+ ],
2614
+ 'ticket.updated': ['ticket.is_deleted'],
2615
+ "ticket.label.updated": ['ticket.is_deleted'],
2616
+ 'reaction.added': [],
2617
+ 'message.updated': [],
2618
+ 'message.flagged': [],
2619
+ 'message.unflagged': [],
2620
+ 'message.deleted': [],
2621
+ 'ticket.closed': ['ticket.is_deleted'],
2622
+ 'chat.label.updated': [],
2623
+ 'task.created': [],
2624
+ 'task.assignee.updated': [],
2625
+ };