> Documentation index: https://www.socialcrawl.dev/llms.txt > Every page is also available as Markdown by adding .md. # Comment watch (/docs/recipes/new-comments-to-a-webhook) Get comments since your last check on an account's posts, then let a Monitor send new ones to your webhook Send a profile link and a time, and get back the comments left under its recent posts since then. Posts with no new comment cost nothing. A Monitor then runs the same read every hour and sends only the comments it has never sent before. Measured on 23/11/2026: a 3-hour check on the five newest posts of National Geographic on Instagram found 48 new comments for 36 credits. A 2-minute check found 1 new comment for 6 credits. ## Start in five minutes Set your key once. Every block on this page reads it. ```bash title="Terminal" export SOCIALCRAWL_API_KEY=YOUR_API_KEY ``` Paste this prompt into your coding agent: ```text title="Prompt" Read https://www.socialcrawl.dev/docs/recipes/new-comments-to-a-webhook.md and follow it to watch the comments under the five newest posts of https://www.instagram.com/natgeo/. Use the key in SOCIALCRAWL_API_KEY. Price the read with a dry run first and show me the hold. Then price the hourly Monitor with a dry run and show me estimated_cost_per_run. Ask me before you create it, and send max_credits_per_month with the cap I agree to. ``` Or price the read yourself. A dry run quotes it for 0 credits: ```bash title="cURL" curl -G "https://www.socialcrawl.dev/v1/prism/profile/comments" \ -H "x-api-key: $SOCIALCRAWL_API_KEY" \ --data-urlencode "url=https://www.instagram.com/natgeo/" \ --data-urlencode "posts=5" \ --data-urlencode "per_post=20" \ --data-urlencode "since=2026-11-23T20:00:00Z" \ --data-urlencode "dry_run=true" ``` ## How it works - `prism/profile/comments` reads the account's recent posts, then the comments under each one. - `since` stops each post at its first comment older than that time. - A post with no new comment reads no comment page, so it costs nothing. - `posts` sets how many recent posts are read, and `per_post` caps the comments taken from each. - The call holds its worst case up front and refunds what it did not read. ## What you need | Call | What it gives | Credits | | --- | --- | --- | | `GET /v1/prism/profile/comments` | New comments under the profile's recent posts | The post list page, plus each comment page read | | `POST /v1/monitors?dry_run=1` | The price of an hourly Monitor of that read | 0 | | An HTTPS endpoint of your own | Receives each signed delivery | Free | On Instagram a comment page costs 5 credits. On most other platforms it costs 1. The [roster](/docs/endpoint-pricing.md) lists every price. ## Steps ### Step 1: read the comments since a time **cURL** ```bash title="cURL" curl -G "https://www.socialcrawl.dev/v1/prism/profile/comments" \ -H "x-api-key: $SOCIALCRAWL_API_KEY" \ --data-urlencode "url=https://www.instagram.com/natgeo/" \ --data-urlencode "posts=5" \ --data-urlencode "per_post=20" \ --data-urlencode "since=2026-11-23T20:00:00Z" ``` **Python** ```python title="Python" import json, os, urllib.request url = "https://www.socialcrawl.dev/v1/prism/profile/comments?url=https%3A%2F%2Fwww.instagram.com%2Fnatgeo%2F&posts=5&per_post=20&since=2026-11-23T20:00:00Z" req = urllib.request.Request(url, headers={"x-api-key": os.environ["SOCIALCRAWL_API_KEY"]}) page = json.load(urllib.request.urlopen(req, timeout=180)) for p in page["data"]["posts"]: print(p["url"], p["comments_new"], p["credits"]) print(len(page["data"]["items"]), page["credits_used"]) ``` - `data.items` holds the new comments, each under `comment` with its text, author and time. - `data.posts` says, post by post, how many comments were new and what each cost. - `since` takes an ISO 8601 time on a direct call. ### Step 2: keep the newest time you read Save the time of the run once it finishes, and send it as `since` on the next run. Keep each comment by `comment.id`, so a comment that comes back is not stored twice. ```json title="Response (trimmed)" { "data": { "items": [{ "comment": { "id": "18135330661764616", "post_id": "DgCpvD5A-3U", "published_at": "2026-11-23T23:20:41.000Z" } }], "credits": { "posts": 1, "comments": 35, "replies": 0, "charged": 36, "held": 51 } }, "credits_used": 36 } ``` ### Step 3: let a Monitor send only the new ones The Monitor below runs the read every hour and sends new comments to your webhook. With `webhook_rows: "new"` it remembers every comment it has read, so none is sent twice. Its first run is the baseline: it remembers what is there and sends nothing. ## Store only what is new - Key each comment on `comment.id`. - Overlap the windows. Send a `since` an hour or two earlier than your last run, so a failed run loses nothing. - In a Monitor, send `since: "now-3h"`. It is resolved at every run to the time three hours earlier. - Keep each run under 200 comments with `since` and `per_post`. Rows past that are not stored. ## What it costs A check pays for the post list page and for each comment page it reads. A post with no new comment reads no page. A Monitor adds 1 scheduling credit a run. What the runs measured on 23/11/2026: | Run | Comments | Credits | | --- | --- | --- | | The dry run of the read | 0 | 0 (it holds 51) | | 3 hours, five posts | 48 | 36 | | 2 minutes, five posts | 1 | 6 | | A post with no new comment | 0 | 0 | ## Run this every day Price the Monitor with a dry run, which creates nothing: ```bash title="cURL" curl -X POST "https://www.socialcrawl.dev/v1/monitors?dry_run=1" \ -H "x-api-key: $SOCIALCRAWL_API_KEY" \ -H "content-type: application/json" \ -d '{"recipe": "prism/profile/comments", "params": {"url": "https://www.instagram.com/natgeo/", "posts": "5", "per_post": "20", "since": "now-3h"}, "cadence": "hourly", "webhook_url": "https://example.com/hooks/socialcrawl", "track": {"metrics": ["items[].comment.engagement.likes", "total"], "max_rows": 200}, "webhook_rows": "new", "alert_rules": [{"metric": "rows_new", "op": "gt", "value": 0}], "suppress_webhook_unless_alert": true}' ``` - `estimated_cost_per_run` in the answer is the worst case, every post with a full page of new comments. - `rows_new gt 0` with `suppress_webhook_unless_alert: true` sends nothing in an hour with no new comment. - Send the same body without `dry_run=1` to create it, with `max_credits_per_month` set to your limit. - The answer carries `would_be_refused` when your plan has no free Monitor slot. - Store the `webhook_secret` from the create answer, and [verify every delivery](/docs/webhooks.md#verifying-signatures). ## Tips, and what not to use - A chat app's incoming-webhook address is refused, because it cannot check a signature. Run the [short relay](/docs/webhook-endpoints.md#send-events-to-a-chat-channel) and register its address instead. - Start with five posts. Older posts rarely get new comments, and each one adds to the hold. - Read `webhook_delivery` on the Monitor's runs to see the status your endpoint returned for each delivery. - Use [Read the comments under many posts](/docs/recipes/comments-in-bulk.md) for a one-off export of every comment. - Watch one post with `instagram/post/comments` and `sort=recent` when only one post matters. ## Copy it - [Get a free key](/auth/register?utm_source=docs&utm_medium=playbook&utm_campaign=new-comments-to-a-webhook): New accounts start with free credits. No card needed. - [n8n workflow](/blueprints/n8n/post-comments.json): Reads the newest comments under your post links every morning into a sheet. - [Make blueprint](/blueprints/make/post-comments.blueprint.json): The same read as a Make scenario. Import it with Import Blueprint. ## Full program and agent brief **Full program (Python)** ```python title="Python" # comment_watch.py: the new comments under a profile's recent posts, each kept once. # Run: SOCIALCRAWL_API_KEY=... python3 comment_watch.py (Python 3.9+, nothing to install) import datetime import json import os import time import urllib.error import urllib.parse import urllib.request KEY = os.environ["SOCIALCRAWL_API_KEY"] BASE = "https://www.socialcrawl.dev/v1" PROFILE = "https://www.instagram.com/natgeo/" STATE_FILE = "comment_watch.json" OVERLAP = datetime.timedelta(hours=2) # a failed run loses nothing def get(path, query): url = f"{BASE}/{path}?" + urllib.parse.urlencode(query) for attempt in range(6): req = urllib.request.Request(url, headers={"x-api-key": KEY}) try: with urllib.request.urlopen(req, timeout=180) as res: return json.load(res) except urllib.error.HTTPError as err: if err.code == 402: raise SystemExit(json.load(err)["error"]["message"]) # never retry a 402 if err.code not in (429, 503) or attempt == 5: raise time.sleep(int(err.headers.get("Retry-After", "2"))) now = datetime.datetime.now(datetime.timezone.utc) state = {"last_run": (now - datetime.timedelta(hours=3)).isoformat(), "seen": []} if os.path.exists(STATE_FILE): state = json.load(open(STATE_FILE)) since = datetime.datetime.fromisoformat(state["last_run"]) - OVERLAP seen = set(state["seen"]) page = get("prism/profile/comments", { "url": PROFILE, "posts": "5", "per_post": "20", "since": since.strftime("%Y-%m-%dT%H:%M:%SZ"), }) fresh = [i["comment"] for i in page["data"]["items"] if i["comment"]["id"] not in seen] for c in fresh: print(c["published_at"], c["post_id"], c["text"][:80]) print(f"{len(fresh)} new comments, {page['credits_used']} credits") state["seen"] = sorted(seen | {c["id"] for c in fresh})[-5000:] state["last_run"] = now.isoformat() json.dump(state, open(STATE_FILE, "w")) ``` **Agent brief** ```text title="Agent brief" Goal: the new comments under an account's recent posts, sent to my webhook. Read https://www.socialcrawl.dev/docs/recipes/new-comments-to-a-webhook.md first. 1. Send GET /v1/prism/profile/comments with url, posts=5, per_post=20, since and dry_run=true. Show me the hold. 2. Run it without dry_run. Keep each comment by comment.id and report only new ones. 3. Send POST /v1/monitors?dry_run=1 with the body on the page and my webhook_url. Show me estimated_cost_per_run. 4. Create the Monitor only after I agree to a max_credits_per_month. Store the webhook_secret it returns. ``` ## Next steps - [Monitors](/docs/engines/monitors.md): Schedules, alerts and the free dry run. - [Webhooks](/docs/webhooks.md): The delivery body, signatures and retries. - [Read the comments under many posts](/docs/recipes/comments-in-bulk.md): Every comment of a list of posts, once.