AI Agent Component Spec
AI Agent Component Spec
| Field | Value |
|---|---|
| Package | @cometchat/chat-uikit-react |
| Import | import { CometChatSoundManager } from "@cometchat/chat-uikit-react"; |
| Play sound | CometChatSoundManager.play(CometChatSoundManager.Sound.incomingCall) — or pass custom audio path as second arg |
| Pause sound | CometChatSoundManager.pause() |
| Sound events | incomingCall, outgoingCall, incomingMessage, incomingMessageFromOther, outgoingMessage |
| Source | GitHub |
CometChatSoundManager is a helper class for managing and playing audio cues in the UI Kit — incoming/outgoing calls and messages.
Sound is a frozen object on CometChatSoundManager, not a separate export. Access sound event keys via CometChatSoundManager.Sound.
Methods
play
Plays the default or custom audio resource for a given sound event.| Parameter | Type | Description |
|---|---|---|
sound | "incomingCall" | "incomingMessage" | "incomingMessageFromOther" | "outgoingCall" | "outgoingMessage" | Sound event key |
customSound | string | null | Optional custom audio file URL. Defaults to null (uses built-in sound). |
pause
Pauses the currently playing sound and resets playback position.onIncomingMessage
Plays the incoming message sound directly. Accepts an optionalcustomSound URL.
onIncomingOtherMessage
Plays the incoming message from another user sound directly. Accepts an optionalcustomSound URL.
onOutgoingMessage
Plays the outgoing message sound directly. Accepts an optionalcustomSound URL.
onIncomingCall
Plays the incoming call sound (loops). Accepts an optionalcustomSound URL.
onOutgoingCall
Plays the outgoing call sound (loops). Accepts an optionalcustomSound URL.
hasInteracted
Returnsboolean — checks whether the user has interacted with the page (required by browser autoplay policies).
Sound Events
| Event Key | When it plays |
|---|---|
incomingCall | Incoming call detected |
outgoingCall | Outgoing call initiated |
incomingMessage | New message received from the current conversation |
incomingMessageFromOther | New message received from a different conversation |
outgoingMessage | Message sent |
CometChatSoundManager.Sound.incomingCall, etc.