Developer recipe

Export a filtered inbox safely

Page through GramClaw's conversation store with an account or pipeline filter instead of requesting an unbounded inbox.

Result
A script retrieves every matching conversation while respecting cursor pagination and the 100-row page limit.
Time
10 minutes
Key scopes
read

Use server-side filters

Add account_id, stage_key, or both to reduce the dataset before it reaches your process. The example exports qualified conversations as JSON.

Page until has_more is false

Node.js
const base = process.env.GRAMCLAW_BASE_URL || "https://gramclaw.com";
const key = process.env.GRAMCLAW_API_KEY;
let cursor = null;
const chats = [];

do {
  const url = new URL("/api/v1/chats", base);
  url.searchParams.set("limit", "100");
  url.searchParams.set("stage_key", "qualified");
  if (cursor) url.searchParams.set("cursor", cursor);

  const response = await fetch(url, {
    headers: { Authorization: `Bearer ${key}` },
  });
  if (!response.ok) throw new Error(`GramClaw returned ${response.status}`);

  const page = await response.json();
  chats.push(...page.chats);
  cursor = page.has_more ? page.next_cursor : null;
} while (cursor);

console.log(JSON.stringify(chats, null, 2));
  • The endpoint reads GramClaw's synchronized store and does not call Telegram once per row.
  • Treat exported conversation metadata as customer data and store it accordingly.
Chat on Telegram