Skip to main content

AI Bots

AI Bots in CometChat are designed to facilitate conversations with users. Each AI Bot is associated with a specific AI Personality.

Before you begin

Image
  1. Configure the AI settings through the CometChat dashboard as detailed in the Overview section.
  2. Navigate to AI Bots section and add a new bot by clicking on the "+" button.
  3. Enter bot details like UID, Avatar, Bot name and assign a Personality from the dropdown. Then "Enable" the bot.
  4. These details can be edited by clicking on the three dots. Similarly, you can also delete a bot.

How does it work?

Direct Conversation

Users can engage in direct conversations with bots by typing messages or asking questions. Bots respond in real-time, providing relevant information or responses based on their configured personality.

Ask for Suggestions in a Conversation

Users can also request suggestions or recommendations from bots. Bots analyze user input and provide suggestions accordingly. For example, a user may ask a bot for movie recommendations, and the bot will respond with a list of movie suggestions.

info

Bots Suggestion are request-response based, so they will not know about the previous questions asked when asking for a suggestion. However, an end-user can converse with a Bot in a Direct Conversation.

CometChat AI Bot goes through the messages of a conversation to understand the context of a conversation & answer a question asked to the Bot. The CometChat SDK has a method to ask a question to the CometChat AI Bot. It returns a string response.

The number of messages to be fetched to generate relevant suggestion is configurable. By default the CometChat AI Bot takes the recent 1000 messages of a conversation. It can be configured to timestamp specific or for unread messages only.

ConfigurationValue
lastNMessagesThis will fetch specific number of messages.
fromTimestampThis will fetch messages from a particular timestamp.
toTimestampThis will fetch messages until a particular timestamp.
unreadOnlyThis will fetch only the unread messages.
info

While using any configuration mentioned above a maximum of only 1000 messages will be fetched.

Implementation

SDKs

To implement AI Bots in the platform of your choice, you may utilize the following code samples:

const receiverId = "UID/GUID";
const receiverType = "user/group";
const botUid = "UID";
const question = "Question for Bot";
const configuration = { lastNMessages: 100 };

CometChat.askBot(
receiverId,
receiverType,
botUid,
question,
configuration
).then(
(answer) => {
console.log("Bot Reply", answer);
},
(error) => {
console.log("An error occurred while fetching bot response.", error);
}
);

UI Kits

Assuming the necessary pre-requisites are met, AI Bots function seamlessly in the latest v4 Chat UI Kits.