Guide · comments:write
Reply to comments
A small bot that checks the comments on your latest posts and answers the new ones, without ever answering twice.
Scopes: posts:read and comments:write (optional: likes:write).
The endpoints#
| Endpoint | Use |
|---|---|
GET /me/posts | Your latest posts. |
GET /posts/{id}/comments | Comments on a post (paginated). |
POST /posts/{id}/comments | Write a comment or a reply. |
DELETE /comments/{id} | Delete your comment, or a comment on your post. |
POST /posts/{id}/like | Like a post. |
1. Read the comments#
curl "https://api.linework.app/open/v1/posts/1043/comments?limit=100" \
-H "Authorization: Bearer $LINEWORK_API_KEY"
{
"data": [
{
"id": "88121",
"text": "Where is this?",
"author": { "id": "5512", "username": "giulia" },
"createdAt": "2026-10-14T09:30:00.000Z"
}
],
"next_cursor": null
}
2. Reply#
To reply to a specific comment, pass its id as parentId; without it the comment goes on the post.
curl https://api.linework.app/open/v1/posts/1043/comments \
-H "Authorization: Bearer $LINEWORK_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "text": "Lake Como, from Varenna 😊", "parentId": "88121" }'
3. Put it together#
Remember which comments you already answered (here in a local file) and skip your own comments.
import { readFile, writeFile } from "node:fs/promises";
const API = "https://api.linework.app/open/v1";
const headers = {
Authorization: `Bearer ${process.env.LINEWORK_API_KEY}`,
"Content-Type": "application/json",
};
const get = (p) => fetch(API + p, { headers }).then((r) => r.json());
const seen = new Set(JSON.parse(await readFile("seen.json", "utf8").catch(() => "[]")));
const me = await get("/me");
const posts = await get("/me/posts?limit=10");
for (const post of posts.data) {
const comments = await get(`/posts/${post.id}/comments?limit=100`);
for (const c of comments.data) {
if (seen.has(c.id) || c.author.id === me.id) continue;
const reply = answer(c.text);
if (reply) {
await fetch(`${API}/posts/${post.id}/comments`, {
method: "POST",
headers,
body: JSON.stringify({ text: reply, parentId: c.id }),
});
}
seen.add(c.id);
}
}
await writeFile("seen.json", JSON.stringify([...seen]));
function answer(text) {
if (/where|dove/i.test(text)) return "Lake Como, from Varenna 😊";
return null; // no canned answer: leave it to a human
}
import json, os, re, requests
API = "https://api.linework.app/open/v1"
s = requests.Session()
s.headers["Authorization"] = f"Bearer {os.environ['LINEWORK_API_KEY']}"
try:
seen = set(json.load(open("seen.json")))
except FileNotFoundError:
seen = set()
def answer(text):
if re.search(r"where|dove", text, re.I):
return "Lake Como, from Varenna 😊"
return None # no canned answer: leave it to a human
me = s.get(API + "/me", timeout=30).json()
posts = s.get(API + "/me/posts", params={"limit": 10}, timeout=30).json()
for post in posts["data"]:
comments = s.get(f"{API}/posts/{post['id']}/comments", params={"limit": 100}, timeout=30).json()
for c in comments["data"]:
if c["id"] in seen or c["author"]["id"] == me["id"]:
continue
reply = answer(c["text"])
if reply:
s.post(f"{API}/posts/{post['id']}/comments",
json={"text": reply, "parentId": c["id"]}, timeout=30)
seen.add(c["id"])
json.dump(sorted(seen), open("seen.json", "w"))
Run it every few minutes (cron, a scheduled job, a serverless timer). Each run makes a handful of requests, far below the limit of 120 per minute.
Rules for comment bots#
- Daily quota: 300 comments and 500 likes per account.
- Reply only where the reply is useful. Do not post the same text over and over, and do not comment on posts of people who never interacted with you.
- When the bot is unsure, stay silent and let a person answer.