ChatbotX icon indicating copy to clipboard operation
ChatbotX copied to clipboard

[inbox] call API for conversation list and message list

Open realcodesiman opened this issue 1 year ago • 0 comments

DoD

Add API and handle actions for:

  • conversations list
  • messages list

Add a button to add new message randomly from chat room DON'T care about websocket, will be implemented later

Actions for message:

  • add new:
    • reorder conversation list
    • retrieve conversation if this does not exists in the list

Reference

https://clerk.com/blog/authenticated-next-chat-app-with-ably-and-clerk

Database

Inbox {
    id String    @id @default(cuid(2))
    createdAt DateTime  @default(now())
    updatedAt     DateTime  @updatedAt
    chatbotId String
    channelType String // eg: ChannelWebWidget | ChannelMessenger | ChannelWhatsapp | ...
    channelId String
    name String
}

ContactInbox {
    contactId String
    inboxId String
    createdAt DateTime  @default(now())
    updatedAt     DateTime  @updatedAt
    chatbotId String
    sourceId String  // id message of messenger or whatsapp, ...
}

WebWidgetTemplate {
    id String    @id @default(cuid(2))
    name String
}

ChannelWebWidget {
    id String    @id @default(cuid(2))
    chatbotId String
    // welcomeFlowId String? -> relation to Flow.id, add later
    authorizedDomains String[]
    // suggestedMessages Json // dự kiến [{ key: hello, actionType: SendFlow | OpenWebsite | Text, value: .... }]
    // menus Json // dự kiến [{ key: hello, menuType: SendFlow | OpenWebsite, value: .... }]
    webWidgetTemplateId String
    brandColor String @default("#007bff")
    showHeader Boolean @default(true)
    showPersonalLogo Boolean @default(false)
    showMessageInput Boolean @default(true)
    customizeCss String?
}

Conversation {
    id String    @id @default(cuid(2))
    createdAt DateTime  @default(now())
    updatedAt     DateTime  @updatedAt
    chatbotId String
    contactId String
    contactInboxId String
    contactLastSeenAt DateTime?
    agentLastSeenAt DateTime?
    sourceId String  // id message of messenger or whatsapp, ...
}

ConversationParticipant {
    id String    @id @default(cuid(2))
    createdAt DateTime  @default(now())
    updatedAt     DateTime  @updatedAt
    chatbotId String
    conversationId String
    userId String
    contactId String
}

Message {
    id String    @id @default(cuid(2))
    createdAt DateTime  @default(now())
    updatedAt     DateTime  @updatedAt
    conversationId String
    inboxId String
    chatbotId String
    messageType MessageType // enum: text | image | markdown | audio | video | file | location | carousel | card | dropdown | choice
    content String?
    senderType SenderType
    senderId String?
}

Attachment {
    id String    @id @default(cuid(2))
    createdAt DateTime  @default(now())
    updatedAt     DateTime  @updatedAt
    chatbotId String
    attachmentType Attachment // enum: image | audio | video | ...
    messageId String
}

realcodesiman avatar Jan 02 '25 13:01 realcodesiman