Declarative Agents
Define your bot's personality, language, and behavior in a few lines. No complex configurations needed.
The simplest way to create structured AI conversations. Define your agent and flows declaratively, let the LLM handle the complexity.
Traditional chatbot frameworks require hundreds of lines of boilerplate code. FlowKit lets you focus on what matters: the conversation.
import { agent, flow, FlowEngine, MemoryStorage, OllamaAdapter, name, yesNo } from "@andresaya/flowkit";
// Define your agent
const bot = agent("Alex")
.personality("friendly and helpful")
.build();
// Build your flow
const myFlow = flow("greeting", bot)
.ask("name", "Hi! What's your name?", name(), "user_name")
.then("confirm")
.ask("confirm", "Nice to meet you {{user_name}}! Need help?", yesNo(), "needs_help")
.when({ yes: "help", no: "bye" })
.say("help", "I'm here to help!")
.done()
.say("bye", "Goodbye {{user_name}}!")
.done()
.build();
// Run it
const engine = new FlowEngine(myFlow, {
llm: new OllamaAdapter({ model: "llama3.2" }),
storage: new MemoryStorage()
});
const result = await engine.start("session-1");
console.log(result.message); // "Hi! What's your name?"| Traditional Approach | With FlowKit |
|---|---|
| 150+ lines of code | ~30 lines |
| Manual regex/parsing | LLM understands context |
| Hardcoded language | Works in any language |
| Complex state management | Declarative flows |
| Provider lock-in | Swap providers easily |