Back to The Times of Claw

How to Build a CRM for E-Commerce in DenchClaw

Learn how to build a complete e-commerce CRM in DenchClaw to track customers, orders, LTV, and retention campaigns—all local-first with DuckDB.

Mark Rachapoom
Mark Rachapoom
·8 min read
How to Build a CRM for E-Commerce in DenchClaw

How to Build a CRM for E-Commerce in DenchClaw

Most e-commerce businesses have a gap: their store platform (Shopify, WooCommerce, etc.) tracks transactions, but they have no system for actually managing customer relationships. Who are your best customers? Who's about to churn? Which segment should you hit with a re-engagement campaign? That intelligence lives scattered across store dashboards, email tools, and ad platforms.

DenchClaw fixes this by giving you a local-first CRM where you own all your customer data in DuckDB — queryable with SQL, navigable with natural language, and extensible without per-seat fees.

Here's how to build a complete e-commerce CRM in DenchClaw from scratch.

What an E-Commerce CRM Tracks#

Unlike a B2B sales CRM focused on deals and pipelines, an e-commerce CRM centers on:

  • Customer profiles — who bought, how often, total spend, preferences
  • Order history — what they bought, when, at what price
  • Segments — VIP customers, one-time buyers, at-risk churners
  • Campaigns — which customers received which emails or promotions
  • Lifetime value — customer LTV, average order value, purchase frequency

DenchClaw's flexible object system handles all of this. You're not fighting against a rigid CRM schema designed for B2B sales — you're building exactly the data model your business needs.

Step 1: Define Your Objects#

Tell the agent to set up the following objects:

"Create these CRM objects: customers (for individual buyers), orders (for purchase transactions), products (for your catalog), and campaigns (for marketing outreach)"

Customers Object Fields#

fields:
  - name: Full Name
    type: text
  - name: Email
    type: email
  - name: Phone
    type: phone
  - name: Total Orders
    type: number
  - name: Lifetime Value
    type: number
  - name: Average Order Value
    type: number
  - name: First Purchase Date
    type: date
  - name: Last Purchase Date
    type: date
  - name: Customer Segment
    type: enum
    options: [VIP, Loyal, Potential Loyal, At Risk, Churned, New]
  - name: Acquisition Source
    type: enum
    options: [Organic Search, Paid Ads, Social, Referral, Email, Direct]
  - name: Notes
    type: richtext

Orders Object Fields#

fields:
  - name: Order ID
    type: text
  - name: Customer
    type: relation
    related_object: customers
  - name: Order Date
    type: date
  - name: Total Amount
    type: number
  - name: Status
    type: enum
    options: [Pending, Fulfilled, Shipped, Delivered, Returned, Refunded]
  - name: Items
    type: text
  - name: Shipping Address
    type: text

Step 2: Import Your Customer Data#

From Shopify#

DenchClaw's browser agent can log into Shopify (you're already authenticated via Chrome profile copy) and export your customer data:

"Log into my Shopify admin, go to Customers, export all customers as CSV, and import them into the customers object in DenchClaw"

Or do it manually: export from Shopify, then ask the agent to parse and import the CSV.

From WooCommerce#

WooCommerce exports a CSV with order data. Ask the agent:

"I have a WooCommerce customer export at ~/Downloads/customers.csv. Import all rows into the customers object, mapping: billing_email → Email, billing_first_name + billing_last_name → Full Name, order_count → Total Orders, total_spent → Lifetime Value"

The agent writes the SQL import directly into DuckDB.

Calculating Derived Fields#

Once order data is imported, calculate derived metrics:

-- Update Average Order Value for all customers
UPDATE entry_fields ef
SET value = CAST(
  (SELECT SUM(amount.value::decimal) / COUNT(*)
   FROM orders_view ov
   WHERE ov.customer_id = ef.entry_id) AS TEXT
)
WHERE ef.field_id = (SELECT id FROM fields WHERE name = 'Average Order Value');

Or just ask the agent: "Recalculate average order value and lifetime value for all customers based on their order history"

Step 3: Build Customer Segments#

The most powerful use of an e-commerce CRM is segmentation. Define views for each customer tier:

VIP Customers (Top 20% by LTV)#

- name: VIP Customers
  filters:
    - field: Lifetime Value
      operator: greater_than
      value: 500
    - field: Total Orders
      operator: greater_than
      value: 3
  sort:
    - field: Lifetime Value
      direction: desc

