Skip to content

About

AI support chatbot demo

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

AI Chat Bot

A simple, real AI chatbot: a web chat widget backed by a small Node.js server that talks to a large language model (Claude or ChatGPT).

This is intentionally small and readable. It demonstrates three things that matter for real chatbot work:

  1. Model-agnostic design — the LLM lives behind one interface (llm.js). Switching Claude ↔ ChatGPT is a one-line change in .env, no rewrite.
  2. Persistent sessions — the conversation is saved in the browser, so it does not reset on page refresh or tab switch.
  3. A clean backend boundary — the browser never sees your API key; it only talks to your own /api/chat endpoint.

1. Get an API key (required — there is no real bot without this)

Pick ONE:

Both have low-cost / free trial credit. A demo costs cents to run.

2. Set up locally

# install Node.js 18+ first: https://nodejs.org

npm install
cp .env.example .env      # on Windows PowerShell: copy .env.example .env

Open .env and paste your real API key. Leave LLM_PROVIDER=anthropic for Claude, or set it to openai for ChatGPT.

3. Run it

npm start

Open http://localhost:3000 — you now have a working chatbot.


4. Deploy it to get a public link (for your portfolio)

Easiest free option: Render (https://render.com)

  1. Push this folder to a GitHub repo.
  2. On Render: New → Web Service → connect the repo.
  3. Build command: npm install — Start command: npm start
  4. Add your environment variables (LLM_PROVIDER, ANTHROPIC_API_KEY, ANTHROPIC_MODEL) under the service's Environment tab.
  5. Deploy. Render gives you a public https://...onrender.com URL.

That URL is your real, shareable demo link.


How it works (so you can explain it)

Browser (public/index.html)
   │  POST /api/chat  { messages: [...] }
   ▼
server.js  ──►  llm.js  ──►  Claude or ChatGPT API
   ▲                              │
   └──────── { reply } ◄──────────┘
  • public/index.html — the chat UI. Stores history in localStorage (persistent session).
  • server.js — serves the page and the /api/chat endpoint.
  • llm.js — the model-agnostic layer. This is where Claude vs ChatGPT is decided.

About

AI support chatbot demo

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages