Introduction
Welcome to the JavaScript SDK documentation. This guide will walk you through the integration process to add chat and presence monitoring capabilities to your application using our SDK.
Key Features
- Real-time messaging within chatrooms.
- Online presence tracking to see when users are online, or offline.
- Support for both single and group chatrooms.
- File uploads within messages.
- Message receipts including user typing, message delivered, and message read notifications.
- Extensive event handling to react to chat activities in real-time.
Getting Started
Prerequisites
Before integrating ezajil-js-sdk into your project, ensure you have:
- Modern web browser with JavaScript enabled (e.g., Google Chrome, Mozilla Firefox, Safari, Edge).
- Support for ES6 (ECMAScript 2015) or later for optimal SDK functionality.
- An account registered on our platform.
Obtaining an API Key
Sign up on our platform and navigate to ezajil dashboard to create a new project. Upon creation, you will be provided with an endpoint and an API key required for authenticating your application.
Installation
To install the SDK in your project, run the following command in your project directory:
npm install ezajil-js-sdk --save
Basic usage
Authentication
API Key Usage
Effective authentication is crucial for the security and functionality of your application when integrating with our SDK.
It's essential to understand the proper use of API keys and the implementation of a token retrieval mechanism to maintain secure and uninterrupted sessions.
The API key is a sensitive piece of information that authenticates the communication between your application and our SaaS backend. It is paramount that the API key is not exposed in client-facing applications, such as browser apps, to prevent unauthorized access and potential security vulnerabilities.
- The API key should be securely stored and used exclusively within your backend service.
- Your backend service will use the API key to communicate with our SaaS backend to obtain access tokens, which are then used by the client application to interact with the SDK.
curl -X POST https://saasEndpoint/api/v1/users/auth
-H "Content-Type: application/json"
-H "api-key: yourApiKey"
-d '{
"userId": "userId",
"screenName": "userScreenName"
"avatarUrl": "userAvatarUrl"
"email": "userEmail"
"metadata": {...}
}'
Implementing a Fetch Token Callback
To streamline the authentication process and handle token lifecycle management efficiently, we recommend implementing a fetch token callback. This callback is invoked automatically by the SDK whenever a new access token is required, either due to token expiration or when the current token is invalid.
Make sure to replace saasEndpoint
with the actual value you obtained from the dashboard.
This example also assumes you're replacing userId
, userScreenName
, userAvatarUrl
, userEmail
, and userMetadata
with the user information relevant to your application context.
import { Session, User } from 'ezajil-js-sdk';
const userMetadata = {...};
const currentUser = new User('userId', 'userScreenName', 'userAvatarUrl', 'userEmail', userMetadata);
const sdkConfig = { enableLogging: true };
const session = new Session('saasEndpoint', currentUser, sdkConfig);
session.setFetchTokenCallback(() => {
// Make an HTTP request to YOUR backend service. This endpoint should be responsible for
// obtaining the access token from the authentication server using the API key securely stored
// on the server.
const request = this.http.get<{ accessToken: string }>(`YOUR_BACKEND_ENDPOINT`, ...)
.pipe(map(response => response.accessToken));
return firstValueFrom(request);
});
session.connect();
Create a Private 1-to-1 Chatroom
To initiate private communication between two users, you first need to create a private 1-to-1 chatroom.
This chatroom will be the space where the two users can exchange messages securely and privately.
The chatroomMetadata
field allows you to attach key-value pairs to the chatroom, enabling you to store additional context-specific information. This metadata can be anything relevant to your application's context, like user roles, conversation topics, or initiation timestamps.
const chatroomMetadata = {...};
this.session.createSingleChatroom('chatroomName', 'participantId', chatroomMetadata)
.then(chatroom => {
// Handle chatroom
})
.catch(error => {
// Handle the error, an APIError type with status, message, and details attributes
});
Send Your First Message
To send a message, ensure you're authenticated and have a chatroom.
Here's how you can send a simple "Hello, World!" message.
const sentMessage = chatroom.sendChatMessage('Hello World!');
Subscribe to User's Presence Event
To monitor the presence status of other users, your application can subscribe to presence events. This feature allows you to track when users go online or offline, enabling real-time updates within your application.
By subscribing to a user's presence, you can receive immediate notifications about their online and offline status changes.
To subscribe to a user's presence events, use the subscribeToUsersPresence
method. You need to pass an array of user IDs you want to track. The callback function will provide the status of these users.
Once subscribed, you can listen for online-user
and offline-user
events to react to changes in user status. These events are triggered whenever a user you are subscribed to changes their presence status.
const users = await session.subscribeToUsersPresence(['otherUserId'])
session
.on('online-user', (onlineUser) => {
// Handle subscribed user changing status to online
})
.on('offline-user', (offlineUser) => {
// Handle subscribed user changing status to offline
});
Comprehensive Feature Guide
Dive into the intricacies of the SDK with this detailed guide, exploring the essential components and their utilization within your application:
- User: The User component is the cornerstone of user identity within the SDK, encapsulating vital attributes like unique identifiers and personal details, facilitating a personalized and secure user experience.
- Session: The Session component acts as the critical bridge connecting your application to our backend, managing authentication and orchestrating the seamless flow of operations like chatroom interactions and real-time presence updates.
- Chatroom: At the heart of user interaction, the Chatroom component serves as the dynamic environment for message exchanges, offering robust tools for managing conversations, participants, and message history.
- Message: Each Message is a vital unit of communication within a chatroom, embodying the sender's intent, content, and metadata, while also reflecting its lifecycle stages from sending to reception and acknowledgment.
In the following sections, we will explore each component in greater detail, providing you with the knowledge to fully leverage the SDK's features.
User
The User component represents an application user and is a fundamental part of user management within the SDK. It encapsulates all the necessary information about a user, allowing for a robust and flexible way to handle user data within your application.
idstringA unique identifier for the user, ensuring each user is distinct within the application.
screenNamestringThe user's display name within the application, which may be different from their real name.
avatarUrlstringA URL pointing to the user's avatar image, providing a visual representation of the user.
emailstringThe user's email address, used for communication and identification purposes.
metadataMapA key-value store for additional information related to the user that can be used by the application.
onlinebooleanA boolean value indicating whether the user is currently online or offline.
lastSeennumberA timestamp indicating the last time the user was active or seen on the application (in nano precision).
Create user_constructor_
This method initializes a user instance and connects it to the ezajil backend, which, in turn, broadcasts an online presence event to all subscribers of the current user.Parameters
userIdstringRequiredA unique identifier for the user, essential for differentiating each user within the application.
screenNamestringRequiredA display name for the user, used within the application interface.
avatarUrlstringA link to the user's avatar image. This is optional and can be used to visually represent the user.
emailstringThe user's email address. While not mandatory, it is crucial for user identification and communication.
metadataMapAn optional key-value pair storage associated with the user, allowing for the storage of additional information pertinent to the user within the application context.
Returns
userUserThe newly created user instance.
const user = new User(userId, screenName, avatarUrl, email);
Session
The Session component is pivotal in linking your application with the ezajil backend, necessitating an active user instance and authentication credentials. To obtain these credentials and configure your session, please visit the ezajil dashboard.
Create session_constructor_
Connects the current user to the ezajil backend. This will trigger online presence event to all current user's subscribers.Parameters
endpointstringRequiredezajil provided endpoint, can be found on Dashboard
apiKeystringRequiredezajil provided api key, can be found on Dashboard
userUserRequiredcurrent user
sdkConfigObjectoptional SDK global configuration settings, such as enabling or disabling logging
Returns
sessionSessionthe newly created session instance
const currentUser = new User(userId, screenName, avatarUrl, email);
const sdkConfig = {
enableLogging: true
};
const session = new Session('your-endpoint', 'your-apiKey', currentUser, sdkConfig);
Manage Session Lifecycle
Connect sessionconnect
Establishes a connection between the current user and ezajil backend, which in turn activates online presence notifications for the user's subscribers.Parameters
No parameters.
Disconnect Sessiondisconnect
Disconnects the current user's connection with the ezajil backend, triggering an offline presence notification for the user's subscribers.Parameters
No parameters.
Interact with Chatrooms
Create a Private 1-to-1 ChatroomcreateSingleChatroom
Creates a private chatroom between the current user and another specified user.Parameters
namestringRequiredThe name associated with the chatroom, useful for display purposes.
participantIdstring[]RequiredThe unique identifier of the other user in this private chatroom.
metadataMapA key-value store for holding extra information pertinent to the chatroom.
Output
errorAPIError | nullDetails of any error that occurred during chatroom creation.
chatroomChatroom | nullThe newly created chatroom object.
session.createSingleChatroom(name, participantId, metadata)
.then(chatroom => {
// Handle created chatroom
})
.catch(error => {
// Handle the error, an APIError type with status, message, and details attributes
});
Create a Group ChatroomcreateGroupChatroom
Creates a new group chatroom with specified participants.Parameters
namestringRequiredThe name associated with the chatroom, intended for display purposes.
participantIdsstring[]RequiredThe unique identifiers of the users included in the chatroom.
metadataMapA key-value pair storage for additional information pertinent to the chatroom.
Output
errorAPIError | nullDetails of any error encountered during the creation of the chatroom.
chatroomChatroom | nullThe newly established group chatroom object.
session.createGroupChatroom(name, participantIds, metadata)
.then(chatroom => {
// Handle created chatroom
})
.catch(error => {
// Handle the error, an APIError type with status, message, and details attributes
});
Get Chatroom by IDgetChatroomById
Retrieves the details of a specific chatroom using its unique identifier.Parameters
chatroomIdstringRequiredThe unique identifier of the chatroom to be fetched.
Output
errorAPIError | nullDetails of any error that occurred during the retrieval process.
chatroomChatroom | nullThe retrieved chatroom object.
session.getChatroomById(chatroomId)
.then(chatroom => {
// Handle chatroom
})
.catch(error => {
// Handle the error, an APIError type with status, message, and details attributes
});
Get User's ChatroomsgetChatroomsOfUser
Retrieves a list of chatrooms that the current user is a part of.Parameters
No parameters.
Output
errorAPIError | nullDetails of any error encountered during the fetch process.
chatroomsChatroom[] | nullAn array of chatroom objects associated with the user.
session.getChatroomsOfUser()
.then(chatrooms => {
// Handle user's chatrooms
})
.catch(error => {
// Handle the error, an APIError type with status, message, and details attributes
});
Interact with Users
Get Chatroom UsersgetChatroomUsers
Retrieves a list of users participating in a specified chatroom.Parameters
chatroomIdstringRequiredThe unique identifier of the chatroom whose users are being requested.
Output
errorAPIError | nullDetails of any error encountered during the user fetch process.
usersUser[] | nullAn array of User objects representing the participants of the chatroom.
session.getChatroomUsers(chatroomId)
.then(users => {
// Handle chatroom users
})
.catch(error => {
// Handle the error, an APIError type with status, message, and details attributes
});
Retrieve UsersgetUsers
Retrieves a collection of users based on their unique identifiers.Parameters
userIdsstring[]RequiredThe array of user identifiers for the users to be fetched.
Output
errorAPIError | nullAny error that occurred during the fetch operation.
usersUser[] | nullAn array of user objects corresponding to the fetched user IDs.
session.getUsers(userIds)
.then(users => {
// Handle users
})
.catch(error => {
// Handle the error, an APIError type with status, message, and details attributes
});
Manage Presence Subscriptions
Subscribe to Users' Presence EventssubscribeToUsersPresence
Enables the current user to monitor the online status of specified users through presence events.Parameters
userIdsstring[]RequiredThe identifiers of the users whose presence events we wish to subscribe to.
Output
errorAPIError | nullDetails of any errors encountered during the subscription process.
usersUser[] | nullA list of users with their current presence status.
session.subscribeToUsersPresence(userIds)
.then(users => {
// Handle users
})
.catch(error => {
// Handle the error, an APIError type with status, message, and details attributes
});
Unsubscribe from Users' Presence EventsunsubscribeFromUsersPresence
Ceases the current user's subscription to the presence updates of selected users.Parameters
userIdsstring[]RequiredThe identifiers of the users from whom to unsubscribe presence updates.
Output
errorAPIError | nullDetails of any errors that occurred during the unsubscription process.
session.unsubscribeFromUsersPresence(userIds)
.then(() => {
// Successful unsubscribe
})
.catch(error => {
// Handle the error, an APIError type with status, message, and details attributes
});
Unsubscribe from All Users' Presence EventsunsubscribeFromAllUsersPresence
This operation disconnects the current user from receiving presence updates for all users they previously subscribed to.Parameters
No parameters.
Output
errorAPIError | nullDetails of any errors encountered during the unsubscription process.
session.unsubscribeFromAllUsersPresence()
.then(() => {
// Successful unsubscribe
})
.catch(error => {
// Handle the error, an APIError type with status, message, and details attributes
});
Manage Message Receipts
Fire User TypingfireUserTyping
Initiates a user-typing
event in the specified chatroom, signaling to other participants that the current user is typing a message. Currently, this feature is available exclusively for Private chatrooms.Parameters
chatroomIdstringRequiredThe identifier of the chatroom where the typing event is being signaled.
session.fireUserTyping(chatroomId);
Mark Messages as DeliveredmarkMessageAsDelivered
Designates messages within a specified chatroom as delivered, triggering a messages-delivered
event for recipients to acknowledge. Currently, this functionality is exclusive to Private chatrooms.Parameters
chatroomIdstringRequiredThe identifier of the chatroom where messages are marked as delivered.
latestMessageDeliveredTimestampnumberRequiredTimestamp indicating the sending date of the most recent message confirmed as delivered, in nano precision.
session.markMessageAsDelivered(chatroomId, latestMessageDeliveredTimestamp);
Mark Messages as ReadmarkMessagesAsRead
Designates messages within a specified chatroom as read, triggering a messages-read
event for other participants. Currently, this feature is available exclusively for Private chatrooms.Parameters
chatroomIdstringRequiredThe identifier of the chatroom where messages are marked as read.
latestMessageReadTimestampnumberRequiredTimestamp for the sending date of the most recent message that was read, in nano precision.
session.markMessageAsRead(chatroomId, latestMessageReadTimestamp);
Handle Session Events
In our SDK, events play a crucial role in enabling real-time responsiveness and interactivity within your application. By listening to various events, your application can react dynamically to changes and activities occurring in the system. Events provide a powerful way to hook into the core functionality of the SDK, allowing you to execute custom logic when specific actions or changes occur. Whether it's detecting a user's presence, receiving messages, or handling errors, events ensure your application stays synchronized with the state of the chat environment.
Below, we detail the available events and their respective payloads, offering insights into the data you can leverage to enhance user experience and application performance.
session
.on('connected', () => {
// Handle session connected event
})
.on('disconnected', (code, reason, isClientError) => {
// Handle session disconnected event
})
.on('online-user', (onlineUser) => {
// Handle online-user event
})
.on('offline-user', (offlineUser) => {
// Handle offline-user event
})
...
Emitted when the user has successfully connected.
Emitted when the user's session is disconnected. The event provides a code indicating the disconnection type, a reason for the disconnection, and a flag to denote if it was a client-side error.
Please note that in the event of any disconnection, it is essential to manually retrieve your messages through our API. To do this, utilize the Retrieve Messages feature. Keep in mind that our WebSocket service does not deliver messages for periods during which a user is offline. Ensuring you refetch messages post-disconnection guarantees that you stay updated with all missed communications
Possible Disconnection Codes:
code | reason | client error | automatic reconnection |
---|
400 | Bad Request during handshake: Project suspended, Users limit exceeded... | True | False |
401 | Authorization failed during handshake: Wrong API key, Origin URL not allowed in dashboard... | True | True |
500 | Internal server error during handshake | False | False |
1000-1015 | Standard WebSocket codes (see RFC 6455) | False | True |
4000 | Bad Request | True | False |
4001 | Unauthorized | True | False |
4002 | Concurrent users limit has been exceeded | True | True |
4004 | Resource not found | True | False |
Payload
Emitted when a user that the current session is subscribed to comes online. The event provides a User object with details about the user.
Payload
{
"userId": "1100",
"screenName": "ezajil2",
"avatarUrl": "https://avatar.url",
"email": "[email protected]",
"lastSeen": 1708985038723678741,
"metadata": {
"dateOfBirth": "12/01/2000"
}
}
This event occurs when a user that the current session is subscribed to changes their status to offline. The event listener receives a User object containing details about the user who went offline.
Payload
{
"userId": "1100",
"screenName": "ezajil2",
"avatarUrl": "https://avatar.url",
"email": "[email protected]",
"lastSeen": 1708985038723678741,
"metadata": {
"dateOfBirth": "12/01/2000"
}
}
Emitted when the current user receives a new chat message, this event provides the message details, enabling real-time message handling within the application.
Payload
{
"chatroomId": "72621fb3-f89c-4d39-a368-41448fd19858",
"messageId": "6642a6c3-fbea-4796-aeee-2c4cb64aeb06",
"author": "ezajil2",
"screenName": "ezajil2",
"content": "test",
"mediaUrls": null,
"preview": false,
"sendingDate": 1708984467871000000
}
This event is triggered whenever a user begins typing in a chatroom, providing real-time feedback to other participants and enhancing the interactive chat experience.
Payload
{
"chatroomId": "72621fb3-f89c-4d39-a368-41448fd19858",
"userId": "1100",
"screenName": "ezajil2",
"avatarUrl": "https://avatar.url",
"email": "[email protected]",
"lastSeen": 1708985038723678741,
"metadata": {
"dateOfBirth": "12/01/2000"
}
}
This event is fired when a message dispatched by the current user is successfully confirmed by the server, providing a confirmation that the message has been processed and sent.
Payload
{
"chatroomId": "72621fb3-f89c-4d39-a368-41448fd19858",
"messageId": "6642a6c3-fbea-4796-aeee-2c4cb64aeb06"
}
This event occurs when a delivery receipt for a message is received, indicating that the message has reached the recipient's device. It provides the chatroom ID and the timestamp of the latest message delivered, allowing for accurate tracking of message delivery status.
Payload
{
"chatroomId": "72621fb3-f89c-4d39-a368-41448fd19858",
"latestMessageDelivered": 1708985039244587475
}
This event occurs when a read receipt is received, indicating that a message has been read by the recipient. It provides the chatroom ID and the timestamp of the latest message read, enabling tracking of message engagement.
Payload
{
"chatroomId": "72621fb3-f89c-4d39-a368-41448fd19858",
"latestMessageRead": 1708985039244587475
}
This event is primarily triggered in response to WebSocket errors, providing crucial details about the encountered issue. The payload includes a code, message, and, if available, the causing error object. Developers can utilize this information to handle WebSocket-related errors gracefully and effectively troubleshoot issues. For specific WebSocket error codes, refer to the WebSocket close codes provided by the Internet Assigned Numbers Authority (IANA).
Payload
Chatroom
The Chatroom component is an integral part of the messaging framework, encapsulating the environment where users engage in conversations.
It is designed to accommodate both one-on-one and group interactions, providing a versatile structure to support various communication scenarios.
chatroomIdstringA unique identifier for the chatroom.
namestringThe name or title of the chatroom.
latestMessagestringThe most recent message sent in the chatroom.
creationDatestringThe timestamp indicating when the chatroom was created.
creatorIdstringThe unique identifier of the user who created the chatroom.
singlebooleanIndicates whether the chatroom is a private, one-on-one chat.
participantIdsstring[]An array of user IDs representing the participants of the chatroom.
metadataMapA key-value pair object for storing additional information related to the chatroom that can be used by the application.
Retrieve MessagesgetMessages
Retrieves a set of messages from a chatroom, offering paginated access to the chat history. Messages are presented in reverse chronological order.Parameters
fromstringRequiredThe starting point for pagination.
limitstringRequiredThe maximum number of messages to fetch in this request.
Output
errorAPIError | nullAny error encountered during the retrieval process.
messagesMessage[] | nullAn array of message objects fetched from the chatroom.
chatroom.getMessages(from, limit)
.then(messages => {
// Handle messages
})
.catch(error => {
// Handle the error, an APIError type with status, message, and details attributes
});
Retrieve Chatroom UsersgetUsers
Retrieves a list of users participating in a specific chatroom.Parameters
No parameters.
Returns
errorAPIError | nullDetails of any errors that occurred during the user retrieval process.
usersUser[] | nullAn array of user objects representing the participants of the chatroom.
chatroom.getUsers()
.then(users => {
// Handle chatroom users
})
.catch(error => {
// Handle the error, an APIError type with status, message, and details attributes
});
Send Text MessagesendChatMessage
Sends a text message from the current user within a specified chatroom.Parameters
messagestringRequiredThe text content of the message to be sent.
Returns
messageMessage | nullThe message object that was sent, including its details and status.
chatroom.sendChatMessage('Hello World!');
Upload AttachmentuploadFile
Enables the current user to upload an attachment file within a chatroom.Parameters
fileFileRequiredThe file to be uploaded as an attachment.
Output
errorAPIError | nullDetails of any errors that occurred during the file upload process.
messageMessage | nullThe message object associated with the uploaded file, detailing the upload status and file information.
const file = document.getElementById('attachmentInput').files[0];
chatroom.uploadFile(file, (message, error) => {
.then(message => {
// Process the uploaded message
// This message will contain the link of the uploaded attachment
})
.catch(error => {
// Handle the error, an APIError type with status, message, and details attributes
});
Fire user typingfireUserTyping
Initiates a user-typing
event in the specified chatroom, signaling to other participants that the current user is typing a message. Currently, this feature is available exclusively for Private chatrooms.Parameters
No parameters.
chatroom.fireUserTyping();
Mark messages as deliveredmarkMessageAsDelivered
Designates messages within a specified chatroom as delivered, triggering a messages-delivered
event for recipients to acknowledge. Currently, this functionality is exclusive to Private chatrooms.Parameters
latestMessageDeliveredTimestampnumberRequiredTimestamp indicating the sending date of the most recent message confirmed as delivered, in nano precision.
chatroom.markMessagesAsDelivered(latestMessageDeliveredTimestamp);
Mark messages as readmarkMessagesAsRead
Designates messages within a specified chatroom as read, triggering a messages-read
event for other participants. Currently, this feature is available exclusively for Private chatrooms.Parameters
latestMessageReadTimestampnumberRequiredTimestamp for the sending date of the most recent message that was read, in nano precision.
chatroom.markMessagesAsRead(latestMessageReadTimestamp);
Handle Chatroom Events
Chatroom events provide a granular level of interaction within specific chatroom contexts, allowing developers to respond to various actions and updates that occur within those environments. While some events, such as chat-message, user-typing, message-sent, messages-delivered, and messages-read, are also available at the session level, there are instances where monitoring these events at the chatroom level is necessary for more targeted functionality and logic.
Below, we detail the available events and their respective payloads, offering insights into the data you can leverage.
Emitted when the current user receives a new chat message, this event provides the message details, enabling real-time message handling within the application.
Payload
{
"chatroomId": "72621fb3-f89c-4d39-a368-41448fd19858",
"messageId": "6642a6c3-fbea-4796-aeee-2c4cb64aeb06",
"author": "ezajil2",
"screenName": "ezajil2",
"content": "test",
"mediaUrls": null,
"preview": false,
"sendingDate": 1708984467871000000
}
This event is triggered whenever a user begins typing in a chatroom, providing real-time feedback to other participants and enhancing the interactive chat experience.
Payload
{
"chatroomId": "72621fb3-f89c-4d39-a368-41448fd19858",
"userId": "1100",
"screenName": "ezajil2",
"avatarUrl": "https://avatar.url",
"email": "[email protected]",
"lastSeen": 1708985038723678741,
"metadata": {
"dateOfBirth": "12/01/2000"
}
}
This event is fired when a message dispatched by the current user is successfully confirmed by the server, providing a confirmation that the message has been processed and sent.
Payload
{
"chatroomId": "72621fb3-f89c-4d39-a368-41448fd19858",
"messageId": "6642a6c3-fbea-4796-aeee-2c4cb64aeb06"
}
This event occurs when a delivery receipt for a message is received, indicating that the message has reached the recipient's device. It provides the chatroom ID and the timestamp of the latest message delivered, allowing for accurate tracking of message delivery status.
Payload
{
"chatroomId": "72621fb3-f89c-4d39-a368-41448fd19858",
"latestMessageDelivered": 1708985039244587475
}
This event occurs when a read receipt is received, indicating that a message has been read by the recipient. It provides the chatroom ID and the timestamp of the latest message read, enabling tracking of message engagement.
Payload
{
"chatroomId": "72621fb3-f89c-4d39-a368-41448fd19858",
"latestMessageRead": 1708985039244587475
}
The payload-delivery-error event is triggered when there is an error delivering a payload within a chatroom. This event provides information about the error code, reason for the error, affected chatroom, and the type of payload that encountered the delivery error.
Possible Error Codes:
Error Code | Description | Examples of Reasons |
---|
400 | occurs when the operational constraints defined by the billing plan, including limits on resource usage, are exceeded | - Chat messages limit has been exceeded
- Users limit has been exceeded
- Storage size limit has been exceeded
|
404 | indicates that the payload being delivered is associated with resources that could not be located | |
500 | indicates an unexpected condition or failure on the server-side while attempting to process the payload delivery request | |
Payload
codenumberThe error code associated with the delivery error.
reasonstringA description of the reason for the delivery error.
chatroomIdstringThe identifier of the chatroom where the payload delivery error occurred.
payloadPayloadDeliveryErrorPayloadAn object containing the type of payload and the specific payload data we failed to deliver.
Message
The Message component is a core entity in the messaging system, encapsulating all the necessary information about a single message within a chatroom.
chatroomIdstringThe identifier of the chatroom to which the message belongs, linking the message to its conversational context.
messageIdstringA unique identifier for the message, ensuring each message can be distinctly referenced and managed.
authorstringThe identifier of the user who authored the message, providing accountability and context within the chat.
screenNamestringThe display name of the message author as it should appear within the chat interface.
contentstringThe textual content of the message, which may include text, emojis, or other forms of data meant for display.
mediaUrls{ [key: string]: string }A dictionary of media URLs attached to the message, allowing for the inclusion of images, videos, or other multimedia content.
previewbooleanA flag indicating whether the message includes a preview of linked content, enhancing user interaction and engagement.
sendingDatenumberA timestamp representing when the message was sent in nano precision, used for ordering messages chronologically in the chat view.
status'NOT_SENT' | 'SENT' | 'DELIVERED' | 'READ'The current status of the message, indicating its delivery and read state, which helps in providing feedback to the sender.
systemMessagebooleanA boolean indicating whether the message is a system-generated notification or a user-generated message, differentiating between automated and direct communication.