A step-by-step guide to the pattern behind AutoValue's listing agent: a conversational AI that calls real functions, keeps state across turns, and lives entirely in one Next.js route.

Most "build a chatbot" tutorials stop at text in, text out. Production agents are different: they call your functions, wait for real data, and decide what to do next based on the results. I run one in production at AutoValue, where a conversational agent walks Nigerian car sellers through a full listing flow: identifying the car from a photo, reading the odometer, pulling live market prices, and publishing the finished listing to the marketplace. This tutorial builds the core of that pattern from scratch: a tool-calling agent inside a single Next.js route handler.

You'll need Node 18+, a Next.js App Router project, and an Anthropic API key.

Step 1: Install the SDK and set your key

npm install @anthropic-ai/sdk