_SH Log's
Back to Root
EST: 4 min read

How I Built BikroyBuddy: AI Social-Commerce Agent

BikroyBuddy is an AI shopping agent for Bangladesh handling discovery and negotiation over chat, serving 5,000+ users. Here's the full architecture.

#ai-agents#go#social-commerce#bangladesh

BikroyBuddy is an AI shopping agent built for Bangladesh's social-commerce market — where buying and selling happens on Facebook groups and WhatsApp, not structured marketplaces. It handles product discovery, price negotiation, and deal summaries over chat, serving 5,000+ active users.

The market problem

Bangladesh's informal e-commerce is dominated by Facebook group commerce — sellers post photos and prices in unstructured text, buyers negotiate in comment threads. There's no search, no structured catalog, no price history. BikroyBuddy crawls these sources and turns them into a queryable AI agent.

Architecture

User (WhatsApp / Web chat)
  → Webhook handler (Go)
  → Intent classifier (Claude Haiku — fast, cheap)
  → [Branch on intent]
      → Product search → pgvector semantic search + metadata filter
      → Negotiation → Claude Sonnet + negotiation state machine
      → Summarize deal → Claude Haiku
  → Response formatter → WhatsApp API / WebSocket

Intent classification runs on Claude Haiku ($0.00025/1k tokens) because 80% of messages are simple product queries. Negotiation and complex reasoning escalate to Sonnet.

Product catalog ingestion

Facebook group posts are unstructured. I use a two-stage pipeline:

type RawPost struct {
    Text      string
    ImageURLs []string
    Timestamp time.Time
    GroupID   string
}

type StructuredProduct struct {
    Name        string
    Price       int    // BDT
    Condition   string // new, used, refurbished
    Location    string
    Embedding   []float32 // 1536-dim, text-image
    SourceURL   string
}

Stage 1: Claude Vision extracts structured fields from post text + image. Stage 2: text+image embedding via OpenAI's text-embedding-3-small stored in pgvector.

Negotiation state machine

Negotiation in Bangladeshi commerce follows predictable patterns. I modeled it as a state machine rather than free-form LLM generation:

OPEN → BUYER_OFFER → SELLER_COUNTER → AGREED | FAILED

Each state has a prompt template + constraints (e.g., never go below seller's floor price, never exceed buyer's stated budget). The LLM fills in culturally appropriate phrasing — respectful Bangla negotiation language matters here.

type NegotiationState struct {
    Phase        Phase
    SellerFloor  int
    BuyerCeiling int
    CurrentOffer int
    Turns        int
}

func (n *NegotiationState) NextMove(llm LLMClient) (string, error) {
    if n.Turns > 8 {
        return n.generateFallback(), nil // prevent infinite loops
    }
    return llm.Complete(negotiationPrompt(n))
}

Capping turns at 8 prevents infinite negotiation loops — real negotiations in Bangladesh close in 3–5 exchanges or not at all.

Scale challenges at 5,000 users

The biggest bottleneck was webhook delivery from WhatsApp's Cloud API — it doesn't guarantee order, and out-of-order messages broke the negotiation state machine.

Fix: Redis-based per-conversation message queue with a 200ms coalescing window. Messages arriving within 200ms of each other are processed as a batch in timestamp order.

func (w *Worker) processConversation(convID string) {
    msgs := w.redis.LRange(ctx, "conv:"+convID, 0, -1)
    sort.Slice(msgs, func(i, j int) bool {
        return msgs[i].Timestamp.Before(msgs[j].Timestamp)
    })
    for _, msg := range msgs {
        w.handle(msg)
    }
}

Localization: Bangla + English code-switching

Bangladeshi users naturally mix Bangla and English (Banglish). The system prompt instructs the LLM to respond in whatever language ratio the user used. If input is 70% Bangla, output is 70% Bangla. This detail improved retention measurably.

FAQ

What is BikroyBuddy? BikroyBuddy is an AI shopping agent designed for Bangladesh's social-commerce ecosystem, enabling product discovery and price negotiation over WhatsApp and web chat.

How does it handle unstructured Facebook commerce data? It uses Claude Vision to extract structured product data from unstructured social posts, then stores vector embeddings in pgvector for semantic search.

What language model powers the negotiation? Intent classification uses Claude Haiku for speed and cost. Complex negotiation uses Claude Sonnet within a deterministic state machine that prevents runaway conversations.

How many users does BikroyBuddy have? 5,000+ active users as of mid-2026.

Why build for Bangladesh specifically? Bangladesh's social-commerce market is large and underserved by Western platforms. Local context — Bangla language, BDT pricing, informal negotiation culture — is a moat that generic tools can't replicate.


Written by Shihab Shahriar Antor — AI Engineer & Founder at Shahriar Labs. See also: Scaling an AI Agent to 300k+ Users on Kubernetes.