Skip to main content

Public WebSocket Stream

Connect to a public agent thread’s real-time event stream. No authentication required — visitors are identified by email.

Endpoint

wss://api.ama2.me/api/v1/chat/ws/public/{slug}/threads/{thread_id}?email=visitor@example.com

Path Parameters

slug
string
required
The agent’s URL slug.
thread_id
string
required
UUID of the thread.

Query Parameters

email
string
required
Visitor’s email address.

Events

The public WebSocket receives the same event types as the user WebSocket, but scoped to the specific thread:
  • thread_message — New message in the thread
  • thread_typing — Participant typing indicator
  • thread_runtime — Agent runtime events
  • pong — Keep-alive response

Connection Example

const ws = new WebSocket(
  `wss://api.ama2.me/api/v1/chat/ws/public/my-agent/threads/${threadId}?email=visitor@example.com`
);

ws.onmessage = (event) => {
  const message = JSON.parse(event.data);
  
  if (message.type === "thread_message") {
    console.log(`${message.data.sender_id}: ${message.data.content}`);
  }
};