Skip to main content

Guardrails

Guardrails are safety controls that prevent your agents from behaving in undesirable ways. They set hard boundaries on topics, actions, and responses.

Why Guardrails Matter

Without guardrails, agents may:
  • Discuss topics outside their expertise
  • Make promises they can’t keep
  • Share sensitive information
  • Engage with inappropriate content
  • Stay on calls indefinitely
Guardrails ensure consistent, safe, and brand-appropriate interactions.

Types of Guardrails

Topic Restrictions

Prevent discussion of specific topics:
{
  "guardrails": {
    "blocked_topics": [
      {
        "topic": "medical_advice",
        "keywords": ["diagnose", "prescribe", "should I take"],
        "response": "I'm not qualified to provide medical advice. Please consult with a healthcare provider."
      },
      {
        "topic": "legal_advice",
        "keywords": ["sue", "legal action", "lawyer"],
        "response": "I can't provide legal advice. I'd recommend speaking with an attorney."
      },
      {
        "topic": "competitor_comparison",
        "keywords": ["competitor_name", "vs", "compared to"],
        "response": "I'm happy to tell you about our services. Is there something specific you'd like to know?"
      }
    ]
  }
}

Content Filters

Block inappropriate content:
{
  "guardrails": {
    "content_filters": {
      "profanity": {
        "action": "redirect",
        "response": "I want to help, but let's keep our conversation professional."
      },
      "harassment": {
        "action": "end_call",
        "response": "I'm not able to continue this conversation. Goodbye."
      },
      "pii_disclosure": {
        "action": "prevent",
        "patterns": ["ssn", "credit_card", "password"]
      }
    }
  }
}

Action Limits

Restrict what agents can do:
{
  "guardrails": {
    "action_limits": {
      "max_bookings_per_call": 3,
      "max_transfers": 2,
      "allowed_transfer_destinations": [
        "+14155551111",
        "+14155552222"
      ],
      "require_confirmation": ["cancel_appointment", "refund"]
    }
  }
}

Time Limits

Control call duration:
{
  "guardrails": {
    "time_limits": {
      "max_call_duration": 600,
      "warning_at": 540,
      "warning_message": "We've been talking for a while. Is there anything else I can quickly help with?",
      "end_message": "I need to wrap up now. Thank you for calling!"
    }
  }
}

Escalation Triggers

Define when to escalate to humans:
{
  "guardrails": {
    "escalation_triggers": [
      {
        "condition": "keyword",
        "keywords": ["emergency", "urgent", "911"],
        "action": "immediate_transfer",
        "destination": "+14155559999"
      },
      {
        "condition": "sentiment",
        "threshold": -0.7,
        "action": "offer_human",
        "message": "I sense this is frustrating. Would you like to speak with a manager?"
      },
      {
        "condition": "repeated_request",
        "keyword": "speak to human",
        "after_attempts": 1,
        "action": "transfer"
      }
    ]
  }
}

PII Handling

Control how sensitive data is handled:
{
  "guardrails": {
    "pii_handling": {
      "collection_allowed": ["name", "phone", "email", "dob"],
      "collection_blocked": ["ssn", "credit_card"],
      "redaction": {
        "enabled": true,
        "in_transcripts": true,
        "in_logs": true
      },
      "storage": {
        "encrypt": true,
        "retention_days": 30
      }
    }
  }
}

Redaction Patterns

{
  "pii_patterns": {
    "ssn": "\\d{3}-\\d{2}-\\d{4}",
    "credit_card": "\\d{4}[- ]?\\d{4}[- ]?\\d{4}[- ]?\\d{4}",
    "phone": "\\d{3}[- ]?\\d{3}[- ]?\\d{4}"
  }
}

Behavioral Boundaries

Promise Restrictions

Prevent agents from making commitments:
{
  "guardrails": {
    "promise_restrictions": {
      "blocked_phrases": [
        "I guarantee",
        "I promise",
        "100% sure",
        "definitely will"
      ],
      "alternatives": {
        "I guarantee": "I'll do my best to",
        "I promise": "I'll make sure to note that",
        "definitely will": "should be able to"
      }
    }
  }
}

Scope Limitations

Keep agents in their lane:
{
  "guardrails": {
    "scope": {
      "allowed_actions": [
        "schedule_appointment",
        "provide_information",
        "take_message",
        "transfer_call"
      ],
      "out_of_scope_response": "That's outside what I can help with. Let me connect you with someone who can assist."
    }
  }
}

Real-Time Monitoring

Alert Configuration

Get notified of guardrail triggers:
{
  "guardrails": {
    "alerts": {
      "enabled": true,
      "channels": ["webhook", "email"],
      "triggers": [
        {
          "event": "profanity_detected",
          "severity": "medium"
        },
        {
          "event": "escalation_triggered",
          "severity": "high"
        },
        {
          "event": "max_duration_reached",
          "severity": "low"
        }
      ]
    }
  }
}

Webhook Alerts

{
  "event": "guardrail.triggered",
  "call_id": "call_abc123",
  "guardrail": "profanity_filter",
  "action_taken": "redirect",
  "transcript_snippet": "[REDACTED] detected at 02:34",
  "timestamp": "2024-01-15T10:30:00Z"
}

Industry-Specific Guardrails

Healthcare

{
  "guardrails": {
    "industry": "healthcare",
    "rules": {
      "no_diagnosis": true,
      "no_treatment_advice": true,
      "defer_clinical": true,
      "hipaa_patterns": true,
      "emergency_detection": {
        "enabled": true,
        "keywords": ["chest pain", "can't breathe", "overdose"],
        "response": "If this is a medical emergency, please hang up and call 911 immediately."
      }
    }
  }
}

Financial Services

{
  "guardrails": {
    "industry": "financial",
    "rules": {
      "no_investment_advice": true,
      "no_guarantees": true,
      "rate_disclaimers": true,
      "pci_compliance": {
        "never_say_card_number": true,
        "redirect_to_secure_system": true
      }
    }
  }
}
{
  "guardrails": {
    "industry": "legal",
    "rules": {
      "no_legal_advice": true,
      "attorney_client_reminder": true,
      "conflict_check_reminder": true,
      "defer_to_attorney": {
        "triggers": ["should I", "what do you think", "is this legal"],
        "response": "I can't provide legal advice, but I can schedule a consultation with one of our attorneys."
      }
    }
  }
}

Testing Guardrails

Test Scenarios

ScenarioExpected Behavior
Ask for medical diagnosisDecline and redirect
Use profanityRedirect conversation
Request SSNBlock and explain
Say “emergency”Trigger escalation
Call exceeds 10 minutesWarning then wrap-up

Guardrail Testing Mode

curl -X POST https://api.usecrew.ai/v1/agents/{agent_id}/test \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "test_type": "guardrails",
    "scenarios": [
      "profanity_input",
      "pii_request",
      "out_of_scope_topic"
    ]
  }'

Analytics

Track guardrail effectiveness:
MetricDescription
Trigger rateHow often guardrails activate
False positive rateIncorrect triggers
Escalation rateTriggers leading to human transfer
Topic distributionMost common blocked topics

Best Practices

Begin with tight guardrails and relax based on real-world performance.
Actively try to break your guardrails before going live.
High trigger rates may indicate overly strict rules or user confusion.
Don’t just block—guide users to appropriate resources.
Update guardrails as your business and regulations evolve.

Next Steps