AI Integration Quick Reference
AI Integration Quick Reference
Overview
The Message Privately feature streamlines direct messaging by enabling:- Quick entry into a one-on-one conversation from a user context.
- Automatic conversation creation if none exists.
- Optional initial message send to surface the chat in lists.
MessagesActivity with the target user’s UID → chat UI loads.
Prerequisites
- Android Studio project with CometChat Android UI Kit v5 (
com.cometchat:chatuikit-kotlinorcom.cometchat:chatuikit-jetpack) added tobuild.gradle. - Valid CometChat App ID, Auth Key, and Region initialized.
<uses-permission android:name="android.permission.INTERNET"/>inAndroidManifest.xml.- Users created in your CometChat app.
- User must be logged in via
CometChatUIKit.login()before invoking this feature. - Existing
MessagesActivitycapable of handling one-on-one chats.
Components
Integration Steps
1. Launch One-on-One Chat from Profile
Navigate fromUserDetailsActivity to MessagesActivity with the selected user.
- Kotlin (XML Views)
- Jetpack Compose
2. Handle Incoming Intent in Chat Screen
Deserialize theUser JSON extra and configure the chat UI.
- Kotlin (XML Views)
- Jetpack Compose
3. (Optional) Programmatically Create Conversation
Send an initial greeting to ensure the chat appears in conversation lists.- Kotlin (XML Views)
- Jetpack Compose
Implementation Flow
Customization Options
- Button Text & Style: Update
messagePrivatelyBtninactivity_user_details.xml. - Intent Extras Key: Use a custom key instead of
R.string.app_user. - Dummy Message: Customize initial message content or omit step if undesired.
Edge Cases
Summary / Feature Matrix
Android Sample App (Kotlin)
Explore this feature in the CometChat SampleApp:
GitHub → SampleApp