How to Set Up a WebSocket Connection
Akece allows you to establish real-time connections using the WebSocket protocol, enabling continuous data exchange
between client and server. This feature is ideal for building custom integrations, such as real-time dashboards, mobile
interfaces, and instant conversation updates.
Why Use WebSocket?
A WebSocket connection delivers real-time updates without requiring a page refresh. This results in a smoother user
experience — especially useful in internal tools, mobile apps, or custom interfaces.
How to Establish a WebSocket Connection
The WebSocket URL for Akece follows this format:
wss://dash.akece.com/cable
To authenticate, you’ll need a corresponding PubSub token. There are two types:
- User token: used by agents or admins. It can be obtained via the profile API.
- Contact token: automatically generated when creating a contact via API. It is limited to that customer session.
Example Connection
const stringify = (payload = {}) => JSON.stringify(payload);
const pubSubToken = "<your-pubsub-token>";
const accountId = "<your-account-id>";
const userId = "<your-user-id>";
const connection = new WebSocket("wss://dash.akece.com/cable");
connection.send(
stringify({
command: "subscribe",
identifier: stringify({
channel: "RoomChannel",
pubsub_token: pubSubToken,
account_id: accountId,
user_id: userId,
}),
})
);
Updating Presence Status
To maintain online presence status, send the following payload every 30 seconds:
For agents/admins:
const userPayload = stringify({
command: "message",
identifier: stringify({
channel: "RoomChannel",
pubsub_token: "<user-pubsub-token>",
account_id: accountId,
user_id: userId,
}),
data: stringify({ action: "update_presence" }),
});
connection.send(userPayload);
For contacts:
const contactPayload = stringify({
command: "message",
identifier: stringify({
channel: "RoomChannel",
pubsub_token: "<contact-pubsub-token>",
}),
data: stringify({ action: "update_presence" }),
});
connection.send(contactPayload);
Supported Event Types
You’ll receive real-time events as interactions happen on the platform. Here are some of the key event types:
- conversation.created – a new conversation has started
- message.created – a new message was received
- message.updated – a message was edited
- conversation.status_changed – conversation status was updated
- conversation.typing_on / typing_off – typing indicators
- contact.updated – contact information changed
- presence.update – online/offline status update
- notification_created – a new notification was triggered
These events can be used to build dynamic interfaces, automated flows, or custom dashboards.
Need help integrating with WebSocket?
📩 [email protected] | 📱 @akece.ai