Endpoint
wss://platform.watermelonn.app/ws?token=YOUR_WIDGET_TOKEN
Incoming message types
| Type | Purpose |
|---|---|
message | Send user chat content. |
typing | Send typing indicator to other participants. |
ping | Keepalive check. |
history | Request conversation history. |
Outgoing message types
| Type | Purpose |
|---|---|
connected | Confirms successful auth and connection. |
message | Final non-stream response payload. |
typing | Typing state event. |
history | Conversation history payload. |
pong | Keepalive response. |
stream_start | Marks beginning of streamed assistant response. |
stream_chunk | One chunk of generated response text. |
stream_end | Marks end of streaming. |
error | Protocol or processing error. |
Example
const ws = new WebSocket('wss://platform.watermelonn.app/ws?token=YOUR_TOKEN');
ws.onopen = () => {
ws.send(JSON.stringify({
type: 'message',
payload: {
message: 'Cancel my order #5678',
stream: true
}
}));
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log(data.type, data.payload);
};