replyToComment

This method allows you to reply to a comment.

typescript
try {
  const workflow = await linkedapi.replyToComment.execute({
    commentUrl: "https://www.linkedin.com/feed/update/urn:li:activity:123/?dashCommentUrn=urn:li:fsd_comment:(456,urn:li:activity:123)",
    text: "Totally agree — thanks for adding this!"
  });

  const { data, errors } = await linkedapi.replyToComment.result(workflow.workflowId);

  // The list of possible execution errors is below
  if (errors && errors.length > 0) {
    console.warn('Workflow completed with execution errors:');
    errors.forEach(error => {
      console.warn(` - Type: ${error.type}, Message: ${error.message}`);
    });
  }

  // The structure of the 'data' object is below
  if (data) {
    console.log('Workflow completed successfully. Data:', data);
  }
} catch (e) {
  // A list of all critical errors can be found here:
  // https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors
  if (e instanceof LinkedApiError) {
    console.error(`Critical Error - Type: ${e.type}, Message: ${e.message}`);
  } else {
    console.error('An unexpected, non-API error occurred:', e);
  }
}

Params

  • commentUrl – deep-link URL of the comment to reply to. You can obtain it from the commentUrl field returned by commentOnPost, replyToComment, or a comment retrieved via fetchPost.
  • text – reply text.

Data

  • commentUrn – LinkedIn URN of the created reply, if available.
  • commentUrl – canonical deep-link URL of the created reply, if available. It can be used as the commentUrl input for reactToComment or replyToComment.

Errors

  • commentNotFound – the comment could not be opened or no longer exists.
  • replyingNotAllowed – replying is not allowed on this comment.
  • duplicateComment – this account already replied with the same text to this comment through Linked API within the last 24 hours, so the reply was not published again. Text is compared after trimming and collapsing whitespace. The message links the earlier reply when it is known.