Skip to content

Latest commit

 

History

History

README.md

Flight Booking App

Deploy with Vercel

This example shows how to use Workflow to make AI agents more reliable and production-ready by adding automatic retries, resume capabilities, and fault tolerance to AI SDK applications. It showcases a conversational flight booking assistant that can search flights, check status, and book tickets—all while being resilient to network failures and LLM errors.

Getting Started

Prerequisites

Local Development

  1. Clone this example and install dependencies:

    git clone https://github.com/vercel/workflow-examples
    cd workflow-examples/flight-booking-app
    pnpm install
  2. Create a .env.local file:

    touch .env.local
  3. Add your API key to the .env.local file:

    AI_GATEWAY_API_KEY=your_api_key_here
  4. Start the development server:

    pnpm dev
  5. Open http://localhost:3000 to see the app

Deploying

Vercel (Recommended)

Deploy directly to Vercel, no additional configuration is needed. Workflow works out of the box.

Deploy with Vercel

Other Platforms (Railway, Render, etc.)

For non-Vercel deployments, you can configure a PostgreSQL World to handle workflow state persistence.

Deploy on Railway

Manual Setup

  1. Set up a PostgreSQL database (Supabase, Neon, etc.)

  2. Add environment variables:

    WORKFLOW_TARGET_WORLD="@workflow/world-postgres"
    WORKFLOW_POSTGRES_URL="postgres://postgres:password@db.yourdb.co:5432/postgres"
    WORKFLOW_POSTGRES_JOB_PREFIX="workflow_"
    WORKFLOW_POSTGRES_WORKER_CONCURRENCY=10
  3. Create the database schema:

    pnpm exec workflow-postgres-setup
  4. Start the PostgreSQL World:

In your Next.js instrumentation.ts:

export async function register() {
  if (process.env.NEXT_RUNTIME !== "edge") {
    console.log("Starting workflow workers...");
    import("workflow/runtime").then(async ({ getWorld }) => {
      console.log("Starting Postgres World...");
      await getWorld().start?.();
    });
    console.log("Workflow workers started!");
  }
}
  1. Deploy to your platform of choice

Learn more about the Workflow PostgreSQL World here.

Key Features

  • DurableAgent - @workflow/ai's DurableAgent provides automatic retries, fault tolerance, and stream reconnection for AI SDK applications
  • Multi-turn conversations - Agent maintains conversation state across tool-calling loops and multiple LLM interactions
  • Stream reconnection - Client can reconnect to in-progress workflows using WorkflowChatTransport after network failures
  • Tool execution - Five flight booking tools (search, status check, airport info, booking, baggage) showing real-world agent patterns
  • PostgreSQL World - Optional PostgreSQL backend for custom deployment needs beyond Vercel (Railway, Render, etc.)

This project uses the following stack: