Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.zavu.dev/llms.txt

Use this file to discover all available pages before exploring further.

Functions

A Zavu Function is a serverless TypeScript snippet that runs in Zavu Cloud and reacts to messaging events or AI agent tool calls. You write the code locally, run zavu deploy, and seconds later your agent is live with tools backed by real business logic — no servers, no Docker, no webhook receivers to maintain.

What is a Zavu Function?

Think of a Function as the code-side counterpart to an AI Agent. Where an Agent decides what to say, a Function executes the actions the Agent needs — query a database, check inventory, book a reservation, call your own API.
  • Declare an agent in code with defineAgent — config stays in sync with your repo.
  • Declare tools with defineTool — handlers run inside Zavu Cloud when the LLM decides to call them.
  • React to events with defineFunctionmessage.inbound, broadcast.completed, etc.
  • Auto-provisioned API key — the function can call any Zavu API endpoint without you handling credentials.
import { defineAgent, defineTool } from "@zavu/functions"

defineAgent({
  senderId: process.env.SENDER_ID!,
  name: "Bella",
  provider: "zavu",
  model: "openai/gpt-4o-mini",
  prompt: "You are Bella, host at La Pizzeria. Be brief.",
  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 here
    return { available: true, slots: ["19:00", "21:00"] }
  },
})
That’s the entire integration. One file, zavu deploy, done.

How it relates to AI Agents

NeedUse
A no-code agent configured from the dashboardAI Agents
An agent with custom business logic in your own codeZavu Functions
Both — start no-code, evolve to codeStart with AI Agents, migrate when you need real 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 on every deploy. The dashboard surfaces “managed by function” on these agents and disables manual edits to prevent drift.

Mental model

+----------------+        +--------------------+        +-----------+
| 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 — zavu deploy handles 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.completed, etc.) via triggers.
  • Auto-provisioned credentials. Every function gets a scoped ZAVU_API_KEY in its environment so it can call our SDK without you handling key distribution.

Lifecycle

  1. zavu fn init — scaffolds a project with index.ts, package.json, and a .zavu/ config that links the local directory to a Function record in your Zavu project.
  2. zavu fn secrets set KEY value — encrypts and stores secrets that will be injected as env vars at runtime.
  3. zavu deploy — bundles your code + dependencies, ships them to Zavu Cloud, syncs the agent + tool declarations from your code into your project, and starts serving traffic. The dashboard reflects the new state immediately.
  4. zavu fn logs --tail — streams runtime logs from invocations as they happen.
  5. zavu fn versions — list deploys and roll back to any previous one.

Pricing model

Functions are metered by invocation units, where one unit equals one invocation of a 128 MB function. Higher memory configs cost proportionally more units per invocation — a 256 MB function costs 2 units per invocation, 512 MB costs 4, 1024 MB costs 8. Each paid plan includes a generous monthly quota; overage is billed automatically on your next invoice via Stripe Meters.
PlanIncluded unitsOverage
Free100kHard cap — invocations blocked when reached
Hobby1M$5 / 1M units
Standard5M$4 / 1M units
Growth10M$3 / 1M units
Cold start, network call, error — every invocation counts the same. The unit model is intentionally aligned with the underlying compute cost so you can predict overage from your code’s memory profile.

Continue