Automating Cancel for Future Flight Credit with KaibanJS and Claude Code

This example shows how KaibanJS can deliver a high-volume airline call center workflow—canceling a reservation while preserving value as future flight credit—by combining native multi-agent orchestration with ExternalCodingAgent and the Claude Code CLI for policy-grounded eligibility research. It is modeled on Kaiban's product use case for airlines, adapted into an open developer reference you can run locally.

Why This Use Case Matters

Passengers frequently contact airlines to cancel a booking and keep the value as future credit. That sounds simple, but in practice it requires interpreting fare-specific rules, fees, restrictions, and exceptions—often scattered across systems. Kaiban describes how AI agents can modernize this workflow for call centers: faster handling, clearer customer communication, and more consistent policy application (read the full Kaiban story).

From a KaibanJS perspective, the same business outcome maps cleanly to a three-task team: research eligibility with a coding-native agent that can hit official sources, pause for human-in-the-loop (HITL) when the customer must accept or decline terms, then branch to final resolution. ExternalCodingAgent is the bridge that lets the first step run inside Claude Code—using Bash-style tooling to fetch and interpret policy pages—while the rest of the workflow stays in standard KaibanJS agents and tasks.

The AI Agents in This Demo

The workflow uses three KaibanJS agents, each bound to one task on the board. The first slot is special: it is still one agent and one task in KaibanJS, but Claude Code performs a large eligibility assignment using its own multi-step tool loop (Bash, curl, text extraction, fallbacks) before returning a single structured result to the team.

Task 1ExternalCodingAgent → Claude CodeOne agent · One heavyweight task

Eligibility Evaluator

Fare rules & cancellation policy specialist

In KaibanJS this appears as a single agent on the team. Under the hood it is an ExternalCodingAgent with codingBackend: 'claude-code' and allowedTools: 'Bash'. That is enough for a wide research surface: Claude Code can chain terminal work—fetch official airline pages, strip HTML to readable text, scan for fee and credit keywords, detect bot walls or JavaScript-only shells, fall back to curated reference rules when the live web is unusable, and only then consolidate into the markdown + JSON-style answer KaibanJS expects for task 1.

You do not need a dozen micro-agents in KaibanJS for every curl or grep: the advantage of Claude Code is that it carries an entire research episode inside one task boundary, with native tooling and retries, while KaibanJS still owns sequencing, timeouts, and handoff to the next task.

Task 2KaibanJS agent

Customer Notification Agent

Customer service communication specialist

Reads the eligibility output via {taskResult:task1} and authoritative reservation fields, then drafts the customer review card: credit amount, fees, expiration, accept vs decline consequences. This is classic KaibanJS orchestration—clear role, no external CLI—optimized for tone and clarity.

Task 3KaibanJS agent

Resolution Agent

Reservation cancellation & resolution specialist

Runs after HITL approval. Uses prior task context ({taskResult:task1}, {taskResult:task2}) plus the same reservation inputs to produce a final outcome: simulated cancellation and future flight credit when the customer accepts, or a structured escalation brief when they decline.

The Challenge: Volume, Rules, and Trust

The operational pain points Kaiban highlights for this journey also explain why a framework-first implementation is valuable.

Manual, repetitive handling

Agents must repeatedly interpret similar requests, which increases handle time and error risk during peaks.

Complex fare rules

Nuanced conditions and exceptions are easy to misapply without a structured research step and explicit sourcing.

Policy consistency

Customers expect the same answer every time; variability erodes trust and creates downstream servicing issues.

Scalability under surge

Spikes in cancellations need automation that still preserves review points for regulated or high-risk decisions.

The Solution: KaibanJS Orchestration + Claude Code Execution

The reference demo implements a realistic cancellation-for-credit pipeline: eligibility research delegated to Claude Code, a customer review card with HITL, then resolution that either simulates credit issuance or escalates when the customer declines.

Claude Code on task 1

One Eligibility Evaluator step delegates the whole research episode to Claude Code with Bash—see the agent roster above for how that stays a single KaibanJS task while the CLI runs its own tool chain.

Native agents for customer language

The Customer Notification Agent turns structured eligibility outputs into a clear review card, using {taskResult:task1} so later tasks inherit the first task's conclusions inside normal KaibanJS interpolation.

HITL before irreversible steps

