Prerequisites

Before creating training examples, ensure you have:

Account & Agent Setup

  • StateSet account with API access
  • At least one agent created and configured
  • API credentials from the StateSet Dashboard

Technical Requirements

  • Node.js 16+ installed (for SDK examples)
  • Basic understanding of REST APIs and JavaScript
  • Text editor for JSON/code editing

Training Data

  • Collection of real customer conversations for training data
  • Access to your customer support team for example validation
  • Understanding of your brand voice and service standards

Domain Knowledge

  • Familiarity with machine learning concepts (helpful)
  • Understanding of conversational AI training principles
  • Knowledge of your customer service workflows and scenarios

Introduction

Examples are the cornerstone of training effective AI agents in StateSet ReSponse. By providing real conversation examples, you teach your agents how to handle various scenarios, maintain consistent tone, and deliver accurate responses. This guide will show you how to create, manage, and optimize examples for maximum agent performance.

What are Examples?

Examples are curated conversation snippets that demonstrate ideal agent behavior. They consist of:

  • User Input: The customer’s question or statement
  • Agent Response: The ideal response from your agent
  • Context: Metadata about the scenario (tags, categories, sentiment)
  • Annotations: Notes about why this response is effective

Why Examples Matter

Consistency

Ensure uniform responses across all agents and channels

Accuracy

Reduce hallucinations and improve factual correctness

Brand Voice

Maintain your unique brand personality in every interaction

Getting Started

1

Install the SDK

npm install stateset-node
2

Initialize the Client

const { StateSetClient } = require('stateset-node');

const client = new StateSetClient({
  apiKey: process.env.STATESET_API_KEY
});
3

Create Your First Example

const example = await client.examples.create({
  category: 'order_status',
  user_input: 'Where is my order? I placed it 3 days ago.',
  agent_response: `I'd be happy to help you track your order! To locate it quickly, could you please provide your order number or the email address used for the purchase? 
  
  Once I have that information, I'll check the current status and expected delivery date for you right away.`,
  tags: ['order_tracking', 'polite_request', 'information_gathering'],
  sentiment: 'neutral',
  effectiveness_score: 0.95
});

Example Categories

1. Customer Service Scenarios

Order Inquiries

const orderExample = await client.examples.create({
  category: 'order_status',
  user_input: 'My order #12345 hasn\'t arrived yet',
  agent_response: `I understand your concern about order #12345. Let me check that for you right away.

I can see your order was shipped on [date] via [carrier] with tracking number [tracking]. According to the latest update, it's currently in [location] and expected to arrive by [date].

If it doesn't arrive by then, please let me know and I'll be happy to help resolve this for you, including exploring replacement or refund options.`,
  tags: ['order_tracking', 'proactive_solution', 'empathy'],
  metadata: {
    requires_data: ['order_number', 'shipping_info'],
    tone: 'empathetic_professional'
  }
});

Product Questions

const productExample = await client.examples.create({
  category: 'product_inquiry',
  user_input: 'What\'s the difference between the Pro and Standard versions?',
  agent_response: `Great question! Let me break down the key differences between our Pro and Standard versions:

**Standard Version:**
- Core features for everyday use
- 5GB storage
- Email support
- Perfect for individuals

**Pro Version:**
- All Standard features PLUS:
- Unlimited storage
- Priority 24/7 support
- Advanced analytics
- Team collaboration tools
- API access

The Pro version is ideal if you need team features or extensive storage. Would you like me to help you choose which one best fits your needs?`,
  tags: ['product_comparison', 'structured_response', 'upsell_opportunity'],
  effectiveness_score: 0.92
});

2. Technical Support Examples

Troubleshooting

