⚡ Log meal nutrition from LINE food photos to Google Sheets with Gemini AI

⚡ 37 views · ⚡ Personal Productivity

Description

Log meal nutrition from LINE food photos to Google Sheets using Gemini AI


Who is this for

Health-conscious individuals, people on a diet, and anyone who wants to track daily nutrition without manual data entry. Designed especially for LINE users (Japan, Taiwan, Thailand, etc.) who want an effortless way to monitor calories and macronutrients from meal photos.

What this workflow does

Send a meal photo to a LINE bot and Gemini 1.5 Flash automatically identifies the food and estimates calories, protein, fat, and carbohydrates. Each meal is logged to Google Sheets with a timestamp and user ID. The workflow calculates the running daily calorie total and warns when the personal limit is exceeded. Every Monday morning, a weekly nutrition summary with AI-generated advice is pushed via LINE automatically.

How to set up

  1. Create a LINE Messaging API channel and copy the Channel Access Token
  2. Copy your LINE User ID for weekly Push messages
  3. Set up a Google Sheet with columns: Timestamp, LINE_UID, Food_Name, Meal_Type, Calories, Protein, Fat, Carbs, Confidence
  4. Get a Google Gemini API key (free tier available)
  5. Configure CALORIE_LIMIT (default 2000) and LINE_USER_ID in the Set Config Fields node
  6. Register the n8n Webhook URL in LINE Developer Console

Requirements

How to customize

Adjust CALORIE_LIMIT in the Set Config Fields node for different dietary goals. Add a Slack notification node to share weekly reports with a fitness accountability group. Modify the Gemini prompt to track additional nutrients like fiber or sodium.


Node List

#Node NameTypeRole
1Set Config FieldsSetCentralizes LINE token, Sheet ID, calorie limit, and user ID
2When LINE Event ReceivedWebhookReceives LINE Webhook (POST)
3If Image MessageIfBranches on image vs text message
4If Report CommandIfChecks whether text is a report command
5Send Help Reply via LINEHTTP RequestSends usage guide as reply
6Fetch LINE Image DataHTTP RequestDownloads image from LINE Content API
7Encode Image to Base64CodeConverts image binary to Base64 string
8Gemini Food Analysis ConfigGemini Chat ModelGemini 1.5 Flash model for food analysis
9Process Food AnalysisLLM ChainEstimates nutrition info from meal image as JSON
10Extract Nutrition DataCodeExtracts and parses JSON from Gemini response
11Append Meal to SheetsGoogle SheetsAppends nutrition data to spreadsheet
12Read Today’s Total from SheetsGoogle SheetsRetrieves all records for today
13Compute Daily Calorie TotalCodeCalculates total calories for the day
14If Over Calorie LimitIfChecks whether daily limit is exceeded
15Send Calorie Warning via LINEHTTP RequestSends calorie warning reply via LINE
16Send Nutrition Info via LINEHTTP RequestSends nutrition info and daily total via LINE
17Weekly 9AM ScheduleSchedule TriggerTriggers weekly report every Monday at 9 AM JST
18Read Weekly Data from SheetsGoogle SheetsRetrieves records from the past 7 days
19Summarize Weekly StatsCodeAggregates weekly totals, averages, and peak day
20Gemini Weekly Report ConfigGemini Chat ModelGemini 1.5 Flash model for weekly comment
21Create Weekly Comment with LLMLLM ChainGenerates personalized nutrition advice
22Deliver Weekly Report via LINEHTTP RequestSends weekly report via LINE Push
23Send Webhook Response OKRespond to WebhookReturns HTTP 200 to Webhook

Total: 23 nodes (+ 9 Sticky Notes)


Sticky Note Compliance

#Sticky Note TitleColorRole
1Main Sticky Note (Overview)YellowWorkflow overview, How it works, Setup steps, Customization
2Set configuration fieldsWhiteCovers configuration setup
3Receive and verify message typeWhiteCovers LINE webhook and message type checks
4Download and convert imageWhiteCovers image fetch and Base64 encoding
5Analyze image and parse dataWhiteCovers Gemini analysis and data parsing
6Log and calculate nutritionWhiteCovers meal logging and daily total calculation
7Notify via LINE based on calorieWhiteCovers calorie warning and nutrition info LINE replies
8Weekly report scheduling and statsWhiteCovers schedule trigger and weekly aggregation
9Respond to LINE webhookWhiteCovers webhook response

All sticky notes use H2 headings (## ) and follow n8n public guidelines.


Setup Guide

1. Create a LINE Messaging API channel

  1. Log in to LINE Developers
  2. Create a new provider and a Messaging API channel
  3. Issue a long-lived Channel Access Token and copy it
  4. Copy your User ID from the channel basic settings

2. Prepare Google Sheets

  1. Create a new spreadsheet
  2. Add the following headers in row 1:
Timestamp | LINE_UID | Food_Name | Meal_Type | Calories | Protein | Fat | Carbs | Confidence
  1. Copy the spreadsheet ID from the URL (between /d/ and /edit)

3. Get a Google Gemini API key

  1. Go to Google AI Studio
  2. Create an API key (free tier available)
  3. Register it as a Google PaLM API credential in n8n

4. Configure the n8n workflow

  1. Import the workflow JSON into n8n
  2. Open Set Config Fields and enter:
    • LINE_CHANNEL_ACCESS_TOKEN
    • GOOGLE_SHEET_ID
    • CALORIE_LIMIT (default: 2000)
    • LINE_USER_ID
  3. Set up Google Sheets OAuth2 and Google PaLM API credentials

5. Register the Webhook URL

  1. Activate the workflow in n8n
  2. Copy the Webhook URL
  3. Paste it into LINE Developers Console → Messaging API settings
  4. Enable Webhook and verify the connection

6. Test

  1. Send a meal photo to your LINE bot → confirm nutrition info is returned
  2. Send “report” as text → confirm weekly summary is returned
  3. Send other text → confirm help message is returned

Tags

ai gemini line google-sheets health nutrition-tracking image-recognition automation

🔗 Nodes Used

Google Sheets, HTTP Request, Webhook, Schedule Trigger, Basic LLM Chain, Google Gemini Chat Model

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup