The problem
Thai customers type their ID number, phone number or bank account straight into a chat, and an AI agent that reads the chat sends all of it to a model, into tool calls and into logs. Under PDPA you are responsible for every copy, and most shops only find out where the numbers went when someone asks.
Architecture
- Channel
- Customer chat channel
- Guard on your server
- Agent
- Reads masked message
- Answers the customer
- Calls OTP tool with token
- Tools
- Policy file per data type
- Token store with expiry
- Audit log without values
- Human
- Owner reviews flagged messages
Where the data stays: Detection runs on your own server with no network call; the model sees tokens and labels, the token store holds real values until expiry and must be guarded like a secret, and the audit log never holds a value.
Design flow
- Customer message arrives on your server
- Guard detects 9 data types and acts per policy
- Card number found: message blocked, nothing sentOnly sometimes
- Agent answers from masked text; OTP tool resolves token
- Reply to customer shows tokens masked
- Owner reviews flagged and blocked messages, tunes policyHuman checkpoint
Setup
Total time: 5 h 45 min our estimate
- 45 min
The README says the CLI never prints a value and runs on Node only. This step shows you which data types your customers actually send before you write a policy.
Done when: You exported a week of chat history (JSONL, CSV or a LINE OA export), ran the CLI on it, and have a count per data type without a single real value printed.
- 1 h
The example policy tokenises phones (only otp_send may resolve them), labels ID numbers, shows bank accounts as last 4 digits and blocks card numbers. Start from it and change only what your business needs.
Done when: A JSON policy sets one of redact, mask, tokenise, hash, flag or block for each of the nine types, and the owner can say in one sentence why each choice was made.
- 1 h 30 min
The example's README recommends setting your own AI_GATEWAY_API_KEY, says the default placeholder channel auth must be replaced before customers use it, and notes the OTP sender is a stub that only logs what it would send.
Done when: The example in examples/pdpa-agent runs with eve dev on eve 0.80.x, calls Claude Haiku 5.5 through the AI Gateway with your own key, and a test message with a phone number shows the model a token, not the number.
- 2 h
The README says eve's HTTP channel is not masked on the way out and that a broken token store fails closed, so test both: a reply containing a token and a deliberately broken store.
Done when: Your channel (the example says LINE, Telegram or Slack channels can be wrapped the same way) goes through pdpa.channel, the token store is a guarded Redis with expiry set, and a missing key stops the agent from starting.
- 30 min
Done when: Once a week the owner reads the audit log's flagged and blocked entries (counts and types, never values), checks for customers who were blocked wrongly, and adjusts the policy or the cue words.
Ticks are saved on this browser.
Starter prompt
Written from how the use case works and its sources. Replace the parts in square brackets.
You are the customer service agent for [your shop]. Messages reach you after a privacy guard has run: some values arrive as tokens like [tok:...] or as labels like [national ID], [licence plate] or a bank account shown as last four digits only. Treat a token or label as the customer's real value: never ask the customer to repeat the full number, never try to guess or reconstruct it, and never write it into notes. When a step needs the real phone number, such as sending an OTP, call the OTP tool with the token and let the tool resolve it. If a message was blocked because it contained a card number, apologise, explain that we never accept card numbers in chat, and point the customer to [your payment link or counter]. Answer in Thai, politely, in no more than four sentences, and hand over to a person for [refunds, complaints, anything about a specific order you cannot see].
Risks and data
Data
The guard reduces copies of personal data but creates one sensitive place: the token store, which holds real phone numbers until tokens expire. Keep it on your own infrastructure, set the shortest expiry the job allows, guard its credentials like any secret, and remember names and addresses are not detected yet, so the model may still see those.
How it goes wrong
Two ways it goes wrong: a real ID number written without the cue word slips past as plain digits, or a valid looking 13 digit order number is blocked and a customer gets no answer. You notice the first in the weekly review of what the model saw, and the second when a customer complains in another channel. The README calls its accuracy figures an upper bound, so test on your own old chats before you trust the counts.
How the agent works
It starts
A guard runs on your own server between the customer channel and the AI agent; the open source project says no AI is involved in the detection and nothing goes over the network.
The agent works
Every inbound message is cleaned first (Thai and full width digits become ordinary digits, invisible characters inside numbers are removed), then checked for nine types of personal data: national ID, phone, email, bank account, credit card, LINE user ID, licence plate, date of birth and passport number, each with a confidence score from checksums (mod 11 for the ID, Luhn for cards), patterns and cue words such as เลขบัญชี. A JSON policy file sets one action per type: redact, mask, tokenise, hash, flag or block. In the example agent a phone number becomes a token the model can pass around but not read, and only the tool that sends an OTP can swap it back, for that purpose, in the same chat, for five minutes; bank accounts show the last four digits, an ID number becomes the label [เลขบัตรประชาชน], and a credit card number stops the whole message. Replies going back to the customer show tokens masked like xxx-xxx-7777. An audit log records what was found and done, never the value.
The result
The owner reviews the flagged and blocked messages and tunes the policy.
Worked example
eve-pdpa-extension is an MIT licensed open source project published by mintelligence-dev (copyright 2026 M Intelligence), with 186 commits and the newest ones on 25 November 2026 adding Express, Hono and Next.js middleware (GitHub, opened 26 November 2026). Its README states the job as detecting and protecting Thai personal data before it reaches an AI model, an AI agent, a tool, a log or a human reviewer, with the guard sitting between your customers and the AI on your own server. The pipeline is: normalise digits, detect 9 types with checksums and cue words, settle overlapping matches, act per policy (redact, mask, tokenise, hash, flag or block), swap a token back only for an allowed purpose in the same session before expiry (at most 3600 seconds), and audit without ever storing a value. The example agent, built for a fictional Thai shop, turns phone numbers into tokens that only the otp_send tool may resolve for 5 minutes, shows bank accounts as the last 4 digits, labels ID numbers, LINE user IDs, licence plates, birth dates and passports, fingerprints emails and blocks any message with a credit card number; its token store holds real values until tokens expire, so the README says to guard it like any secret. No named business is using it yet, the Used by section is empty, and the README says it is a technical tool, not a certification of compliance with Thailand's PDPA.
The project's example agent runs on the eve agent framework (eve 0.80.x only, not 1.x yet) and calls Claude Haiku 5.5 through Vercel's AI Gateway, which is why Claude is the tag; the guard itself is model agnostic, so OpenAI and Gemini are listed for a build that calls another model. The core library has no dependencies and runs on Node 18.18 and later, Deno, Bun, Cloudflare Workers and browsers; the CLI scans old chat exports (JSONL, CSV, LINE OA); middleware for Express, Hono and Next.js was being added in the newest commits and the README said it was not yet on npm. Names and addresses are not detected yet, eve's HTTP channel is not masked on the way out, and the README calls the accuracy figures from synthetic data an upper bound.
Join the Agent OS Club
Get hours back with a team of AI agents for every department, set up step by step for the tools you use, with a person answering your questions. Founding member price: USD 14.95 a month or USD 150 a year, locked for as long as you stay. Cancel any time.
Founding offer, ends 31 December 2026 or at member 100
Join the Agent OS ClubBuilding this for an organization? Learn more at theagentiv.com
Sources
- https://github.com/mintelligence-dev/eve-pdpa-extension
- https://github.com/mintelligence-dev/eve-pdpa-extension/blob/main/README.th.md
- https://github.com/mintelligence-dev/eve-pdpa-extension/tree/main/examples/pdpa-agent
- https://github.com/mintelligence-dev/eve-pdpa-extension/commits/main
Published: 2026-11-26