@periskope/types 0.6.135 → 0.6.137

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