Zavu Functions
Deploy serverless code that powers your agents — no infra to manage, just `npx zavudev deploy`.
Zavu Functions
Zavu Functions let you run TypeScript in our cloud and wire it directly to your
WhatsApp/SMS/Email senders. You write the code locally, run npx zavudev deploy, and
seconds later your agent is live with tools backed by real business logic.
TypeScriptimport { defineAgent, defineTool } from "@zavudev/functions" defineAgent({ senderId: process.env.SENDER_ID!, name: "Bella", provider: "zavu", model: "openai/gpt-5.6-luna", prompt: "Eres Bella, anfitriona de la Pizzeria. Sé breve.", channels: ["whatsapp"], }) defineTool({ name: "check_availability", description: "Get free reservation slots for a date and party size.", parameters: { type: "object", properties: { date: { type: "string" }, partySize: { type: "number" }, }, required: ["date", "partySize"], }, handler: async ({ date, partySize }) => { // your real booking logic — DB, POS, external API, whatever return { available: true, slots: ["19:00", "21:00"] } }, })
That's the entire integration. One file. npx zavudev deploy. Done.
When to use Functions
Customer asks something, the LLM decides which tool to call, your code runs, real data goes back as the answer.
Receive inbound from Stripe, GitHub, your own systems, then forward as a WhatsApp message.
Daily report digests, reminder broadcasts, cleanup tasks.
React to message.inbound, broadcast.status_changed, etc. with custom logic
without managing webhook receivers yourself.
How it relates to AI Agents
Zavu has two complementary ways to build agents:
| You want | Use |
|---|---|
| A no-code agent configured from the dashboard | AI Agents |
| An agent with custom business logic in your own code | Zavu Functions (this guide) |
| Both — start no-code, evolve to code | Start with AI Agents, migrate when you need tools or custom flows |
Functions can fully manage an AI Agent: the defineAgent call creates and
keeps the agent config in sync with your code. Once your function declares
defineAgent, the agent is "managed by the function" — the dashboard surfaces
this and disables manual edits to prevent drift.
Mental model
Code+----------------+ +--------------------+ +-----------+ | WhatsApp user | -----> | Zavu sender (WABA) | -----> | AI Agent | +----------------+ +--------------------+ +-----------+ | (tool call) v +-------------------------------+ | Your Zavu Function | | defineTool(handler) | +-------------------------------+ | (return result) v Agent answers user
- Fully managed runtime. Each function runs in Zavu's serverless cloud. No
consoles to log into —
npx zavudev deployhandles bundling, dependencies, and publishing. - Internal invocation. When the agent calls a tool, we use signed internal invocations — your function is not publicly exposed. No HTTP, no HMAC secrets to rotate, no DDoS surface.
- Native event binding. Functions can also subscribe to Zavu events
(
message.inbound,broadcast.status_changed, etc) via triggers. - Auto-provisioned credentials. Every function gets a scoped
ZAVU_API_KEYin its environment so it can call our SDK without you handling key distribution.
Quick tour
Install the CLI
terminalnpx zavudev@latest --version # or install it globally: npm install -g zavudev # or grab a standalone binary from # https://github.com/zavudev/zavu-cli/releasesLogin (one time)
terminalnpx zavudev loginOpens your browser, lets you pick a project. The API key is saved to
~/.zavu/credentials.jsonand used by every later command.Scaffold a function
terminalnpx zavudev fn init --template restaurant-booking -y cd reservationsCreates
index.tswithdefineAgent+defineToolboilerplate.Set secrets
terminalnpx zavudev fn secrets set SENDER_ID jn76vnxet8g5nq661by3v06y1581bmmnThe agent will run on this WhatsApp sender. Get the ID from
npx zavudev senders list.Deploy
terminalnpx zavudev deployBundle, upload, agent + tools synced to your sender.
Try it
Send a WhatsApp to the sender's number. The agent answers, calls your tool handlers, returns real data.
Continue
Full step-by-step from zero to live agent in 10 minutes.
Every zavu command, flag by flag.
defineAgent API, providers, prompts, models.
defineTool API, schemas, handlers, error handling.
Environment variables encrypted at rest.
Listen to Zavu events from your function.
How pinning works, when to upgrade.
Complete restaurant booking agent, walked through.