Skip to content

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 ​

AspectFlexible ModeStrict Mode
Response styleNatural, adaptiveExact script
LLM freedomHighMinimal
Best forGeneral supportRegulated 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.

Released under the MIT License.