Skip to content

Add Ask Matt AI agent interface with Turnstile verification#316

Open
MattBidewell wants to merge 3 commits into
mainfrom
claude/add-ask-matt-agent-b0brf
Open

Add Ask Matt AI agent interface with Turnstile verification#316
MattBidewell wants to merge 3 commits into
mainfrom
claude/add-ask-matt-agent-b0brf

Conversation

@MattBidewell

Copy link
Copy Markdown
Owner

Summary

This PR introduces a new "Ask Matt" feature that allows users to interact with a guardrailed AI agent about Matt's work, writing, and projects. The implementation includes a conversational UI component with Cloudflare Turnstile bot protection and a dedicated page.

Key Changes

  • New AskMatt component (src/components/agent/AskMatt.astro): A conversational interface that:

    • Displays a message history between user and agent
    • Submits questions to a backend agent API with Turnstile verification
    • Implements a 5-message-per-session limit with appropriate user feedback
    • Handles various error states (rate limiting, verification failures, network errors)
    • Manages conversation state and prevents submission when busy
    • Includes accessibility features (ARIA labels, semantic HTML, keyboard support)
  • Styling (src/components/agent/AskMatt.module.css): Complete visual design with:

    • Message bubble layout (user messages right-aligned, agent messages left-aligned)
    • Responsive design for mobile devices
    • Status indicators and error messaging
    • Textarea input with character limit (500 chars)
    • Turnstile widget integration
  • New page (src/pages/agent.astro): Dedicated route for the Ask Matt feature with proper SEO metadata

  • Environment configuration (.env.example): Documentation for required environment variables:

    • PUBLIC_AGENT_URL: Backend agent Worker endpoint
    • PUBLIC_TURNSTILE_SITE_KEY: Cloudflare Turnstile public key

Notable Implementation Details

  • Inline script uses IIFE pattern to avoid global scope pollution
  • Turnstile library is lazy-loaded on demand with promise-based caching
  • Conversation history is maintained client-side and sent with each request for context
  • Form submission is prevented when at message limit, with clear user messaging
  • Turnstile widget is reset after each successful submission
  • Supports Astro's page transition events (astro:page-load) for proper initialization
  • Comprehensive error handling with user-friendly messages for different HTTP status codes

https://claude.ai/code/session_014wWrTmyNCJxRVFyTJYLPZj

Adds a static /agent route hosting a guardrailed chat UI. The page
calls out to a separate Worker (private repo, deployed at
agent.matty.dev) for answers — the main site stays fully static.

Turnstile-gated, 5-turn session cap, 500-char input limit. Styles
use existing design tokens so the widget matches both themes.
Requires PUBLIC_AGENT_URL and PUBLIC_TURNSTILE_SITE_KEY (see
.env.example).

https://claude.ai/code/session_014wWrTmyNCJxRVFyTJYLPZj
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
matty-dev fe03e6d Commit Preview URL

Branch Preview URL
Apr 16 2026, 09:39 PM

claude added 2 commits April 16, 2026 21:33
Drops the site nav/footer on the agent route via a dedicated
AgentLayout. Adds a back link to matty.dev, a centered empty state
with clickable suggestion chips, avatar-flanked AI responses,
right-aligned user bubbles, animated thinking dots, and a rounded
pill composer with icon send button. Visually matches the standard
AI chat aesthetic (Claude/ChatGPT) using existing design tokens so
both light and dark themes stay consistent.

https://claude.ai/code/session_014wWrTmyNCJxRVFyTJYLPZj
Surfaces a clear warning in two places: a prominent disclaimer box
in the empty state noting responses are AI-generated, may be
inaccurate, and don't represent Matt's own words; plus a shorter
permanent footnote under the composer reinforcing the same.

https://claude.ai/code/session_014wWrTmyNCJxRVFyTJYLPZj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants