Quick overview
This workflow turns a LINE Official Account into a plant care assistant that can analyze plant photos and answer follow-up questions, using Google Gemini for AI responses and n8n Data Tables to store plant profiles, observations, conversation history, and the user’s language preference.
How it works
- Receives an incoming LINE Messaging API webhook event and routes it based on whether the message is an image or text.
- For image messages, downloads the image from the LINE content API and loads the user’s active plant, preferred language, and recent conversation history from n8n Data Tables.
- Sends the image and context to Google Gemini to identify the plant (or defer when uncertain) and assess visible health symptoms, possible causes, and care advice.
- If the image matches the active plant, keeps the existing plant identity; if it is a new plant, upserts a plant profile and updates the user’s active plant; if uncertain, asks for a better diagnostic photo without changing the active plant.
- Stores the image-based analysis as a plant observation in an n8n Data Table and replies to the user in LINE with a formatted summary and confidence.
- For text messages, loads the user’s active plant, recent observations, and conversation history, then asks Google Gemini to generate a contextual reply.
- Saves the user and assistant messages to conversation history, updates the saved preferred language only when the user explicitly requests a language change, and replies in LINE.
Setup
- Create a LINE Official Account, enable the Messaging API, and configure the webhook URL to point to the workflow’s production webhook path (plantcare-line-webhook).
- Add a LINE Messaging API channel access token as an HTTP Header Auth credential in n8n and use it for the LINE content download and reply requests.
- Add a Google Gemini (Google PaLM) API credential for the two Gemini nodes used for image analysis and chat responses.
- Create four n8n Data Tables named plant_users, plants, plant_observations, and conversations with the columns used in the workflow, and select the correct table IDs in each Data Table node.