DEV Community

Ujjwal Dubey
Ujjwal Dubey

Posted on

One Order, One Reference: Designing an Order-ID Scheme That Indian WhatsApp Automations Can Actually Match

Most small Indian businesses I talk to have the same quiet problem: the order exists in four places and none of them share a key. The customer's WhatsApp chat says "the blue one, 2 pieces". The invoice software has its own number. The payment screenshot has a UPI reference. The courier has a docket number. A person in the shop holds it all together by memory.

Before anyone, including an AI automation agency India teams hire to connect WhatsApp to their books, can automate status replies, that memory has to become a reference scheme.

The rule: mint your own ID at the first message

Do not wait for the invoice. Create an internal order reference the moment an enquiry turns into an order, and send it to the customer in the confirmation message.

import secrets, string
ALPHABET = string.ascii_uppercase.replace('O', '').replace('I', '') + '23456789'

def order_ref(prefix='ORD'):
    # short, readable over a phone call, no O/0 or I/1 confusion
    return prefix + '-' + ''.join(secrets.choice(ALPHABET) for _ in range(6))
Enter fullscreen mode Exit fullscreen mode

Short and readable matters more than clever. Customers will read this back to you on a call.

Store the other IDs against it, never instead of it

CREATE TABLE order_refs (
  order_ref     TEXT PRIMARY KEY,
  wa_phone      TEXT NOT NULL,   -- normalised +91 number
  invoice_no    TEXT,            -- filled when billing creates it
  payment_ref   TEXT,            -- UPI/UTR text, typed or approved by a person
  docket_no     TEXT,            -- courier, if any
  status        TEXT NOT NULL DEFAULT 'confirmed',
  updated_at    TIMESTAMP NOT NULL
);
Enter fullscreen mode Exit fullscreen mode

Each later system adds its own number to the same row. Status replies then look up one key.

Three edge cases to design for

  1. One chat, many orders. Repeat customers order again in the same thread. Always ask "which order?" when more than one is open, and show the references.
  2. Payment reference typed by a person. Do not let a model read a screenshot and mark an order paid. Let it draft the match; a person approves.
  3. Edits after confirmation. Changing quantity should keep the reference and log the change, not mint a new one.

What this unlocks

With one reference per order, "where is my order?" stops being a search through chats. It becomes a lookup, and a draft reply a person can approve in one tap. If you want to think through which step to automate first, our post on auditing one workflow before you buy AI walks through it.

I run NxFlowAI, an AI automation agency in Mumbai. The code above is illustrative and dependency-free.

Top comments (0)