You'll end up with: a deployed voice function that greets the caller and hangs up. No template — every line is yours.
If you want the template-based route instead, see the quickstart.
- CLI installed and authenticated — see cli/installation.
- A Sinch number you own and a Voice App it's assigned to. (You can rent one with
sinch numbers available rent— see the CLI quickstart.)
sinch functions init --name my-first-functionPick Node.js when prompted and choose the "empty" option (not a full template). The CLI creates a minimal project:
my-first-function/
├── function.ts
├── package.json
├── tsconfig.json
├── sinch.json
└── .envChange into the directory and install dependencies:
cd my-first-function
npm installOpen function.ts and replace its contents:
import type { VoiceFunction } from '@sinch/functions-runtime';
import { IceSvamlBuilder } from '@sinch/functions-runtime';
export default {
async ice(context, data) {
context.log?.info(`Call received from ${data.cli}`);
return new IceSvamlBuilder()
.say(`Hello! You dialed ${data.to?.endpoint}. Thanks for calling.`)
.hangup()
.build();
},
} satisfies VoiceFunction;That's the whole function. When a call comes in, Sinch posts an ICE callback to your function, you log the caller, speak a greeting, and hang up.
If you prefer C#, see the C# runtime guide for the controller equivalent.
sinch functions devThe CLI starts your function on http://localhost:3000 with hot reload. It asks whether to open a public tunnel — say Yes. The tunnel gives your laptop a public URL, and the CLI optionally updates your Voice App's callback URL to point at it.
Leave the terminal running. You can test without making a real call:
# In another terminal
curl -X POST http://localhost:3000/ice \
-H "Content-Type: application/json" \
-d '{
"callid": "test-123",
"cli": "+15551234567",
"to": { "type": "number", "endpoint": "+15559876543" }
}'You should see a SVAML response in the curl output and a log line in the dev server.
Or call your Sinch number from a phone. If the tunnel is active, the call hits your laptop directly and you'll see the request live.
sinch functions deployThe CLI validates, packages, uploads, and waits for the rollout. Once it reports Running, your function is live at https://fn-<id>.functions.sinch.com.
If your sinch.json is bound to a Voice App, the CLI updates the app's callback URL to the new function URL automatically. Calls to your Sinch number now hit production.
sinch functions logs --followOpens an interactive terminal UI. Call your Sinch number and watch the ICE request come in live. Arrow keys to navigate, Enter to expand, q to exit.
You wrote 12 lines of code. They handle every call to your Sinch number — billing, routing, authentication, TLS, logging, and scaling all happen on the platform. The only thing you had to care about was what the caller hears.
The same pattern extends to everything else Sinch Functions can do:
- Add a menu — replace
.hangup()with.runMenu(MenuTemplates.business('Acme'))and export apiehandler to route the result. See build an IVR. - Handle SMS — export a
conversationWebhookand send replies withcontext.conversation. See build an SMS responder. - Add a REST endpoint — export a
statusorhealthfunction. See add a custom endpoint. - Call an AI voice agent — use
.connectAgent(AgentProvider.ElevenLabs, ...). See build an AI voice agent.
- Quickstart — same flow using a pre-built template
- Handlers concept — the Express / ASP.NET MVC framing
- Voice callbacks — what ICE, ACE, PIE, DICE actually are
- Node.js runtime / C# runtime — deeper per-runtime guides