Lesson

Intermediate Capstone Challenge

You've graduated from the Web UI to the API. You know how to securely manage keys, maintain conversation state, force JSON formatting, and execute local functions via Tool Calling.

It is time to build a real AI application architecture.

The Scenario

You are the lead developer for a massive e-commerce company, "MegaMart." The customer support team is drowning in emails. They want you to build an automated AI triaging system that runs on your Node.js backend.

The system needs to read incoming emails, categorize them, and if the user is asking about an order status, the system should automatically fetch the order details from the database and reply to the user.

Your Challenge

You need to architect the code flow for this system. You don't need to write the actual Express routes or database connections, but you need to define the API payloads and the logic flow.

Step 1: The Setup Define the System Prompt. It needs to instruct Claude to act as a MegaMart support bot. It must be polite, but it must never offer refunds autonomously.

Step 2: Define the Tool Write the JSON schema definition for a tool called check_order_status. It should require one argument: order_number (a string).

Step 3: The First API Call A user emails: "Where is my package? My order number is MM-12345." Construct the API payload. You must include the System Prompt, the Tools array, the tool_choice: auto setting, and the messages array containing the user's email.

Step 4: Handling the Response Assume Claude correctly outputs a tool_use block for check_order_status with the input MM-12345. Write the pseudo-code logic that intercepts this block, calls a fake local function db.getOrder("MM-12345"), and receives the result { status: "Shipped", date: "Tomorrow" }.

Step 5: The Final API Call Construct the final chatHistory array that you will send back to Claude. It must include the original user message, Claude's tool_use request, and the tool_result containing your database data.

Review

If you can successfully conceptualize this flow, you are ready to build production-grade AI applications. You have learned how to chain prompts, tools, and local execution into a cohesive Agent.

In the Advanced course, we will dive into complex architectures like RAG (Retrieval-Augmented Generation), dealing with massive codebases, and fine-tuning models. See you there!

Ready to test your understanding? Take the quiz to reinforce what you learned.

© 2026 Ant Skillsv.26.07.07-23:01