Overview
Vocantly uses WebSockets for all messaging operations. Messages are sent through the SDK and delivered in real-time to all conversation participants.Sending Messages
Basic Usage
With Message Type
With Metadata
Receiving Messages
Listen for incoming messages on a conversation:Message Object
Optimistic Updates
When you send a message, the SDK creates an optimistic message immediately:Message Lifecycle
- Optimistic - Message created locally,
isOptimistic: true - Confirmed - Server confirms,
isOptimistic: false - Delivered - Recipient received,
receiptState: 'delivered' - Read - Recipient read,
receiptState: 'read'
Receipt States
Track message delivery status:Message Deduplication
The SDK automatically handles duplicate messages:- Messages with the same ID are deduplicated
- You’ll only receive one
messageevent per unique message - Server echoes are reconciled with optimistic messages
Complete Example
React Integration
Best Practices
Optimistic UI
Show messages immediately using
isOptimistic flag, then update when confirmed.Error Handling
Always handle the
error event to catch and display messaging errors.Deduplication
The SDK handles this, but ensure your UI can handle message updates.
Stop Typing
Call
stopTyping() before sending a message to clear the typing indicator.Next Steps
Typing
Typing indicators
Receipts
Read receipts
Presence
Online/offline status
Examples
Complete examples