Skip to main content
This page contains Flutter SDK code examples for User Engagement extensions. For feature documentation, setup instructions, and extension settings, see User Engagement Extensions.

How to Use Extensions with SDK

1

Enable in Dashboard

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

Configure settings (if required)

Some extensions require API keys or additional configuration. Open the extension settings in the Dashboard.
3

Implement SDK methods

Use the code examples below to call extension APIs and extract extension data from messages.
4

Build your UI

Create UI components to display extension data (e.g., polls, stickers, GIFs).

Giphy

Add GIFs from Giphy to your conversations.
String url = '/v1/trending?offset=1&limit=15';

CometChat.callExtension('gifs-giphy', 'GET', url, null,
  onSuccess: (Map<String, dynamic> response) {
    // GIFs data from Giphy
    debugPrint('Trending GIFs: $response');
  },
  onError: (CometChatException e) {
    debugPrint('Error: ${e.message}');
  }
);

Search for GIFs

String query = 'awesome';
String url = '/v1/search?offset=1&limit=15&query=$query';

CometChat.callExtension('gifs-giphy', 'GET', url, null,
  onSuccess: (Map<String, dynamic> response) {
    // GIFs data from Giphy
    debugPrint('Search GIFs: $response');
  },
  onError: (CometChatException e) {
    debugPrint('Error: ${e.message}');
  }
);

Message Translation

Translate messages into 70+ languages.

Translate Message

Map<String, dynamic> body = {
  'msgId': 12,
  'text': 'Hey there! How are you?',
  'languages': ['ru', 'hi', 'mr'],
};

CometChat.callExtension('message-translation', 'POST', '/v2/translate', body,
  onSuccess: (Map<String, dynamic> response) {
    // Result of translations
    debugPrint('Translations: $response');
  },
  onError: (CometChatException e) {
    debugPrint('Error: ${e.message}');
  }
);

Polls

Create and vote on polls in conversations.

Creating a Poll

Map<String, dynamic> body = {
  'question': 'Which OS do you use?',
  'options': ['Windows', 'Ubuntu', 'MacOS', 'Other'],
  'receiver': 'cometchat-uid-1',
  'receiverType': 'user',
};

CometChat.callExtension('polls', 'POST', '/v2/create', body,
  onSuccess: (Map<String, dynamic> response) {
    // Details about the created poll
    debugPrint('Poll created: $response');
  },
  onError: (CometChatException e) {
    debugPrint('Error: ${e.message}');
  }
);

Voting in a Poll

Map<String, dynamic> body = {
  'vote': '3',
  'id': 'd5441d53-c191-4696-9e92-e4d79da7463',
};

CometChat.callExtension('polls', 'POST', '/v2/vote', body,
  onSuccess: (Map<String, dynamic> response) {
    debugPrint('Vote submitted successfully');
  },
  onError: (CometChatException e) {
    debugPrint('Error: ${e.message}');
  }
);

Getting Results

String pollId = 'd5441d53-c191-4696-9e92-e4d79da7463';
String url = '/v2/results?id=$pollId';

CometChat.callExtension('polls', 'GET', url, null,
  onSuccess: (Map<String, dynamic> response) {
    // Poll results
    debugPrint('Poll results: $response');
  },
  onError: (CometChatException e) {
    debugPrint('Error: ${e.message}');
  }
);

Reminders

Set reminders for messages or custom events.

Set Message Reminders

Map<String, dynamic> body = {
  'about': 1,
  'isCustom': false,
  'timeInMS': 1638351344989,
};

CometChat.callExtension('reminders', 'POST', '/v1/reminder', body,
  onSuccess: (Map<String, dynamic> response) {
    debugPrint('Reminder created successfully');
  },
  onError: (CometChatException e) {
    debugPrint('Error: ${e.message}');
  }
);

Set Personal Reminders

Map<String, dynamic> body = {
  'about': 'Drinking water',
  'isCustom': true,
  'timeInMS': 1638351344989,
};

CometChat.callExtension('reminders', 'POST', '/v1/reminder', body,
  onSuccess: (Map<String, dynamic> response) {
    debugPrint('Personal reminder created successfully');
  },
  onError: (CometChatException e) {
    debugPrint('Error: ${e.message}');
  }
);

List Reminders

CometChat.callExtension('reminders', 'GET', '/v1/fetch', null,
  onSuccess: (Map<String, dynamic> response) {
    var reminders = response['reminders'];
    debugPrint('Reminders: $reminders');
  },
  onError: (CometChatException e) {
    debugPrint('Error: ${e.message}');
  }
);

Delete Reminders

Map<String, dynamic> body = {
  'reminderId': 'e9cda52a-3839-4fd5-a010-b70db136f0f1',
};

CometChat.callExtension('reminders', 'DELETE', '/v1/reminder', body,
  onSuccess: (Map<String, dynamic> response) {
    debugPrint('Reminder deleted successfully');
  },
  onError: (CometChatException e) {
    debugPrint('Error: ${e.message}');
  }
);

Stickers

Load and send stickers in conversations.

Loading Stickers

CometChat.callExtension('stickers', 'GET', '/v1/fetch', null,
  onSuccess: (Map<String, dynamic> response) {
    // Stickers received
    debugPrint('Stickers: $response');
  },
  onError: (CometChatException e) {
    debugPrint('Error: ${e.message}');
  }
);

Stipop

Access Stipop’s sticker platform.
String lang = 'en';
int limit = 20;
int pageNumber = 1;
String countryCode = 'US';
String url = '/v1/trending?lang=$lang&limit=$limit&pageNumber=$pageNumber&countryCode=$countryCode';

CometChat.callExtension('stickers-stipop', 'GET', url, null,
  onSuccess: (Map<String, dynamic> response) {
    // Stickers in response
    debugPrint('Trending stickers: $response');
  },
  onError: (CometChatException e) {
    debugPrint('Error: ${e.message}');
  }
);

Search for Stickers

String lang = 'en';
int limit = 20;
int pageNumber = 1;
String query = 'happy';
String url = '/v1/search?lang=$lang&limit=$limit&pageNumber=$pageNumber&query=$query';

CometChat.callExtension('stickers-stipop', 'GET', url, null,
  onSuccess: (Map<String, dynamic> response) {
    // Stickers in response
    debugPrint('Search stickers: $response');
  },
  onError: (CometChatException e) {
    debugPrint('Error: ${e.message}');
  }
);

Tenor

Add GIFs from Tenor to your conversations.
String url = '/v1/trending?offset=1&limit=15';

CometChat.callExtension('gifs-tenor', 'GET', url, null,
  onSuccess: (Map<String, dynamic> response) {
    // GIFs data from Tenor
    debugPrint('Trending GIFs: $response');
  },
  onError: (CometChatException e) {
    debugPrint('Error: ${e.message}');
  }
);

Search for GIFs

String query = 'awesome';
String url = '/v1/search?offset=1&limit=15&query=$query';

CometChat.callExtension('gifs-tenor', 'GET', url, null,
  onSuccess: (Map<String, dynamic> response) {
    // GIFs data from Tenor
    debugPrint('Search GIFs: $response');
  },
  onError: (CometChatException e) {
    debugPrint('Error: ${e.message}');
  }
);