@realtimex/email-automator 2.11.2 โ 2.12.0
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/api/src/routes/index.ts +2 -0
- package/api/src/routes/rulePacks.ts +204 -0
- package/api/src/services/RulePackService.ts +354 -0
- package/api/src/services/SDKService.ts +18 -7
- package/api/src/services/gmail.ts +68 -0
- package/api/src/services/intelligence.ts +160 -22
- package/api/src/services/microsoft.ts +99 -0
- package/api/src/services/processor.ts +146 -12
- package/api/src/services/rulePacks/developer.ts +179 -0
- package/api/src/services/rulePacks/executive.ts +143 -0
- package/api/src/services/rulePacks/index.ts +63 -0
- package/api/src/services/rulePacks/operations.ts +183 -0
- package/api/src/services/rulePacks/sales.ts +160 -0
- package/api/src/services/rulePacks/types.ts +116 -0
- package/api/src/services/rulePacks/universal.ts +83 -0
- package/api/src/services/supabase.ts +40 -0
- package/dist/api/src/routes/index.js +2 -0
- package/dist/api/src/routes/rulePacks.js +179 -0
- package/dist/api/src/services/RulePackService.js +296 -0
- package/dist/api/src/services/SDKService.js +18 -7
- package/dist/api/src/services/gmail.js +56 -0
- package/dist/api/src/services/intelligence.js +153 -21
- package/dist/api/src/services/microsoft.js +79 -0
- package/dist/api/src/services/processor.js +133 -12
- package/dist/api/src/services/rulePacks/developer.js +176 -0
- package/dist/api/src/services/rulePacks/executive.js +140 -0
- package/dist/api/src/services/rulePacks/index.js +58 -0
- package/dist/api/src/services/rulePacks/operations.js +180 -0
- package/dist/api/src/services/rulePacks/sales.js +157 -0
- package/dist/api/src/services/rulePacks/types.js +7 -0
- package/dist/api/src/services/rulePacks/universal.js +80 -0
- package/dist/assets/index-B5rXh3y8.css +1 -0
- package/dist/assets/index-B62ViZum.js +105 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/supabase/migrations/20260131000000_add_rule_packs.sql +176 -0
- package/supabase/migrations/20260131000001_set_zero_config_defaults.sql +51 -0
- package/supabase/migrations/20260131095000_backfill_user_settings.sql +36 -0
- package/supabase/migrations/20260131100000_rule_templates_table.sql +154 -0
- package/supabase/migrations/20260131110000_auto_init_user_data.sql +90 -0
- package/supabase/migrations/20260131120000_backfill_universal_pack.sql +84 -0
- package/supabase/migrations/20260131130000_simplify_rules_with_categories.sql +87 -0
- package/supabase/migrations/20260131140000_fix_action_constraint.sql +11 -0
- package/supabase/migrations/20260131150000_fix_trigger_error_handling.sql +71 -0
- package/supabase/migrations/20260131160000_enable_intelligent_rename_by_default.sql +14 -0
- package/dist/assets/index-BuWrl4UD.js +0 -105
- package/dist/assets/index-CtDzSy0n.css +0 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operations Pack - Support & Customer Success
|
|
3
|
+
*
|
|
4
|
+
* Designed for operations, support, and customer success teams who need to:
|
|
5
|
+
* - Organize customer support tickets
|
|
6
|
+
* - Track internal announcements
|
|
7
|
+
* - Monitor system health
|
|
8
|
+
* - Manage receipts and expenses
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { RulePack } from './types.js';
|
|
12
|
+
|
|
13
|
+
export const OPERATIONS_PACK: RulePack = {
|
|
14
|
+
id: 'operations',
|
|
15
|
+
name: 'Operations Pack',
|
|
16
|
+
description: 'Organize tickets, internal communications, and operations',
|
|
17
|
+
icon: '๐ ๏ธ',
|
|
18
|
+
enabled_by_default: false,
|
|
19
|
+
target_roles: ['operations'],
|
|
20
|
+
rules: [
|
|
21
|
+
{
|
|
22
|
+
id: 'ops-support-tickets',
|
|
23
|
+
name: '๐ซ Support Ticket Organizer',
|
|
24
|
+
intent: 'Organize customer support tickets and cases',
|
|
25
|
+
description: 'Labels support tickets from Zendesk, Intercom, and other support tools',
|
|
26
|
+
condition: {
|
|
27
|
+
or: [
|
|
28
|
+
{
|
|
29
|
+
sender_domain: 'zendesk.com'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
sender_domain: 'intercom.io'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
sender_domain: 'freshdesk.com'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
contains_keywords: ['ticket', 'case created', 'support request', 'customer inquiry']
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
category: 'support',
|
|
42
|
+
confidence_gt: 0.7
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
actions: ['label:Support'],
|
|
47
|
+
priority: 80,
|
|
48
|
+
is_enabled_by_default: true
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'ops-urgent-tickets',
|
|
52
|
+
name: '๐จ Urgent Ticket Highlighter',
|
|
53
|
+
intent: 'Highlight high-priority and urgent customer issues',
|
|
54
|
+
description: 'Stars urgent support tickets that need immediate attention',
|
|
55
|
+
condition: {
|
|
56
|
+
category: 'support',
|
|
57
|
+
or: [
|
|
58
|
+
{
|
|
59
|
+
contains_keywords: ['urgent', 'emergency', 'critical', 'down', 'not working']
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
ai_priority: 'High'
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
actions: ['star', 'important'],
|
|
67
|
+
priority: 100,
|
|
68
|
+
is_enabled_by_default: true
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'ops-system-alerts',
|
|
72
|
+
name: 'โ ๏ธ System Alerts Organizer',
|
|
73
|
+
intent: 'Organize system monitoring and uptime alerts',
|
|
74
|
+
description: 'Labels system alerts while starring critical incidents',
|
|
75
|
+
condition: {
|
|
76
|
+
or: [
|
|
77
|
+
{
|
|
78
|
+
sender_domain: 'pingdom.com'
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
sender_domain: 'uptimerobot.com'
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
sender_domain: 'statuspage.io'
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
sender_domain: 'datadog.com'
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
actions: ['label:Monitoring'],
|
|
92
|
+
priority: 70,
|
|
93
|
+
is_enabled_by_default: true
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: 'ops-critical-alerts',
|
|
97
|
+
name: '๐ฅ Critical Alert Highlighter',
|
|
98
|
+
intent: 'Highlight critical system incidents',
|
|
99
|
+
description: 'Stars critical alerts that indicate system downtime or major issues',
|
|
100
|
+
condition: {
|
|
101
|
+
or: [
|
|
102
|
+
{
|
|
103
|
+
sender_domain: 'pingdom.com',
|
|
104
|
+
contains_keywords: ['down', 'offline']
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
sender_domain: 'datadog.com',
|
|
108
|
+
contains_keywords: ['critical', 'incident']
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
actions: ['star', 'important', 'pin'],
|
|
113
|
+
priority: 100,
|
|
114
|
+
is_enabled_by_default: true
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: 'ops-internal-announcements',
|
|
118
|
+
name: '๐ข Internal Announcements',
|
|
119
|
+
intent: 'Keep internal company announcements in inbox',
|
|
120
|
+
description: 'Keeps HR, team, and company-wide announcements visible (doesn\'t archive)',
|
|
121
|
+
condition: {
|
|
122
|
+
or: [
|
|
123
|
+
{
|
|
124
|
+
category: 'internal',
|
|
125
|
+
confidence_gt: 0.7
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
sender_domain: 'company.com', // This should be customizable
|
|
129
|
+
contains_keywords: ['all-hands', 'team announcement', 'company update']
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
actions: [], // No actions - keep in inbox
|
|
134
|
+
priority: 50,
|
|
135
|
+
is_enabled_by_default: true
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: 'ops-project-management',
|
|
139
|
+
name: '๐จ Project Management Organizer',
|
|
140
|
+
intent: 'Organize project management tool notifications',
|
|
141
|
+
description: 'Archives project management notifications unless you\'re directly mentioned',
|
|
142
|
+
condition: {
|
|
143
|
+
or: [
|
|
144
|
+
{
|
|
145
|
+
sender_domain: 'atlassian.net',
|
|
146
|
+
not: {
|
|
147
|
+
contains_keywords: ['assigned to you', 'mentioned you']
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
sender_domain: 'asana.com',
|
|
152
|
+
not: {
|
|
153
|
+
contains_keywords: ['assigned to you']
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
sender_domain: 'trello.com'
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
sender_domain: 'monday.com'
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
actions: ['label:Tools', 'archive'],
|
|
165
|
+
priority: 15,
|
|
166
|
+
is_enabled_by_default: true
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
id: 'ops-receipts-invoices',
|
|
170
|
+
name: '๐งพ Receipt & Invoice Labeler',
|
|
171
|
+
intent: 'Label receipts and invoices for expense tracking',
|
|
172
|
+
description: 'Labels transactional emails for easy expense reporting',
|
|
173
|
+
condition: {
|
|
174
|
+
category: 'transactional',
|
|
175
|
+
contains_keywords: ['receipt', 'invoice', 'payment', 'order confirmation'],
|
|
176
|
+
confidence_gt: 0.75
|
|
177
|
+
},
|
|
178
|
+
actions: ['label:Finance/Receipts'],
|
|
179
|
+
priority: 60,
|
|
180
|
+
is_enabled_by_default: true
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sales Pack - Revenue & Customer Communications
|
|
3
|
+
*
|
|
4
|
+
* Designed for sales, business development, and customer-facing teams who need to:
|
|
5
|
+
* - Prioritize leads and customer communications
|
|
6
|
+
* - Track CRM notifications
|
|
7
|
+
* - Manage travel for client meetings
|
|
8
|
+
* - Focus on revenue-generating activities
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { RulePack } from './types.js';
|
|
12
|
+
|
|
13
|
+
export const SALES_PACK: RulePack = {
|
|
14
|
+
id: 'sales',
|
|
15
|
+
name: 'Sales Pack',
|
|
16
|
+
description: 'Prioritize leads and customer communications',
|
|
17
|
+
icon: '๐ผ',
|
|
18
|
+
enabled_by_default: false,
|
|
19
|
+
target_roles: ['sales'],
|
|
20
|
+
rules: [
|
|
21
|
+
{
|
|
22
|
+
id: 'sales-vip-clients',
|
|
23
|
+
name: 'โญ VIP Client Prioritizer',
|
|
24
|
+
intent: 'Star and prioritize emails from key clients and prospects',
|
|
25
|
+
description: 'Automatically highlights emails from VIP contacts and hot leads',
|
|
26
|
+
condition: {
|
|
27
|
+
or: [
|
|
28
|
+
{
|
|
29
|
+
sender_is_vip: true // From VIP list
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
category: 'client',
|
|
33
|
+
ai_priority: 'High'
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
actions: ['star', 'important'],
|
|
38
|
+
priority: 100,
|
|
39
|
+
is_enabled_by_default: true
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'sales-direct-questions',
|
|
43
|
+
name: 'โก Customer Questions Highlighter',
|
|
44
|
+
intent: 'Highlight customer questions that need responses',
|
|
45
|
+
description: 'Identifies emails from customers asking questions or requesting information',
|
|
46
|
+
condition: {
|
|
47
|
+
recipient_type: 'to',
|
|
48
|
+
contains_keywords: ['?', 'question', 'wondering', 'can you', 'could you'],
|
|
49
|
+
not: {
|
|
50
|
+
category: 'newsletter'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
actions: ['important'],
|
|
54
|
+
priority: 90,
|
|
55
|
+
is_enabled_by_default: true
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'sales-crm-notifications',
|
|
59
|
+
name: '๐ CRM Notification Organizer',
|
|
60
|
+
intent: 'Organize Salesforce, HubSpot, and CRM notifications',
|
|
61
|
+
description: 'Archives CRM notifications unless they require direct action',
|
|
62
|
+
condition: {
|
|
63
|
+
or: [
|
|
64
|
+
{
|
|
65
|
+
sender_domain: 'salesforce.com',
|
|
66
|
+
not: {
|
|
67
|
+
contains_keywords: ['assigned to you', 'mentioned you', 'deal closed']
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
sender_domain: 'hubspot.com',
|
|
72
|
+
not: {
|
|
73
|
+
contains_keywords: ['new lead', 'hot lead', 'assigned']
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
sender_domain: 'pipedrive.com'
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
actions: ['label:CRM', 'archive'],
|
|
82
|
+
priority: 15,
|
|
83
|
+
is_enabled_by_default: true
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: 'sales-calendar-responses',
|
|
87
|
+
name: '๐
Calendar Response Cleaner',
|
|
88
|
+
intent: 'Clean up calendar accept/decline notifications',
|
|
89
|
+
description: 'Deletes automatic calendar responses without custom messages',
|
|
90
|
+
condition: {
|
|
91
|
+
contains_keywords: ['accepted:', 'declined:', 'tentative:'],
|
|
92
|
+
not: {
|
|
93
|
+
recipient_type: 'to'
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
actions: ['delete'],
|
|
97
|
+
priority: 10,
|
|
98
|
+
is_enabled_by_default: false // Disabled by default - deletion is aggressive
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: 'sales-travel-itineraries',
|
|
102
|
+
name: 'โ๏ธ Travel Organizer',
|
|
103
|
+
intent: 'Organize flight confirmations and hotel bookings',
|
|
104
|
+
description: 'Labels travel-related emails for easy access before client meetings',
|
|
105
|
+
condition: {
|
|
106
|
+
or: [
|
|
107
|
+
{
|
|
108
|
+
sender_domain: 'delta.com'
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
sender_domain: 'united.com'
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
sender_domain: 'aa.com'
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
sender_domain: 'hilton.com'
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
sender_domain: 'marriott.com'
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
sender_domain: 'airbnb.com'
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
contains_keywords: ['itinerary', 'flight confirmation', 'booking confirmation', 'reservation confirmed']
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
actions: ['label:Travel'],
|
|
131
|
+
priority: 70,
|
|
132
|
+
is_enabled_by_default: true
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: 'sales-proposals',
|
|
136
|
+
name: '๐ Proposal & Contract Highlighter',
|
|
137
|
+
intent: 'Highlight proposals and contracts',
|
|
138
|
+
description: 'Stars emails containing proposals, quotes, and contracts',
|
|
139
|
+
condition: {
|
|
140
|
+
or: [
|
|
141
|
+
{
|
|
142
|
+
sender_domain: 'docusign.com'
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
sender_domain: 'hellosign.com'
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
sender_domain: 'pandadoc.com'
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
contains_keywords: ['proposal', 'quote', 'contract', 'agreement', 'signature required']
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
actions: ['label:Contracts', 'star'],
|
|
156
|
+
priority: 85,
|
|
157
|
+
is_enabled_by_default: true
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule Pack Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Rule packs are pre-configured sets of automation rules designed for specific user roles
|
|
5
|
+
* or use cases. They enable zero-configuration UX by providing smart defaults.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export type EmailCategory =
|
|
9
|
+
| 'newsletter'
|
|
10
|
+
| 'promotional'
|
|
11
|
+
| 'spam'
|
|
12
|
+
| 'transactional'
|
|
13
|
+
| 'social'
|
|
14
|
+
| 'support'
|
|
15
|
+
| 'client'
|
|
16
|
+
| 'internal'
|
|
17
|
+
| 'personal'
|
|
18
|
+
| 'other';
|
|
19
|
+
|
|
20
|
+
export type EmailAction =
|
|
21
|
+
| 'delete'
|
|
22
|
+
| 'archive'
|
|
23
|
+
| 'draft'
|
|
24
|
+
| 'read'
|
|
25
|
+
| 'star'
|
|
26
|
+
| 'unstar'
|
|
27
|
+
| 'important'
|
|
28
|
+
| 'pin'
|
|
29
|
+
| `label:${string}`
|
|
30
|
+
| `forward:${string}`;
|
|
31
|
+
|
|
32
|
+
export type RecipientType = 'to' | 'cc' | 'bcc';
|
|
33
|
+
|
|
34
|
+
export type EmailSentiment = 'sales' | 'urgent' | 'casual' | 'formal';
|
|
35
|
+
|
|
36
|
+
export type Priority = 'High' | 'Medium' | 'Low';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Enhanced rule condition supporting AI-powered matching
|
|
40
|
+
*/
|
|
41
|
+
export interface EnhancedRuleCondition {
|
|
42
|
+
// Legacy field-based matching (kept for backwards compatibility)
|
|
43
|
+
field?: 'subject' | 'sender' | 'body';
|
|
44
|
+
operator?: 'equals' | 'contains' | 'domain_equals';
|
|
45
|
+
value?: string;
|
|
46
|
+
|
|
47
|
+
// AI-powered conditions (leverage intelligence service)
|
|
48
|
+
category?: EmailCategory; // AI categorization (newsletter, spam, etc.)
|
|
49
|
+
sentiment?: EmailSentiment; // AI tone detection
|
|
50
|
+
confidence_gt?: number; // Minimum AI confidence (0.0 to 1.0)
|
|
51
|
+
|
|
52
|
+
// AI priority and quality
|
|
53
|
+
ai_priority?: Priority; // AI-assigned priority
|
|
54
|
+
is_useless?: boolean; // AI-detected low-value email
|
|
55
|
+
|
|
56
|
+
// Recipient analysis
|
|
57
|
+
recipient_type?: RecipientType; // Where user appears (to/cc/bcc)
|
|
58
|
+
recipient_count_gt?: number; // Number of recipients threshold
|
|
59
|
+
is_first_contact?: boolean; // No prior thread with sender
|
|
60
|
+
|
|
61
|
+
// Content matching
|
|
62
|
+
contains_keywords?: string[]; // Any of these words (case-insensitive)
|
|
63
|
+
matches_pattern?: string; // Regex pattern
|
|
64
|
+
|
|
65
|
+
// Sender analysis
|
|
66
|
+
sender_domain?: string; // Match sender domain
|
|
67
|
+
sender_in_contacts?: boolean; // Is sender in user's contacts
|
|
68
|
+
sender_is_vip?: boolean; // Is sender in VIP list
|
|
69
|
+
|
|
70
|
+
// Time-based
|
|
71
|
+
older_than_days?: number; // Email age threshold
|
|
72
|
+
|
|
73
|
+
// Logical operators for complex conditions
|
|
74
|
+
and?: EnhancedRuleCondition[]; // All must match
|
|
75
|
+
or?: EnhancedRuleCondition[]; // Any must match
|
|
76
|
+
not?: EnhancedRuleCondition; // Must NOT match
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Rule template definition
|
|
81
|
+
*/
|
|
82
|
+
export interface RuleTemplate {
|
|
83
|
+
id: string; // Unique template ID (e.g., 'universal-newsletters')
|
|
84
|
+
name: string; // Display name with emoji (e.g., '๐ Newsletter Sweeper')
|
|
85
|
+
intent: string; // Human-readable purpose
|
|
86
|
+
description?: string; // Detailed explanation
|
|
87
|
+
condition: EnhancedRuleCondition; // When this rule applies
|
|
88
|
+
actions: EmailAction[]; // What to do
|
|
89
|
+
instructions?: string; // Draft generation instructions (if action includes 'draft')
|
|
90
|
+
priority?: number; // Evaluation order (higher = first)
|
|
91
|
+
is_enabled_by_default: boolean; // Should be enabled when installed
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Rule pack definition
|
|
96
|
+
*/
|
|
97
|
+
export interface RulePack {
|
|
98
|
+
id: string; // Pack identifier (e.g., 'universal', 'executive')
|
|
99
|
+
name: string; // Display name (e.g., 'Universal Pack')
|
|
100
|
+
description: string; // What this pack does
|
|
101
|
+
icon?: string; // Emoji or icon identifier
|
|
102
|
+
rules: RuleTemplate[]; // Rule templates in this pack
|
|
103
|
+
enabled_by_default: boolean; // Auto-install for matching users
|
|
104
|
+
target_roles?: string[]; // Which roles this pack is designed for
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* User role types for personalization
|
|
109
|
+
*/
|
|
110
|
+
export type UserRole =
|
|
111
|
+
| 'executive' // Leadership, CEO, VP
|
|
112
|
+
| 'developer' // Software engineers, DevOps
|
|
113
|
+
| 'sales' // Sales, Business Development
|
|
114
|
+
| 'operations' // Support, Operations, Customer Success
|
|
115
|
+
| 'marketing' // Marketing, Growth
|
|
116
|
+
| 'other'; // Manual setup, no personalization
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal Pack - Essential Rules for Everyone
|
|
3
|
+
*
|
|
4
|
+
* These 4 rules provide immediate value to all users regardless of role.
|
|
5
|
+
* They're safe, conservative, and focus on noise reduction and organization.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { RulePack } from './types.js';
|
|
9
|
+
|
|
10
|
+
export const UNIVERSAL_PACK: RulePack = {
|
|
11
|
+
id: 'universal',
|
|
12
|
+
name: 'Universal Pack',
|
|
13
|
+
description: 'Essential automation rules that help everyone stay organized',
|
|
14
|
+
icon: '๐ฆ',
|
|
15
|
+
enabled_by_default: true,
|
|
16
|
+
target_roles: undefined, // Available to all roles
|
|
17
|
+
rules: [
|
|
18
|
+
{
|
|
19
|
+
id: 'universal-newsletters',
|
|
20
|
+
name: '๐ Newsletter Sweeper',
|
|
21
|
+
intent: 'Keep newsletters organized and out of main inbox',
|
|
22
|
+
description: 'Automatically archives newsletters and mass-marketing emails so you can read them later without inbox clutter',
|
|
23
|
+
condition: {
|
|
24
|
+
category: 'newsletter',
|
|
25
|
+
confidence_gt: 0.7
|
|
26
|
+
},
|
|
27
|
+
actions: ['archive', 'read'],
|
|
28
|
+
priority: 10,
|
|
29
|
+
is_enabled_by_default: true
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'universal-cold-outreach',
|
|
33
|
+
name: 'โ๏ธ Cold Outreach Filter',
|
|
34
|
+
intent: 'Filter unsolicited sales and marketing emails',
|
|
35
|
+
description: 'Identifies and archives cold emails from unknown senders with sales language',
|
|
36
|
+
condition: {
|
|
37
|
+
or: [
|
|
38
|
+
{
|
|
39
|
+
// High-confidence promotional emails that are first contact
|
|
40
|
+
category: 'promotional',
|
|
41
|
+
confidence_gt: 0.85,
|
|
42
|
+
is_first_contact: true
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
// Spam category (very high confidence)
|
|
46
|
+
category: 'spam',
|
|
47
|
+
confidence_gt: 0.9
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
actions: ['archive'],
|
|
52
|
+
priority: 20,
|
|
53
|
+
is_enabled_by_default: true
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 'universal-cc-organizer',
|
|
57
|
+
name: '๐ CC/FYI Organizer',
|
|
58
|
+
intent: 'Keep inbox focused on direct communications',
|
|
59
|
+
description: 'Archives emails where you\'re CC\'d in group threads, keeping your inbox for direct messages',
|
|
60
|
+
condition: {
|
|
61
|
+
recipient_type: 'cc',
|
|
62
|
+
recipient_count_gt: 3 // Group emails (more than 3 recipients)
|
|
63
|
+
},
|
|
64
|
+
actions: ['archive'],
|
|
65
|
+
priority: 5,
|
|
66
|
+
is_enabled_by_default: true
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'universal-receipts',
|
|
70
|
+
name: '๐งพ Receipt Organizer',
|
|
71
|
+
intent: 'Auto-label receipts for easy tax and expense retrieval',
|
|
72
|
+
description: 'Labels transactional emails (receipts, invoices, confirmations) for easy searching',
|
|
73
|
+
condition: {
|
|
74
|
+
category: 'transactional',
|
|
75
|
+
contains_keywords: ['receipt', 'invoice', 'payment', 'order confirmation', 'purchase'],
|
|
76
|
+
confidence_gt: 0.75
|
|
77
|
+
},
|
|
78
|
+
actions: ['label:Finance/Receipts'],
|
|
79
|
+
priority: 15,
|
|
80
|
+
is_enabled_by_default: true
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
};
|
|
@@ -133,6 +133,10 @@ export interface Rule {
|
|
|
133
133
|
attachments?: any[];
|
|
134
134
|
is_enabled: boolean;
|
|
135
135
|
created_at: string;
|
|
136
|
+
// Rule Pack Support (Zero-Config UX)
|
|
137
|
+
pack?: string | null; // Pack identifier (e.g., 'universal', 'executive', 'developer')
|
|
138
|
+
rule_template_id?: string | null; // Template ID (e.g., 'universal-newsletters')
|
|
139
|
+
is_system_managed?: boolean; // If true, part of a pack - can be disabled but not deleted
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
export interface ProcessingLog {
|
|
@@ -158,4 +162,40 @@ export interface UserSettings {
|
|
|
158
162
|
sync_interval_minutes: number;
|
|
159
163
|
created_at: string;
|
|
160
164
|
updated_at: string;
|
|
165
|
+
// Zero-Config UX Support
|
|
166
|
+
user_role?: string | null; // User role (executive, developer, sales, operations, other)
|
|
167
|
+
onboarding_completed?: boolean; // Whether user completed role selection onboarding
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Zero-Config UX: Pack Installation Tracking
|
|
171
|
+
export interface PackInstallation {
|
|
172
|
+
id: string;
|
|
173
|
+
user_id: string;
|
|
174
|
+
pack_id: string;
|
|
175
|
+
installed_at: string;
|
|
176
|
+
uninstalled_at: string | null;
|
|
177
|
+
source: 'onboarding' | 'manual' | 'auto';
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Zero-Config UX: Rule Effectiveness Metrics
|
|
181
|
+
export interface RuleMetrics {
|
|
182
|
+
rule_id: string;
|
|
183
|
+
date: string;
|
|
184
|
+
times_triggered: number;
|
|
185
|
+
times_undone: number;
|
|
186
|
+
times_edited: number;
|
|
187
|
+
enabled: boolean;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Zero-Config UX: Action History for Undo Capability
|
|
191
|
+
export interface ActionHistory {
|
|
192
|
+
id: string;
|
|
193
|
+
email_id: string;
|
|
194
|
+
rule_id: string | null;
|
|
195
|
+
action: string;
|
|
196
|
+
sync_id: string | null;
|
|
197
|
+
executed_at: string;
|
|
198
|
+
undone: boolean;
|
|
199
|
+
undone_at: string | null;
|
|
200
|
+
metadata: Record<string, unknown> | null;
|
|
161
201
|
}
|
|
@@ -8,6 +8,7 @@ import settingsRoutes from './settings.js';
|
|
|
8
8
|
import emailsRoutes from './emails.js';
|
|
9
9
|
import migrateRoutes from './migrate.js';
|
|
10
10
|
import sdkRoutes from './sdk.js';
|
|
11
|
+
import rulePacksRoutes from './rulePacks.js';
|
|
11
12
|
const router = Router();
|
|
12
13
|
router.use('/health', healthRoutes);
|
|
13
14
|
router.use('/auth', authRoutes);
|
|
@@ -18,4 +19,5 @@ router.use('/settings', settingsRoutes);
|
|
|
18
19
|
router.use('/emails', emailsRoutes);
|
|
19
20
|
router.use('/migrate', migrateRoutes);
|
|
20
21
|
router.use('/sdk', sdkRoutes);
|
|
22
|
+
router.use('/rule-packs', rulePacksRoutes);
|
|
21
23
|
export default router;
|