Skip to main content

WebSocket Chat Communication

The ProductFlo WebSocket API provides robust support for real-time chat communication between users, teams, and AI assistants.

Chat Message Types

The following message types are used for chat communication:

Sending Chat Messages

To send a chat message, use the following format:

Required Fields

  • code: Must be “chat”
  • user_id: The user ID of the sender
  • room_id: The conversation or room ID
  • data.message: The text message content
  • data.sender: The user ID of the sender (same as user_id)

Optional Fields

  • data.message_id: Unique ID for the message (auto-generated if not provided)
  • data.attached_files: Array of file IDs attached to the message
  • data.reply_to: ID of the message being replied to
  • timestamp: ISO format timestamp (auto-generated if not provided)

Receiving Chat Messages

When a chat message is received, it will have the following format:

Typing Indicators

To indicate that a user is typing, send a message with the RoomStatus.TYPING code:

Read Receipts

To mark a message as read, send a message with the RoomStatus.READ_RECEIPT code:

Presence Updates

To update user presence status, send a message with the RoomStatus.PRESENCE code:

Conversation Rooms

Chat messages are organized into rooms based on the conversation ID. When joining a conversation, you should:
  1. Join the conversation room:
  2. Request history messages (optional):
  3. Update your presence:

Message Metadata

Chat messages can include metadata for additional context:

File Attachments

To send a message with file attachments:
  1. First upload the files using the /files API endpoint
  2. Then include the file IDs in the chat message:

Broadcast Messages

To send a message to multiple rooms, use a server-side broadcast through the API. Clients cannot directly broadcast messages for security reasons.