Skip to main content

Conversations & Messages

Conversation (Chat)

A Conversation (stored in the chats table) represents a threaded exchange between your organization and a contact on a specific channel. Each conversation is tied to one contact and one channel (WhatsApp, Facebook Messenger, Instagram, email, or internal).

Key fields

FieldTypeDescription
idUUIDPrimary key
organization_idUUIDOwning tenant
customer_idUUIDLinked contact
channeltextChannel identifier (whatsapp, facebook, instagram, email, internal)
statustextConversation state (open, closed, pending)
assigned_toUUIDAgent handling this conversation
last_message_attimestamptzTimestamp of the most recent message
unread_countintegerNumber of unread inbound messages
metadatajsonbChannel-specific metadata

Lifecycle

  1. Created — when a new inbound message arrives from an unknown thread, or an agent initiates an outbound conversation.
  2. Open — actively being handled by an agent.
  3. Pending — waiting for customer reply or internal action.
  4. Closed — resolved; can be reopened if the customer sends a new message.

Message

A Message is a single communication unit within a conversation. Messages can be text, media (image, video, document, audio), template messages, or system events.

Key fields

FieldTypeDescription
idUUIDPrimary key
chat_idUUIDParent conversation
sender_typetextcustomer, agent, or system
sender_idUUIDUser or contact who sent the message
contenttextMessage body (text)
media_urltextURL of attached media
media_typetextMIME type of media
message_typetexttext, image, video, document, audio, template, reaction
external_idtextID from the external platform (e.g., WhatsApp message ID)
statustextDelivery status (sent, delivered, read, failed)
directiontextinbound or outbound
created_attimestamptzWhen the message was sent/received

Channel-specific behavior

  • WhatsApp: Messages flow through whatsapp-webhook (inbound) and whatsapp-send-message (outbound). Template messages use whatsapp-send-template.
  • Facebook Messenger: Inbound via facebook-webhook, outbound via facebook-send-message.
  • Instagram: Inbound via instagram-webhook, outbound via instagram-send-message.
  • Internal: Used for internal team chat and ticket notes.

Thread

Conversations may contain sub-threads when a single contact has multiple open topics. In the current implementation, each channel-contact pair creates one conversation, with messages ordered chronologically.

TablePurpose
chatsConversation records
messagesIndividual messages
whatsapp_credentialsWhatsApp Business API credentials (per org)
message_templatesReusable message templates