<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Yaser Sweity]]></title><description><![CDATA[Yaser Sweity]]></description><link>https://yasersweity.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sun, 22 Nov 2026 17:39:01 GMT</lastBuildDate><atom:link href="https://yasersweity.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[A $0 WhatsApp AI Checks My Sales Team's Work: 1,863 Screenshots in 32 Days, Zero Lost]]></title><description><![CDATA[I run a remote sales team: eleven women across Palestine, selling home goods through Facebook groups, WhatsApp statuses, Snapchat, Instagram and TikTok…]]></description><link>https://yasersweity.hashnode.dev/a-0-whatsapp-ai-checks-my-sales-team-s-work-1-863-screenshots-in-32-days-zero-lost</link><guid isPermaLink="true">https://yasersweity.hashnode.dev/a-0-whatsapp-ai-checks-my-sales-team-s-work-1-863-screenshots-in-32-days-zero-lost</guid><category><![CDATA[AI]]></category><category><![CDATA[whatsapp]]></category><category><![CDATA[supabase]]></category><category><![CDATA[gemini]]></category><dc:creator><![CDATA[Yaser A.M. Sweity | ياسر سويطي]]></dc:creator><pubDate>Sat, 21 Nov 2026 00:37:34 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b00acb9067523b492652cb9/30174e52-0f2e-4d2d-b4f4-2f388a112336.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I run a remote sales team: eleven women across Palestine, selling home goods through Facebook groups, WhatsApp statuses, Snapchat, Instagram and TikTok. They work from their phones, on their own hours, in five different apps.</p>
<p>My problem was simple to state and miserable to live with: <strong>I had no idea who actually worked today.</strong></p>
<p>Every evening I'd scroll through dozens of screenshots in a WhatsApp chat, try to remember who posted where, and send the same reminders by hand. It didn't scale past three people. At eleven, it was a full-time job I didn't have time for.</p>
<p>So I built a system that does it for me. Every rep registers with the bot herself, and it tells her exactly what it counts and why. It's a tool for her as much as for me: she can ask it at any moment what's left for today. It's been running in production for 32 days. Here's what it does, the numbers it produced, and the four problems that almost killed it.</p>
<h2>The numbers first</h2>
<table>
<thead>
<tr>
<th>Metric</th>
<th>Value</th>
</tr>
</thead>
<tbody><tr>
<td>Days in production</td>
<td>32</td>
</tr>
<tr>
<td>Active sales reps</td>
<td>11</td>
</tr>
<tr>
<td>Messages received from reps</td>
<td>4,694</td>
</tr>
<tr>
<td>Replies the bot wrote</td>
<td>3,261</td>
</tr>
<tr>
<td>Screenshots verified by AI</td>
<td>1,863</td>
</tr>
<tr>
<td>Screenshots accepted as real work</td>
<td>1,642 (88%)</td>
</tr>
<tr>
<td>AI calls that failed (quota, overload, timeouts)</td>
<td>1,332</td>
</tr>
<tr>
<td>Screenshots lost because of those failures</td>
<td><strong>0</strong></td>
</tr>
<tr>
<td>Monthly infrastructure bill</td>
<td><strong>$0.00</strong></td>
</tr>
</tbody></table>
<p>Those last two rows are the whole story. Getting an LLM to answer a WhatsApp message is a weekend project. Getting it to work <em>every day</em> for real people on a free tier that fails a thousand times a month is the engineering.</p>
<h2>What it actually does</h2>
<p>A rep posts an offer in a Facebook group, takes a screenshot, and sends it to the bot's WhatsApp number. Within seconds:</p>
<pre><code class="language-plaintext">✅ انحسبت! جروبات: 3/5
ضايلك 2، كمّلي 💪
</code></pre>
<p><em>(Counted! Groups: 3/5. Two left, keep going 💪)</em></p>
<p>Behind that one line, the system:</p>
<ol>
<li>Downloads the image from WhatsApp's media API.</li>
<li>Asks a vision model: <em>what platform is this, is it a post or a story, was it posted today, how many items are in it?</em></li>
<li>Rejects screenshots of chats, old posts, and duplicates (same image or same caption twice).</li>
<li>Counts it against that rep's daily target for that platform.</li>
<li>Replies in Palestinian Arabic dialect: short, warm, never robotic.</li>
</ol>
<p>Reps can also just <em>talk</em> to it. "What's left for me today?" "Shorten this post for a reel." "That one you counted as Snap was actually a WhatsApp status." The bot answers from their real data, edits their own drafts (never inventing prices or facts), and fixes its own mistakes through a tool call that updates the database for real.</p>
<p>Three times a day, the reps get reminders that say exactly what's missing. Every evening, I get a PDF report of the whole team.</p>
<h2>The architecture</h2>
<pre><code class="language-plaintext"> Rep's phone (WhatsApp)
        │
        ▼
 WhatsApp Cloud API (official, Meta)
        │  webhook
        ▼
 Supabase Edge Function (Deno) ──────► Gemini (vision + chat)
        │   - registration flow             with model fallback
        │   - screenshot verification
        │   - AI assistant + tools
        │   - retry queue (pg_cron, 5 min)
        ▼
 Postgres (Supabase)
        ▲
        │  sync
 Local Node.js worker (my PC)
   - monitors public profiles (FB / IG / TikTok)
   - computes daily progress per rep
   - reminders 3×/day, PDF report nightly
