Skip to main content

Direct Messages Home Feed

The Home Feed is a vital component of many applications, providing users with a centralized hub to discover and engage with various content, including chatrooms, discussions, and other interactive features. In the context of the React SDK, the Home Feed serves as a customizable and dynamic feed that can be tailored to suit your application's needs.

This guide provide step-by-step instructions, code snippets, and best practices for integrating the Direct Messages Feed.

Let's dive into the world of Direct Messages Feed integration with the React SDK and unlock the potential for vibrant chatroom communities within your application.

Steps to fetch Direct Message Chatrooms

  1. To fetch direct messages, use the method fetchDMFeed() provided by the client you initialised..
  2. Pass in the required parameter page, to fetch the Direct Message Feed by page.
  3. Process the response as per your requirement.
const payload: any = {
page: 1,
};
const response = await lmChatClient.fetchDMFeed(payload);

if (response.success) {
// your function to process the response data
processResponse(response);
} else {
// your function to process error message
processError(response);
}

Fetch DM Feed Payload

VariableTypeDescriptionOptional
pageintpage

Fetch DM Feed Response

VariableTypeDescription
successbooleanapi success status
error_messagestringerror log incase the api fails
dm_chatroomsobjectList of Direct Messages chatrooms

Steps to Check Direct Messages Status

  1. To check Direct Messages status, use the method checkDMStatus() provided by the client you initialised.
  2. Pass in the required parameter requestFrom, to give the channel from where you are requesting.
  3. Process the response as per your requirement.
const payload: any = {
page: 1,
};
const response = await lmChatClient.fetchDMFeed(payload);

if (response.success) {
// your function to process the response data
const payloadCheckDM: any = {
requestFrom: "",
};
const responseCheckDM = await lmChatClient.checkDMStatus(payloadCheckDM);

if (responseCheckDM.success) {
// your function to process the response data
processResponse(responseCheckDM);
} else {
// your function to process error message
processError(responseCheckDM);
}
} else {
// your function to process error message
processError(response);
}

Check DM Status Payload

VariableTypeDescriptionOptional
requestFromstringchannel from which you are fetching DM. Either group_channel or dm_feed_v2

Check DM Status Response

VariableTypeDescription
successbooleanAPI success status
error_messagestringError message in case of failure
ctastringCustom route for the target screen
show_dmbooleanDirect Messages is ON or OFF from dashboard