Small TypeScript library for authoring Kapso workflows as code.
It builds a graph, validates obvious mistakes, and compiles to the same source shape used by kapso pull and kapso push.
import { START, Workflow } from "@kapso/workflows";
const workflow = new Workflow("inbound-support", {
name: "Inbound Support",
});
workflow.addTrigger({
type: "inbound_message",
phoneNumberId: "15551234567",
});
workflow.addNode(START, {
position: { x: 100, y: 100 },
});
workflow.addNode("normalize", {
type: "function",
functionSlug: "normalize-phone",
saveResponseTo: "normalized_phone",
});
workflow.addNode("classify", {
type: "decide",
decisionType: "function",
functionSlug: "classify-message",
conditions: [
{ label: "sales", description: "Sales inquiry" },
{ label: "support", description: "Support request" },
],
});
workflow.addNode("support", {
type: "call",
workflowSlug: "support-flow",
});
workflow.addEdge(START, "normalize");
workflow.addEdge("normalize", "classify");
workflow.addEdge("classify", "support", { label: "support" });
const { metadata, definition, definitionJson } = workflow.toSourceFiles();bun install
bun run build
bun testThis package does not execute workflows locally. It only creates source definitions.