What it does

PayFox turns any Facebook Page into an AI-powered store inside Messenger. Customers send a voice note, browse a product catalog, tap "Buy", and pay with PayPal — all in the same chat. Payments confirm automatically via webhooks.

One voice note → product cards → one tap → paid → receipt. Automatically.

Inspiration

Over 500 million people use Facebook Messenger every month. Millions of small businesses — especially in Southeast Asia — sell through chat. But taking payment means sending bank account numbers, waiting for transfer screenshots, and manual reconciliation. That's friction, fraud risk, and lost sales.

We asked: what if the entire store — catalog, checkout, payment, receipt — lived inside one chat?

How we built it

The flow (end-to-end, working live):

  1. Discover — new customer opens the chat → automatic welcome message
  2. Browse — voice note or type "catalog" → product cards with photos, prices, and Buy buttons (Messenger Generic Template)
  3. Buy — tap Buy Now → PayFox creates a PayPal order (Orders API v2) and sends the payment link
  4. Pay — customer pays on PayPal (card, bank, or balance)
  5. Auto-capture — PayPal webhook CHECKOUT.ORDER.APPROVED → PayFox auto-captures the payment → money moves
  6. Receipt — PayPal webhook PAYMENT.CAPTURE.COMPLETED → PayFox sends a receipt card (Messenger Receipt Template) with the customer's name, product photo, order number, and total — automatically in chat

PayPal APIs used:

  • Orders API v2 — create order, approve link, auto-capture on approval
  • OAuth2 — client credentials token management
  • Webhooks — live-registered; APPROVED triggers capture, COMPLETED triggers the receipt card
  • Invoicing v2 — paypal_invoice tool for formal B2B orders

AI brain:

  • Muse Spark 1.3 (Meta Model API) — routes intents, calls tools, transcribes voice notes, writes every reply. Zero hardcoded responses — even the quick "On it!" acknowledgment is model-generated via a parallel intent-router request.

Store management:

  • Store owners manage the catalog conversationally: "add product: Gayo Coffee 1kg, $35" → the catalog updates instantly
  • Product photos generated with Muse Image
  • Product cards served via Messenger Generic Templates
  • Order tracking (order_id → Messenger user) persists to disk — webhooks survive restarts

Challenges we faced

The tool-routing fix. Early versions confused "show catalog" with "add product" — the model picked the wrong tool 100% of the time with real users. Fix: tool descriptions with explicit routing rules + a system prompt that maps intent → tool name. Result: 100% correct routing in E2E tests.

The catalog singleton bug. Two catalog instances (one for the agent, one for the webhook handler) meant every Buy button tap returned "product not found" — the agent added products to one catalog, the BUY button read from a stale second one. Fix: one shared catalog instance across the entire process.

The auto-capture lesson. PayPal Orders API is two-step: customer approves, then the merchant captures. Without the capture call, money stays in limbo even after the customer pays. PayFox auto-captures on the APPROVED webhook — money moves without human intervention.

Dev-mode Messenger. The demo runs in development mode (standard pre-launch). Production rollout requires Meta's app review. The harness is production-ready beyond that gate.

What we learned

  • Conversational commerce needs precise tool routing — "similar" tool descriptions confuse LLMs. Explicit routing rules in system prompts are the fix.
  • PayPal webhooks are the backbone of automated commerce — they turn a "payment sent" into "order confirmed, receipt delivered, customer informed" without any human in the loop.
  • The difference between a tech demo and a product is the confirmation loop: welcome → browse → buy → pay → automatic receipt. If the customer doesn't get instant proof of payment, trust breaks. ## What it does

How we built it

Challenges we ran into

Accomplishments that we're proud of

What we learned

What's next for PayFox — AI Commerce Agent

Built With

Share this project:

Updates

Submission history