Create Direct Message Chatroom
LikeMinds React Chat SDK offers a convenient feature to create Direct Message Chatrooms, allowing you to communicate privately with specific individuals.
Steps to check Direct Messages limit
- Check Direct Message Chatroom already exist or not and member have not crossed its limit to send Direct Message request, use the method
checkDMLimit()
- Pass in the required parameter
memberId
. - Process the response as per your requirement.
const payload: any = {
memberId: 23233, // Enter the member's ID to initiate a private message.
};
const response = await lmChatClient.checkDMLimit(payload);
if (response.success) {
// your function to process the response data
processResponse(response);
} else {
// your function to process error message
processError(response);
}
Check DM Limit Payload
List of parameters for the checkDMLimit()
function.
Variable | Type | Description | Optional |
---|---|---|---|
memberId | number | Member Id |
Check DM Limit Response
List of parameters in the response.
Variable | Type | Description |
---|---|---|
success | boolean | API success status |
error_message | string | Error message in case of failure |
is_request_dm_limit_exceeded | boolean | checks whether the limit for sending request has already been hit or not. |
chatroom_id | number | Chatroom ID if the chatroom already exists |
Steps to create direct message chatroom
- If Direct Message Chatroom does not exist and limit is not exceeded, use the method
createDMChatroom()
- Pass in the required parameter
memberId
. - Process the response as per your requirement.
const payload: any = {
memberId: 23233, // Enter the member's Id to initiate a private message.
};
const response = await lmChatClient.checkDMLimit(payload);
if (response.success) {
// your function to process the response data
let res = response?.data;
if (!!res?.chatroom_id) {
//DM already created
processResponse(response); // Open the respective chatroom
} else {
if (res?.is_request_dm_limit_exceeded === false) {
const payloadCreateDM: any = {
memberId: 23233, // Enter the member's ID to initiate a private message.
};
const responseCreateDM = await lmChatClient.createDMChatroom(
payloadCreateDM
);
if (responseCreateDM.success) {
// your function to process the response data
processResponse(responseCreateDM);
} else {
// your function to process error message
processError(responseCreateDM);
}
} else {
alert("Request limit exceeded"); ////Show disclaimer popup on limit exceed.
}
}
} else {
// your function to process error message
processError(response);
}
Create DM Chatroom Payload
List of parameters for the createDMChatroom()
function.
Variable | Type | Description | Optional |
---|---|---|---|
memberId | number | Member Id |
Create DM Chatroom Response
List of parameters in the response.
Variable | Type | Description |
---|---|---|
success | boolean | API success status |
error_message | string | Error message in case of failure |
chatroom | object | Chatroom Details |