Skip to content
chatAgent
Esc
↑↓navigate↵open⌘Jpreview
On this page

WhatsApp Shopping Bot

WhatsApp Shopping Bot

Project Overview

AI-powered WhatsApp bot for shopping sites. Uses Rivet durable actors for per-user isolation, AgentOS for sandboxed execution, Pi Agent Core for LLM orchestration, and @shopify/dev-mcp for e-commerce integration.

Each user automatically gets a dedicated actor on first message — no registration, no signup. The actor is durable, sleeps when idle, and survives restarts.

High-Level System View

graph TB
    subgraph "User Layer"
        USER[WhatsApp User] --> WA[WhatsApp Cloud API]
    end

    subgraph "Gateway Layer"
        WA -->|webhook| GW[FastAPI<br/>Thin Router]
    end

    subgraph "Actor Layer (Rivet)"
        GW -->|get_actor| R[Rivet Runtime]
        R --> A1["Actor A<br/>(AgentOS + Pi Agent)"]
        R --> A2["Actor B<br/>(AgentOS + Pi Agent)"]
        R --> AN["Actor N<br/>(AgentOS + Pi Agent)"]
    end

    subgraph "Service Layer"
        A1 --> MCP["@shopify/dev-mcp"]
        A1 --> LLM[LLM Provider]
        A1 --> STATE[(Rivet Durable State)]
    end

    MCP --> SHOP[Shopify Storefront]
    A1 -->|reply| WA
    WA --> USER

    style R fill:#f3e5f5,stroke:#7b1fa2,stroke-width:3px
    style A1 fill:#c8e6c9,stroke:#388e3c
    style A2 fill:#c8e6c9,stroke:#388e3c
    style AN fill:#c8e6c9,stroke:#388e3c

Key Design Choices

Choice Decision Why
Agent management Rivet actors (not in-process pool) Durability, distribution, free concurrency
Agent runtime Pi Agent Core (Python) Mature tool calling, streaming, multi-LLM
Sandbox AgentOS (V8 isolates) 92× faster cold starts than containers
E-commerce Official @shopify/dev-mcp First-party, Storefront-scoped, cart/checkout built-in
Messaging WhatsApp Cloud API Official, scalable, webhooks
State Rivet Durable State Built-in persistence, survives restarts
Language Python 3.12+ Async-native, rich ecosystem

Current Phase

Stage 1: Shopify integration

Core Requirements

  • Not a general chatbot — executes tools to send WhatsApp messages
  • Isolates actors per user (Rivet durable actors)
  • Natural language product discovery (via MCP tools)
  • Runs inside AgentOS V8 isolates
  • Uses WhatsApp Cloud API for messaging
  • Defense in depth: rate limits, injection detection, sanitization

User Journey

sequenceDiagram
    actor U as User
    participant W as WhatsApp
    participant G as Gateway
    participant R as Rivet
    participant A as Actor
    participant P as Pi Agent
    participant S as Shopify

    U->>W: "Show me laptops under $1000"
    W->>G: Webhook POST
    G-->>W: 200 OK (instant)
    G->>R: get_actor(user_id)

    alt First message
        R->>A: Create + on_init()
    end

    R-->>G: actor
    G->>A: on_message(text)
    A->>P: agent.prompt(text)
    P->>S: search_shop_catalog(query)
    S-->>P: 5 products
    P-->>A: Response
    A-->>G: Response
    G->>W: Send reply
    W-->>U: Display products

    U->>W: "Tell me more about the Dell XPS"
    W->>G: Webhook POST
    G-->>W: 200 OK
    G->>R: get_actor(user_id)
    R-->>G: actor (same one)
    G->>A: on_message(text)
    Note over A: Has full conversation history
    A->>S: get_product_details(handle)
    S-->>A: Full specs
    A-->>G: Response
    G->>W: Send reply
    W-->>U: Display specs

    Note over A: Sleeps after 5min idle

Key Decisions Log

Date Decision Rationale
2026-07-26 Use Official @shopify/dev-mcp Shopify’s first-party MCP: Storefront-scoped, cart/checkout built-in
2026-07-26 Pi Agent Core (Python) over building from scratch Mature agent runtime with tool calling, streaming
2026-07-26 Rivet actors over in-process pool Durability, distribution, free concurrency management
2026-07-26 AgentOS (V8 isolates) over containers 92× faster cold starts, 47× less memory
2026-07-26 FastAPI thin gateway No agent logic in gateway, just routing
2026-07-26 Durable state in Rivet Built-in persistence, no manual save/restore

Architecture Documents

Document Scope
Architecture High-level system overview
Agent Architecture Agent stack and layers
Rivet Actor Model Actor implementation (canonical)
Agent Lifecycle Message → actor flow
AgentOS Configuration Sandbox setup
Pi Agent Setup Pi Agent Core installation
Pi Agent Core API Reference Python API reference
Building Pi Extensions Extension development
Concurrency & Security Rate limiting, injection
Shopify Integration Research MCP decision
WhatsApp Business Cloud API WhatsApp integration
Integration Guide End-to-end wiring

Next Steps

  1. ✅ Shopify integration research
  2. ✅ Integration approach selected (Official MCP)
  3. ✅ Architecture designed (Rivet actors)
  4. 🔲 Clone + study Shopify/shop-chat-agent reference
  5. 🔲 Set up Shopify Partner account + dev store
  6. 🔲 Set up WhatsApp Business API access
  7. 🔲 Build minimal actor with one MCP tool
  8. 🔲 Add security layers (rate limit, injection)
  9. 🔲 Integrate with WhatsApp webhook
  10. 🔲 End-to-end prototype

Last updated on July 26, 2026