Conversations
Conversation Events
Subscribe to client and server conversation events including start, token streaming, completion, and rating feedback.
Overview
Asiyst provides a comprehensive event emitter on the client SDK and webhook notifications on the server to notify your application whenever a visitor starts a chat, sends a message, receives an answer, or leaves rating feedback.
Client SDK Events
Subscribe to lifecycle events directly in your frontend code:
import { Asiyst } from "@asiyst/sdk";
// Conversation opened
Asiyst.on("conversation:started", ({ conversationId }) => {
console.log("Started conversation:", conversationId);
});
// User dispatched a query
Asiyst.on("message:sent", ({ text, timestamp }) => {
console.log("User asked:", text);
});
// Assistant completed generation
Asiyst.on("message:received", ({ text, citations, latencyMs }) => {
console.log("Assistant responded in", latencyMs, "ms");
});
// Visitor submitted feedback thumbs up / down
Asiyst.on("feedback:submitted", ({ messageId, rating, comment }) => {
console.log("Feedback:", rating, comment);
});
Server Webhook Events
Configure HTTP endpoints via the Asiyst Webhooks console (/dashboard/api/webhooks) to receive server-side notifications:
| Event Type | Trigger | Key Payload Fields |
|---|---|---|
conversation.started | Visitor initiates a new dialogue | conversationId, visitorId, startedAt |
conversation.message | Message sent by user or assistant | messageId, role, content, citations |
conversation.completed | Dialogue concludes or times out | turnCount, durationSeconds, transcript |
feedback.created | Visitor rates an answer | rating (up/down), comment, messageId |
Webhook Payload Example:
{
"event": "conversation.completed",
"timestamp": "2026-09-28T03:30:00Z",
"data": {
"conversationId": "conv_9a8b7c6d5e",
"projectId": "proj_9f8a2b3c4d",
"turnCount": 4,
"durationSeconds": 142,
"satisfactionScore": 5
}
}
Capturing User Feedback & Ratings
When visitors click the thumbs-up or thumbs-down buttons beneath assistant answers:
- The rating is stored alongside the message transcript.
- Feedback is aggregated in the Analytics > Conversation Quality dashboard.
- If negative feedback is submitted with a comment, an alert can be dispatched to your team's Slack or Discord channel.
Integrating with External Analytics
Forward Asiyst conversation events to Google Analytics, PostHog, or Segment:
Asiyst.on("conversation:completed", (data) => {
// Google Analytics 4
if (typeof gtag === "function") {
gtag("event", "assistant_conversation_completed", {
conversation_id: data.conversationId,
turn_count: data.turnCount,
});
}
// PostHog
if (window.posthog) {
posthog.capture("Assistant Conversation Completed", data);
}
});