User Data & Context Schemas
Pass customer context to your AI for personalized responses
User Data (Context Schemas) let you inject real-time customer information into conversations. Unlike memory (which is learned), user data is passed from your system at conversation start.
What Is User Data?
User data is information about the customer you pass to Goldilocks:
- Customer attributes - Name, email, plan
- Session data - Current page, cart contents
- Account details - Subscription status, tenure
- Custom fields - Any business-specific data
How It Works
- Your website collects customer data
- Data is passed when initializing the widget
- AI receives this context
- Responses are personalized based on data
Context Schemas
Schemas define what data fields you'll pass and how the AI should use them.
Viewing Schemas
- Go to AI Agents > User Data (or Personalization)
- See list of configured schemas
- Click to view/edit details
Creating a Schema
- Go to AI Agents > User Data
- Click Create Schema
- Fill in:
- Name - "Customer Context"
- Description - What this schema contains
- Add fields
- Save
Schema Fields
Each field in your schema represents a piece of data.
Field Properties
| Property | Description |
|---|---|
| Path | JSON path (e.g., customer.name) |
| Type | string, number, boolean, array, object |
| Label | Human-readable name |
| Description | What this field contains |
| AI Hint | How AI should use this field |
| Sensitivity | none, internal, pii, secret |
| Visibility | always, contextual, never |
Example Fields
Customer Name:
path: customer.name
type: string
label: Customer Name
description: The customer's full name
ai_hint: Use to address the customer personally
sensitivity: pii
visibility: alwaysSubscription Plan:
path: subscription.plan
type: string
label: Plan Type
description: Current subscription plan (free, pro, enterprise)
ai_hint: Use to provide plan-appropriate guidance
sensitivity: none
visibility: alwaysCart Contents:
path: cart.items
type: array
label: Shopping Cart
description: Items currently in the customer's cart
ai_hint: Reference when discussing purchases or recommendations
sensitivity: none
visibility: contextualPassing Data to Widget
Pass user data when initializing the widget:
Basic Example
new Goldilocks({
apiKey: 'your-key',
customerId: 'cust_123',
customerData: {
customer: {
name: 'John Smith',
email: 'john@example.com'
},
subscription: {
plan: 'pro',
status: 'active'
}
}
});Shopify Example
new Goldilocks({
apiKey: 'your-key',
customerId: '{{ customer.id }}',
customerData: {
customer: {
name: '{{ customer.name }}',
email: '{{ customer.email }}',
orders_count: {{ customer.orders_count }},
total_spent: '{{ customer.total_spent }}'
},
shop: {
name: '{{ shop.name }}',
currency: '{{ shop.currency }}'
}
}
});Using Templates
Goldilocks offers pre-built schema templates:
Available Templates
| Template | Description |
|---|---|
| Shopify | Customer, order, cart data |
| Generic E-commerce | Standard e-commerce fields |
| SaaS | Subscription, usage data |
| Custom | Build your own |
Adopting a Template
- Go to AI Agents > User Data
- Click Create from Template
- Select a template
- Customize fields as needed
- Save
Template Updates
When templates are updated:
- You're notified of changes
- Can adopt new version or keep current
- Existing data mappings preserved
Field Visibility
Control when fields are included in AI context:
Always
Always included in AI context:
- Customer name
- Account type
- Core identifiers
Contextual
Included only when relevant:
- Cart contents (for purchase questions)
- Order history (for order questions)
- Technical details (for tech support)
Never
Never sent to AI:
- Passwords
- Full credit card numbers
- Internal system IDs
Sensitivity Levels
Mark fields appropriately:
| Level | Description | Handling |
|---|---|---|
| None | Public info | Normal use |
| Internal | Business-sensitive | Use carefully |
| PII | Personal info | Privacy protections |
| Secret | Highly sensitive | Redact/mask |
Linking to Personas
Connect schemas to specific personas:
- Go to persona configuration
- Find Context Schemas section
- Select schemas to use
- Set priority if multiple
Generating Embed Code
Get embed code with your schema fields:
- Go to Widget > Embed
- Select your schema
- Choose your platform (Shopify, custom, etc.)
- Copy the generated code
- Update placeholder values
Testing User Data
- Go to Widget > Preview
- Open developer tools
- Pass test data in configuration
- Verify AI references the data appropriately
Best Practices
Pass Relevant Data Only
Don't pass everything—only what helps the AI:
Good:
- Customer name, plan, tenure
- Recent orders, open tickets
- Relevant preferences
Avoid:
- Internal IDs with no meaning
- Excessive historical data
- Sensitive unnecessary data
Keep Data Fresh
Ensure passed data is current:
- Pull data at widget load
- Refresh for long sessions
- Handle missing data gracefully
Handle Missing Data
Not all data is always available:
customerData: {
customer: {
name: customerName || 'Guest',
plan: customerPlan || 'unknown'
}
}Document Your Schema
Maintain documentation of:
- What fields you pass
- Where data comes from
- How AI should use it