Quickstart
From a new workspace to a call handled by your program, on your machine.
You will run a small program on your laptop, bring your workspace's calls to it through the tunnel, and call it from your computer. You need Node 22.18 or later.
1. Create a workspace
Sign up at herald cloud. The workspace comes with a test line: digits that ring your workspace from any SIP phone, before you add a number of your own. Lines → Test line shows it.
2. Write the program
mkdir hello && cd hello
npm init -y && npm pkg set type=module
npm install @herald-voice/sdk wsimport { herald, tone } from "@herald-voice/sdk";
const app = herald({
secret: process.env.HERALD_SECRET,
onCall: async (call) => {
console.log(`call from ${call.from} to ${call.number}`);
await call.play(tone(660, 300));
const { digits } = await call.digits({ max: 1, timeout: "6s", prompt: tone(880, 200) });
console.log(`the caller pressed ${digits || "nothing"}`);
await call.play(tone(440, 300));
await call.hangup();
},
onEnded: (ev) => console.log(`ended: ${ev.end_reason}`),
});
await app.listen(4000, { path: "/herald" });onCall runs once for each call. Each await waits for the caller: play plays audio, digits waits for keys, hangup ends the call. secret makes the app refuse requests herald did not sign.
3. Sign in the CLI
npx @herald-voice/cli login --app <herald cloud URL>It opens the browser: sign in and approve the code the terminal shows. Then write the workspace's signing secret to .env:
npx @herald-voice/cli env > .env4. Start the program and the tunnel
node --env-file=.env server.tsIn another terminal:
npx @herald-voice/cli tunnel 4000 --path /heraldcalls reach http://127.0.0.1:4000/herald
call your test line: sip:712345678901@<herald SIP address>
leave this running; Ctrl-C stops itThe tunnel switches the workspace to it: herald now sends the workspace's calls to http://127.0.0.1:4000/herald on your machine.
5. Call it
On macOS, call the test line with the computer's microphone and speaker:
npx @herald-voice/cli phoneYou hear a tone, then a higher one: press a key. The program prints it, plays a last tone and hangs up. From another computer, call sip:<test line>@<herald SIP address> from a SIP softphone.
To try the program without calling, send it a signed test request and see what it answered:
npx @herald-voice/cli test6. See the call
npx @herald-voice/cli callsThe dashboard shows it too, under Calls, with how it ended.
Next
- Add your number and the SIP account (trunk) that brings its calls: Lines in the dashboard, or
herald-cloud numbersandtrunks. See Concepts. - Talk to the caller with a voice model:
connectRealtime. - Deploy the program and give herald its public URL:
herald-cloud backend --url, or Lines → Test line → A public URL. - Place calls out:
HeraldClient.