Blog › AI · Published 2026-11-26

How to add an AI chatbot to your website that handles orders

The problem

You want visitors to ask "where is my order?" or "change my booking" in plain language, and get a real answer from your order system instead of a generic reply.

The approach

Never put the AI key in the browser. The widget talks to your backend. The backend calls the AI API and, when needed, your order API.

  1. Build the chat widget (HTML/JS or React) that posts messages to /chat on your server.
  2. On the server, send the conversation to the AI model together with a short system prompt that sets the rules (what it may do, when to hand over to a human).
  3. Give the model tools (function calling) such as get_order_status. Your server runs the tool against your order API and returns the result to the model.
  4. Require confirmation before any change or cancellation, and log every action.

Minimal backend call

import requests, os
r = requests.post(
  "https://api.anthropic.com/v1/messages",
  headers={"x-api-key": os.environ["ANTHROPIC_API_KEY"],
           "anthropic-version": "2023-06-01",
           "content-type": "application/json"},
  json={"model": "MODEL_NAME", "max_tokens": 500,
        "system": "You help customers with orders. Ask before changing anything.",
        "messages": [{"role": "user", "content": "Where is order 123?"}]})
print(r.json())

Replace MODEL_NAME with a current model from the provider documentation. Keep the key in an environment variable.

Safety checklist

Official sources

Need help with your project?
We build websites, systems and automation. Start your project WhatsApp

All articles