<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Google Gemini | Figarri Keisha</title><link>https://kfigarri.github.io/tags/google-gemini/</link><atom:link href="https://kfigarri.github.io/tags/google-gemini/index.xml" rel="self" type="application/rss+xml"/><description>Google Gemini</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Thu, 10 Jul 2025 00:00:00 +0000</lastBuildDate><image><url>https://kfigarri.github.io/media/icon_hu1335818982437251170.png</url><title>Google Gemini</title><link>https://kfigarri.github.io/tags/google-gemini/</link></image><item><title>🛒 Building a WhatsApp-Based Grocery Assistant in 3 Days Using n8n</title><link>https://kfigarri.github.io/post/grocery-assistant/</link><pubDate>Thu, 10 Jul 2025 00:00:00 +0000</pubDate><guid>https://kfigarri.github.io/post/grocery-assistant/</guid><description>&lt;h2 id="1-background">1. Background&lt;/h2>
&lt;p>As a student living in the UK, balancing study, life, and cooking has been a challenge. Between coursework, lectures, and late-night study sessions, I often forget what’s already sitting in my fridge. This leads to the all-too-familiar outcome: buying groceries I already have, letting things expire, and ultimately wasting food and money.&lt;/p>
&lt;p>I wanted a solution that didn’t require me to change my habits or download new apps, just something that worked where I already spend time: &lt;strong>WhatsApp&lt;/strong>.&lt;/p>
&lt;hr>
&lt;h2 id="2-the-solution">2. The Solution&lt;/h2>
&lt;p>I built a &lt;strong>Grocery Assistant&lt;/strong>, an AI-powered tool that helps me:&lt;/p>
&lt;ul>
&lt;li>Extract items from receipt images and store them in a live inventory table&lt;/li>
&lt;li>Remind me of expiring items and help generate grocery lists&lt;/li>
&lt;li>Communicate entirely through &lt;strong>WhatsApp&lt;/strong>, which I already use daily&lt;/li>
&lt;/ul>
&lt;p>This means no extra app installations, no switching platforms, just smart grocery help through a familiar interface.&lt;/p>
&lt;hr>
&lt;h3 id="-demo">🧪 Demo&lt;/h3>
&lt;p>Below are three short demo clips that showcase the main features of the WhatsApp-based Grocery Assistant:&lt;/p>
&lt;h4 id="-1-receipt-upload--inventory-update">📸 1. Receipt Upload → Inventory Update&lt;/h4>
&lt;p>A user sends a photo of a grocery receipt via WhatsApp. The assistant:&lt;/p>
&lt;ul>
&lt;li>Detects it as a receipt&lt;/li>
&lt;li>Extracts the items using AI&lt;/li>
&lt;li>Adds them to the inventory table&lt;/li>
&lt;li>Responds with a bullet-point confirmation of what was added&lt;/li>
&lt;/ul>
&lt;p>&lt;video src="./demo/simulation1.mp4" width="1280" height="720" controls>&lt;/video>&lt;/p>
&lt;hr>
&lt;h4 id="-2-generate-grocery-list-from-expiring-items">🛒 2. Generate Grocery List from Expiring Items&lt;/h4>
&lt;p>The user asks, &lt;em>“Give me grocery list based on expiring items”&lt;/em>&lt;/p>
&lt;p>The assistant checks for items that are low in quantity or expiring soon and replies with a smart grocery list.&lt;/p>
&lt;p>&lt;video src="./demo/simulation2.mp4" width="1280" height="720" controls>&lt;/video>&lt;/p>
&lt;hr>
&lt;h4 id="-3-upload-non-receipt-image">❌ 3. Upload Non-Receipt Image&lt;/h4>
&lt;p>A user sends a random photo (e.g. a street sign or a product box). The assistant:&lt;/p>
&lt;ul>
&lt;li>Classifies it as &lt;strong>not a receipt&lt;/strong>&lt;/li>
&lt;li>Transcribes visible text (if any)&lt;/li>
&lt;li>Responds politely, explaining that no grocery extraction was possible&lt;/li>
&lt;/ul>
&lt;p>&lt;video src="./demo/simulation3.mp4" width="1280" height="720" controls>&lt;/video>&lt;/p>
&lt;hr>
&lt;h3 id="-using-postgresql-with-supabase">🛢️ Using PostgreSQL with Supabase&lt;/h3>
&lt;p>To store and manage the grocery data, I used &lt;strong>PostgreSQL hosted on &lt;a href="https://supabase.com/" target="_blank" rel="noopener">Supabase&lt;/a>&lt;/strong>. The schema consists of two key tables:&lt;/p>
&lt;h4 id="1-product_shelf_life">1. &lt;code>product_shelf_life&lt;/code>&lt;/h4>
&lt;p>This is a reference table containing general knowledge about how long common grocery categories typically last. For example, &lt;code>Milk&lt;/code> expires in 12 days, &lt;code>Vegetables&lt;/code> in 3 days, &lt;code>Snacks&lt;/code> in 180 days, etc.&lt;/p>
&lt;p>&lt;a href="./demo/productshelflife.png">
&lt;figure >
&lt;div class="flex justify-center ">
&lt;div class="w-100" >&lt;img src="./demo/productshelflife.png" alt="" loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/a>&lt;/p>
&lt;h4 id="2-inventory">2. &lt;code>inventory&lt;/code>&lt;/h4>
&lt;p>This table records items extracted from receipts and keeps track of:&lt;/p>
&lt;ul>
&lt;li>Item name&lt;/li>
&lt;li>Product category&lt;/li>
&lt;li>Quantity and unit&lt;/li>
&lt;li>Inferred &lt;code>expiry_date&lt;/code>&lt;/li>
&lt;li>Timestamp of purchase&lt;/li>
&lt;/ul>
&lt;p>&lt;a href="./demo/inventory.png">
&lt;figure >
&lt;div class="flex justify-center ">
&lt;div class="w-100" >&lt;img src="./demo/inventory.png" alt="" loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/a>&lt;/p>
&lt;p>The &lt;code>expiry_date&lt;/code> is automatically calculated as:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="n">expiry_date&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">current_date&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">expected_expired_days&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h2 id="3-prototyping-with-n8n">3. Prototyping with n8n&lt;/h2>
&lt;p>To build this fast, I used &lt;strong>n8n&lt;/strong>, an open-source workflow automation tool. Why n8n?&lt;/p>
&lt;ul>
&lt;li>✅ Low-code with visual logic&lt;/li>
&lt;li>✅ Easy integration with WhatsApp (via Business API)&lt;/li>
&lt;li>✅ Supports AI models and custom databases&lt;/li>
&lt;li>✅ Fast iteration; I built and tested this in under &lt;strong>3 days&lt;/strong>&lt;/li>
&lt;/ul>
&lt;p>For prototypes like this, n8n is perfect. It’s modular, visual, and allows integrating AI tools with databases, HTTP endpoints, and messaging platforms with minimal boilerplate.&lt;/p>
&lt;hr>
&lt;h2 id="4-workflow-breakdown">4. Workflow Breakdown&lt;/h2>
&lt;p>Let me walk you through the system design, as shown in the visual below:&lt;/p>
&lt;p>&lt;a href="./demo/fullschema.png">
&lt;figure >
&lt;div class="flex justify-center ">
&lt;div class="w-100" >&lt;img src="./demo/fullschema.png" alt="" loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/a>&lt;/p>
&lt;h3 id="-grocery-assistant">🟫 Grocery Assistant&lt;/h3>
&lt;p>When a user sends a text message, the &lt;strong>Grocery Assistant&lt;/strong> (powered by Gemini 2.5 Flash) processes it. It chooses the right tool based on intent: whether it’s to create a grocery list, check for expiring items, or ask about what’s in stock.&lt;/p>
&lt;p>✅ Tools used:&lt;/p>
&lt;ul>
&lt;li>&lt;code>Postgres Chat Memory&lt;/code> to access inventory data&lt;/li>
&lt;li>&lt;code>Expiring Items&lt;/code> to check for near-expiry products (connected with PostgreSQL)&lt;/li>
&lt;li>Replies are sent directly back via WhatsApp.&lt;/li>
&lt;/ul>
&lt;p>&lt;a href="./demo/groceryassistantschema.png">
&lt;figure >
&lt;div class="flex justify-center ">
&lt;div class="w-100" >&lt;img src="./demo/groceryassistantschema.png" alt="" loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/a>&lt;/p>
&lt;hr>
&lt;h3 id="-image-classifier">🟦 Image Classifier&lt;/h3>
&lt;p>If the input is an image (e.g., a photo of a receipt), it’s routed to the &lt;strong>Image Classifier&lt;/strong>. This step uses Gemini 1.5 Flash to classify whether the image is a &lt;strong>receipt&lt;/strong> or something else.&lt;/p>
&lt;p>📌 Outcome:&lt;/p>
&lt;ul>
&lt;li>If it&amp;rsquo;s a receipt → go to receipt extractor.&lt;/li>
&lt;li>If not → transcribe and send the text back with a polite fallback.&lt;/li>
&lt;/ul>
&lt;p>&lt;a href="./demo/imageclassifierschema.png">
&lt;figure >
&lt;div class="flex justify-center ">
&lt;div class="w-100" >&lt;img src="./demo/imageclassifierschema.png" alt="" loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/a>&lt;/p>
&lt;hr>
&lt;h3 id="-no-receipt-response">🟪 No Receipt Response&lt;/h3>
&lt;p>If the image is not a receipt, the system still makes use of it. The agent transcribes visible text using Gemini 1.5 Flash and replies via WhatsApp with the message:&lt;/p>
&lt;blockquote>
&lt;p>“This image does not appear to be a receipt, so no extraction was performed.”&lt;/p>
&lt;/blockquote>
&lt;p>This ensures a graceful fallback and lets users know what&amp;rsquo;s happening.&lt;/p>
&lt;p>&lt;a href="./demo/noreceiptschema.png">
&lt;figure >
&lt;div class="flex justify-center ">
&lt;div class="w-100" >&lt;img src="./demo/noreceiptschema.png" alt="" loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/a>&lt;/p>
&lt;hr>
&lt;h3 id="-smart-receipt-extractor">🟩 Smart Receipt Extractor&lt;/h3>
&lt;p>When a valid receipt is detected, the image goes through the &lt;strong>Smart Receipt Extractor&lt;/strong> workflow:&lt;/p>
&lt;ol>
&lt;li>🔗 Merge the binary image&lt;/li>
&lt;li>📄 Extract raw text using &lt;strong>Gemini 2.5 Flash&lt;/strong>&lt;/li>
&lt;li>🗂️ Match products to known categories via database&lt;/li>
&lt;li>🧠 Parse structured items with &lt;strong>Gemini 1.5 Flash&lt;/strong>&lt;/li>
&lt;li>🧹 Clean and transform the data (add expiry based on category shelf life)&lt;/li>
&lt;li>🔄 Split items for individual inserts&lt;/li>
&lt;li>🛒 Insert into PostgreSQL inventory&lt;/li>
&lt;li>📬 Aggregate and send a WhatsApp checklist of added items&lt;/li>
&lt;/ol>
&lt;p>Despite being entirely no-code, this workflow handles multi-model orchestration, structured output parsing, and real-time database updates.&lt;/p>
&lt;p>&lt;a href="./demo/receiptextractorschema.png">
&lt;figure >
&lt;div class="flex justify-center ">
&lt;div class="w-100" >&lt;img src="./demo/receiptextractorschema.png" alt="" loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/a>&lt;/p>
&lt;hr>
&lt;h2 id="5-conclusion">5. Conclusion&lt;/h2>
&lt;p>The Grocery Assistant &lt;strong>works&lt;/strong> and it already saves me time and reduces food waste. It’s still a &lt;strong>prototype&lt;/strong>, but the foundation is solid and extensible.&lt;/p>
&lt;h3 id="-what-can-be-improved">🛠️ What can be improved?&lt;/h3>
&lt;ul>
&lt;li>🔔 Add a &lt;strong>cron job&lt;/strong> to send &lt;strong>WhatsApp reminders&lt;/strong> when items are close to expiry&lt;/li>
&lt;li>🧠 Improve product mapping by adding more granular shelf-life estimates per &lt;strong>product name&lt;/strong> (not just by category)&lt;/li>
&lt;li>🤖 Better handling of OCR errors from low-quality receipts&lt;/li>
&lt;li>📊 Build a small dashboard to visualize inventory freshness trends&lt;/li>
&lt;/ul>
&lt;h3 id="-final-thoughts-on-n8n">🧠 Final Thoughts on n8n&lt;/h3>
&lt;p>While I haven’t yet explored the feasibility of &lt;strong>public, large-scale deployment&lt;/strong> using n8n, I found it incredibly powerful for &lt;strong>prototyping and rapid iteration&lt;/strong>. Within just a few days, I was able to build a fully functional AI-powered grocery assistant with real database integration and WhatsApp automation, all without writing a full backend from scratch. For now, I see n8n as a reliable tool for internal workflows, testing ideas quickly, or building MVPs.&lt;/p>
&lt;p>👉 &lt;a href="https://gist.github.com/kfigarri/ad675adb668482a8515f2956c38ce66b#file-grocery_assistant-json" target="_blank" rel="noopener">Download the n8n workflow of the Grocery Assistant here&lt;/a>&lt;/p>
&lt;h3 id="did-you-find-this-page-helpful-consider-sharing-it-">Did you find this page helpful? Consider sharing it 🙌&lt;/h3></description></item></channel></rss>