Conversations
Conversation Events
Subscribe to client conversation events including start, token streaming, completion, and rating feedback. Overview Asiyst provides a comprehensive event...
On this page (4 sections)
Overview
Asiyst provides a comprehensive event emitter on the client SDK 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);
});
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);
}
});