const troubleshootingExample = await client.examples.create({
  category: 'technical_support',
  user_input: 'The app keeps crashing when I try to upload photos',
  agent_response: `I'm sorry you're experiencing crashes with photo uploads. Let's troubleshoot this together:

1. **Quick Fix** - Try these first:
   - Force close the app and restart it
   - Check if you have at least 500MB free storage
   - Ensure you're on WiFi (large uploads can fail on cellular)

2. **If still crashing:**
   - Update to the latest app version (Settings > About > Check Updates)
   - Clear app cache (Settings > Storage > Clear Cache)

3. **Still having issues?**
   - What device and OS version are you using?
   - What's the file size of the photos?
   - Does it crash with all photos or specific ones?

Let me know what happens, and I'll help you get this resolved!`,
  tags: ['troubleshooting', 'step_by_step', 'diagnostic_questions'],
  metadata: {
    escalation_point: 'step_3',
    requires_follow_up: true
  }
});

3. Sales and Upsell Examples

Subscription Upgrade

const upsellExample = await client.examples.create({
  category: 'sales_upsell',
  user_input: 'I\'m running out of storage space',
  agent_response: `I see you're getting close to your storage limit! You're currently using 4.8GB of your 5GB Standard plan.

Here are your options:

**Immediate Solution:**
- Free up space by removing old files (I can help identify large files)

**Long-term Solution - Upgrade to Pro:**
- Unlimited storage (never worry about limits again)
- Only $10/month more than your current plan
- Includes bonus features like priority support and advanced analytics
- **Special offer**: Upgrade today and get the first month 50% off!

Would you like me to help free up space now, or shall I tell you more about the Pro benefits?`,
  tags: ['upsell', 'problem_solving', 'value_proposition', 'urgency'],
  conversion_rate: 0.34
});

4. Complaint Resolution

Refund Request

const complaintExample = await client.examples.create({
  category: 'complaint_resolution',
  user_input: 'This product is terrible! I want a full refund immediately!',
  agent_response: `I sincerely apologize that our product hasn't met your expectations. Your satisfaction is extremely important to us, and I want to make this right.

I can absolutely help you with a refund. To process this quickly:

1. I'll initiate a full refund to your original payment method
2. You'll receive a confirmation email within the next hour
3. The refund will appear in your account within 3-5 business days

Additionally, I'd love to understand what went wrong so we can improve. Would you mind sharing what specific issues you experienced? This helps us serve customers better in the future.

Is there anything else I can help resolve for you today?`,
  tags: ['de-escalation', 'refund_process', 'feedback_request', 'empathy'],
  sentiment: 'negative',
  resolution_score: 0.89
});

Best Practices

1. Example Quality Guidelines

// ❌ Poor Example - Too brief, no personality
{
  user_input: "Where's my order?",
  agent_response: "Check your email for tracking info."
}

// ✅ Good Example - Helpful, branded, actionable
{
  user_input: "Where's my order?",
  agent_response: `I'd be happy to help locate your order! 
  
  To find it quickly, I'll need either:
  - Your order number (starts with #)
  - The email address used for purchase
  
  Once you share that, I'll pull up the tracking details and expected delivery date immediately.`
}

2. Organizing Examples

Create a structured taxonomy:

// Create examples with consistent categorization
const exampleCategories = [
  'order_management',
  'product_support',
  'billing_inquiries',
  'technical_issues',
  'account_management',
  'complaints',
  'general_questions'
];

// Tag examples for easy retrieval
const tags = [
  'requires_authentication',
  'sensitive_data',
  'escalation_candidate',
  'positive_feedback',
  'negative_feedback'
];

3. Regular Updates

// Track example performance
async function analyzeExampleEffectiveness(exampleId) {
  const metrics = await client.examples.getMetrics(exampleId);
  
  if (metrics.usage_count > 100 && metrics.satisfaction_score < 0.7) {
    // Flag for review
    await client.examples.update(exampleId, {
      needs_review: true,
      review_reason: 'Low satisfaction score'
    });
  }
}

