AutomationProjects

Luk Jiab · Chicken Farm Bot

A LINE chatbot for a pullet farm that closes the whole loop: the owner plans, the bot reminds workers in the LINE group, workers report through LIFF, and everything is stored in a Google Sheet. Built with Next.js 16 + LINE Messaging API + LIFF + Vercel in a single session.

12 min read

A LINE chatbot for a pullet farm. The owner plans 3 meals a day, the bot reminds workers in the group chat on time, workers report through a LIFF form, and everything lands in Google Sheets automatically.

Next.js 16React 19TypeScriptLINE Messaging APILIFFGoogle Sheets APIVercelcron-job.org

The problem

Why does feeding on a pullet farm need a system?

A crowd of brown hens eating from a feeder
Daily farm work: several meals, several barns, and every one has to be recorded · Photo: Arisa Chattasa / Unsplash

A pullet farm has to feed on time, 3 meals a day, every day. If a worker forgets, the birds go hungry and the owner doesn't know until they visit the farm. Reports like "how many sacks today, how many died, how many sick" end up partly on paper and partly in LINE chat, then get lost and can't be combined.

— Insight from a real farm owner, before Luk Jiab was built

Feeding times must be exact, but are easy to forget

Pullets need to eat at 06:00 / 10:00 / 16:00 every day. If a meal slips by an hour, laying production drops and the birds get stressed. Workers find it hard to remember, especially on days off or when they're newly hired.

Reports are scattered across notebooks, chats and paper

"How many sacks today?" "How many died in which barn?" Some people type it in chat, some write it in a notebook. When it's time for a monthly summary, nothing can be found and meals can't be compared.

The owner can't see what's happening in real time

A worker may say they've fed the birds when they haven't, or a meal wasn't finished and nobody said so. The owner finds out at the farm or the next day, which is too late.

Workers don't want a new app

Farm workers know LINE well but don't want to download a special app. They install it, forget the password, forget how it works. The UX has to live where they already are.

The owner wants a spreadsheet, not a deep dashboard

The farm owner wants raw data they can edit and send straight to the accountant or vet. No complicated admin panel.


The solution

Put the bot in the LINE group workers already use: reminders on schedule, input through forms, storage in a Sheet

The 6-button rich menu in LINE: plan feed, plan mixing, view report, submit report, log mixing, check quota
The bot's real rich menu: every task starts from a button in the LINE chat workers already use

The bot reminds the LINE group at every meal

The "Luk Jiab" bot joins the farm group workers are already in. At 05:45 it sends a bubble with the number of sacks the owner planned; at 08:00 it sends a bubble asking for the report. Three meals a day.

Fill in forms right inside LINE, no app to download

Built with LIFF (LINE Front-end Framework): tap a button in the bubble and the form opens inside LINE. No sign-up, no login, nothing extra to install.

Google Sheet as the source of truth

Every plan, report and log is appended to a Google Sheet. The owner can open it, filter, sort and export to Excel without learning a new system.

A confirmation dialog to prevent mistakes

Before any form is submitted, a modal summarizes everything (6 values + date + total) and asks for confirmation, because typos are easy on a phone and hard to fix later in the Sheet.

The menu only appears for the word "main menu"

The bot sits in a group where workers chat normally, so replying to every message would be annoying. The keyword "main menu" is the only trigger, so the bot stays quiet like any other group member.


User Flow

A day with Luk Jiab: the owner plans at night, the bot runs on its own all day

