AGENT SKILL

retellai-policy-guardrails

Implement Retell AI lint rules, policy enforcement, and automated guardrails. Use when setting up code quality rules for Retell AI integrations, implementing pre-commit hooks, or configuring CI policy checks for Retell AI best practices. Trigger with phrases like "retellai policy", "retellai lint", "retellai guardrails", "retellai best practices check", "retellai eslint".

License 许可
MIT
最近更新
2026-05-26
Stars
★ 0
Forks
0

01 前言 Front Matter

name
retellai-policy-guardrails
author
Jeremy Longshore <jeremy@intentsolutions.io>
license
MIT
version
1.0.0
description
Implement Retell AI lint rules, policy enforcement, and automated guardrails. Use when setting up code quality rules for Retell AI integrations, implementing pre-commit hooks, or configuring CI policy checks for Retell AI best practices. Trigger with phrases like "retellai policy", "retellai lint", "retellai guardrails", "retellai best practices check", "retellai eslint".
allowed-tools
Read, Write, Edit, Bash(npx:*)
compatible-with
claude-code, codex, openclaw

03 SKILL.md 正文

Retell AI Policy Guardrails

Overview

Policy enforcement for Retell AI voice agent deployments. Voice AI agents interact with real people over phone calls, requiring strict controls around conversation content, call recording consent, data handling, and cost management.

Prerequisites

  • Retell AI agent configured
  • Understanding of telephony compliance (TCPA, GDPR)
  • Call recording consent requirements for your jurisdiction

Instructions

Step 1: Conversation Content Boundaries

Define what the agent can and cannot discuss to prevent liability.

const CONVERSATION_POLICY = {
  blockedTopics: [
    'medical advice', 'legal advice', 'financial advice',
    'political opinions', 'competitor pricing'
  ],
  requiredDisclosures: [
    'This is an AI assistant',
    'This call may be recorded'
  ],
  maxCallDuration: 600,  // 10 minutes  # 600: timeout: 10 minutes
  escalationTriggers: ['speak to a human', 'talk to manager', 'real person']
};

function enforceContentPolicy(agentResponse: string): string {
  for (const topic of CONVERSATION_POLICY.blockedTopics) {
    if (agentResponse.toLowerCase().includes(topic)) {
      return "I'm not able to advise on that topic. Let me connect you with a specialist.";
    }
  }
  return agentResponse;
}

Step 2: Call Recording Consent

Many jurisdictions require two-party consent for recording. Enforce upfront disclosure.

const CONSENT_SCRIPT = {
  opening: "Hi, this is an AI assistant calling from [Company]. This call may be recorded for quality purposes. Is that okay?",
  noConsent: "I understand. I'll continue without recording. How can I help you today?",
  consentReceived: true
};

app.post('/retell-webhook', async (req, res) => {
  const { call_id, turn_number, transcript } = req.body;

  // First turn: always deliver consent disclosure
  if (turn_number === 0) {
    return res.json({ response: CONSENT_SCRIPT.opening });
  }

  // Second turn: check for consent
  if (turn_number === 1) {
    const consented = /yes|okay|sure|that's fine/i.test(transcript);
    if (!consented) {
      await retell.call.update(call_id, { recording_enabled: false });
      return res.json({ response: CONSENT_SCRIPT.noConsent });
    }
  }

  // Normal processing
  const response = await generateResponse(req.body);
  return res.json({ response: enforceContentPolicy(response) });
});

Step 3: Cost Controls

Voice calls cost per minute. Cap concurrent calls and duration.

class CallCostPolicy {
  private activeCalls = new Map<string, number>();
  private maxConcurrent = 10;
  private maxDurationSec = 600;  # 600: timeout: 10 minutes
  private dailyBudget = 100;  // dollars
  private costPerMinute = 0.10;

  canInitiateCall(): boolean {
    if (this.activeCalls.size >= this.maxConcurrent) return false;
    if (this.getDailySpend() >= this.dailyBudget) return false;
    return true;
  }

  monitorDuration(callId: string) {
    const started = this.activeCalls.get(callId);
    if (started && (Date.now() - started) / 1000 > this.maxDurationSec) {  # 1000: 1 second in ms
      return { action: 'end', reason: 'Maximum call duration exceeded' };
    }
    return { action: 'continue' };
  }

  getDailySpend(): number {
    let totalMinutes = 0;
    for (const started of this.activeCalls.values()) {
      totalMinutes += (Date.now() - started) / 60000;  # 60000: 1 minute in ms
    }
    return totalMinutes * this.costPerMinute;
  }
}

Step 4: Human Escalation Triggers

Detect when callers want a human and transfer gracefully.

function checkEscalation(transcript: string): boolean {
  const triggers = ['speak to a human', 'real person', 'talk to someone', 'supervisor', 'manager'];
  return triggers.some(t => transcript.toLowerCase().includes(t));
}

Error Handling

Issue Cause Solution
Compliance violation Agent gives restricted advice Content filtering on responses
Recording without consent Missing disclosure Enforce consent script on first turn
Runaway call costs No duration/budget limits Implement cost controls
Frustrated caller No human escalation Detect escalation triggers, transfer

Examples

Policy Dashboard

const dashboard = {
  activeCalls: costPolicy.activeCalls.size,
  dailySpend: costPolicy.getDailySpend().toFixed(2),
  escalationRate: metrics.rate('escalations'),
  avgCallDuration: metrics.avg('call_duration_sec')
};

Resources

Output

  • Configuration files or code changes applied to the project
  • Validation report confirming correct implementation
  • Summary of changes made and their rationale

04 同仓库更多 Skills

SamuelChien
SamuelChien/mega-skills-collection

zustand-store-ts

Create Zustand stores with TypeScript, subscribeWithSelector middleware, and proper state/action separation. Use when building React state management, creating global stores, or implementing reactive state patterns with Zustand.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zustand-store-creator

Zustand Store Creator - Auto-activating skill for Frontend Development. Triggers on: zustand store creator, zustand store creator Part of the Frontend Development skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zero-trust-config-helper

Zero Trust Config Helper - Auto-activating skill for Security Advanced. Triggers on: zero trust config helper, zero trust config helper Part of the Security Advanced skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zapier-integration-helper

Zapier Integration Helper - Auto-activating skill for Business Automation. Triggers on: zapier integration helper, zapier integration helper Part of the Business Automation skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zai-cli

Execute z.AI CLI providing vision, search, reader, and GitHub exploration via CLI and MCP. Use when user needs image/video analysis, OCR, UI-to-code conversion, error diagnosis, real-time web search, web page to markdown extraction, or GitHub code exploration. Trigger with phrases like "analyze this image", "search the web for", "read this page", "explore this repo", or "use zai". Requires Z_AI_API_KEY.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

yt-research

Research competitor YouTube channels, niches, and trending topics for your content strategy. Use this skill whenever the user says "research channels", "analyze competitors", "find trending topics", "niche analysis", "competitive research", "what are other creators doing", "scrape YouTube channels", or wants to understand the competitive landscape for a specific tool or topic area. Use when working with yt research. Trigger with 'yt', 'research'.

★ 0