Overview

Vocantly uses WebSockets for all messaging operations. Messages are sent through the SDK and delivered in real-time to all conversation participants.
Messages are sent exclusively over WebSockets.This guarantees ordering, real-time delivery, typing indicators, presence, and receipts.REST APIs are used for history, analytics, and internal automation only.

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

  1. Optimistic - Message created locally, isOptimistic: true
  2. Confirmed - Server confirms, isOptimistic: false
  3. Delivered - Recipient received, receiptState: 'delivered'
  4. 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 message event 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