@periskope/types 0.6.12 → 0.6.13-7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/rules.types.ts ADDED
@@ -0,0 +1,1103 @@
1
+ import { Merge, OverrideProperties } from 'type-fest';
2
+ import { Tables } from './supabase.types';
3
+
4
+ export type AppendTypes<T extends object, O extends string> = {
5
+ [K in keyof T & string as `${K}${O}${keyof T[K] & string}`]: T[K][keyof T[K]];
6
+ };
7
+
8
+ export type TicketVariablesType = Merge<
9
+ Pick<
10
+ Tables<'tbl_chat_tickets'>,
11
+ | 'assigned_by'
12
+ | 'assignee'
13
+ | 'status'
14
+ | 'subject'
15
+ | 'is_deleted'
16
+ | 'priority'
17
+ | 'raised_by'
18
+ | 'due_date'
19
+ | 'ticket_id'
20
+ >,
21
+ {
22
+ labels: string[];
23
+ }
24
+ >;
25
+
26
+ export type MessageVariablesType = Pick<
27
+ Tables<'tbl_chat_messages'>,
28
+ | 'body'
29
+ | 'sender_phone'
30
+ | 'timestamp'
31
+ | 'flag_status'
32
+ | 'has_quoted_msg'
33
+ | 'media'
34
+ | 'performed_by'
35
+ | 'message_id'
36
+ | 'chat_id'
37
+ >;
38
+
39
+ export type SenderVariablesType = Merge<
40
+ Pick<
41
+ Tables<'tbl_contacts'>,
42
+ | 'is_business'
43
+ | 'is_enterprise'
44
+ | 'is_internal'
45
+ | 'contact_name'
46
+ | 'contact_id'
47
+ >,
48
+ {
49
+ labels: string[];
50
+ }
51
+ >;
52
+
53
+ export type ReactionVariablesType = Pick<
54
+ Tables<'tbl_chat_reactions'>,
55
+ 'reaction' | 'sender_id' | 'reaction_id' | 'message_id' | 'chat_id'
56
+ >;
57
+
58
+ export type ChatVariablesType = Merge<
59
+ Pick<
60
+ Tables<'view_chats'>,
61
+ 'assigned_to' | 'chat_name' | 'org_phone' | 'chat_type' | 'chat_id'
62
+ >,
63
+ {
64
+ members: string[];
65
+ labels: string[];
66
+ }
67
+ >;
68
+
69
+ export type MessageRulesInfoType = Merge<
70
+ AppendTypes<
71
+ {
72
+ message: MessageVariablesType;
73
+ sender: SenderVariablesType;
74
+ chat: ChatVariablesType;
75
+ },
76
+ '.'
77
+ >,
78
+ {
79
+ rule: Tables<'tbl_automation_rules'>[];
80
+ id: 'message.message_id';
81
+ type: `message.${'created' | 'updated' | 'flagged'}`;
82
+ org_id: string;
83
+ }
84
+ >;
85
+
86
+ export type TicketRulesInfoType = Merge<
87
+ AppendTypes<
88
+ {
89
+ ticket: TicketVariablesType;
90
+ message: MessageVariablesType;
91
+ sender: SenderVariablesType;
92
+ chat: ChatVariablesType;
93
+ },
94
+ '.'
95
+ >,
96
+ {
97
+ id: 'ticket.ticket_id';
98
+ type: `ticket.${'created' | 'updated'}`;
99
+ org_id: string;
100
+ rule: Tables<'tbl_automation_rules'>[];
101
+ }
102
+ >;
103
+
104
+ export type ReactionRulesInfoType = Merge<
105
+ AppendTypes<
106
+ {
107
+ reaction: ReactionVariablesType;
108
+ message: MessageVariablesType;
109
+ sender: SenderVariablesType;
110
+ ticket: TicketVariablesType;
111
+ chat: ChatVariablesType;
112
+ },
113
+ '.'
114
+ >,
115
+ {
116
+ rule: Tables<'tbl_automation_rules'>[];
117
+ id: 'reaction.reaction_id';
118
+ type: `reaction.${'created' | 'updated'}`;
119
+ org_id: string;
120
+ }
121
+ >;
122
+
123
+ export type ChatRulesInfoType = Merge<
124
+ AppendTypes<
125
+ {
126
+ chat: ChatVariablesType;
127
+ message: MessageVariablesType;
128
+ sender: SenderVariablesType;
129
+ },
130
+ '.'
131
+ >,
132
+ {
133
+ rule: Tables<'tbl_automation_rules'>[];
134
+ id: 'chat.chat_id';
135
+ type: 'chat.created' | 'chat.label.updated';
136
+ org_id: string;
137
+ }
138
+ >;
139
+
140
+ export type RuleInfoType =
141
+ | MessageRulesInfoType
142
+ | ChatRulesInfoType
143
+ | TicketRulesInfoType
144
+ | ReactionRulesInfoType;
145
+
146
+ export interface Filter {
147
+ id: string;
148
+ condition:
149
+ | 'CONTAINS'
150
+ | 'NCONTAINS'
151
+ | 'EQ'
152
+ | 'NEQ'
153
+ | 'LT'
154
+ | 'LTE'
155
+ | 'GT'
156
+ | 'GTE'
157
+ | 'KNOWN'
158
+ | 'NKNOWN'
159
+ | 'IS'
160
+ | 'NIS'; // Add other condition types as needed
161
+ variable: string;
162
+ value: string | string[];
163
+ variable_type?: 'string' | 'date'; // Optional, like 'Date'
164
+ }
165
+
166
+ export const isFilter = (filter: any): filter is Filter => {
167
+ return (
168
+ typeof filter === 'object' &&
169
+ 'id' in filter &&
170
+ 'condition' in filter &&
171
+ 'variable' in filter &&
172
+ 'value' in filter
173
+ );
174
+ };
175
+
176
+ export const FilterNameMap: Record<
177
+ Filter['condition'],
178
+ {
179
+ name: string;
180
+ input: boolean;
181
+ }
182
+ > = {
183
+ CONTAINS: {
184
+ name: 'contains',
185
+ input: true,
186
+ },
187
+ NCONTAINS: {
188
+ name: 'does not contain',
189
+ input: true,
190
+ },
191
+ EQ: {
192
+ name: 'equals to',
193
+ input: true,
194
+ },
195
+ NEQ: {
196
+ name: 'not equals to',
197
+ input: true,
198
+ },
199
+ LT: {
200
+ name: 'less than',
201
+ input: true,
202
+ },
203
+ LTE: {
204
+ name: 'less than or equals to',
205
+ input: true,
206
+ },
207
+ GT: {
208
+ name: 'greater than',
209
+ input: true,
210
+ },
211
+ GTE: {
212
+ name: 'greater than or equals to',
213
+ input: true,
214
+ },
215
+ KNOWN: {
216
+ name: 'is known',
217
+ input: false,
218
+ },
219
+ NKNOWN: {
220
+ name: 'is not known',
221
+ input: false,
222
+ },
223
+ IS: {
224
+ name: 'is',
225
+ input: true,
226
+ },
227
+ NIS: {
228
+ name: 'is not',
229
+ input: true,
230
+ },
231
+ };
232
+
233
+ export type VariableNameValueType = {
234
+ text: string;
235
+ type: 'string' | 'date' | 'boolean' | 'dropdown';
236
+ value?:
237
+ | string
238
+ | {
239
+ id: string;
240
+ value: string;
241
+ label: string;
242
+ }[]
243
+ | null;
244
+ filters: Filter['condition'][];
245
+ hidden?: boolean;
246
+ };
247
+
248
+ export const MessageVariableNameMap: Record<
249
+ keyof AppendTypes<{ message: MessageVariablesType }, '.'>,
250
+ VariableNameValueType
251
+ > = {
252
+ 'message.body': {
253
+ text: 'Message Body',
254
+ type: 'string',
255
+ filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
256
+ },
257
+ 'message.sender_phone': {
258
+ text: 'Message Sender Phone',
259
+ type: 'string',
260
+ filters: ['EQ', 'NEQ'],
261
+ },
262
+ 'message.timestamp': {
263
+ text: 'Message Timestamp',
264
+ type: 'date',
265
+ filters: ['LT', 'LTE', 'GT', 'GTE', 'IS'],
266
+ },
267
+ 'message.flag_status': {
268
+ text: 'Message Flag Status',
269
+ filters: ['IS'],
270
+ type: 'boolean',
271
+ },
272
+ 'message.has_quoted_msg': {
273
+ text: 'Quoted Message',
274
+ filters: ['IS'],
275
+ type: 'boolean',
276
+ },
277
+ 'message.media': {
278
+ text: 'Message Media',
279
+ type: 'boolean',
280
+ filters: ['KNOWN', 'NKNOWN'],
281
+ },
282
+ 'message.performed_by': {
283
+ text: 'Message Performed By',
284
+ type: 'dropdown',
285
+ value: 'org.members',
286
+ filters: ['EQ', 'NEQ'],
287
+ },
288
+ "message.chat_id":{
289
+ text: 'Chat ID',
290
+ type: 'string',
291
+ filters: ['EQ', 'NEQ'],
292
+ hidden: true
293
+ },
294
+ "message.message_id":{
295
+ text: 'Message ID',
296
+ type: 'string',
297
+ filters: ['EQ', 'NEQ'],
298
+ hidden: true
299
+ }
300
+ };
301
+
302
+ export const SenderVariableNameMap: Record<
303
+ keyof AppendTypes<{ sender: SenderVariablesType }, '.'>,
304
+ VariableNameValueType
305
+ > = {
306
+ 'sender.is_business': {
307
+ // remove
308
+ text: 'Sender is business',
309
+ type: 'boolean',
310
+ filters: ['IS'],
311
+ },
312
+ 'sender.is_enterprise': {
313
+ // remove
314
+ text: 'Sender is enterprise',
315
+ type: 'boolean',
316
+ filters: ['IS'],
317
+ },
318
+ 'sender.is_internal': {
319
+ text: 'Sender is internal',
320
+ type: 'boolean',
321
+ filters: ['IS'],
322
+ },
323
+ 'sender.contact_name': {
324
+ text: 'Sender Name',
325
+ type: 'string',
326
+ filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
327
+ },
328
+ 'sender.contact_id': {
329
+ text: 'Sender Contact Phone',
330
+ type: 'string',
331
+ filters: ['EQ', 'NEQ'],
332
+ },
333
+ 'sender.labels': {
334
+ text: 'Sender Labels',
335
+ type: 'dropdown',
336
+ value: 'org.labels',
337
+ filters: ['EQ', 'NEQ'],
338
+ },
339
+ };
340
+
341
+ export const ChatVariableNameMap: Record<
342
+ keyof AppendTypes<{ chat: ChatVariablesType }, '.'>,
343
+ VariableNameValueType
344
+ > = {
345
+ 'chat.assigned_to': {
346
+ text: 'Chat Assignee',
347
+ type: 'dropdown',
348
+ value: 'org.members',
349
+ filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
350
+ },
351
+ 'chat.chat_name': {
352
+ text: 'Chat Name',
353
+ type: 'string',
354
+ filters: ['EQ', 'NEQ'],
355
+ },
356
+ 'chat.org_phone': {
357
+ text: 'Chat Org Phone',
358
+ type: 'string',
359
+ filters: ['EQ', 'NEQ'],
360
+ },
361
+ 'chat.chat_type': {
362
+ text: 'Chat Type',
363
+ type: 'dropdown',
364
+ value: [
365
+ { id: 'user', value: 'user', label: 'User' },
366
+ { id: 'group', value: 'group', label: 'Group' },
367
+ ],
368
+ filters: ['EQ', 'NEQ'],
369
+ },
370
+ 'chat.members': {
371
+ text: 'Chat Members',
372
+ type: 'string',
373
+ filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
374
+ },
375
+ 'chat.labels': {
376
+ text: 'Chat Labels',
377
+ type: 'dropdown',
378
+ value: 'org.labels',
379
+ filters: ['CONTAINS', 'NCONTAINS'],
380
+ },
381
+ "chat.chat_id": {
382
+ text: 'Chat ID',
383
+ type: 'string',
384
+ filters: ['EQ', 'NEQ'],
385
+ hidden: true
386
+ }
387
+ };
388
+
389
+ export const TicketVariableNameMap: Record<
390
+ keyof AppendTypes<{ ticket: TicketVariablesType }, '.'>,
391
+ VariableNameValueType
392
+ > = {
393
+ 'ticket.subject': {
394
+ text: 'Ticket Subject',
395
+ type: 'string',
396
+ filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
397
+ },
398
+ 'ticket.status': {
399
+ text: 'Ticket Status',
400
+ type: 'dropdown',
401
+ value: [
402
+ { id: 'open', value: 'open', label: 'Open' },
403
+ { id: 'closed', value: 'closed', label: 'Closed' },
404
+ { id: 'inprogress', value: 'inprogress', label: 'In progress' },
405
+ ],
406
+ filters: ['EQ', 'NEQ'],
407
+ },
408
+ 'ticket.priority': {
409
+ text: 'Ticket Priority',
410
+ type: 'dropdown',
411
+ value: [
412
+ { id: '0', value: '0', label: 'No Prioriy' },
413
+ { id: '1', value: '1', label: 'Low' },
414
+ { id: '2', value: '2', label: 'Medium' },
415
+ { id: '3', value: '3', label: 'High' },
416
+ { id: '4', value: '4', label: 'Urgent' },
417
+ ],
418
+ filters: ['EQ', 'NEQ'],
419
+ },
420
+ 'ticket.assignee': {
421
+ text: 'Ticket Assignee',
422
+ type: 'dropdown',
423
+ value: 'org.members',
424
+ filters: ['EQ', 'NEQ'],
425
+ },
426
+ 'ticket.labels': {
427
+ text: 'Ticket Labels',
428
+ type: 'dropdown',
429
+ value: 'org.labels',
430
+ filters: ['EQ', 'NEQ'],
431
+ },
432
+ 'ticket.is_deleted': {
433
+ text: 'Ticket is deleted',
434
+ type: 'boolean',
435
+ filters: ['IS'],
436
+ },
437
+ 'ticket.raised_by': {
438
+ text: 'Ticket Raised By',
439
+ type: 'dropdown',
440
+ value: 'org.members',
441
+ filters: ['EQ', 'NEQ'],
442
+ },
443
+ 'ticket.due_date': {
444
+ text: 'Ticket Due Date',
445
+ type: 'date',
446
+ filters: ['LT', 'LTE', 'GT', 'GTE'],
447
+ },
448
+ 'ticket.assigned_by': {
449
+ text: 'Ticket assignee',
450
+ type: 'dropdown',
451
+ value: 'org.members',
452
+ filters: ['EQ', 'NEQ'],
453
+ },
454
+ "ticket.ticket_id": {
455
+ text: 'Ticket ID',
456
+ type: 'string',
457
+ filters: ['EQ', 'NEQ'],
458
+ hidden: true
459
+ }
460
+ };
461
+
462
+ export const ReactionVariableNameMap: Record<
463
+ keyof AppendTypes<{ reaction: ReactionVariablesType }, '.'>,
464
+ VariableNameValueType
465
+ > = {
466
+ 'reaction.reaction': {
467
+ text: 'Reaction',
468
+ type: 'string',
469
+ filters: ['EQ', 'NEQ'],
470
+ },
471
+ 'reaction.sender_id': {
472
+ text: 'Reaction Sender Phone',
473
+ type: 'string',
474
+ filters: ['EQ', 'NEQ'],
475
+ },
476
+ 'reaction.message_id': {
477
+ text: 'Reaction Message ID',
478
+ type: 'string',
479
+ filters: ['EQ', 'NEQ'],
480
+ hidden: true
481
+ },
482
+ "reaction.chat_id": {
483
+ text: 'Chat ID',
484
+ type: 'string',
485
+ filters: ['EQ', 'NEQ'],
486
+ hidden: true
487
+ },
488
+ "reaction.reaction_id": {
489
+ text: 'Reaction ID',
490
+ type: 'string',
491
+ filters: ['EQ', 'NEQ'],
492
+ hidden: true
493
+ }
494
+ };
495
+
496
+ export enum FilterConditionMap {
497
+ 'CONTAINS' = 'contains',
498
+ 'NCONTAINS' = 'does not contain',
499
+ 'EQ' = '=',
500
+ 'NEQ' = '<>',
501
+ 'LT' = '<',
502
+ 'LTE' = '<=',
503
+ 'GT' = '>',
504
+ 'GTE' = '>=',
505
+ 'KNOWN' = 'is known',
506
+ 'NKNOWN' = 'is not known',
507
+ 'IS' = '=',
508
+ 'NIS' = '<>',
509
+ }
510
+
511
+ interface FilterGroup {
512
+ filters: Filter[];
513
+ condition: 'allOf' | 'anyOf';
514
+ }
515
+
516
+ export interface Conditions {
517
+ filters: FilterGroup[];
518
+ condition: 'allOf' | 'anyOf';
519
+ variables: string[];
520
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
521
+ org_phones: string[];
522
+ }
523
+
524
+ export type SendMessageAction = {
525
+ id: string;
526
+ type: 'send_message';
527
+ metadata: {
528
+ message: string;
529
+ media?: {
530
+ url: string;
531
+ type: 'image' | 'video' | 'audio' | 'document';
532
+ name: string;
533
+ };
534
+ };
535
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
536
+ };
537
+
538
+ export type NotifyHttpAction = {
539
+ id: string;
540
+ type: 'notify_http';
541
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
542
+ metadata: {
543
+ url: string;
544
+ };
545
+ };
546
+
547
+ export type CreateTicketAction = {
548
+ id: string;
549
+ type: 'create_ticket';
550
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
551
+ metadata: {
552
+ assignee?: string;
553
+ priority?: 0 | 1 | 2 | 3 | 4;
554
+ label?: string;
555
+ };
556
+ };
557
+
558
+ export type FlagMessageAction = {
559
+ id: string;
560
+ type: 'flag_message';
561
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
562
+ metadata: {};
563
+ };
564
+
565
+ export type AssignTicketAction = {
566
+ id: string;
567
+ type: 'assign_ticket';
568
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
569
+ metadata: {
570
+ email: string;
571
+ };
572
+ };
573
+
574
+ export type CloseTicketAction = {
575
+ id: string;
576
+ type: 'close_ticket';
577
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
578
+ metadata: {
579
+ closing_note: string;
580
+ };
581
+ };
582
+
583
+ export type AddChatLabelAction = {
584
+ id: string;
585
+ type: 'add_chat_label';
586
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
587
+ metadata: {
588
+ label: string;
589
+ };
590
+ };
591
+
592
+ export type AddTicketLabelAction = {
593
+ id: string;
594
+ type: 'add_ticket_label';
595
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
596
+ metadata: {
597
+ label: string;
598
+ };
599
+ };
600
+
601
+ export type AssignChatAction = {
602
+ id: string;
603
+ type: 'assign_chat';
604
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
605
+ metadata: {
606
+ email: string;
607
+ };
608
+ };
609
+
610
+ export type ForwardMessageAction = {
611
+ id: string;
612
+ type: 'forward_message';
613
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
614
+ metadata: {
615
+ chat_id: string;
616
+ prefix: string;
617
+ };
618
+ };
619
+
620
+ export type SendEmailAction = {
621
+ id: string;
622
+ type: 'send_email';
623
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
624
+ metadata: {
625
+ email: string;
626
+ subject: string;
627
+ body: string;
628
+ };
629
+ };
630
+
631
+ export type ReplyToMessageAction = {
632
+ id: string;
633
+ type: 'reply_to_message';
634
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
635
+ metadata: {
636
+ message: string;
637
+ media?: {
638
+ url: string;
639
+ type: 'image' | 'video' | 'audio' | 'document';
640
+ name: string;
641
+ };
642
+ };
643
+ };
644
+
645
+ export type UpdateCustomPropertyAction = {
646
+ id: string;
647
+ type: 'update_custom_property';
648
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
649
+ metadata: {
650
+ property_id: string;
651
+ value: string;
652
+ };
653
+ };
654
+
655
+ export type Action =
656
+ | SendMessageAction
657
+ | NotifyHttpAction
658
+ | CreateTicketAction
659
+ | FlagMessageAction
660
+ | AssignTicketAction
661
+ | CloseTicketAction
662
+ | AddChatLabelAction
663
+ | AddTicketLabelAction
664
+ | AssignChatAction
665
+ | ForwardMessageAction
666
+ | SendEmailAction
667
+ | ReplyToMessageAction
668
+ | UpdateCustomPropertyAction;
669
+
670
+ export const isSendMessageAction = (
671
+ action: Action
672
+ ): action is SendMessageAction => {
673
+ return action.type === 'send_message';
674
+ };
675
+
676
+ export type Rule = OverrideProperties<
677
+ Tables<'tbl_automation_rules'>,
678
+ {
679
+ actions: Action[];
680
+ conditions: Conditions;
681
+ trigger:
682
+ | 'message.created'
683
+ | 'message.updated'
684
+ | 'chat.created'
685
+ | 'ticket.updated'
686
+ | 'ticket.created'
687
+ | 'reaction.added'
688
+ | 'chat.label.updated'
689
+ | 'message.flagged';
690
+ }
691
+ >;
692
+
693
+ export const RuleNameMap: Record<
694
+ Rule['trigger'],
695
+ {
696
+ title: string;
697
+ description: string;
698
+ base_conditions: {
699
+ org_phone: boolean;
700
+ };
701
+ }
702
+ > = {
703
+ 'message.created': {
704
+ title: 'New Message Received',
705
+ description: 'When a new message is sent or received',
706
+ base_conditions: {
707
+ org_phone: true,
708
+ },
709
+ },
710
+ 'chat.created': {
711
+ title: 'New Chat Created',
712
+ description: 'When a new chat is created',
713
+ base_conditions: {
714
+ org_phone: true,
715
+ },
716
+ },
717
+ 'ticket.created': {
718
+ title: 'New Ticket Created',
719
+ description: 'When a new ticket is created',
720
+ base_conditions: {
721
+ org_phone: false,
722
+ },
723
+ },
724
+ 'reaction.added': {
725
+ title: 'New Reaction Added',
726
+ description: 'When a reaction is added on a message',
727
+ base_conditions: {
728
+ org_phone: true,
729
+ },
730
+ },
731
+ 'message.updated': {
732
+ title: 'Message Updated',
733
+ description: 'When a message is updated',
734
+ base_conditions: {
735
+ org_phone: true,
736
+ },
737
+ },
738
+ 'ticket.updated': {
739
+ title: 'Ticket Updated',
740
+ description: 'When a ticket is updated',
741
+ base_conditions: {
742
+ org_phone: false,
743
+ },
744
+ },
745
+ 'chat.label.updated': {
746
+ title: 'Chat Label Added/Removed',
747
+ description: 'When labels on chats are updated',
748
+ base_conditions: {
749
+ org_phone: false,
750
+ },
751
+ },
752
+ 'message.flagged': {
753
+ title: 'Message Flagged',
754
+ description: 'When a message is flagged',
755
+ base_conditions: {
756
+ org_phone: true,
757
+ },
758
+ },
759
+ };
760
+
761
+ export const ActionNameMap: Record<
762
+ Action['type'],
763
+ {
764
+ title: string;
765
+ description: string;
766
+ inputs: Record<
767
+ string,
768
+ {
769
+ id: string;
770
+ type: 'text' | 'dropdown' | 'editor' | 'date' | 'file' | 'textarea' | 'dynamic';
771
+ value:
772
+ | 'ticket.labels'
773
+ | 'org.members'
774
+ | 'chat.labels'
775
+ | 'org.chats'
776
+ | {
777
+ id: string;
778
+ value: string;
779
+ label: string;
780
+ }[]
781
+ | null
782
+ | 'org.custom_properties'
783
+ | 'custom_property_values';
784
+ label: string;
785
+ placeholder: string;
786
+ }
787
+ >;
788
+ validTriggers: Rule['trigger'][];
789
+ }
790
+ > = {
791
+ send_message: {
792
+ title: 'Send Message',
793
+ description: 'Send a message',
794
+ inputs: {
795
+ message: {
796
+ id: 'message',
797
+ type: 'editor',
798
+ label: 'Message',
799
+ placeholder: 'Enter message',
800
+ value: null,
801
+ },
802
+ media: {
803
+ id: 'media',
804
+ type: 'file',
805
+ label: 'Media',
806
+ placeholder: 'Upload media',
807
+ value: null,
808
+ },
809
+ },
810
+ validTriggers: [
811
+ 'message.created',
812
+ 'message.updated',
813
+ 'chat.created',
814
+ 'ticket.updated',
815
+ 'ticket.created',
816
+ 'reaction.added',
817
+ 'message.flagged',
818
+ ],
819
+ },
820
+ reply_to_message: {
821
+ title: 'Reply to message',
822
+ description: 'Send a message with the quoted message',
823
+ inputs: {
824
+ message: {
825
+ id: 'message',
826
+ type: 'editor',
827
+ label: 'Message',
828
+ placeholder: 'Enter message',
829
+ value: null,
830
+ },
831
+ media: {
832
+ id: 'media',
833
+ type: 'file',
834
+ label: 'Media',
835
+ placeholder: 'Upload media',
836
+ value: null,
837
+ },
838
+ },
839
+ validTriggers: [
840
+ 'message.created',
841
+ 'message.updated',
842
+ 'reaction.added',
843
+ 'message.flagged',
844
+ ],
845
+ },
846
+ notify_http: {
847
+ title: 'Notify HTTP',
848
+ description: 'Notify an HTTP endpoint',
849
+ inputs: {
850
+ url: {
851
+ id: 'url',
852
+ type: 'text',
853
+ label: 'URL',
854
+ placeholder: 'Enter URL',
855
+ value: null,
856
+ },
857
+ },
858
+ validTriggers: [
859
+ 'message.created',
860
+ 'message.updated',
861
+ 'chat.created',
862
+ 'ticket.updated',
863
+ 'ticket.created',
864
+ 'reaction.added',
865
+ 'message.flagged',
866
+ ],
867
+ },
868
+ create_ticket: {
869
+ title: 'Create Ticket',
870
+ description: 'Create a ticket',
871
+ inputs: {
872
+ assignee: {
873
+ id: 'assignee',
874
+ type: 'dropdown',
875
+ value: 'org.members',
876
+ label: 'Assignee',
877
+ placeholder: 'Select assignee',
878
+ },
879
+ priority: {
880
+ id: 'priority',
881
+ type: 'dropdown',
882
+ value: [
883
+ { id: '0', value: '0', label: 'Low' },
884
+ { id: '1', value: '1', label: 'Medium' },
885
+ { id: '2', value: '2', label: 'High' },
886
+ { id: '3', value: '3', label: 'Urgent' },
887
+ { id: '4', value: '4', label: 'Immediate' },
888
+ ],
889
+ label: 'Priority',
890
+ placeholder: 'Select priority',
891
+ },
892
+ label: {
893
+ id: 'label',
894
+ type: 'dropdown',
895
+ value: 'ticket.labels',
896
+ label: 'Label',
897
+ placeholder: 'Select label',
898
+ },
899
+ },
900
+ validTriggers: [
901
+ 'message.created',
902
+ 'message.updated',
903
+ 'chat.created',
904
+ 'reaction.added',
905
+ 'message.flagged',
906
+ ],
907
+ },
908
+ flag_message: {
909
+ title: 'Update flag status',
910
+ description: 'Flag/Unflag a message',
911
+ inputs: {
912
+ flag: {
913
+ id: 'flag',
914
+ type: 'dropdown',
915
+ value: [
916
+ { id: 'flag', value: 'true', label: 'TRUE' },
917
+ { id: 'unflag', value: 'false', label: 'FALSE' },
918
+ ],
919
+ label: 'Flag status',
920
+ placeholder: 'Select flag',
921
+ },
922
+ },
923
+ validTriggers: ['message.created', 'message.updated', 'reaction.added'],
924
+ },
925
+ assign_ticket: {
926
+ title: 'Assign Ticket',
927
+ description: 'Assign a ticket',
928
+ inputs: {
929
+ assignee: {
930
+ id: 'assignee',
931
+ type: 'dropdown',
932
+ value: 'org.members',
933
+ label: 'Assignee',
934
+ placeholder: 'Select assignee',
935
+ },
936
+ },
937
+ validTriggers: ['ticket.updated', 'ticket.created'],
938
+ },
939
+ close_ticket: {
940
+ title: 'Close Ticket',
941
+ description: 'Close a ticket',
942
+ inputs: {
943
+ closing_note: {
944
+ id: 'closing_note',
945
+ type: 'textarea',
946
+ label: 'Closing Note',
947
+ placeholder: 'Enter closing note',
948
+ value: null,
949
+ },
950
+ },
951
+ validTriggers: ['ticket.updated', 'ticket.created'],
952
+ },
953
+ add_chat_label: {
954
+ title: 'Add Chat Label',
955
+ description: 'Add a label to referred chat',
956
+ inputs: {
957
+ label: {
958
+ id: 'label',
959
+ type: 'dropdown',
960
+ value: 'chat.labels',
961
+ label: 'Label',
962
+ placeholder: 'Select label',
963
+ },
964
+ },
965
+ validTriggers: [
966
+ 'message.created',
967
+ 'message.updated',
968
+ 'chat.created',
969
+ 'ticket.updated',
970
+ 'ticket.created',
971
+ 'reaction.added',
972
+ ],
973
+ },
974
+ add_ticket_label: {
975
+ title: 'Add Ticket Label',
976
+ description: 'Add a label to referred ticket',
977
+ inputs: {
978
+ label: {
979
+ id: 'label',
980
+ type: 'dropdown',
981
+ value: 'ticket.labels',
982
+ label: 'Label',
983
+ placeholder: 'Select label',
984
+ },
985
+ },
986
+ validTriggers: ['ticket.updated', 'ticket.created'],
987
+ },
988
+ update_custom_property: {
989
+ description: 'Update a custom property',
990
+ title: 'Update Chat Custom Property',
991
+ validTriggers: [
992
+ 'message.created',
993
+ 'message.updated',
994
+ 'chat.created',
995
+ 'ticket.updated',
996
+ 'ticket.created',
997
+ 'reaction.added',
998
+ 'message.flagged',
999
+ ],
1000
+ inputs: {
1001
+ property_id: {
1002
+ id: 'property_id',
1003
+ type: 'dropdown',
1004
+ value: 'org.custom_properties',
1005
+ label: 'Property',
1006
+ placeholder: 'Select property',
1007
+ },
1008
+ value: {
1009
+ id: 'value',
1010
+ type: 'dynamic',
1011
+ label: 'Value',
1012
+ placeholder: 'Enter value',
1013
+ value: 'custom_property_values',
1014
+ },
1015
+ }
1016
+ },
1017
+ assign_chat: {
1018
+ title: 'Assign Chat',
1019
+ description: 'Assign a chat',
1020
+ inputs: {
1021
+ assignee: {
1022
+ id: 'assignee',
1023
+ type: 'dropdown',
1024
+ value: 'org.members',
1025
+ label: 'Assignee',
1026
+ placeholder: 'Select assignee',
1027
+ },
1028
+ },
1029
+ validTriggers: [
1030
+ 'message.created',
1031
+ 'message.updated',
1032
+ 'chat.created',
1033
+ 'ticket.updated',
1034
+ 'ticket.created',
1035
+ 'reaction.added',
1036
+ ],
1037
+ },
1038
+ forward_message: {
1039
+ title: 'Forward Message',
1040
+ description: 'Forward a message',
1041
+ inputs: {
1042
+ chat_id: {
1043
+ id: 'chat_id',
1044
+ type: 'dropdown',
1045
+ value: 'org.chats',
1046
+ label: 'Chat',
1047
+ placeholder: 'Select chat',
1048
+ },
1049
+ prefix: {
1050
+ id: 'prefix',
1051
+ type: 'editor',
1052
+ label: 'Prefix',
1053
+ placeholder: 'Enter prefix',
1054
+ value: null,
1055
+ },
1056
+ },
1057
+ validTriggers: [
1058
+ 'message.created',
1059
+ 'message.updated',
1060
+ 'chat.created',
1061
+ 'ticket.updated',
1062
+ 'ticket.created',
1063
+ 'reaction.added',
1064
+ 'message.flagged',
1065
+ ],
1066
+ },
1067
+ send_email: {
1068
+ title: 'Send Email',
1069
+ description: 'Send an email',
1070
+ inputs: {
1071
+ email: {
1072
+ id: 'email',
1073
+ type: 'text',
1074
+ label: 'Email',
1075
+ placeholder: 'Enter email',
1076
+ value: null,
1077
+ },
1078
+ subject: {
1079
+ id: 'subject',
1080
+ type: 'text',
1081
+ label: 'Subject',
1082
+ placeholder: 'Enter subject',
1083
+ value: null,
1084
+ },
1085
+ body: {
1086
+ id: 'body',
1087
+ type: 'editor',
1088
+ label: 'Body',
1089
+ placeholder: 'Enter body',
1090
+ value: null,
1091
+ },
1092
+ },
1093
+ validTriggers: [
1094
+ 'message.created',
1095
+ 'message.updated',
1096
+ 'chat.created',
1097
+ 'ticket.updated',
1098
+ 'ticket.created',
1099
+ 'reaction.added',
1100
+ 'message.flagged',
1101
+ ],
1102
+ },
1103
+ };