Day 1 of 5
⏱ ~60 minutes
Build an AI Chatbot — Day 1

Project Setup and Your First Chat Response

You will build a working AI chatbot from scratch over 5 days. Day 1 covers the project structure, Node.js setup, and getting your first response from the Claude API.

What You Are Building

By the end of this course you will have a full-stack AI chatbot: a Node.js backend that calls the Claude API, a clean chat UI in the browser, RAG (retrieval-augmented generation) to answer questions from your own documents, and a deployed URL you can share. Every day produces working code.

Prerequisites

Project Structure

Terminal
mkdir my-chatbot && cd my-chatbot
npm init -y
npm install express @anthropic-ai/sdk dotenv cors
touch .env server.js index.html
.env
ANTHROPIC_API_KEY=your_api_key_here

First API Call

server.js
const express = require('express');
const Anthropic = require('@anthropic-ai/sdk');
const cors = require('cors');
require('dotenv').config();

const app = express();
const client = new Anthropic();

app.use(express.json());
app.use(cors());
app.use(express.static('.'));

app.post('/chat', async (req, res) => {
  const { message } = req.body;
  
  const response = await client.messages.create({
    model: 'claude-opus-4-5',
    max_tokens: 1024,
    messages: [{ role: 'user', content: message }]
  });

  res.json({ reply: response.content[0].text });
});

app.listen(3000, () => {
  console.log('Server running on http://localhost:3000');
});
Terminal — Test It
node server.js

# In another terminal:
curl -X POST http://localhost:3000/chat   -H "Content-Type: application/json"   -d '{"message": "Hello! What can you help me with?"}'
💡
If you get an auth error: Check that your .env file has the correct API key and that it does not have extra spaces. The key starts with sk-ant-.
Day 1 Exercise
Get Your First Chat Response
  1. Set up the project structure and install dependencies.
  2. Add your API key to .env.
  3. Copy the server.js code and run the server.
  4. Test the /chat endpoint with curl or Postman.
  5. Change the message and confirm you get a relevant response back.

Day 1 Summary

  • Project scaffolded: Express server, Anthropic SDK, dotenv, cors installed.
  • Single /chat endpoint that takes a message and returns Claude's response.
  • API key stored in .env — never hardcoded in source files.
Finished this lesson?