Goldilocks Docs
AI Agents

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

  1. Your website collects contact data
  2. Data is passed when initializing the widget
  3. AI receives this context
  4. 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

  1. Go to AI Agents > Context
  2. See list of configured schemas
  3. Click to view/edit details

Creating a Schema

  1. Go to AI Agents > Context
  2. Click Create Schema
  3. Fill in:
    • Name - "Contact Context"
    • Description - What this schema contains
  4. Add fields
  5. Save

Schema Fields

Each field in your schema represents a piece of data.

Field Properties

PropertyDescription
PathJSON path (e.g., customer.name)
Typestring, number, boolean, array, object
LabelHuman-readable name
DescriptionWhat this field contains
AI HintHow AI should use this field
Sensitivitynone, internal, pii, secret
Visibilityalways, 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: always

Subscription 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: always

Cart 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: contextual

Passing 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

TemplateDescription
ShopifyContact, order, cart data
Generic E-commerceStandard e-commerce fields
SaaSSubscription, usage data
CustomBuild your own

Adopting a Template

  1. Go to AI Agents > Context
  2. Click Create from Template
  3. Select a template
  4. Customize fields as needed
  5. 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:

LevelDescriptionHandling
NonePublic infoNormal use
InternalBusiness-sensitiveUse carefully
PIIPersonal infoPrivacy protections
SecretHighly sensitiveRedact/mask

Linking to Personas

Connect schemas to specific personas:

  1. Go to persona configuration
  2. Find Context Schemas section
  3. Select schemas to use
  4. Set priority if multiple

Generating Embed Code

Get embed code with your schema fields:

  1. Go to Widget > Embed
  2. Select your schema
  3. Choose your platform (Shopify, custom, etc.)
  4. Copy the generated code
  5. Update placeholder values

Testing Context

  1. Go to Widget > Preview
  2. Open developer tools
  3. Pass test data in configuration
  4. 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