The notification task sets externalValidationRequired: true, pausing the workflow until the customer accepts or declines—then the API resumes execution, matching how regulated servicing flows should behave.

Observable execution

The companion app streams task updates over Server-Sent Events and renders progress in kaiban-board, so stakeholders see the same Kanban mental model KaibanJS teams use everywhere else.

Implementation Architecture

End-to-end flow from the demo UI through Next.js API routes into a KaibanJS team definition

1

Customer request captured in the UI

The demo exposes preset reservations (for example AA, DL, UA routes) so operators can start a workflow without wiring a live PNR. Inputs become the team's inputs payload.

2

POST /api/team/start runs the team server-side

The API route constructs createCancellationTeam(inputs), starts the workflow, and streams structured events to the browser for board updates.

3

Task 1 — Eligibility via Claude Code

ExternalCodingAgent runs with useBare: true and allowedTools: 'Bash' so Claude Code can curl official airline URLs, extract readable text, and return a JSON-shaped final answer for KaibanJS.

4

Task 2 — Customer review + HITL

A KaibanJS agent composes the customer-facing review card from eligibility results and authoritative reservation fields, then the workflow blocks until validation completes.

5

Task 3 — Resolution or escalation

The final agent produces confirmation-style output when the customer accepts (simulated credit issuance) or an escalation brief when they decline—always grounded in the same reservation inputs.

Key components

  • cancellation-team.ts: server-side team, tasks, prompts, and deterministic fallbacks for demo stability
  • active-teams.ts: in-memory session registry so HITL resume calls reach the correct running team
  • remote-team-bridge.ts: KaibanBoard-compatible client bridge that mirrors remote workflow state from SSE
  • /api/team/validate: resumes after accept or reject decisions

Production deployments would swap simulated resolution for real reservation systems, durable workflow storage, auth, and audit trails—the pattern stays the same.

How ExternalCodingAgent Unlocks This Use Case

Policy research is not only an LLM prompt—it is a coding task in practice: fetch pages, detect bot walls, normalize HTML into text, and cite what was actually retrieved. That is why Claude Code fits naturally as the execution surface for task one while KaibanJS retains control of sequencing, guardrails, and HITL boundaries.

Potential beyond the demo presets

The demo ships with three curated itineraries so recordings stay deterministic. The same architecture extends to arbitrary reservations once you connect real inventory and fare display systems—the team contract (inputs → eligibility → HITL → resolution) remains stable.

  • Attach a live PNR / ticketing adapter at the API boundary
  • Replace curated fare snippets with a versioned policy store
  • Route HITL actions to your CRM or agent desktop
  • Emit structured citations for compliance review

Learn the agent primitive first

If you are new to ExternalCodingAgent, start with the focused playground example, then return here for a full product-shaped workflow.

Read the ExternalCodingAgent overview →

Official concept docs: ExternalCodingAgent on docs.kaibanjs.com.

Demo: KaibanJS + Claude Code in Action

Watch the walkthrough of automating airline flight cancellations for future credit with KaibanJS and Claude Code, including the Kaiban board, HITL review, and resolution paths.

Clone the companion Next.js repository, configure your Anthropic key, install Claude Code CLI, and run the same workflow locally.

View demo source on GitHub

Getting Started

Requirements and commands mirror the demo README: Node 20+, Claude Code on PATH, and an Anthropic API key for headless runs.

1. Install Claude Code

npm install -g @anthropic-ai/claude-code claude --version

2. Configure secrets

# .env.local ANTHROPIC_API_KEY=sk-ant-... # optional KAIBAN_CLAUDE_CLI=/absolute/path/to/claude

3. Run the demo

git clone https://github.com/kaiban-ai/kaibanjs-claude-code-cancel-flight-for-future-credit-demo.git cd kaibanjs-claude-code-cancel-flight-for-future-credit-demo npm install --force npm run dev

Open the printed localhost URL, pick a preset itinerary, start the workflow, and exercise accept vs decline on the HITL card.

Ship Airline-Grade Workflows with KaibanJS

Cancel-for-credit is one of many servicing journeys where combining structured teams, external coding agents, and HITL produces both speed and accountability.

GitHub Stars

We’re almost there! 🌟 Help us hit 100 stars!

Star KaibanJS - Only 100 to go! ⭐