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
- To fetch direct messages, use the method
fetchDMFeed()
provided by the client you initialised.. - Pass in the required parameter page, to fetch the Direct Message Feed by page.
- 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
Variable | Type | Description | Optional |
---|---|---|---|
page | int | page |
Fetch DM Feed Response
Variable | Type | Description |
---|---|---|
success | boolean | api success status |
error_message | string | error log incase the api fails |
dm_chatrooms | object | List of Direct Messages chatrooms |
Steps to Check Direct Messages Status
- To check Direct Messages status, use the method
checkDMStatus()
provided by the client you initialised. - Pass in the required parameter
requestFrom
, to give the channel from where you are requesting. - 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
Variable | Type | Description | Optional |
---|---|---|---|
requestFrom | string | channel from which you are fetching DM. Either group_channel or dm_feed_v2 |
Check DM Status Response
Variable | Type | Description |
---|---|---|
success | boolean | API success status |
error_message | string | Error message in case of failure |
cta | string | Custom route for the target screen |
show_dm | boolean | Direct Messages is ON or OFF from dashboard |