Architecture
All CRM data lives in thecrm_entries Elasticsearch index. Each entry is linked to an external record via two fields:
| Field | Type | Description |
|---|---|---|
reference_type | keyword | The type of record (e.g. customer, order, lead) |
reference_id | keyword | The ID of the referenced record |
Concepts
Entities
An entity defines a type of CRM record (e.g. “Deals”, “Contacts”, “Tracker”). Each entity has:- A name and slug (machine-readable identifier)
- Fields that define the data structure
- Pipelines with stages for workflow tracking
Fields
Fields define what data can be stored on entries. Each field has:| Property | Description |
|---|---|
label | Human-readable label |
key | Machine-readable key (used in API and templates) |
type | text, number, date, boolean, or select |
Pipelines & Stages
Pipelines represent workflows. Each pipeline contains ordered stages with optional colors and semantic statuses (e.g.won, lost, active). Entries move through stages as they progress.
Customer CRM Data
The most common pattern is linking CRM entries to customers. When a customer visits a page, the template engine automatically resolves theircustomer_id from Elasticsearch (creating the customer record if needed).
Example: Weight Loss Tracker
- Create a CRM entity called “Weight Tracker” with fields like
current_weight,goal_weight,last_checkin - Create a pipeline “Progress” with stages “Starting”, “In Progress”, “Goal Reached”
- Store data via backend scripts or the template engine:
- Read it back on any page:
Viewing Customer CRM Data
Customer CRM entries are visible in the Customer Details page under the CRM tab. This shows all CRM entries linked to that customer across all entity types.Template Engine Functions
The CRM adapter exposes three functions in the template engine:| Function | Description |
|---|---|
getCrmEntries({ slug, ... }) | Fetch entries for one entity slug + reference |
getCrmField({ slug, fieldKey, ... }) | Get one field (slug + fieldKey required) |
setCrmField({ slug, fieldKey, value, ... }) | Set one field (slug, fieldKey, value required) |
slug is always required (the entity’s slug from CRM settings). Reference defaults: customer + session customer id.