At-Risk Customers (Haven't Bought in 90+ Days)#

- name: At Risk
  filters:
    - field: Last Purchase Date
      operator: less_than_days_ago
      value: 90
    - field: Total Orders
      operator: greater_than
      value: 1

One-Time Buyers (Only One Purchase)#

- name: One-Time Buyers
  filters:
    - field: Total Orders
      operator: equals
      value: 1
  sort:
    - field: First Purchase Date
      direction: desc

These segments become your targeting lists for campaigns.

Step 4: Set Up the Customer Kanban#

For active relationship management — following up with VIPs, re-engaging at-risk customers — use the kanban view:

default_view: kanban
view_settings:
  kanbanField: "Customer Segment"

Now you can drag customers between segments as their behavior changes, and the AI agent can move them automatically based on purchase data updates.

Step 5: Build a Revenue Dashboard#

Ask the agent to build a Dench App dashboard showing your e-commerce KPIs:

"Build me a dashboard app that shows: total customers by segment (pie chart), monthly revenue trend (line chart), top 10 customers by LTV (table), and average order value this month vs last month"

The app queries your DuckDB directly:

const segmentData = await dench.db.query(`
  SELECT ef.value as segment, COUNT(*) as count
  FROM entry_fields ef
  JOIN fields f ON ef.field_id = f.id
  WHERE f.name = 'Customer Segment'
  GROUP BY ef.value
`);
 
// Render with Chart.js
new Chart(ctx, {
  type: 'pie',
  data: {
    labels: segmentData.map(r => r.segment),
    datasets: [{ data: segmentData.map(r => r.count) }]
  }
});

Step 6: Automate Segment Updates#

Keep segments fresh automatically. Ask the agent to run a daily classification job:

"Every morning at 7am, reclassify customer segments based on: LTV > $500 and orders > 3 = VIP, orders > 1 and last purchase < 30 days = Loyal, last purchase between 30-90 days = At Risk, last purchase > 90 days = Churned, first purchase within 30 days = New"

The agent creates a cron job that runs the classification SQL nightly.

Step 7: Campaign Tracking#

Add a campaigns object to track which customers you've reached out to and with what offer:

fields:
  - name: Campaign Name
    type: text
  - name: Segment Targeted
    type: relation
    related_object: customers
  - name: Launch Date
    type: date
  - name: Offer
    type: text
  - name: Open Rate
    type: number
  - name: Revenue Generated
    type: number

After running a re-engagement email campaign, log the results. Ask the agent: "Log the results of our March re-engagement campaign: 847 customers targeted, 23% open rate, $4,200 revenue generated"

Combining E-Commerce Data with Your Support History#

Add a support_tickets object and link it to customers. Now you can see — for any VIP customer — how many support issues they've had. This context is invaluable when a high-LTV customer contacts your team.

Because DenchClaw is a local CRM with full SQL access, these cross-object queries run instantly:

"Show me all VIP customers who've had more than 2 support tickets in the past 6 months"

Frequently Asked Questions#

Can DenchClaw replace Klaviyo or Drip for e-commerce email marketing?#

DenchClaw is a CRM for relationship management, not a full email service provider. Use DenchClaw to segment customers and track campaign results, while continuing to use an ESP for actual email delivery. DenchClaw can pass segments to your ESP via CSV export or API, and import campaign results back.

How do I sync real-time order data from Shopify?#

The cleanest approach is Shopify webhooks → DenchClaw webhook endpoint. Configure Shopify to fire a webhook on new orders, and DenchClaw creates an order entry and updates the customer's total orders and LTV fields automatically.

Is DenchClaw suitable for a store with 100,000+ customers?#

DuckDB handles analytical queries on millions of rows efficiently — it's designed for this. For a 100k customer base, DenchClaw performs excellently as an analytics and segmentation layer. For transactional operations (real-time order processing), keep your Shopify/WooCommerce stack and use DenchClaw for the relationship intelligence layer on top.

Can I connect DenchClaw to Facebook Ads to track acquisition source?#

Not natively, but the browser agent can log into your Facebook Ads manager and pull acquisition data. Alternatively, use UTM parameters on your website and pass the acquisition source in your form webhook payload.

How do I export a segment for an email campaign?#

Ask the agent: "Export all At Risk customers as a CSV with name, email, last purchase date, and lifetime value". It runs the SQL and saves the file, ready to import into your email platform.

Ready to try DenchClaw? Install in one command: npx denchclaw. Full setup guide →

Mark Rachapoom

Written by

Mark Rachapoom

Building the future of AI CRM software.

Continue reading

DENCH

© 2026 DenchHQ · San Francisco, CA