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.Get Trending GIFs
- Kotlin
- Java
val url = "/v1/trending?offset=1&limit=15"
CometChat.callExtension("gifs-giphy", "GET", url, null,
object : CometChat.CallbackListener<JSONObject>() {
override fun onSuccess(jsonObject: JSONObject) {
// GIFs data from Giphy
}
override fun onError(e: CometChatException) {
// Some error occurred
}
}
)
String URL = "/v1/trending?offset=1&limit=15";
CometChat.callExtension("gifs-giphy", "GET", URL, null,
new CometChat.CallbackListener<JSONObject>() {
@Override
public void onSuccess(JSONObject jsonObject) {
// GIFs data from Giphy
}
@Override
public void onError(CometChatException e) {
// Some error occured
}
});
Search for GIFs
- Kotlin
- Java
val query = "awesome"
val url = "/v1/search?offset=1&limit=15&query=$query"
CometChat.callExtension("gifs-giphy", "GET", url, null,
object : CometChat.CallbackListener<JSONObject>() {
override fun onSuccess(jsonObject: JSONObject) {
// GIFs data from Giphy
}
override fun onError(e: CometChatException) {
// Some error occurred
}
}
)
String query = "awesome";
String URL = "/v1/search?offset=1&limit=15&query=" + query;
CometChat.callExtension("gifs-giphy", "GET", URL, null,
new CometChat.CallbackListener<JSONObject>() {
@Override
public void onSuccess(JSONObject jsonObject) {
// GIFs data from Giphy
}
@Override
public void onError(CometChatException e) {
// Some error occured
}
});
Tenor
Add GIFs from Tenor to your conversations.Get Trending GIFs
- Kotlin
- Java
val url = "/v1/trending?offset=1&limit=15"
CometChat.callExtension("gifs-tenor", "GET", url, null,
object : CometChat.CallbackListener<JSONObject>() {
override fun onSuccess(jsonObject: JSONObject) {
// GIFs data from Tenor
}
override fun onError(e: CometChatException) {
// Some error occurred
}
}
)
String URL = "/v1/trending?offset=1&limit=15";
CometChat.callExtension("gifs-tenor", "GET", URL, null,
new CometChat.CallbackListener<JSONObject>() {
@Override
public void onSuccess(JSONObject jsonObject) {
// GIFs data from Tenor
}
@Override
public void onError(CometChatException e) {
// Some error occured
}
});
Search for GIFs
- Kotlin
- Java
val query = "awesome"
val url = "/v1/search?offset=1&limit=15&query=$query"
CometChat.callExtension("gifs-tenor", "GET", url, null,
object : CometChat.CallbackListener<JSONObject>() {
override fun onSuccess(jsonObject: JSONObject) {
// GIFs data from Tenor
}
override fun onError(e: CometChatException) {
// Some error occurred
}
}
)
String query = "awesome";
String URL = "/v1/search?offset=1&limit=15&query=" + query;
CometChat.callExtension("gifs-tenor", "GET", URL, null,
new CometChat.CallbackListener<JSONObject>() {
@Override
public void onSuccess(JSONObject jsonObject) {
// GIFs data from Tenor
}
@Override
public void onError(CometChatException e) {
// Some error occured
}
});
Message Translation
Translate messages into 70+ languages.Translate Message
- Kotlin
- Java
val body = JSONObject()
val languages = JSONArray()
languages.put("ru")
languages.put("hi")
body.put("msgId", 12)
body.put("languages", languages)
body.put("text", "Hey there! How are you?")
CometChat.callExtension("message-translation", "POST", "/v2/translate", body,
object : CometChat.CallbackListener<JSONObject>() {
override fun onSuccess(jsonObject: JSONObject) {
// Result of translations
}
override fun onError(e: CometChatException) {
// Some error occurred
}
}
)
JSONObject body = new JSONObject();
JSONArray languages = new JSONArray();
languages.put("ru");
languages.put("hi");
body.put("msgId", 12);
body.put("languages", languages);
body.put("text", "Hey there! How are you?");
CometChat.callExtension("message-translation", "POST", "/v2/translate", body,
new CometChat.CallbackListener<JSONObject>() {
@Override
public void onSuccess(JSONObject jsonObject) {
// Result of translations
}
@Override
public void onError(CometChatException e) {
// Some error occured
}
});
Polls
Create and vote on polls in conversations.Creating a Poll
- Kotlin
- Java
val body = JSONObject()
val options = JSONArray()
options.put("Milk")
options.put("Cereal")
body.put("question", "Milk goes first or the cereal?")
body.put("options", options)
body.put("receiver", "cometchat-guid-1")
body.put("receiverType", "group")
CometChat.callExtension("polls", "POST", "/v2/create", body,
object : CometChat.CallbackListener<JSONObject>() {
override fun onSuccess(jsonObject: JSONObject) {
// On Success
}
override fun onError(e: CometChatException) {
// On Failure
}
}
)
JSONObject body = new JSONObject();
JSONArray options = new JSONArray();
options.put("Milk");
options.put("Cereal");
body.put("question", "Milk goes first or the cereal?");
body.put("options", options);
body.put("receiver", "cometchat-guid-1");
body.put("receiverType", "group");
CometChat.callExtension("polls", "POST", "/v2/create", body,
new CometChat.CallbackListener<JSONObject>() {
@Override
public void onSuccess(JSONObject jsonObject) {
//On Success
}
@Override
public void onError(CometChatException e) {
//On Failure
}
});
Voting in a Poll
- Kotlin
- Java
val body = JSONObject()
body.put("vote", "3")
body.put("id", "d5441d53-c191-4696-9e92-e4d79da7463")
CometChat.callExtension("polls", "POST", "/v2/vote", body,
object : CometChat.CallbackListener<JSONObject>() {
override fun onSuccess(jsonObject: JSONObject) {
// Vote submitted successfully
}
override fun onError(e: CometChatException) {
// Some error occurred
}
}
)
JSONObject body = new JSONObject();
body.put("vote", "3");
body.put("id", "d5441d53-c191-4696-9e92-e4d79da7463");
CometChat.callExtension("polls", "POST", "/v2/vote", body,
new CometChat.CallbackListener<JSONObject>() {
@Override
public void onSuccess(JSONObject jsonObject) {
// Vote submitted successfully
}
@Override
public void onError(CometChatException e) {
// Some error occured
}
});
Getting Results
- Kotlin
- Java
val pollId = "d5441d53-c191-4696-9e92-e4d79da7463"
val url = "/v2/results?id=$pollId"
CometChat.callExtension("polls", "GET", url, null,
object : CometChat.CallbackListener<JSONObject>() {
override fun onSuccess(jsonObject: JSONObject) {
// Poll results
}
override fun onError(e: CometChatException) {
// Some error occurred
}
}
)
String pollId = "d5441d53-c191-4696-9e92-e4d79da7463";
String URL = "/v2/results?id=" + pollId;
CometChat.callExtension("polls", "GET", URL, null,
new CometChat.CallbackListener<JSONObject>() {
@Override
public void onSuccess(JSONObject jsonObject) {
// Poll results
}
@Override
public void onError(CometChatException e) {
// Some error occured
}
});
Stickers
Load and send stickers in conversations.Loading Stickers
- Kotlin
- Java
CometChat.callExtension("stickers", "GET", "/v1/fetch", null,
object : CometChat.CallbackListener<JSONObject>() {
override fun onSuccess(responseObject: JSONObject) {
// Stickers received here.
}
override fun onError(e: CometChatException) {
// Some error occurred.
}
}
)
CometChat.callExtension("stickers", "GET", "/v1/fetch", null,
new CometChat.CallbackListener<JSONObject>() {
@Override
public void onSuccess(JSONObject responseObject) {
// Stickers received here.
}
@Override
public void onError(CometChatException e) {
// Some error occured.
}
});
Stipop
Access Stipop’s sticker platform.Get Trending Stickers
- Kotlin
- Java
val lang = "en"
val limit = 20
val pageNumber = 1
val countryCode = "US"
val url = "/v1/trending?lang=$lang&limit=$limit&pageNumber=$pageNumber&countryCode=$countryCode"
CometChat.callExtension("stickers-stipop", "GET", url, null,
object : CometChat.CallbackListener<JSONObject>() {
override fun onSuccess(responseObject: JSONObject) {
// Stickers in response
}
override fun onError(e: CometChatException) {
// Some error occurred
}
}
)
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,
new CometChat.CallbackListener<JSONObject>() {
@Override
public void onSuccess(JSONObject responseObject) {
// Stickers in response
}
@Override
public void onError(CometChatException e) {
// Some error occured
}
});
Search for Stickers
- Kotlin
- Java
val lang = "en"
val limit = 20
val pageNumber = 1
val query = "happy"
val url = "/v1/search?lang=$lang&limit=$limit&pageNumber=$pageNumber&query=$query"
CometChat.callExtension("stickers-stipop", "GET", url, null,
object : CometChat.CallbackListener<JSONObject>() {
override fun onSuccess(responseObject: JSONObject) {
// Stickers in response
}
override fun onError(e: CometChatException) {
// Some error occurred
}
}
)
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,
new CometChat.CallbackListener<JSONObject>() {
@Override
public void onSuccess(JSONObject responseObject) {
// Stickers in response
}
@Override
public void onError(CometChatException e) {
// Some error occured
}
});
Reminders
Set reminders for messages or custom events.Set Message Reminders
- Kotlin
- Java
val body = JSONObject()
body.put("about", 1)
body.put("isCustom", false)
body.put("timeInMS", 1638351344989L)
CometChat.callExtension("reminders", "POST", "/v1/reminder", body,
object : CometChat.CallbackListener<JSONObject>() {
override fun onSuccess(responseObject: JSONObject) {
// Reminder created successfully
}
override fun onError(e: CometChatException) {
// Some error occurred
}
}
)
JSONObject body = new JSONObject();
body.put("about", 1);
body.put("isCustom", false);
body.put("timeInMS", 1638351344989L);
CometChat.callExtension("reminders", "POST", "/v1/reminder", body,
new CometChat.CallbackListener<JSONObject>() {
@Override
public void onSuccess(JSONObject responseObject) {
// Reminder created successfully
}
@Override
public void onError(CometChatException e) {
// Some error occured
}
});
Set Personal Reminders
- Kotlin
- Java
val body = JSONObject()
body.put("about", "Drinking water")
body.put("isCustom", true)
body.put("timeInMS", 1638351344989L)
CometChat.callExtension("reminders", "POST", "/v1/reminder", body,
object : CometChat.CallbackListener<JSONObject>() {
override fun onSuccess(responseObject: JSONObject) {
// Personal reminder created successfully
}
override fun onError(e: CometChatException) {
// Some error occurred
}
}
)
JSONObject body = new JSONObject();
body.put("about", "Drinking water");
body.put("isCustom", true);
body.put("timeInMS", 1638351344989L);
CometChat.callExtension("reminders", "POST", "/v1/reminder", body,
new CometChat.CallbackListener<JSONObject>() {
@Override
public void onSuccess(JSONObject responseObject) {
// Personal reminder created successfully
}
@Override
public void onError(CometChatException e) {
// Some error occured
}
});
List Reminders
- Kotlin
- Java
CometChat.callExtension("reminders", "GET", "/v1/fetch", null,
object : CometChat.CallbackListener<JSONObject>() {
override fun onSuccess(responseObject: JSONObject) {
// Reminders list
}
override fun onError(e: CometChatException) {
// Some error occurred
}
}
)
CometChat.callExtension("reminders", "GET", "/v1/fetch", null,
new CometChat.CallbackListener<JSONObject>() {
@Override
public void onSuccess(JSONObject responseObject) {
// Reminders list
}
@Override
public void onError(CometChatException e) {
// Some error occured
}
});
Delete Reminders
- Kotlin
- Java
val body = JSONObject()
body.put("reminderId", "e9cda52a-3839-4fd5-a010-b70db136f0f1")
CometChat.callExtension("reminders", "DELETE", "/v1/reminder", body,
object : CometChat.CallbackListener<JSONObject>() {
override fun onSuccess(responseObject: JSONObject) {
// Reminder deleted successfully
}
override fun onError(e: CometChatException) {
// Some error occurred
}
}
)
JSONObject body = new JSONObject();
body.put("reminderId", "e9cda52a-3839-4fd5-a010-b70db136f0f1");
CometChat.callExtension("reminders", "DELETE", "/v1/reminder", body,
new CometChat.CallbackListener<JSONObject>() {
@Override
public void onSuccess(JSONObject responseObject) {
// Reminder deleted successfully
}
@Override
public void onError(CometChatException e) {
// Some error occured
}
});