AI · Automation · Web
SourceOpen — LLM chatbot and QR attendance prototypes in Laravel
An experimental Laravel 11 workspace: web chatbots that fall back to a large language model with cached conversation history, and a QR-code attendance check-in flow that forwards scans to an external backend.
Problem
What needed solving?
Two questions were worth answering with working code rather than reading: how a conventional rule-based chatbot framework can hand off to an LLM for anything it does not recognise, while keeping the model on-topic for a specific organisation; and how a QR-code check-in flow can be built quickly for events and classes without a mobile app.
Context
Who was it for?
Personal prototype repository · PHP / Laravel
Approach
- Use BotMan's web driver for deterministic intents (greetings, capturing a name) and register a fallback that calls a hosted open model with an organisation-specific system prompt.
- Keep short-term conversation memory per sender in the Laravel cache through a BotMan middleware, capped in size and expiring after a week.
- For attendance, generate an SVG QR code per person and event, and expose a small API endpoint that a scanner posts to; the endpoint forwards the check-in or check-out to an existing backend service.
Architecture
How the system was designed.
A single Laravel application with two independent features. The chatbot route builds a BotMan instance per request, matches known intents, and otherwise sends the message and system prompt to the model provider. The attendance flow renders QR codes server-side and proxies scan events to an external API.
Implementation
What was built.
- 01BotMan 2.8 with the web driver; intents registered with `hears()` and a `fallback()` that posts the user's message to the Together AI chat-completions API using `meta-llama/Llama-3.3-70B-Instruct-Turbo`.
- 02A `MessageHistoryMiddleware` implementing BotMan's `Received` interface stores timestamped messages per sender in the Laravel cache, truncated to 2,000 characters.
- 03Separate bot endpoints with different system prompts, showing how the same pipeline is reused for different organisations.
- 04QR codes generated with simple-qrcode as SVG, encoding a JSON payload of user and event identifiers; a Sanctum-ready API route receives scans and forwards them with cURL to the existing backend.
- 05An `attendances` table with a unique constraint on student, event and date to prevent duplicate records.
AI
Where AI was used and why.
The LLM is used as a fallback behind deterministic intents — the pattern that keeps a chatbot predictable for known questions while still handling open-ended ones. The system prompt constrains the model to the organisation's context and instructs it to decline unrelated topics.
Technology
Relevant stack.
- Laravel 11
- PHP 8.2
- BotMan
- Together AI (Llama 3.3 70B)
- Laravel Sanctum
- simple-qrcode
- MySQL
Outcome
Only factual results.
Outcome to be added. Results are only published here when they can be stated factually — no estimated metrics.
Lessons
Important engineering insights.
- Rule-based first, model second: deterministic handling for the common cases keeps behaviour predictable and costs down.
- Conversation memory needs a size cap and an expiry from day one.
- Prototype code that disables TLS verification or truncates tables via a GET route is fine for a lab — and exactly what must be removed before anything goes to production.
Turn an AI idea into working software.
From retrieval and agents to document intelligence, I build AI systems that plug into real business data and workflows.