Back to Blog
· 3 min read tutorial ai

Build an AI-Powered Contact Form with Claude Code and Postbox

How to use Claude Code to build a contact form with Postbox's smart reply feature — from schema to working form to AI-generated responses, in one session.

Here’s a workflow that didn’t exist a year ago: you paste a text file into an AI coding assistant, describe what you want, and the AI builds it. No docs to read. No boilerplate to write. No Stack Overflow tab open.

This is how building with Postbox and Claude Code works. In this tutorial, we’ll create a contact form that collects messages and uses AI to auto-reply from a knowledge base — all built through a conversation with Claude.

The Setup

You need two things:

  1. A Postbox account (free tier works)
  2. Claude Code or any AI coding assistant (Cursor, Windsurf, etc.)

Step 1: Give Claude Your llms.txt

Every Postbox account gets a personalized llms.txt file. It’s a plain-text document that tells AI assistants everything they need to know about your API: endpoints, authentication, examples, and schema definitions.

Copy it from your Postbox dashboard and paste it into Claude Code:

Here's my Postbox API documentation:

[paste your llms.txt content]

I want to create a contact form that collects name, email,
and message. Enable smart replies with this knowledge base:

- Business hours: Monday-Friday, 9 AM - 6 PM EST
- Response time: We reply within 24 hours
- Services: We build custom web applications
- Pricing: Projects start at $5,000

Step 2: Watch Claude Build It

Claude reads your llms.txt, understands the API, and starts building. It will:

  1. Create the form schema using Postbox’s API:
{
  "name": "Contact",
  "fields": [
    { "name": "name", "type": "text", "required": true },
    { "name": "email", "type": "email", "required": true },
    { "name": "message", "type": "textarea", "required": true }
  ],
  "features": {
    "spam_detection": true,
    "smart_reply": {
      "enabled": true,
      "mode": "auto",
      "knowledge_base": "Business hours: Mon-Fri 9-6 EST. Response time: within 24 hours. Services: custom web applications. Pricing: starting at $5,000."
    }
  }
}
  1. Generate the frontend code — a clean HTML form that POSTs to your Postbox endpoint:
<form id="contact-form">
  <label for="name">Name</label>
  <input type="text" id="name" name="name" required />

  <label for="email">Email</label>
  <input type="email" id="email" name="email" required />

  <label for="message">Message</label>
  <textarea id="message" name="message" required></textarea>

  <button type="submit">Send Message</button>
</form>

<script>
  document.getElementById("contact-form")
    .addEventListener("submit", async (e) => {
      e.preventDefault()
      const data = Object.fromEntries(new FormData(e.target))

      const res = await fetch(
        "https://usepostbox.com/api/YOUR_HASH/f/contact",
        {
          method: "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify(data),
        }
      )

      if (res.ok) {
        e.target.innerHTML = "<p>Thanks! We'll be in touch.</p>"
      }
    })
</script>
  1. Integrate it into your project however it fits — a React component, a static HTML page, or embedded in your existing site.

What Happens When Someone Submits

Here’s the pipeline that fires on each submission:

  1. Spam Detection — Postbox’s AI analyzes the message. Obvious spam gets blocked. Suspicious messages get flagged for review.
  2. Smart Reply — If the message matches something in your knowledge base (like “What are your hours?”), Postbox drafts or auto-sends a response.
  3. Dashboard — The submission appears in your Postbox dashboard. You see the original message, any translation, the smart reply that was sent, and the spam score.

A customer writes “Hi, what are your rates?” at 2 AM. By 2:01 AM, they’ve received: “Thanks for reaching out! Our projects start at $5,000. We’re available Monday through Friday, 9 AM to 6 PM EST, and we’ll follow up with more details within 24 hours.”

No human involved. No chatbot widget. Just an email reply.

Teaching It Over Time

Smart replies get better as you use them. When Postbox sends a reply that’s not quite right, you can correct it in the dashboard. The next time a similar question comes in, the reply reflects your correction.

This is the “learns from your corrections” feature — it doesn’t just repeat your knowledge base verbatim. Over time, the replies start to sound like you wrote them yourself.

Why This Works

The traditional approach to building a contact form with auto-reply involves:

  • A form builder or custom backend
  • An email service (SendGrid, Mailgun)
  • A chatbot or automation tool (Intercom, Zapier)
  • Wiring them all together

With Postbox + Claude Code, you get the same result from a single conversation. The AI understands the API because of llms.txt. The intelligence features are built into the platform. There’s nothing to wire together.

Try It Yourself

  1. Create a free Postbox account
  2. Grab your llms.txt from the dashboard
  3. Paste it into Claude Code with a description of what you want
  4. Ship your contact form in minutes