Menu

#47 [inbox] call API for conversation list and message list

closed
nobody
None
2026-03-23
2025-01-02
Anonymous
No

Originally created by: realcodesiman

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
}

Related

Tickets: #12

Discussion

  • Anonymous

    Anonymous - 2025-01-02
     
  • Anonymous

    Anonymous - 2026-03-23

    Ticket changed by: realcodesiman

    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB