Skip to main content

PingRoom / SDK

Your code.
A human response.

Ask someone on their phone. Get an answer in your application. Keep the next step in your code.

Start with TypeScript
npm install @pingroom/sdk
Open source · MIT
release.tsNode 20+ · Native fetch
import { PingRoom } from '@pingroom/sdk';

const pr = new PingRoom({ token: process.env.PINGROOM_TOKEN });

const question = await pr.questions.ask('AB12CD', {
  prompt: 'Ship the release?',
  options: ['ship', 'hold'],
});

const answer = await pr.questions.waitForAnswer(question.id);
if (answer.state === 'answered' && answer.answer?.value === 'ship') {
  // Your release step goes here.
}

@pingroom/sdk · Typed. Zero runtime dependencies.

View package
01 / Ask. Wait. Continue.

Example code. No request is sent from this page.

01 / First Ping

From an import to a phone.

Install the TypeScript / JavaScript package, supply an approved agent credential, and send to a room your robot can access. Replace AB12CD with that room’s invite code.

The npm package ships TypeScript declarations and uses native fetch. Node.js 20+, Cloudflare Workers, Deno, and Bun are supported. It is an ES module.

npm install @pingroom/sdk

02 / Ask, wait, continue

A human answer in your control flow.

Approvals handle a simple decision. Questions offer choices or a typed reply. Handoffs reach one person privately. Wait helpers return the outcome; your application owns the next action.

Continue only when the result contains the exact approving decision. Pending, expired, and cancelled are separate states.

const approval = await pr.approvals.request('AB12CD', {
  question: 'Ship release 1.4.0 to production?',
  options: ['Ship it', 'Hold'],
  idempotencyKey: 'release-1.4.0-approval',
});

const result = await pr.approvals.waitForDecision(approval.id);

if (result.status === 'decided' && result.decision === 'Ship it') {
  // Run your approved release step here.
}

03 / What you can build

More than a send function.

Use the same TypeScript client for the room, the update, and the response. Start with a single Ping and add the parts your workflow needs.

Updates and acknowledgements

Send a short message with structured data, a link, or a location. Ask for an acknowledgement when you need a person to confirm. Urgent delivery and acknowledgement are separate options.

Questions, approvals, and polls

Ask for a decision and receive a structured result. Address the connected human, open a question to the room, or collect votes from room members.

Live progress

Keep one card updated as a build, delivery, or job moves forward. Running updates are silent; finishing the stream sends a completion alert.

Files with context

Upload a PDF, Markdown, text, HTML, image, or ZIP, then attach its ID to a Ping or question. Uploads require Pro; each file can be up to 5 MiB, with up to four per send.

Rooms and Quick Pings

List, create, and join rooms your credential permits. Configure Quick Ping slots and trigger saved actions from your application.

Replies and webhooks

Read history, listen for incoming Pings, or accept signed outgoing webhooks. Use the signature helper to verify a delivery before processing its payload.

04 / Beyond hello world

Keep the work connected.

These examples use the same authenticated pr client from the quick start. Each pattern fits into an existing worker, script, or backend service.

Reuse the correlation ID for the same job. PingRoom updates the existing live card on supported devices, then ends it when you send done or failed.

import { liveStatus } from '@pingroom/sdk';

await pr.live.push('AB12CD', liveStatus.progress('deploy-42', {
  state: 'running',
  message: 'Building the release',
  progress: 0.4,
}));

// Update this stream as your job advances.
await pr.live.push('AB12CD', liveStatus.done('deploy-42', 'Release shipped'));

05 / Connect with permission

A robot identity. Human-granted access.

Pair a local integration through PingRoom, or supply an agent credential you already manage. Pairing creates a separate robot that the person claims and gives access to selected rooms or all eligible rooms.

import { PingRoom } from '@pingroom/sdk';

const pr = new PingRoom();
const pairing = await pr.auth.startPairing({ agent_label: 'Release bot' });

console.log(pairing.pair_browser_url ?? pairing.pair_url);
const active = await pr.auth.waitForPairing(pairing);

// The client now uses the approved robot credential.
const room = active.home_room ?? active.room;
if (room) {
  await pr.broadcast(room.invite_code, { message: 'Release bot connected.' });
}

The person chooses the access

The approval screen defines the robot’s room access. Installing the app does not grant permission. Reuse the pending pairing link while the person signs in or installs PingRoom.

Keep credentials on the server

Use an environment variable or your secret store for long-lived agent tokens. The JavaScript client works in browsers, but a public browser bundle must never contain your agent credential.

Inspect and disconnect

auth.connection() reports the connected owner and robot. auth.disconnect() revokes the credential and its refresh credentials when the integration is no longer needed.

06 / Production behavior

Handle the answer. Handle the wait.

A human might decline, take a while, or never respond. Make those outcomes explicit in your application and put a deadline around work that cannot wait forever.

Retry a send with the same key

The server may have accepted a request before it timed out. Reuse its idempotencyKey when retrying a broadcast, approval, or question so the server can replay the original result.

Recognize terminal states

Answered, expired, and cancelled mean different things. A negative answer is a valid result. Gate an action on the exact response you require.

Bound your waits

Wait helpers long-poll, back off after transient failures, and honor rate-limit responses. Supply an AbortSignal for your own deadline and onRetry when you need visibility into recovery.

Verify incoming events

Verify webhook signatures over the raw request body. Require V2 signatures and deduplicate delivery IDs before running work; webhook deliveries can be retried.

const result = await pr.questions.waitForAnswer(question.id, {
  signal: AbortSignal.timeout(15 * 60_000),
  onRetry: (error, attempt) => {
    console.warn('Waiting for PingRoom', { code: error.code, attempt });
  },
});

07 / Choose your language

Official clients. Open source.

TypeScript and JavaScript are available on npm today. Official Python, Go, PHP, and Ruby clients are available as source repositories; follow their release status and installation guidance before adding them to your project.

08 / Keep building

References and source code.

Read the full API reference, inspect the source, or choose the CLI and MCP when those fit your workflow.

Should I use the SDK, CLI, or MCP?

Use the SDK inside an application, worker, or service. Use the CLI for terminal scripts and shell pipelines. Use MCP to give a compatible AI client PingRoom tools. All three use your PingRoom rooms and permissions.

Do I need an AI agent to use the SDK?

No. A CI job, backend service, scheduled script, or ordinary application can use it. An agent credential is the integration’s identity and permission to access PingRoom.

Does a question automatically run my code when someone answers?

No. The SDK returns a result to your application. Your code checks the state and chosen answer, then decides whether to continue, stop, or ask again.

Do all SDKs have the same features?

The core Ping, human-response, attachment, and live-status workflows are shared. TypeScript has additional account-pairing, room-management, and MCP helpers. Check the README and changelog of the language and version you use.

What requires PingRoom Pro?

Attachment uploads and creating room webhooks require Pro. Sending and other capabilities remain subject to the connected account’s plan, room access, and service limits. The API returns a specific error when a capability is unavailable.