Agents API
The agent() function creates an agent builder for defining your bot's personality and behavior.
Basic Usage
import { agent } from "@andresaya/flowkit";
const myAgent = agent("Alex")
.company("TechCorp")
.personality("friendly and helpful")
.language("en")
.build();API Reference
agent(name: string)
Creates a new agent builder.
Parameters:
name- The agent's name (used in introductions)
Returns: AgentBuilder
AgentBuilder Methods
.company(name: string)
Sets the company/organization the agent represents.
agent("Alex").company("ACME Corp").personality(description: string)
Describes the agent's personality traits.
agent("Alex").personality("friendly, professional, and patient").language(lang: string)
Sets the agent's primary language.
agent("Alex").language("Spanish")
agent("Alex").language("en") // Also accepts codes.context(text: string)
Adds additional context or instructions for the agent.
agent("Alex").context(`
You are a customer support specialist.
Always verify the customer's account before providing information.
Never discuss competitor products.
`).restrict(...restrictions: string[])
Adds behavioral restrictions.
agent("Alex").restrict(
"Never discuss pricing",
"Do not provide legal advice",
"Always escalate complaints"
).strict()
Enables strict mode - the LLM will follow the script exactly.
agent("Alex").strict().systemPrompt(prompt: string)
Adds a custom system prompt prefix.
agent("Alex").systemPrompt("Always start responses with the user's name.").build()
Builds and returns the final AgentConfig object.
const config = agent("Alex")
.company("TechCorp")
.build(); // Returns AgentConfigAgentConfig Type
interface AgentConfig {
name: string;
company?: string;
personality?: string;
language?: string;
context?: string;
restrictions?: string[];
mode?: "flexible" | "strict";
systemPrompt?: string;
}Examples
Basic Agent
const basic = agent("Support Bot").build();Full Configuration
const enterprise = agent("Enterprise Assistant")
.company("Fortune 500 Corp")
.personality("professional, knowledgeable, and efficient")
.language("English")
.context(`
You handle enterprise support tickets.
Always ask for ticket number first.
Prioritize security and compliance.
`)
.restrict(
"Never share internal documentation",
"Do not discuss unreleased features"
)
.strict()
.build();Multilingual Agent
const spanish = agent("Carlos")
.company("Claro Colombia")
.language("Spanish")
.personality("amable y profesional")
.strict()
.build();Best Practices
Name Selection
Choose names that match your brand voice. "Alex" feels friendly, "Enterprise Assistant" feels professional.
Personality
Be specific about personality traits. Instead of "nice", say "friendly, patient, and empathetic".
Context
Use context for domain-specific knowledge that the base LLM might not have.
Strict Mode
Use strict mode when exact wording matters (compliance, legal, financial flows).