> ## Documentation Index
> Fetch the complete documentation index at: https://docs.thinnest.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Compliance & Security

> Recording consent, hallucination guardrails, topic fencing, and compliance features for voice agents.

# Compliance & Security

These features enforce compliance, prevent hallucinations, and protect against misuse during voice calls.

***

## Recording Consent (Compliance)

Automatically announce that the call is being recorded, either before or after the greeting.

```json theme={null}
{
  "complianceConsentEnabled": true,
  "complianceConsentMessage": "This call may be recorded for quality and training purposes.",
  "complianceConsentPosition": "before_greeting"
}
```

| Setting                     | Type    | Default           | Description                                         |
| --------------------------- | ------- | ----------------- | --------------------------------------------------- |
| `complianceConsentEnabled`  | boolean | `false`           | Enable recording consent announcement               |
| `complianceConsentMessage`  | string  | —                 | Consent announcement text                           |
| `complianceConsentPosition` | string  | `before_greeting` | When to play: `before_greeting` or `after_greeting` |

***

## Hallucination Guardrails

Restrict the agent to specific topics, block sensitive topics, and prevent prohibited statements.

```json theme={null}
{
  "guardrailsEnabled": true,
  "allowedTopics": ["billing", "account", "products", "shipping"],
  "blockedTopics": ["politics", "religion", "competitors"],
  "prohibitedStatements": [
    "I guarantee that...",
    "You will definitely...",
    "We promise..."
  ],
  "requireKnowledgeBase": true,
  "guardrailAction": "apologize"
}
```

| Setting                | Type      | Default     | Description                                        |
| ---------------------- | --------- | ----------- | -------------------------------------------------- |
| `guardrailsEnabled`    | boolean   | `false`     | Enable topic guardrails                            |
| `allowedTopics`        | string\[] | `[]`        | Topics the agent CAN discuss (empty = all allowed) |
| `blockedTopics`        | string\[] | `[]`        | Topics the agent must NEVER discuss                |
| `prohibitedStatements` | string\[] | `[]`        | Phrases the agent must never say                   |
| `requireKnowledgeBase` | boolean   | `false`     | Only provide info from the knowledge base          |
| `guardrailAction`      | string    | `apologize` | On violation: `apologize`, `redirect`, `escalate`  |

### Guardrail Actions

| Action      | Behavior                                           |
| ----------- | -------------------------------------------------- |
| `apologize` | "I'm sorry, I'm not able to help with that topic." |
| `redirect`  | Redirect conversation back to an allowed topic     |
| `escalate`  | Offer to transfer the caller to a human agent      |

***

## Knowledge Gap Detection

Track when the agent doesn't know the answer to a question. Gaps are logged for knowledge base improvement.

```json theme={null}
{
  "knowledgeGapDetectionEnabled": true,
  "knowledgeGapWebhookUrl": "https://your-app.com/webhooks/knowledge-gaps"
}
```

When the agent encounters a question it can't answer, it internally marks it with `[KNOWLEDGE_GAP: topic]`. After the call, gaps are extracted and sent to the configured webhook or saved to the session.

***

## Live Call Monitoring

Allow supervisors to listen to active calls and optionally join (barge-in) or whisper to the agent.

```json theme={null}
{
  "liveMonitoringEnabled": true,
  "monitoringAllowBargeIn": true,
  "monitoringAllowWhisper": true
}
```

| Setting                  | Type    | Default | Description                                  |
| ------------------------ | ------- | ------- | -------------------------------------------- |
| `liveMonitoringEnabled`  | boolean | `false` | Enable live monitoring                       |
| `monitoringAllowBargeIn` | boolean | `false` | Allow supervisor to speak to the caller      |
| `monitoringAllowWhisper` | boolean | `false` | Allow supervisor to coach the agent silently |

***

## Speech Emotion Detection

Monitor the caller's emotional state through voice analysis and adjust the agent's behavior accordingly.

```json theme={null}
{
  "speechEmotionDetectionEnabled": true,
  "emotionDetectionModel": "basic",
  "emotionEscalationThreshold": 0.7
}
```

| Model      | Behavior                                                                                      |
| ---------- | --------------------------------------------------------------------------------------------- |
| `basic`    | Monitor emotions through word choices. Acknowledge frustration empathetically.                |
| `advanced` | Track tone, pace, and word choices. Proactively adjust approach for strong negative emotions. |

***

## Call Scoring & QA

Automatically score each call against quality criteria after it ends.

```json theme={null}
{
  "callScoringEnabled": true,
  "scoringCriteria": [
    "greeting_quality",
    "issue_resolution",
    "professionalism",
    "call_efficiency"
  ],
  "scoringModel": "gpt-4o-mini"
}
```

After the call, the LLM reviews the transcript and assigns scores for each criterion.

***

## Example — Create Agent with Compliance & Security

```bash theme={null}
curl -X POST https://api.thinnest.ai/v1/agents \
  -H "Authorization: Bearer $THINNESTAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Compliant Support Agent",
    "model": "gpt-4o",
    "instructions": "You are a customer support agent. Stay on-topic — only discuss billing, accounts, and products. Never make promises or guarantees.",
    "voiceEnabled": true,
    "transcriber": { "provider": "deepgram", "model": "nova-2-conversationalai" },
    "voice": { "provider": "deepgram", "voiceId": "aura-2-thalia-en" },
    "complianceConsentEnabled": true,
    "complianceConsentMessage": "This call may be recorded for quality and training purposes.",
    "complianceConsentPosition": "before_greeting",
    "guardrailsEnabled": true,
    "allowedTopics": ["billing", "account", "products", "shipping"],
    "blockedTopics": ["politics", "religion", "competitors"],
    "prohibitedStatements": ["I guarantee", "You will definitely", "We promise"],
    "guardrailAction": "apologize",
    "knowledgeGapDetectionEnabled": true,
    "callScoringEnabled": true,
    "scoringCriteria": ["greeting_quality", "issue_resolution", "professionalism"],
    "scoringModel": "gpt-4o-mini"
  }'
```
