The problem
Many Thai businesses buy from or work with Chinese speaking partners, and the day to day coordination happens in LINE groups where one side writes Chinese and the other Thai. Someone bilingual becomes the bottleneck, copy pasting into a translation app, and Thai replies that drop the polite ending or use the wrong one read as curt to a customer or a boss.
Architecture
- Channel
- LINE group chat
- Official account bot
- Agent
- Flask webhook server
- Gemini translates
- Tools
- Politeness rules in the prompt
- Speaker gender in SQLite
- Human
- Bilingual colleague checks
- Members set their gender
Where the data stays: Group messages pass through your own server to the model provider; keys stay in a local .env file and genders in a local SQLite file.
Design flow
- Member writes in Chinese or Thai
- Server checks the LINE signature
- Commands, links or plain English: ignoredOnly sometimes
- Gemini translates with the politeness rules
- Translation posted in the group with a flag
- Bilingual colleague checks and correctsHuman checkpoint
Setup
Total time: 2 h 50 min our estimate
- 20 min
Done when: In LINE Official Account Manager the bot may join group chats, the response mode is Bot and auto reply messages are off.
- 15 min
Done when: The LINE channel access token, channel secret and the Gemini key from Google AI Studio are in .env with owner only rights, and git status shows .env is not tracked.
- 1 h
Done when: The server runs as a service, the webhook URL ends in /line/callback, and Verify in the LINE Developers Console succeeds.
- 15 min
Done when: The config check passes with GEMINI_MODEL and GEMINI_FALLBACK_MODEL set, and a test message is translated.
- 30 min
Done when: The test sentence 非常感谢,我现在通知工厂 comes back with ครับ and ผม for a male speaker, ค่ะ for a female speaker, and never a slash pair like ครับ/ค่ะ.
- 30 min
Done when: The bot is in one supplier or customer group, members were told and asked to set their gender with the command, and the bilingual colleague logs each correction for two weeks.
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 translate messages in a LINE group between Simplified Chinese and Thai. If the message is Chinese, translate it into natural Thai; if it is Thai, translate it into natural Simplified Chinese. Keep product names, part numbers, amounts, dates and links exactly as written. Thai politeness: the speaker is [male, female or unknown]; for a man end sentences with the male polite particle (khrap) and use the male first person pronoun (phom), for a woman use the female polite particle (kha) for statements and its question form for questions, with the formal female first person pronoun (dichan), and for an unknown speaker use neutral business wording with the male polite particle and no first person pronoun. Never write both forms with a slash. Return only the translation, with no explanation. Message: [paste the message]
Risks and data
Data
Every message in the group goes to the model provider, and the automatic guess reads nicknames and profile pictures, which is profiling of personal data. Tell the members, keep the bot out of groups that discuss personal or contract data, prefer the gender command over the guess, and keep the LINE token and model key in the local .env file.
How it goes wrong
A wrong polite ending reads as curt, or a part number or amount is changed in translation and the other side acts on it. Keep product names and numbers untranslated in the prompt, let the bilingual colleague count corrections for two weeks before adding groups, and if a key leaks, regenerate it in the LINE Developers Console or with the model provider and restart the bot.
How the agent works
It starts
The bot is added to the LINE group as an official account with group joining allowed, the default auto reply switched off and a webhook pointing at a small Flask server.
The agent works
Every text message in the group reaches the server through the LINE Messaging API; it checks the LINE signature, then decides whether the message needs translating at all. Messages with Chinese or Thai characters are translated, while commands, plain English or numbers and bare links are ignored so the group is not spammed. The message goes to Gemini with politeness rules added to the prompt: a male speaker gets ครับ and ผม, a female speaker ค่ะ or คะ and ดิฉัน, an unknown speaker neutral business wording. The speaker's gender comes from a command they can send once (for example 我是男生 or ผมเป็นผู้ชาย), and if they never set it the bot asks Gemini to infer it from the LINE nickname and profile picture, only at 75 percent confidence or more, and keeps the result in a local SQLite file. The translation is posted back into the group with a Thai or Chinese flag, so both sides keep reading one chat.
The result
env file that is never committed.
Worked example
MACC Electronics (Thailand) Co., Ltd., a Bangkok company that sells digital signage, kiosks, LED screens and smart displays to businesses in Thailand, publishes the bot as the open source repository macc-line-translate-bot on its GitHub account, with a Chinese and a Thai README. The README documents the flow from LINE webhook to Gemini 3.8 Flash and back, the fallback model gemini-3.1-flash-lite, the gender commands, the three LINE Official Account Manager settings a group deployment needs, the systemd service it runs as, and an automated test suite for the politeness rules; one of its test sentences is a Chinese message that says thank you, I am notifying the factory now. The repository does not say which groups the company runs it in or give any volumes, so measure your own: messages translated per day and corrections the bilingual colleague still has to make.
The translation is one text model call with the politeness rules in the prompt, so Claude or an OpenAI model can take Gemini's place; the gender guess from a profile picture needs a model that reads images, which all three offer. The LINE part is fixed: the official account settings (allow group chats, auto reply off, webhook on) and the Messaging API are what put the bot in the group.
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
Published: 2026-11-04