Skip to main content

chats

type Chat = {
id: TID;
agent: TID;
theme: string; // topic of the chat
created: Date;
};

Controls the list of chats previously created by the current user. The default value is an empty array. The property is an array of chat objects, where each chat object contains the id, agent, theme, and created date.

Example of usage:

const chats = [
{ id: 1, agent: 1, theme: "First Question", created: new Date() }
];

const chatBot = new ChatBot(node, { chats });

How to update the list of chats previously created by current user

const chats = [
{ id: 1, agent: 1, theme: "First Question", created: new Date() }
];

chatBot.setConfig({ chats });

How to update the date format for chats

const chats = [
{ id: 1, agent:1, theme:"First Question", created: new Date() }
];

// Example of updating the date format for existing chats
const updatedChats = chats.map(chat => ({
...chat,
created: new Date(chat.created).toLocaleString()
}));

chatBot.setConfig({ chats: updatedChats });

How to get the current state of the list of chats previously created by the current user

const chats = chatBot.getConfig().chats;