heraldcloud

herald cloud answers the calls to your number and hands each one to your code: a voice agent, a menu, a transfer to a person.

Create a workspace

Try it now

Call this demo program from your terminal with herald's softphone, and watch the call run here, line by line.

$ npx @herald-voice/cli phone --from ···· sip:…

In a Mac terminal. Type two numbers, each followed by #, then talk.

app/herald/route.tsLine free
The caller typed
1import { createPersona, decodeWav, herald } from "@herald-voice/sdk";
2import { textToSpeech } from "@herald-voice/sdk/ai-sdk";
3import { cache } from "./cache"; // WAV files, then Redis
4
5const voice = createPersona({ tts: textToSpeech("elevenlabs/eleven-flash-v2.5"), cache });
6
7const app = herald({
8 secret: process.env.HERALD_SECRET,
9 onCall: (call) =>
10 call.stream(async (live) => {
11 const a = await live.digits({ max: 4, prompt: voice.say("Let's add two numbers. Type the first, then the hash key.") });
12 const b = await live.digits({ max: 4, prompt: voice.say("Now the second, then the hash key.") });
13 const sum = Number(a.digits) + Number(b.digits);
14 await live.play(voice.say(`The sum is ${sum}.`));
15
16 // The caller's audio: record it, play it back.
17 await live.play(voice.say("Say something after the beep, and I'll play it back."));
18 const rec = await live.record({ maxDuration: "5s" });
19 await live.play(decodeWav(rec.wav));
20 await live.play(voice.say("That's all. Bye!"));
21 }),
22});
23
24export const { POST } = app.http();

What your program can do

Each call runs your onCall: plain async code that awaits the caller. Talk to a voice model, read keys, record, transfer, or place the call yourself. On a server, as a Vercel function, or on your laptop through the tunnel.

server.ts
import { herald } from "@herald-voice/sdk";
import { connectRealtime } from "@herald-voice/sdk/ai-sdk";
import { tool } from "ai";
import { z } from "zod";
import { calendar } from "./calendar";

const app = herald({
  secret: process.env.HERALD_SECRET,
  onCall: (call) =>
    connectRealtime(call, {
      model: "openai/gpt-realtime-2",
      instructions: "You book visits for Studio Bianchi, a dentist.",
      greeting: "Answer as Studio Bianchi and ask how you can help.",
      tools: {
        freeSlots: tool({
          description: "The free slots on a day",
          inputSchema: z.object({ day: z.string() }),
          execute: ({ day }) => calendar.free(day),
        }),
      },
    }),
});

await app.listen(4000);

Handle your first call in a few minutes.