Adding SMS automation
This commit is contained in:
@@ -176,6 +176,8 @@ model Organization {
|
||||
loyaltyRewards LoyaltyReward[]
|
||||
loyaltyRedemptions LoyaltyRedemption[]
|
||||
automationRules AutomationRule[]
|
||||
messageAutomationRules MessageAutomationRule[]
|
||||
messageAutomationJobs MessageAutomationJob[]
|
||||
memoryItems MemoryItem[]
|
||||
noteAiSuggestions NoteAiSuggestion[]
|
||||
accountingConnections AccountingConnection[]
|
||||
@@ -1083,6 +1085,93 @@ model AutomationRule {
|
||||
@@index([organizationId, isActive, trigger])
|
||||
}
|
||||
|
||||
enum MessageAutomationTrigger {
|
||||
person_created
|
||||
lead_submitted
|
||||
deal_created
|
||||
deal_stage_changed
|
||||
deal_won
|
||||
deal_lost
|
||||
ticket_created
|
||||
ticket_resolved
|
||||
invoice_issued
|
||||
invoice_paid
|
||||
activity_created
|
||||
activity_done
|
||||
}
|
||||
|
||||
enum MessageAutomationDelayUnit {
|
||||
minutes
|
||||
hours
|
||||
days
|
||||
}
|
||||
|
||||
enum MessageAutomationChannel {
|
||||
app
|
||||
sms
|
||||
both
|
||||
}
|
||||
|
||||
enum MessageAutomationTarget {
|
||||
staff
|
||||
person
|
||||
both
|
||||
}
|
||||
|
||||
enum MessageAutomationJobStatus {
|
||||
pending
|
||||
sent
|
||||
cancelled
|
||||
failed
|
||||
}
|
||||
|
||||
model MessageAutomationRule {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
name String
|
||||
isActive Boolean @default(true)
|
||||
trigger MessageAutomationTrigger
|
||||
startDelayValue Int @default(0)
|
||||
startDelayUnit MessageAutomationDelayUnit @default(minutes)
|
||||
repeatCount Int @default(1)
|
||||
intervalValue Int @default(1)
|
||||
intervalUnit MessageAutomationDelayUnit @default(days)
|
||||
notifyTarget MessageAutomationTarget @default(person)
|
||||
channel MessageAutomationChannel @default(sms)
|
||||
title String
|
||||
body String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
jobs MessageAutomationJob[]
|
||||
|
||||
@@index([organizationId, isActive, trigger])
|
||||
}
|
||||
|
||||
model MessageAutomationJob {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
ruleId String
|
||||
rule MessageAutomationRule @relation(fields: [ruleId], references: [id], onDelete: Cascade)
|
||||
trigger MessageAutomationTrigger
|
||||
entityType String
|
||||
entityId String
|
||||
entityTitle String
|
||||
personId String?
|
||||
ownerId String?
|
||||
assigneeId String?
|
||||
attemptIndex Int
|
||||
sendAt DateTime
|
||||
status MessageAutomationJobStatus @default(pending)
|
||||
createdAt DateTime @default(now())
|
||||
sentAt DateTime?
|
||||
|
||||
@@unique([ruleId, entityId, attemptIndex])
|
||||
@@index([status, sendAt])
|
||||
@@index([organizationId, entityType, entityId, status])
|
||||
}
|
||||
|
||||
/// چالش OTP برای ثبتنام / ورود پنل
|
||||
model AuthChallenge {
|
||||
id String @id @default(cuid())
|
||||
|
||||
Reference in New Issue
Block a user