Context (Context Schemas)
Pass contact context to your AI for personalized responses
Context (Context Schemas) lets you inject real-time contact information into conversations. Unlike memory (which is learned), context is passed from your system at conversation start.
What Is Context?
Context is information about the contact you pass to Goldilocks:
- Contact 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 contact data
- Data is passed when initializing the widget
- AI receives this context
- Responses are personalized based on context
Context Schemas
Schemas define what data fields you'll pass and how the AI should use them.
Viewing Schemas
- Go to AI Agents > Context
- See list of configured schemas
- Click to view/edit details
Creating a Schema
- Go to AI Agents > Context
- Click Create Schema
- Fill in:
- Name - "Contact 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
Contact Name:
path: customer.name
type: string
label: Contact Name
description: The contact's full name
ai_hint: Use to address the contact 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 contact's cart
ai_hint: Reference when discussing purchases or recommendations
sensitivity: none
visibility: contextualPassing Data to Widget
Pass context when initializing the widget:
Basic Example
gl_chat('init', {
apiKey: 'your-key',
customerId: 'cust_123',
settings: {
customer: {
name: 'John Smith',
email: 'john@example.com'
},
subscription: {
plan: 'pro',
status: 'active'
}
}
});Or identify after init:
gl_chat('identify', {
id: 'cust_123',
name: 'John Smith',
email: 'john@example.com',
plan: 'pro',
subscription_status: 'active'
});Shopify Example
gl_chat('identify', {
id: '{{ customer.id }}',
name: '{{ customer.name }}',
email: '{{ customer.email }}',
orders_count: {{ customer.orders_count }},
total_spent: '{{ customer.total_spent }}'
});Using Templates
Goldilocks offers pre-built schema templates:
Available Templates
| Template | Description |
|---|---|
| Shopify | Contact, 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 > Context
- 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:
- Contact 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 Context
- 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:
- Contact 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