Bantuek (บันทึก, Thai for "to record") is a LINE Official Account that sits in work group chats. It records every message, image, file and link, and lets Claude search the archive over MCP.
A recorder, not a connector
In Thailand a lot of work happens in LINE groups. Decisions, files and links pile up there, and finding them later is hard.
LINE doesn't help much. There's no API for reading past messages, and media that people send expires after a while. So a connector that asks LINE for history has nothing to ask for. Bantuek has to record as things happen, and its store ends up being the only copy.
The shape of it
It's one Next.js project with three routes and one Supabase project. There's no queue and no worker.
- The webhook verifies LINE's HMAC over the exact raw bytes, checks that the group is enrolled, stores the event idempotently and returns fast. Media is streamed to storage inside the request, before LINE expires it, and deduplicated by SHA-256.
- An hourly cron does the enrichment: resolving quotes, unfurling links behind an SSRF guard that re-checks every redirect, and grouping bursts of conversation into chunks.
- The MCP endpoint exposes 12 tools to search, read a group or a time window, and fetch attachments.
There's no web UI, by design. The AI client is the interface.
Searching Thai
Postgres full-text search splits text into words, and Thai is written without spaces between words. So Bantuek searches with pg_trgm character trigrams instead, which don't need word boundaries.
Ranking happens in two stages. SQL picks the candidates, then TypeScript re-scores each field with weights and a 180-day recency decay, and reports what matched. On top of that sits a Slack-style query language:
in:design from:somchai has:link after:2026-01-01 "final quote"Dates resolve in Bangkok time, so "yesterday" means yesterday where the chat happened.
Years of history on day one
Recording only covers what happens after the bot joins. LINE's .txt chat export covers the rest. A backfill path parses it, stages it, merges it with what was captured live and promotes it behind acceptance gates, and every batch can be reversed. The first run brought in about 116,000 messages from four and a half years.
Privacy is the default
A bot that records group chats has to earn its place in them. Each group has three gates, and all of them start closed:
- Enrolled. Capture is opt-in, even in groups I'm in. A new group waits until I enable it by hand.
- Consent. Enforced in Postgres with row-level security.
- Sensitivity. Shared or private. Only one search tool can see private groups.
Only I can open the first two, from a terminal. A column-level grant stops the MCP role from setting them, so text inside a chat can't talk the model into granting access.
The MCP route uses a publishable key with row-level security on, and only the webhook and cron hold the secret key. A lint rule keeps the two apart. Sign-in goes through WorkOS with Google SSO and fails closed.
Making it cheap to run
Enrichment runs used to average 37 seconds. Watermarks and incremental chunk rebuilds brought them to about one second, and rebuilding chunks for a new message went from 189 database round trips to 2. A seven-day summary used to take 16 tool calls and about 85,000 tokens. Now it's one read_window call that takes about a second.
What's next
- OCR, so text inside screenshots becomes searchable
- Embeddings for semantic search over chunks. The columns already exist
- Decisions still open: serving attachment bytes, and a retention window
The repository is private for now and may be public soon.