addChat
chat.addChat({ chat: IChat });
The addChat method initializes a new chat within the ChatBot widget. This method is essential for creating agent-based support channels. It requires an object parameter that includes chat details.
IChat Object Properties
convert: boolean - Indicates whether the chat should be converted. Default value isfalse.chat:Chat- Contains chat-specific details like ID, agent ID, theme, and creation date.
Chat Object Properties
id: TID - Unique identifier for the chat.agent: TID - Unique identifier for the agent handling the chat.theme: string - Topic or theme of the chat.created: Date - Timestamp indicating when the chat was created.
Use-Cases
Basic Chat Initialization
To initialize a chat using the addChat method, supply an IChat object with the required properties. This will create a new chat instance within the widget.
const newChat = {
convert: true,
chat: {
id: "12345",
agent: "agent_01",
theme: "Support Request",
created: new Date()
}
};
chat.addChat({ chat: newChat });
console.log("New chat was created", newChat.chat.id, newChat.chat.theme);
In this example, a new chat is created with the ID "12345" and theme "Support Request". The chat is assigned to the agent with ID "agent_01". The creation date is the current date and time. The convert property is set to true.