Skip to content

Comments with the TypeScript SDK ​

The comments resource reads comments that people leave on your published posts and replies to them as the connected account. It needs the Team or Agency plan. Supported platforms are YouTube, Bluesky, Reddit and Mastodon.

Methods ​

MethodWhat it does
list(params?)Comments on your posts, newest first. Open ones by default
sync()Queue a background fetch of new comments. Returns { queued: true }
reply(id, { text })Reply as the connected account and mark the comment done
update(id, { status })Set status to open or done
markDone(id)Shortcut for update(id, { status: 'done' })
reopen(id)Shortcut for update(id, { status: 'open' })

How do I list comments? ​

typescript
const { results, total, supportedPlatforms } = await socifyr.comments.list({
  status: 'open',                 // 'open' (default) | 'done' | 'all'
  platform: 'youtube',            // optional
  connection: 'youtube-mybrand',  // optional slug
  limit: 50,                      // 1 to 100, default 25
})

for (const c of results) {
  console.log(`${c.platform} ${c.author.name}: ${c.text}`)
}

CommentListParams also takes postId (a Socifyr post ID) and page. Your own replies are not included. supportedPlatforms lists the platforms the inbox reads.

Each result is a Comment:

FieldTypeNotes
idstringPass it to reply() and update()
platformstringFor example youtube
connection{ id, slug, name }slug is null if the account was removed
post{ id, platformPostId }id is the Socifyr post ID
textstring
author{ name, handle?, avatarUrl?, profileUrl? }
urlstring | nullLink to the comment on the platform
likeCountnumber | nullOn Reddit, the net score; can be 0 or negative
parentIdstring | nullPlatform ID of the comment this one answers
isOwnbooleantrue for your own replies
status'open' | 'done'
postedAtstringISO 8601
repliedAtstring | nullWhen you replied through Socifyr

How do I fetch new comments now? ​

Comments sync every 30 minutes. To queue a sync now:

typescript
const { queued } = await socifyr.comments.sync() // true
await new Promise((r) => setTimeout(r, 15_000))
const { results } = await socifyr.comments.list()

The API answers 202 with { queued: true } (CommentSyncResult) and the sync runs in the background, so list comments again after a short wait. A sync checks up to 50 posts published in the last 30 days. It is limited to 3 calls per minute.

YouTube comment sync runs on a daily quota budget: a post is only re-read when its comment count changed, or on an age-based backoff. New YouTube comments can take a while to appear.

Comments older than 60 days are removed, and comments deleted on the platform disappear on the next full sync. Disconnecting an account or deleting a workspace deletes its stored comments.

How do I reply to a comment? ​

typescript
const reply = await socifyr.comments.reply(comment.id, {
  text: 'Thanks! Part two is out next week.',
})
console.log(reply.url)

text is 1 to 5000 characters, and must fit the platform's own limit (300 graphemes on Bluesky; on Mastodon the @mention of the author counts). The reply is public as soon as it returns and cannot be edited from Socifyr. The original comment is marked done.

How do I mark a comment done? ​

typescript
await socifyr.comments.markDone(comment.id)   // no reply needed
await socifyr.comments.reopen(comment.id)     // back to open

Example: answer open questions ​

typescript
const { results } = await socifyr.comments.list({ status: 'open' })

for (const c of results) {
  if (c.text.trim().endsWith('?')) {
    await socifyr.comments.reply(c.id, { text: `Thanks ${c.author.name}, we'll answer in our next video.` })
  } else {
    await socifyr.comments.markDone(c.id)
  }
}

What errors should I handle? ​

ErrorWhen
PermissionError (403)The plan is Free or Creator, the key's role lacks comment.reply, or a guarded key called anything other than list()
ValidationError (400)The platform refused the reply, the reply is too long for the platform (Reply is too long for bluesky: 312 of 300 characters), the post or comment was deleted, the account is disconnected, a connection filter does not match an active account, or a parameter is invalid
NotFoundError (404)The comment ID is not in this workspace
SocifyrError (409)A reply to that comment is already being sent
RateLimitError (429)Any comments call over the global limit of 60 requests per minute, more than 3 sync() calls in a minute, or the platform is rate limiting replies

The plan error message is The comments inbox is not available on your current plan. Upgrade to Team or Agency to continue. See Errors.

Next steps ​