Skip to main content
This page contains Flutter SDK code examples for Smart Chat features. For feature documentation, setup instructions, and configuration options, see Smart Chat Features.

How to Use AI Features with SDK

1

Enable in Dashboard

Login to CometChat Dashboard, select your app, then go to Chat & Messaging → Features and enable the AI feature.
2

Configure AI settings

Open the AI feature settings in the Dashboard to configure options like response style, language, etc.
3

Implement SDK methods

Use the code examples below to fetch AI-generated content.
4

Build your UI

Create UI components to display conversation starters, smart replies, and summaries.

Conversation Starter

Retrieve AI-generated initial messages to start conversations.

Get Conversation Starters

String receiveId = "";
String receiverType = CometChatConversationType.user;
Map configuration = { "lastNMessages": 100 };

CometChat.getConversationStarter("cometchat-uid-2", "user", configuration: configuration, onSuccess: (List<String> starters) {
    debugPrint("getConversationStarter Success: $starters");
}, onError: (CometChatException e) {
    debugPrint("getConversationStarter Error: $e");
});

Smart Replies

Retrieve AI-generated reply suggestions based on conversation context.

Get Smart Replies

String receiveId = "";
String receiverType = CometChatConversationType.user;
Map configuration = { "lastNMessages": 100 };

CometChat.getSmartReplies(receiveId, receiverType, configuration: configuration, onSuccess: (HashMap<String, String> map) {
    debugPrint("getSmartReplies Success: $map");
}, onError: (CometChatException e) {
    debugPrint("getSmartReplies Error: $e");
});

Conversation Summary

Retrieve AI-generated summaries of conversations.

Get Conversation Summary

String receiveId = "";
String receiverType = CometChatConversationType.user;
Map configuration = { "lastNMessages": 100 };

CometChat.getConversationSummary(receiveId, receiverType, configuration: configuration, onSuccess:(String summary) {
   debugPrint("getConversationSummary Success: $summary");
}, onError: (CometChatException e) {
   debugPrint("getConversationSummary error: $e");
});