Back to projects

Case study

Carnet NEWIPAY - Credit sales ledger on WhatsApp

Landing page: the credit sales ledger, on WhatsApp, with the free trial button
Merchant side: sign-up in French or Wolof, then a credit sale recorded in a few messages, reminders scheduled
Morning reminders: the message goes out from the merchant's WhatsApp, then a payment spread over two sales
Admin panel: active merchants, reminders this month, payments received and balance outstanding
Merchant list: status, end of subscription, customers, open sales and balance outstanding
A merchant's record on a phone: payment numbers, subscription and action history

Context

In Senegal, many merchants sell on credit and write down what they are owed in a paper notebook. The notebook gets lost, amounts get disputed, and due dates get forgotten.

NEWIPAY, a Senegalese company, wanted to offer them this ledger on WhatsApp, the app they already open all day long, with nothing to install, and to sell it as a monthly subscription paid through Wave or Orange Money. The mission: design and launch the bot, its admin panel and the entire setup on the Meta side, on accounts and a server in the client's name.

Problem & goals

Problem

  • WhatsApp Business rules forbid a platform from writing to third-party merchants' customers itself to ask them to pay: sending the reminders automatically would have put the client's WhatsApp account at risk
  • Some merchants read little or not at all: everything had to work through buttons, icons and short texts, in French or Wolof
  • Outside the 24 hours that follow the last message received, a WhatsApp Business account can only write with message templates approved by Meta, and billed
  • Meta's business verification was a prerequisite for launch, and Meta only accepts certain types of supporting documents, which had to be found among the company's paperwork
  • A client with no technical team and a small server: every extra service to run was one more possible failure

Goals

  • Record a credit sale in under a minute: customer, number, the customer's consent to reminders, amount, due date
  • Keep each customer's balance, with the history of their sales and payments
  • Prepare the day's reminders every morning, with a ready-written message for each customer that the merchant sends personally
  • Record payments received in cash, through Wave or through Orange Money, including a single payment that covers several sales
  • Give NEWIPAY a panel to follow its merchants, extend subscriptions, and suspend and reactivate accounts
  • Handle the setup on the Meta side up to business verification, and leave everything in the client's name

Approach

Everything starts from one rule: the bot never writes to the merchants' customers. I built the service around it and ran the project end to end: design, development, server, Meta procedures, acceptance testing with the client and launch.

  • a single contact for the bot, the subscribed merchant: each reminder is an official WhatsApp link (wa.me) with the message already written, which merchants send from their own phone. No template to get approved for end customers, no Meta fees on reminders, and a single number for the whole service;
  • a state machine of about twenty steps, where each message is processed in a single transaction: nothing is saved before the confirmation screen, and a message received twice never creates a duplicate;
  • forgiving input: “25 000”, “25k” or “25 000 F CFA” for an amount, “demain” (tomorrow), “dans 30 jours” or a date for the due date, a Senegalese number completed with its country code, a shared contact taken as is;
  • a menu designed for merchants who read little: consistent icons, an order that never changes, buttons, and numbers accepted from the keypad, as in the Wave and Orange Money menus;
  • a job queue in PostgreSQL for webhooks, sending and the hourly reminder run: retries, no duplicates after a restart, and no Redis to operate;
  • the WhatsApp API's constraints built in from the design stage: 24-hour window, approved template as a fallback for the morning list, button and list lengths checked before every send;
  • a simulated WhatsApp driver to develop and replay every flow without a Meta account, then a dry run of 646 simulated messages: 29 defects found and fixed before handing the bot over to the client;
  • the Meta procedures carried out for the client: app, system user, webhook, message templates and business verification, obtained on the third request after two rejections over the type of supporting documents.

Every decision is recorded in the repository, along with the Meta procedure, the operations documentation and a user guide for the client.

Technical highlights

Bot: Node.js 22, strict TypeScript, Fastify and Zod. State machine, each message processed in one transaction, flows that expire after 30 minutes without silently dropping anything. Texts in French and Wolof in a typed catalog: a missing key doesn't compile, and a test checks that no French text was left in the Wolof catalog.

WhatsApp: Meta's WhatsApp Cloud API: webhooks with verified signatures, deduplicated and processed in the background, interactive messages (buttons, lists, link buttons), three approved message templates for the morning list and the subscription, prefilled wa.me links for reminders.

Data: PostgreSQL 16 and Drizzle ORM, versioned SQL migrations applied at startup. Job queue in the database (FOR UPDATE SKIP LOCKED locking), with one key per hourly slot: the morning list goes out only once, and never outside its hour.

Admin panel: React 18 and Vite, in French and readable on a phone. Passwords hashed with argon2id, signed session in an httpOnly cookie, five login attempts per quarter of an hour, every admin action logged.

Hosting: VPS in the client's name, Docker Compose, Caddy for HTTPS and security headers. Key-based login only, firewall limited to three ports, automatic security updates, nightly database backup with a tested restore.

Quality: Vitest: unit tests and a webhook harness, each test file on its own throwaway database, copied from a migrated template. The simulated driver replays whole conversations through the same path as real messages.

Results

The bot has been in service since October 2026:

  • self-service sign-up, in French or Wolof: language, first name, shop, then Wave and Orange Money numbers;
  • a credit sale recorded in a few messages, with the customer's consent and two scheduled reminders, three days before the due date and on the day itself;
  • the merchant's ledger: what is still owed, sale by sale, overdue items first, and each customer's record;
  • every morning, the list of the day's reminders: one tap opens the conversation with the customer, with the message already written, including the merchant's Wave and Orange Money numbers;
  • payments in cash, through Wave or through Orange Money, automatically spread over the customer's sales, starting with the oldest due date;
  • a panel for NEWIPAY: merchants, subscriptions extended after payment, suspension and reactivation, figures for the month;
  • the business verified by Meta, a landing page with the company's legal notice, and every account in the client's name.

Spreading a payment over several sales came from the test merchants' feedback: I added it and put it live before final sign-off. The client has already planned the next phase of the project with me.

What I learned

  • reading a platform's policy before writing a line of code, and deriving the architecture from it rather than working around it;
  • designing a conversational interface: one question at a time, buttons, free-text input that is understood, and never a dead end;
  • fitting a reliable job queue into PostgreSQL, with no extra service to operate;
  • carrying out a Meta business verification for a client: the right documents, information copied word for word, exchanges followed through to approval;
  • testing a bot without depending on the network: simulated driver, replayed conversations, a dry run before the client's own acceptance testing;
  • delivering in two languages, with texts the client can change without touching the code.

The constraint that shaped this project the most wasn't technical: it was a Meta rule. Taking it into account from the design stage made it possible to launch the service with no risk to the client's WhatsApp account.

Interested in this project?

Let's discuss your needs and see how I can help you bring your project to life.