Use your data in every chat

Look up an order, book a slot, or update your CRM in the middle of a WhatsApp conversation. Write the logic in JavaScript, and Kapso runs it for you.

async function handler(req, env) {
  const { order_id } = (await req.json()).execution_context.vars
  const order = await fetch(`${env.API_URL}/orders/${order_id}`).then(r => r.json())
  return Response.json({ vars: { eta: order.eta } })
}

How it works

  • A customer asks a question in WhatsApp.
  • Your workflow calls the function and sends it the execution context, including vars.
  • Your function calls your API, then returns vars the workflow uses in its reply.

One function, four places to use it

  • Workflow step: run it in a workflow and use what it returns in the next message.
  • Branching: let it decide which path the conversation takes next.
  • AI agent tool: give your agent a tool it can call when it needs your data.
  • HTTP endpoint: call it from anywhere with a URL, private or public.

Storage and secrets, already wired up

  • env.KV: persistent key-value storage with TTLs.
  • env.DB: your project database, bound as Cloudflare D1.
  • env.API_KEY: encrypted secrets you set on the function page.
  • fetch(): call any API, with standard Web APIs.

Every invocation, recorded

  • See what called each function, what it got, what it returned, and how long it took. It's all in Kapso Logs too.

Frequently asked questions

Where do Kapso functions run?

On Cloudflare Workers. Kapso wraps your code, calls handler(request, env), and gives each project its own KV namespace and D1 database.

How do I store API keys?

Add them as secrets on the function page after you deploy it. Secrets are encrypted, never shown again after you save them, and your code reads them as env.NAME.

Can I call a function over HTTP?

Yes. A deployed function has an invoke URL, https://api.kapso.ai/platform/v1/functions/{function_id}/invoke. It is private by default and needs your X-API-Key header. Make the endpoint public to call it without a key.

Can an AI agent use my function?

Yes. Add it as a function tool on an agent. The agent decides when to call it, and your handler reads the arguments it chose from body.input.