LINE group chat: the bot posts the breakfast feeding plan, records the start time and reminds workers to report
The morning flow in the group: plan → tap start → report reminder (rendered from the bot's real Flex JSON · the chat frame is a mockup)
1

Owner plans

At night the owner fills in 3 meals × 2 barns for the next day

2

Bot reminds workers

At 05:45 it sends a bubble with the number of sacks and a "Start feeding" button

3

Workers report

At 08:00 the bot sends a report bubble → the worker taps it → fills in 6 fields

4

Stored in the Sheet

Data goes into the Sheet immediately, with duration/delay calculated automatically


Tech Stack & Architecture

A stack chosen so one person can run the whole system: no database to manage, no admin UI to build

Scheduler code that reads Thai time and the schedule from Google Sheets, then pushes to the group
Real code: an external cron calls the endpoint every minute, which compares Thai time with the schedule in Google Sheets and pushes to the group
Workers & owner — LINE app
Group Chat 1-on-1 Chat LIFF Forms Flex Carousel
↕
LINE Messaging API + Webhook
follow / join message postback pushMessage
↕
Next.js 16 (App Router) — Vercel
/api/webhook /api/scheduler /api/feeding-plan /api/worker-report /api/feed-mixing
↕
Google Sheets (Source of Truth) + cron-job.org
users groups schedules feeding_plan feeding_report reminder_log
Why this stack?

LINE LIFF opens forms inside LINE, with no app to download and no extra login · Google Sheets API is a database the owner can open natively, so no separate admin UI is needed · Vercel Hobby is free and deploys automatically on git push · cron-job.org is free and fires every minute (Vercel Hobby cron is limited to 2 jobs/day, which isn't enough). The endpoint checks the time itself and covers all 6 trigger times a day.


What I built: 8 core features

The full loop, from planning to stored data

LIFF mixing-plan form: a 7-day calendar, feed formula and target number of sacksLIFF mixing-log form: date, formula, amount mixed and notes
Two more real LIFF forms: mixing plan (owner) · mixing log (worker) · sample data

Plan 3 meals (owner)

A grid table of 3 meals × 2 barns, all visible in one viewport, with a running total and a confirm dialog before saving 6 rows

Submit report (worker)

6 fields (sacks/dead/sick × 2 barns) + a note. Duration and delay against the target time are calculated automatically.

Log feed mixing

Formula + amount mixed + notes, logged in a separate tab to track stock

View report (owner)

A card that opens the Google Sheet directly, so the owner can see raw data and filter, sort or export right away

Carousel Menu

A Flex carousel of 4 cards ordered owner-first (plan → mix → view report → submit), triggered by the keyword "main menu"

Instruction & Report Bubble

Two kinds of Flex bubble: instruction (with sack counts + a start button) and report reminder (a button that opens the LIFF form)

Scheduler + Dedup

An endpoint checks Bangkok time every minute, sends bubbles on schedule, and uses reminder_log to prevent double sends

Group Chat Support

The bot can join LINE groups: it registers the groupId automatically on join and pushes to the group instead of looping over users


What it looks like in the LINE group

The morning flow: the bot sends the instruction → a worker taps start

LINE group chat: the bot reminds workers to mix formula A, target 16 sacks, plus this month's message quota card
The mixing reminder bubble + the message quota card (real Flex JSON · sample numbers)
Luk Jiab · 05:45

Breakfast feeding is coming up

Barn 1: 3.5 sacks
Barn 2: 3.0 sacks
Start breakfast feeding

Tapped "Start feeding" >

Luk Jiab · 05:48

Breakfast start time recorded. You can start feeding now.
When you're done, tap "Submit report" in the bubble I'll send you.

Luk Jiab · 08:00

Time to submit the breakfast report

Enter the actual feed used and the dead/sick birds for each barn

Submit report

What the LIFF forms look like

Plan 3 meals on a single screen (LIFF Tall size, limited viewport)

LIFF feed-plan form: a week calendar showing which days are planned, and a 3 meals × 2 barns table totaling 16.5 sacksLIFF feeding report form for workers: actual feed, dead and sick birds, split by barn 1 and barn 2
The real forms (running from code in mock mode). Left: the owner plans feed · Right: a worker reports

Luk Jiab

Plan feed for each meal
Date to send reminders
May 25, 2026 (tomorrow)
MealBarn 1Barn 2
Morning3.53.0
Midday2.52.0
Evening3.02.5
Total for the day 16.5 sacks
Save plan

Hacking the problems

6 problems I had to solve myself: design constraints + LINE platform limits + serverless quirks

Real code: the main-menu keyword as the only trigger, and a function that formats timestamps in readable Thai time
Two pieces of real code: the bot only responds to "main menu", and timestamps are stored in Thai time the owner can read in the Sheet

LIFF Tall size: 6 fields in 1 viewport

I chose LIFF size Tall (~675px usable), but the owner has to fill in 3 meals × 2 barns = 6 fields at once. With a lot of scrolling, the keyboard covers the bottom rows.

Fix: a grid table layout (3 rows × 2 cols) instead of 6 separate inputs. It uses less than half the vertical space, shows the whole day at a glance, and has a total cell at the bottom that updates in real time.

A bot in a group that replies to everything = noise

The bot sits in a group where workers chat normally. Replying to every text message ("hello", "when?", and so on) would instantly become spam.

Fix: in the webhook handler, check event.message.text.trim() === "เมนูหลัก" (the Thai for "main menu") as the only trigger. For any other message the bot stays completely silent, so it behaves like a normal group member that only speaks when called.

Push to the group, not a loop over users

Workers in the group never added the bot 1-on-1 → LINE blocks pushMessage to their userId → the scheduler can't send bubbles to everyone.

Fix: change the design. The webhook handles the join event and saves the groupId to the sheet tab groups → the scheduler pushes to the groupId (sent once, everyone in the group sees it). Postbacks still capture the userId of whoever tapped. This gives both broadcast efficiency and member identification.

Timestamps hard to read in the Sheet

At first timestamps were stored as ISO UTC (2026-05-24T06:55:38.824Z). The owner couldn't read them and had to add 7 hours every time.

Fix: formatBangkokTimestamp() uses Intl.DateTimeFormat("sv-SE", { timeZone: "Asia/Bangkok" }) to produce YYYY-MM-DD HH:mm:ss in Thai time the owner understands immediately, + parseBangkokTimestamp() converts it back to a Date for duration/delay calculations, + an idempotent migration script converts old data to the new format.

Vercel Hobby cron is limited to 2 jobs/day

I needed 6 triggers a day (5:45 / 8:00 / 9:45 / 11:00 / 15:45 / 18:00). The Vercel Hobby plan only allows 2 cron jobs a day.

Fix: the scheduler endpoint checks the time itself (bangkokNow().time) → cron-job.org (free, can fire every minute) calls it 1,440 times a day → the endpoint returns due=0 whenever it isn't time (95% of calls). No LINE quota is wasted, and new schedules can be added later without touching the cron config.

Next.js 16 Turbopack + bun froze the machine

During development, bun dev (Turbopack by default) + ngrok + incoming traffic → the MacBook froze with a kernel panic and needed a forced reboot, twice in a row.

Fix: switch to next dev --webpack (still supported in Next.js 16). It runs stable at 2.3GB RSS. Turbopack stays in a backup script, dev:turbo, to try again after a future Next.js upgrade. Lesson: new tech always needs a fallback path.

Design decisions to discuss with the client

UX trade-offs that aren't in any playbook: they need explaining and deciding together

The confirmation box before saving a plan, summarizing the 3 meals × 2 barns table, totaling 16.5 sacksThe success screen: the Luk Jiab mascot, a summary of sacks per meal, and a button back to LINE
Confirm dialog before saving → success screen with a summary (reused across all 3 forms)

Every MVP has many trade-offs. Reply to every message or only a keyword? Native date picker or custom? Does the owner mark the group manually or is it auto-detected? There are several "right" answers. My job is to lay out the options, explain the trade-off of each, and not choose on the client's behalf.


Confirm Dialog

A reusable component across all 3 forms: summarize the data before saving


Keyword Trigger

Only "main menu": quiet in the group, no noise


Tomorrow Prefill

Date defaults to today + 1, because the owner plans at night


Sheet Card

"View report" = open the Google Sheet directly, no dashboard built


What I took away from this project

5 lessons from building Luk Jiab, from requirements to production

Brown hens eating from a feeder on the grass
The best tool for field work lives in the app people already use · Photo: Lucas / Unsplash
1. Design for "where the user already is", not pulling users into your system:

Farm workers already use LINE. Choosing LIFF over a separate mobile app meant zero adoption friction: nothing to download, no sign-up, no new UI to learn. Lesson: picking a platform the user knows matters more than picking a stack the developer knows.

2. The source of truth doesn't have to be a database:

Google Sheets is "a database the owner can open, filter, export and share". For a low-traffic MVP whose owner is already a spreadsheet power user, Sheets beats PostgreSQL on every count: no admin UI to build, no migrations to think about, no hosting to pay for. Lesson: choose storage for the owner, not by convention.

3. Confirmation dialogs are an undervalued UX safety net:

A form that writes 6 rows to the Sheet at once → a mistake has to be fixed in the Sheet by hand, which is painful. Every Luk Jiab form has a ConfirmDialog that summarizes all values before saving. It adds 2 seconds but cuts errors a lot. Lesson: friction in the right place is a feature, not a bug.

4. Platform constraints can force better design:

LIFF Tall size limits the viewport → it forced a 3×2 grid instead of 6 stacked inputs → the overview is much better. With more space I might have defaulted to a long, scrolling stacked layout. Lesson: a constraint is a design partner, not an obstacle.

5. Decisions can be revisited; it doesn't have to be perfect the first time:

During the session I switched ISO timestamps → Bangkok format (with a migration), Turbopack → webpack after the freeze, the menu trigger from always-respond → keyword, and added group support after the MVP. Every change was documented and committed as a checkpoint. Lesson: build fast and iterate fast rather than plan for a long time.

6
Google Sheet tabs — source of truth
3
LIFF Forms — Owner + Worker
6×
Reminders per day: instruction + report
0
Apps the user has to download

Tan · Natpakan Sirirat

Product Designer & AI Builder — designing user experiences and building AI tools that actually work.

0%