AI Agent Component Spec
AI Agent Component Spec
| Field | Value |
|---|---|
| Package | @cometchat/chat-uikit-react |
| Key components | CometChatMessages — uses CometChat.blockUsers() / CometChat.unblockUsers() SDK methods |
| Init | CometChatUIKit.init(UIKitSettings) then CometChatUIKit.login("UID") |
| Events | CometChatUserEvents.ccUserBlocked, CometChatUserEvents.ccUserUnblocked |
| UI helpers | CometChatConfirmDialog, CometChatToast |
| Sample app | GitHub |
| Related | All Guides |
Components
| Component / Class | Role |
|---|---|
CometChat.blockUsers() | SDK method to block specific users |
CometChat.unblockUsers() | SDK method to unblock previously blocked users |
CometChatUserEvents.ccUserBlocked | Event fired when a user is blocked |
CometChatUserEvents.ccUserUnblocked | Event fired when a user is unblocked |
CometChatConfirmDialog | Confirmation dialog for block/unblock actions |
Integration Steps
1. Block User
CallCometChat.blockUsers() with the target UID. On success, update the local user object with setBlockedByMe(true) and emit ccUserBlocked so all subscribed components (like the composer) react to the change.
File: CometChatHome.tsx
2. Unblock User
CallCometChat.unblockUsers() with the target UID. On success, reset the action items back to “Block” (instead of “Unblock”), update the local user object, and emit ccUserUnblocked to restore the composer.
File: CometChatHome.tsx
3. Confirmation Dialog
Show a confirmation dialog before blocking. This prevents accidental blocks. The dialog usesCometChatConfirmDialog with localized title, message, and button text.
File: CometChatHome.tsx
4. Composer Blocked State
File: CometChatMessages.tsx When a user is blocked, the composer is replaced with an unblock prompt:5. Event Listeners
File: CometChatHome.tsx Subscribe to block/unblock events to update the UI in real time:Feature Matrix
| Feature | Component / Method | File |
|---|---|---|
| Block user | CometChat.blockUsers([UID]) | CometChatHome.tsx |
| Unblock user | CometChat.unblockUsers([UID]) | CometChatHome.tsx |
| Check blocked status | user.getBlockedByMe() | CometChatMessages.tsx |
| Block confirmation | CometChatConfirmDialog | CometChatHome.tsx |
| Blocked composer state | message-composer-blocked | CometChatMessages.tsx |
| Block events | ccUserBlocked.subscribe() | CometChatHome.tsx |
| Unblock events | ccUserUnblocked.subscribe() | CometChatHome.tsx |
| Update user state | user.setBlockedByMe(boolean) | CometChatHome.tsx |