Support Bot β
A natural, conversational tech support bot using flexible mode in English.
Features β
- πΊπΈ English language
- π¬ Flexible mode (natural conversation)
- π§ Technical troubleshooting
- π Escalation handling
Complete Code β
typescript
import {
agent,
flow,
FlowEngine,
MemoryStorage,
OllamaAdapter,
name,
yesNo,
text,
oneOf,
} from "@andresaya/flowkit";
import * as readline from "readline";
// Flexible mode agent - LLM has freedom to respond naturally
const supportAgent = agent("Alex")
.company("TechSupport Inc")
.personality("friendly, patient, and knowledgeable")
.context(`
You are a helpful technical support assistant.
Be conversational and empathetic.
Help users troubleshoot their issues.
`)
.build();
const supportFlow = flow("tech-support", supportAgent)
.ask("greeting", "Hi there! I'm Alex. What's your name?", name(), "user_name")
.then("issue")
.ask(
"issue",
"Nice to meet you {{user_name}}! What seems to be the problem today?",
text(),
"issue_description"
)
.then("category")
.ask(
"category",
"I see. Is this related to: software, hardware, or network?",
oneOf(["software", "hardware", "network"]),
"issue_category"
)
.when({
software: "software_help",
hardware: "hardware_help",
network: "network_help",
})
.say(
"software_help",
"For software issues, try restarting the application. If that doesn't work, try reinstalling it."
)
.then("resolved")
.say(
"hardware_help",
"Hardware issues can be tricky. Make sure all cables are connected. If it's still not working, it might need repair."
)
.then("resolved")
.say(
"network_help",
"For network issues, try restarting your router. Check if other devices can connect."
)
.then("resolved")
.ask("resolved", "Did that help solve your problem?", yesNo(), "is_resolved")
.when({
yes: "goodbye_happy",
no: "escalate",
})
.say(
"goodbye_happy",
"Awesome! Glad I could help, {{user_name}}! Have a great day! π"
)
.done()
.say(
"escalate",
"No worries, {{user_name}}. I'll escalate this to our senior team. They'll contact you within 24 hours."
)
.done()
.build();
async function main() {
const adapter = new OllamaAdapter({ model: "qwen3:4b" });
const storage = new MemoryStorage();
const engine = new FlowEngine(supportFlow, { llm: adapter, storage });
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
const sessionId = `session-${Date.now()}`;
const startResult = await engine.start(sessionId);
console.log(`\nπ€ Bot: ${startResult.message}\n`);
const chat = () => {
rl.question("π€ You: ", async (input) => {
if (input === "exit") {
rl.close();
return;
}
const result = await engine.handle(sessionId, input);
console.log(`\nπ€ Bot: ${result.message}\n`);
if (result.done) {
console.log("\nπ Collected data:", result.state.slots);
rl.close();
return;
}
chat();
});
};
chat();
}
main().catch(console.error);Sample Conversation β
π€ Bot: Hi there! I'm Alex. What's your name?
π€ You: I'm Sarah
π€ Bot: Nice to meet you Sarah! What seems to be the problem today?
π€ You: My computer keeps crashing when I open Chrome
π€ Bot: I see. Is this related to: software, hardware, or network?
π€ You: software I think
π€ Bot: For software issues, try restarting the application.
If that doesn't work, try reinstalling it.
π€ Bot: Did that help solve your problem?
π€ You: yes it works now!
π€ Bot: Awesome! Glad I could help, Sarah! Have a great day! π
π Collected data: {
user_name: "Sarah",
issue_description: "computer keeps crashing when opening Chrome",
issue_category: "software",
is_resolved: "yes"
}Key Differences from Strict Mode β
| Aspect | Flexible Mode | Strict Mode |
|---|---|---|
| Response style | Natural, adaptive | Exact script |
| LLM freedom | High | Minimal |
| Best for | General support | Regulated flows |
TIP
Flexible mode is great for support scenarios where you want the bot to feel more human and adapt to the user's tone.