select-chat
chat.on("select-chat", ({ id: TID, agent?: TID }) => {
console.log("new chat was selected", id);
if (agent)
console.log("active agent", agent);
});
Used to detect when a new chat interaction is selected by the user. The callback function receives the chat ID and the optionally active agent ID. This event can be utilized to update the UI or perform any specific actions based on the selected chat.
detect that chat was selected
chat.on("select-chat", ({ id: TID, agent?: TID }) => {
console.log("new chat was selected", id);
if (agent)
console.log("active agent", agent);
});
To log the selected chat ID and the active agent ID (if available). This helps in debugging and tracking user interactions. Suitable for scenarios where maintaining context of the conversation is vital.
chat.on("select-chat", ({ id: TID, agent?: TID }) => {
console.log("new chat was selected", id);
if (agent)
console.log("active agent", agent);
});
intercept-select-chat
chat.intercept("select-chat", ({ id: TID, agent?: TID }) => {
console.log("chat selection is blocked", id);
if (agent)
console.log("blocked active agent", agent);
return false;
});
Used to block the chat selection process. The callback function receives the chat ID and optionally the active agent ID. Returning false from the callback function prevents the chat from being selected. This event can be useful when there are certain conditions under which a chat should not be accessible.
How to block chat selection
chat.intercept("select-chat", ({ id: TID, agent?: TID }) => {
console.log("chat selection is blocked", id);
if (agent)
console.log("blocked active agent", agent);
return false;
});
To conditionally block a chat from being selected. This can be used to implement access controls or prevent interactions during certain states (e.g., when an agent is offline or the chat is archived).