// Batch update examples based on feedback
async function improveExamples() {
  const underperforming = await client.examples.list({
    filter: { satisfaction_score: { $lt: 0.7 } },
    limit: 50
  });
  
  for (const example of underperforming) {
    // Analyze common issues and update
    const improved = await improveResponseWithAI(example);
    await client.examples.update(example.id, improved);
  }
}

Advanced Techniques

Dynamic Example Generation

// Generate examples from real conversations
async function createExampleFromConversation(conversationId, messageId) {
  const conversation = await client.conversations.get(conversationId);
  const message = conversation.messages.find(m => m.id === messageId);
  
  if (message.satisfaction_score >= 0.9) {
    const example = await client.examples.create({
      user_input: message.user_input,
      agent_response: message.agent_response,
      category: detectCategory(message),
      tags: extractTags(message),
      source: 'real_conversation',
      conversation_id: conversationId
    });
    
    return example;
  }
}

Multi-turn Examples

// Create examples for complex, multi-turn conversations
const multiTurnExample = await client.examples.create({
  category: 'complex_support',
  conversation_flow: [
    {
      turn: 1,
      user: "I can't log into my account",
      agent: "I'd be happy to help you regain access. Are you receiving any error messages?"
    },
    {
      turn: 2,
      user: "Yes, it says 'Invalid credentials'",
      agent: "Thanks for that information. Let's verify your account. What email address are you using to log in?"
    },
    {
      turn: 3,
      user: "john@example.com",
      agent: "I found your account. For security, I'll send a password reset link to jo***@example.com. You should receive it within 5 minutes. Would you like me to send it now?"
    }
  ],
  tags: ['multi_turn', 'account_recovery', 'security_conscious']
});

A/B Testing Examples

// Test different response styles
async function abTestResponses(category) {
  const variantA = await client.examples.create({
    category,
    variant: 'A',
    user_input: 'How long is shipping?',
    agent_response: 'Standard shipping takes 5-7 business days.',
    style: 'concise'
  });
  
  const variantB = await client.examples.create({
    category,
    variant: 'B',
    user_input: 'How long is shipping?',
    agent_response: `Great question! Here are our shipping options:
    
    📦 Standard (5-7 days): Free on orders over $50
    🚀 Express (2-3 days): $9.99
    ⚡ Next Day: $19.99
    
    Which would work best for you?`,
    style: 'detailed'
  });
  
  // Monitor performance
  setTimeout(async () => {
    const performanceA = await client.examples.getMetrics(variantA.id);
    const performanceB = await client.examples.getMetrics(variantB.id);
    
    // Use the better performing variant
    const winner = performanceA.satisfaction > performanceB.satisfaction ? variantA : variantB;
    await client.examples.setAsDefault(winner.id, category);
  }, 7 * 24 * 60 * 60 * 1000); // Check after 1 week
}

Monitoring & Optimization

Performance Dashboard

// Get insights on example usage and effectiveness
async function getExamplesDashboard() {
  const stats = await client.examples.getStats();
  
  return {
    totalExamples: stats.total,
    categoryCoverage: stats.categories,
    averageEffectiveness: stats.avg_effectiveness,
    mostUsed: stats.top_examples,
    needsAttention: stats.low_performing,
    recentlyAdded: stats.recent,
    coverageGaps: identifyCoverageGaps(stats)
  };
}

Integration with Other Features

Connect with Rules

// Link examples to specific rules
const rule = await client.rules.create({
  name: 'Use refund examples for complaints',
  condition: 'sentiment == "negative" AND intent == "refund"',
  action: 'use_examples',
  example_category: 'complaint_resolution'
});

Enhance with Attributes

// Add context with attributes
const attribute = await client.attributes.create({
  name: 'customer_tier',
  values: ['standard', 'premium', 'vip']
});

// Create tier-specific examples
const vipExample = await client.examples.create({
  category: 'vip_support',
  required_attributes: { customer_tier: 'vip' },
  user_input: 'I need help with my account',
  agent_response: 'Hello! As a VIP member, I\'m prioritizing your request...'
});

Next Steps