Add AI auto sales replies for inbox
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
CREATE TABLE "PageInboxAiAutomation" (
|
||||
"id" TEXT NOT NULL,
|
||||
"pageId" TEXT NOT NULL,
|
||||
"enabled" BOOLEAN NOT NULL DEFAULT false,
|
||||
"personaName" TEXT NOT NULL DEFAULT 'แอดมินพิม',
|
||||
"salesGoal" TEXT NOT NULL DEFAULT '',
|
||||
"instructions" TEXT NOT NULL DEFAULT '',
|
||||
"updatedById" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
CONSTRAINT "PageInboxAiAutomation_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
CREATE TABLE "InboxAiReply" (
|
||||
"id" TEXT NOT NULL,
|
||||
"automationId" TEXT NOT NULL,
|
||||
"sourceId" TEXT NOT NULL,
|
||||
"recipientId" TEXT NOT NULL,
|
||||
"outcome" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT "InboxAiReply_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
CREATE UNIQUE INDEX "PageInboxAiAutomation_pageId_key" ON "PageInboxAiAutomation"("pageId");
|
||||
CREATE UNIQUE INDEX "InboxAiReply_sourceId_key" ON "InboxAiReply"("sourceId");
|
||||
CREATE INDEX "InboxAiReply_automationId_createdAt_idx" ON "InboxAiReply"("automationId", "createdAt");
|
||||
ALTER TABLE "PageInboxAiAutomation" ADD CONSTRAINT "PageInboxAiAutomation_pageId_fkey" FOREIGN KEY ("pageId") REFERENCES "Page"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE "InboxAiReply" ADD CONSTRAINT "InboxAiReply_automationId_fkey" FOREIGN KEY ("automationId") REFERENCES "PageInboxAiAutomation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -170,6 +170,7 @@ model Page {
|
||||
generationJobs PostGenerationJob[]
|
||||
teamPage TeamPage?
|
||||
contentAutomation PageContentAutomation?
|
||||
inboxAiAutomation PageInboxAiAutomation?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
@@ -361,6 +362,35 @@ model Conversation {
|
||||
@@unique([pageId, platform, psid])
|
||||
}
|
||||
|
||||
// Per-page AI sales assistant. Message bodies remain live in Graph and are
|
||||
// never persisted here; only configuration and source-message dedupe are kept.
|
||||
model PageInboxAiAutomation {
|
||||
id String @id @default(cuid())
|
||||
pageId String @unique
|
||||
page Page @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
||||
enabled Boolean @default(false)
|
||||
personaName String @default("แอดมินพิม")
|
||||
salesGoal String @default("")
|
||||
instructions String @default("")
|
||||
updatedById String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
replies InboxAiReply[]
|
||||
}
|
||||
|
||||
model InboxAiReply {
|
||||
id String @id @default(cuid())
|
||||
automationId String
|
||||
automation PageInboxAiAutomation @relation(fields: [automationId], references: [id], onDelete: Cascade)
|
||||
sourceId String @unique
|
||||
recipientId String
|
||||
outcome String
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([automationId, createdAt])
|
||||
}
|
||||
|
||||
model ReplyRule {
|
||||
id String @id @default(cuid())
|
||||
pageId String
|
||||
|
||||
Reference in New Issue
Block a user