</code></pre>
<p>Two halves on purpose. The <strong>edge function</strong> is the real-time brain: it must answer in seconds, 24/7, and it lives in the cloud. The <strong>local worker</strong> does the slow, heavy work (opening profiles in a browser, building PDFs) on a machine that's already on, so I don't pay for compute.</p>
<h2>Problem 1: The free tier is not "free", it's "20 a day"</h2>
<p>The free Gemini tier gives the strong models roughly <strong>20 requests per day each</strong>. With eleven reps sending ~60 screenshots a day plus conversations, I burned through that before lunch.</p>
<p>The naive fix is "tell the user to try again later". That's how you lose a sales team. When a rep sends proof of work and gets an error, she doesn't try again; she stops sending.</p>
<p>So every AI call goes through a fallback chain across five models, each with its own free quota:</p>
<p><img src="https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/zgtgb2qbfoq2rsaizwjh.png" alt="Screenshots go only to the strong vision models; chat starts with the high-quota models; when every model fails, the message waits in a queue that retries every five minutes" /></p>
<pre><code class="language-ts">async function geminiParts(request, budgetMs = 60_000, models = CHAT_MODELS) {
  const deadline = Date.now() + budgetMs;
  const errors: string[] = [];
  // chat should finish in &lt;10s; if a model hangs, move on fast
  const perTry = models === CHAT_MODELS ? 20_000 : 45_000;
  for (const model of models) {
    const left = deadline - Date.now();
    if (left &lt; 5_000) break;
    try {
      const res = await fetch(`${API}/${model}:generateContent`, {
        method: 'POST',
        body: JSON.stringify(request),
        signal: AbortSignal.timeout(Math.min(left, perTry)),
      });
      if (!res.ok) { errors.push(`${model} ${res.status}`); continue; }
      // ...parse text + function calls, return on success
    } catch (e) {
      errors.push(`${model} ${e.name}`);
    }
  }
  throw new GeminiBusy(`gemini unavailable: ${errors.join(' | ')}`);
}
</code></pre>
<p>The trick is <strong>routing by value, not by default</strong>:</p>
<ul>
<li><strong>Screenshots</strong> need accuracy, so they only go to the strong vision models. If those are exhausted, the image waits in a queue instead of being judged by a weak model that will get it wrong.</li>
<li><strong>Chat</strong> goes to the high-quota models <em>first</em> and only touches the strong ones as a last resort, saving their scarce quota for images.</li>
</ul>
<p>When everything fails, nothing is lost. The message goes into a queue, the rep gets <em>"وصلتني 👌 بفحصها خلال دقائق وبرجعلك، ما تبعتيها مرة ثانية"</em> ("Got it 👌 checking it in a few minutes, don't resend"), and a <code>pg_cron</code> job drains the queue every five minutes. Images older than 20 minutes are allowed to fall back to the lighter models, because a slightly less accurate answer now beats a perfect one never.</p>
<p>Result: <strong>1,332 failed AI calls, 0 lost screenshots.</strong></p>
<h2>Problem 2: The model couldn't tell Facebook from Instagram</h2>
<p>This one surprised me. My reps complained that their stories weren't being counted. When I pulled the rejected screenshots, the pattern was obvious once I saw it:</p>
<p><strong>A Facebook story that's cross-posted shows an "Instagram" label inside it.</strong> The model saw the word "Instagram" and confidently said Instagram. Or Snapchat, because both have a full-screen vertical layout.</p>
<p>Prompt tweaking by vibes doesn't fix this. What fixed it was treating the prompt like code and building a test harness around it:</p>
<ol>
<li>Download the real screenshots that were misjudged (by their WhatsApp media ID).</li>
<li>Label each one by hand: <code>118:facebook_story</code>, <code>116:whatsapp_status</code>, <code>234:other</code> …</li>
<li>Run the exact production prompt against all of them offline, and diff the output.</li>
<li>Change the prompt, rerun, and only ship when every case passes.</li>
</ol>
<p>The prompt went from "what platform is this?" to a list of <strong>UI chrome cues</strong> for each platform. Facebook stories have "Share as post", "Highlights", "N viewers". Instagram has "Activity", "Send message", a heart and a paper plane, and only counts as Instagram if none of the Facebook cues are present. And a rule that I wish I'd written on day one:</p>
<blockquote>
<p>Decide by the UI chrome, never by a platform name that appears inside the content.</p>
</blockquote>
<p>Two other bugs fell out of the same investigation:</p>
<ul>
<li><strong>A "My status" list screen</strong> showing 10 statuses was being counted as 1. The schema now returns <code>items_count</code>, stored as <code>units</code>, so one screenshot of a list counts for everything in it, and it never double-counts when the rep <em>also</em> sends them one by one: the count is <code>max(singles, biggest list)</code>.</li>
<li><strong>Screenshots of WhatsApp group chats</strong> were being read as statuses. "Message bubbles plus a typing bar" now means <em>chat</em>, and chats don't count.</li>
</ul>
<p>After the fix, I re-ran the whole day's screenshots silently. Several reps gained work they'd done but hadn't been credited for, and <strong>no previously counted screenshot was lost</strong>. I checked that explicitly before writing anything back.</p>
<h2>Problem 3: An LLM that talks like a newspaper</h2>
<p>My first version answered "good morning" with three paragraphs of motivational text in formal Arabic. My reps hated it. One wrote back, roughly, <em>"you're driving me crazy since this morning."</em></p>
<p>Getting a bot to sound like a person is mostly about <strong>what it doesn't do</strong>:</p>
<ul>
<li><strong>One reply per burst.</strong> People type in bursts: "hi" / "what's left?" / "quick please". Each webhook waits 6 seconds, checks whether a newer message arrived, and if so, stays silent and lets the latest one answer everything at once.</li>
<li><strong>No reply to closers.</strong> "ok", "thanks", 👍, stickers, reactions: silence, unless the bot's last message was a question.</li>
<li><strong>Short and in dialect.</strong> Palestinian Arabic, feminine forms, one emoji, no lectures. Apologies are one line, not a paragraph.</li>
<li><strong>Never claim an action it didn't take.</strong> If the model says "I fixed it", a real tool call must have updated the row. Otherwise the reply is rewritten.</li>
<li><strong>A watchdog.</strong> Every five minutes, any rep message unanswered for more than 3 minutes gets answered, and I get an alert.</li>
</ul>
<p>None of this is AI. It's the boring plumbing that makes the AI feel human.</p>
<h2>Problem 4: The day Meta silently stopped delivering every message</h2>
<p>On day three, the bot "got slow". Then it "stopped answering me". I spent the first hour assuming it was the AI.</p>
<p>It wasn't. The bot was writing every reply on time. <strong>WhatsApp was rejecting all of them</strong> with error <code>131042</code>: first because the business account had no currency configured, then because it had no payment method, even though replies inside the 24-hour customer-service window are free.</p>
<p>Every status callback was already being logged, so the database showed it immediately:</p>
<pre><code class="language-plaintext">[status:failed] 131042 Business eligibility payment issue
Message failed to send because no payment method is set up...
</code></pre>
<p>The lesson I now apply to every bot: <strong>"slow" and "not answering" are usually delivery problems, not model problems. Log every delivery status, and check failures first.</strong> Fix: set the currency, add a card. Paid message templates stay disabled in config, so the balance is still <strong>$0.00</strong>.</p>
<h2>Rules that kept it safe</h2>
<p>When software talks to real people on your behalf, the guardrails matter more than the features:</p>
<ul>
<li><strong>Official WhatsApp API only.</strong> No unofficial libraries, no risk of anyone's personal number getting banned.</li>
<li><strong>Only free messages.</strong> <code>allowPaidTemplates: false</code>. The bot only messages reps who wrote to it in the last 24 hours.</li>
<li><strong>Test before every deploy.</strong> <code>scripts/bot-test.mjs</code> sends fake conversations from <code>999…</code> phone numbers through the <em>real</em> deployed webhook (registration, message bursts, "ok" messages that should get no reply, drafts, screenshots, corrections), prints the full transcript, and deletes its data. Test numbers never get a real WhatsApp message.</li>
<li><strong>The bot never writes a sales post from scratch.</strong> It only edits the rep's own draft, never adds prices or facts. A sales assistant that hallucinates a discount is worse than none.</li>
<li><strong>Per-rep reality.</strong> A rep without Facebook isn't asked for Facebook groups. That sounds obvious, but it was a real bug that made one rep feel she was failing at a job she was never assigned.</li>
</ul>
<h2>What I'd tell you if you're building something similar</h2>
<ol>
<li><strong>Free tiers are a design constraint, not a pricing tier.</strong> Design for the 429 first: queue, fall back, route by value.</li>
<li><strong>Treat prompts like code.</strong> Real failing inputs, hand labels, an offline harness, no shipping on vibes.</li>
<li><strong>Humans judge your bot on silence and length</strong>, not on intelligence.</li>
<li><strong>Log the delivery layer.</strong> The most dramatic outage I had wasn't in my code at all.</li>
<li><strong>Never lose user work.</strong> Accepting a screenshot and checking it later is fine. Making someone resend proof of their work is not.</li>
</ol>
<p>The whole thing is about 5,700 lines of TypeScript: a Deno edge function, a Node worker, ten SQL migrations, and a test script. It runs on the free tiers of Supabase and Gemini, and the heavy work runs on a PC that's already on, so the bill is zero. And for the first time since I started this team, I know at a glance who worked today, and so do they.</p>
<hr />
<p><em>Built with WhatsApp Cloud API, Supabase (Edge Functions, Postgres, pg_cron), Google Gemini, Node.js and Playwright. If you're building tools for small teams in places big SaaS doesn't serve, I'd love to hear about it in the comments.</em></p>
<p><em>I also wrote about the other system I run alone, an e-commerce platform with a website, a mobile app and an admin dashboard: <a href="https://dev.to/yasersweity/one-platform-one-engineer-the-decisions-that-built-glamora-bm1">One Platform, One Engineer: The Decisions That Built Glamora</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[One Platform, One Engineer: The Decisions That Built Glamora]]></title><description><![CDATA[When I decided to launch Glamora, an online store for gifts, home décor and fashion, I didn't have a team. No front-end engineer, no back-end engineer, no…]]></description><link>https://yasersweity.hashnode.dev/one-platform-one-engineer-the-decisions-that-built-glamora</link><guid isPermaLink="true">https://yasersweity.hashnode.dev/one-platform-one-engineer-the-decisions-that-built-glamora</guid><category><![CDATA[Software Engineering]]></category><category><![CDATA[System Design]]></category><category><![CDATA[PostgreSQL]]></category><category><![CDATA[ecommerce]]></category><category><![CDATA[startup]]></category><dc:creator><![CDATA[Yaser A.M. Sweity | ياسر سويطي]]></dc:creator><pubDate>Fri, 20 Nov 2026 20:28:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b00acb9067523b492652cb9/d89d7c7c-4f06-4be3-b7d4-69a5bc11d353.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When I decided to launch Glamora, an online store for gifts, home décor and fashion, I didn't have a team. No front-end engineer, no back-end engineer, no security specialist, no accountant.</p>
<p>Today the platform runs end to end: a website and a mobile app, an admin dashboard for orders and products, an accounting system that calculates the real profit of every item, instant notifications, and a smart shopping assistant that answers customers.</p>
<img src="https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/lpvpzi2c7qf3qzxevhpz.png" alt="Glamora platform architecture" style="display:block;margin:0 auto" />

<p>This isn't an article about what I built. It's about the decisions that made it possible. When you work alone, you can't afford big mistakes: every engineering decision either carries you or sinks you.</p>
<h2>Decision 1: One truth, in one place</h2>
<p>Imagine a shop with three inventory notebooks: one with the seller, one with the accountant, one with the manager. Within a week, none of them match.</p>
<p>The website, the mobile app and the admin dashboard are three different interfaces, but they all read from and write to a single PostgreSQL database. There are no copies to keep in sync, and no "website truth" that differs from the "app truth". When a price changes, it changes everywhere at the same moment. That single decision eliminated an entire class of bugs before they were born.</p>
<h2>Decision 2: Rules live where the data lives</h2>
<p>Instead of writing instructions on every door, write them once, on the safe itself.</p>
<p>The important rules don't live in the screens. They live inside the database as triggers that fire on every change. Glamora sells bundles made of several items, and a bundle's availability is never managed by hand: it is derived from the availability of its parts. Notifications work the same way. When one is created, it is pushed to phones automatically through a cloud function, without any screen being involved.</p>
<p>The rule taught me something more valuable than the rule itself. I once found bundles still marked unavailable after their items were back in stock, because the trigger only reacted to one kind of change. Systems don't fail where you expect them to; they fail where you made assumptions. Since then, I ask of every rule: which cases haven't I thought of?</p>
<h2>Decision 3: Every drawer has its own lock</h2>
<p>Most systems only guard the front door. Once you're in, you can reach everything.</p>
<p>In Glamora, every table is protected by Row Level Security policies. A customer can only see their own orders. Sensitive data, such as product costs and the questions customers ask the assistant, can only be read by the store owner, even if someone tries to query it directly. Security isn't a layer added at the end; it's part of the data model. Deny is the default. Access is the exception.</p>
<h2>Decision 4: Design for the network your customers actually have</h2>
<p>Not every customer has fast internet, and if a page takes three seconds to load, they leave.</p>
<p>Every product image is stored in three WebP sizes: small for lists, medium for product pages, large for zoom. A phone never downloads more than it needs. App updates ship over the air, without waiting for app-store review, so a bug can be fixed in minutes rather than days.</p>
<h2>Decision 5: The smart assistant as a tool for understanding, not decoration</h2>
<p>I built a shopping assistant that answers customers and recommends products. It runs on the server, not on the user's device, with three safeguards: a rate limit per user to protect the system and its cost, anonymous logging of customer questions (the text only, no personal data), and read access to those questions for the store owner only.</p>
<p>Why log the questions? Because what customers ask is the most honest market research there is: what are they looking for and not finding? That turns the assistant from a technical feature into a source of product decisions.</p>
<h2>Decision 6: Engineering doesn't end at deployment. It ends at profit</h2>
<p>A store that sells a lot can also lose a lot, without noticing.</p>
<p>Inside the dashboard, I built an accounting module that links every product to its real cost. When I designed the bundles, I didn't settle for a discount that looked attractive. I checked the margin of every bundle against the cost of every item in it before a single customer saw it. A system that works technically but loses money is a failed system. A good engineer reads numbers as carefully as code.</p>
<h2>What I learned</h2>
<p>Six decisions, and one principle behind them: when you're alone, don't build more. Build right.</p>
<ul>
<li>One source of truth instead of many copies.</li>
<li>Rules in one place instead of scattered instructions.</li>
<li>Security built into the structure, not a guard at the door.</li>
<li>Design for the reality your customers live in, not the one you wish for.</li>
</ul>
<p>Modern tools can give a single engineer the power of a whole team. What they can't give is the most important thing: knowing which decisions are worth making. That isn't bought. It's built, one decision at a time.</p>
<hr />
<p><em>Originally published on</em> <a href="https://dev.to/yasersweity/one-platform-one-engineer-the-decisions-that-built-glamora-bm1"><em>DEV</em></a><em>.</em></p>
]]></content:encoded></item></channel></rss>