Skip to main content

Add Comment

The addComment() function allows users to engage in interactive discussions by adding comments to posts. This powerful feature enables users to express their thoughts, ask questions, and engage with other members in a dynamic and collaborative manner. By integrating the comment functionality, developers can foster meaningful conversations and enhance the overall user experience within their application.

Steps to Add Comment

  1. Create an instance of AddCommentRequest with the required parameters: text and postId.
  2. Call the addComment() function using the instance of the LMFeedClient class, passing the request as a parameter.
  3. Use the response as per your requirement.
// Create an instance of AddCommentRequest
AddCommentRequest request = (AddCommentRequestBuilder()
..postId("post_id")
..text("comment_text"))
.build();

// Get the response from calling the function
final AddCommentResponse addCommentResponse = await lmFeedClient.addComment(addCommentRequest);

// Process the response, as per requirement
if (addCommentResponse.success) {
// your function to handle successful addition of comment
handleAddCommentSuccess(addCommentResponse.reply);
} else {
// your function to handle error message
handleAddCommentError(addCommentResponse.errorMessage);
}

Additional Features

Tag a User

To tag a user, use the getTaggingList() function to fetch the list of users that can be tagged, and use the format <<[user.name]|route://user_profile/[user.sdkClientInfo.uuid]>> to embed it inside the text of the post.

Models

AddCommentRequest

List of parameters for the AddCommentRequest class

VariableTypeDescription
textStringComment text
postIdStringPost ID for comment

AddCommentResponse

List of parameters for the AddCommentResponse class

VariableTypeDescriptionOptional
successboolAPI success status
errorMessageStringError message in failure
replyCommentAdded comment entity