User input: “Create a segment of enterprise users who haven’t logged in for 30 days.”
Step 1: Resolve the criteria
The AI begins by looking up available traits before constructing anything. It doesn’t assume field names. It verifies them first.
GET /api/autoComplete?finder=byUserTraits&q=plan
→ { results: [{ name: "plan", type: "string", count: 5432 }] }
GET /api/autoComplete?finder=byUserTraits&q=last
→ { results: [{ name: "last_seen_at", type: "datetime", count: 5432 }] }
The AI uses autocomplete_query to verify real field names before building the payload. It doesn’t guess.
POST /api/dashboard/segmentsDefinition
{ "name": "Enterprise Users - Inactive 30 Days",
"description": "Enterprise plan users who haven't logged in for 30+ days" }
→ { "id": "seg_9x8y7z6w", "definition": null }
The shell is created with no definition — that gets applied in the next call, after the user confirms.
Confirmation panel
POST /api/dashboard/segmentsDefinition?action=update&segmentId=seg_9x8y7z6w
{
"definition": {
"object": "All",
"groups": [
{ "object": "Single", "type": "UserProperty",
"traitName": "plan", "operation": { "type": "Equals", "operand": "enterprise" } },
{ "object": "Single", "type": "UserSeen",
"userSeenRuleType": "LastSeen", "operation": { "type": "Outside", "operand": 30 } }
]
}
}
→ { "id": "seg_9x8y7z6w", "memberCount": 247 }
Step 2: Test the segment
The wizard advances automatically. At step 2 the wizard prompts: “We’ve created your segment. Let’s test it: do you have a user ID or email in mind?”
GET /api/autoComplete?finder=byUserEmail&q=john@acme.com
→ { results: [{ userId: "usr_abc123", email: "john@acme.com" }] }
GET /api/dashboard/segmentMemberships/usr_abc123
→ { isMember: true, matchedRules: [
{ type: "UserProperty", traitName: "plan", matched: true },
{ type: "UserSeen", matched: true, daysSinceLastSeen: 45 }
] }
The AI responds: “john@acme.com is in this segment. Plan: enterprise. Last seen: 45 days ago. Your segment is working correctly.”
Execution summary
| Action | Endpoint | Policy | Time | Status |
|---|
autocomplete_query | byUserTraits q=plan | Automatic | 87ms | 200 |
autocomplete_query | byUserTraits q=last | Automatic | 92ms | 200 |
segments_create | POST /api/dashboard/segmentsDefinition | Confirm | 234ms | 201 |
segments_update | POST …?action=update | Confirm | 412ms | 200 |
autocomplete_query | byUserEmail | Automatic | 65ms | 200 |
segment_membership_get | usr_abc123 | Automatic | 143ms | 200 |
6 actions · 1,033ms · 100% success
The four reads ran silently. The two writes paused for user confirmation before firing.
What if something fails
If the segments API times out on load, the wizard surfaces a connection error with two options: Retry, or Continue Anyway. If the user continues, the AI builds the segment from scratch without deduplication checks.