Chat Communication
Real-time chat communication via WebSockets
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:
Type | Description |
---|---|
chat | Regular chat messages |
typing | Typing indicator |
read_receipt | Message read confirmation |
presence | User presence updates |
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 senderroom_id
: The conversation or room IDdata.message
: The text message contentdata.sender
: The user ID of the sender (same asuser_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 messagedata.reply_to
: ID of the message being replied totimestamp
: 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:
-
Join the conversation room:
-
Request history messages (optional):
-
Update your presence:
Message Metadata
Chat messages can include metadata for additional context:
File Attachments
To send a message with file attachments:
- First upload the files using the
/files
API endpoint - 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.