id: ai-customer-call-compliance-auditor
namespace: company.compliance
description: |
Audits customer service and outbound sales call transcripts for mandatory regulatory disclosures,
flags prohibited deceptive claims, computes a compliance risk score using Google Gemini,
and routes violations to compliance teams via Slack.
triggers:
- id: scheduled_batch_sweep
type: io.kestra.plugin.core.trigger.Schedule
description: Nightly regulatory compliance sweep of recorded customer
interactions. Shipped disabled by default.
cron: "0 20 * * 1-5"
disabled: true
- id: webhook_transcript_ingest
type: io.kestra.plugin.core.trigger.Webhook
description: Authenticated webhook for contact center (Twilio, Genesys, Aircall)
transcription pipelines.
key: "{{ secret('WEBHOOK_KEY') }}"
inputs:
- id: call_id
type: STRING
defaults: CALL-2026-9481
description: Unique contact center call identifier.
- id: agent_id
type: STRING
defaults: AGENT-402
description: Support or sales representative identifier.
- id: call_transcript
type: STRING
defaults: |
Representative: Hello, thank you for calling Apex Cloud Solutions, my name is Alex. This call is being recorded for quality and training purposes. How can I help you today?
Customer: Hi, I am calling to ask about upgrading our subscription to the dedicated enterprise tier.
Representative: Absolutely! The enterprise plan is $4,500 per month billed annually. We include 24/7 dedicated support and unlimited compute clusters.
Customer: What is your cancellation and refund policy if our engineering roadmap changes?
Representative: All enterprise agreements include a 30-day money-back guarantee with zero cancellation penalty. After 30 days, billing renews automatically each year unless canceled 30 days prior.
Customer: That sounds fair. Let's proceed with the setup.
Representative: Perfect, I will send the agreement to your email for electronic signature. Thank you for choosing Apex Cloud!
description: Raw dialogue transcript of the customer interaction.
tasks:
- id: audit_call_transcript
type: io.kestra.plugin.ai.agent.AIAgent
description: Uses Gemini 2.5 Flash to audit transcript against mandatory
disclosure checklists and prohibited sales claims.
provider:
type: io.kestra.plugin.ai.provider.GoogleGemini
apiKey: "{{ secret('GEMINI_API_KEY') }}"
modelName: gemini-2.5-flash
configuration:
temperature: 0.1
maxToken: 4096
responseFormat:
type: JSON
jsonSchema:
type: object
required:
- call_id
- compliance_verdict
- compliance_score
- recording_consent_disclosed
- refund_policy_disclosed
- recurring_billing_disclosed
- prohibited_claims_detected
- auditor_notes
properties:
call_id:
type: string
compliance_verdict:
type: string
enum:
- PASS
- WARNING
- VIOLATION
compliance_score:
type: integer
minimum: 0
maximum: 100
recording_consent_disclosed:
type: boolean
refund_policy_disclosed:
type: boolean
recurring_billing_disclosed:
type: boolean
prohibited_claims_detected:
type: array
items:
type: string
auditor_notes:
type: string
prompt: |
You are an automated regulatory compliance auditor for an enterprise customer contact center.
Analyze the following customer interaction transcript against regulatory consumer protection standards:
Call ID: {{ inputs.call_id }}
Representative ID: {{ inputs.agent_id }}
Transcript:
\"\"\"
{{ inputs.call_transcript }}
\"\"\"
Audit Requirements:
1. Recording Consent: Did the representative clearly notify the customer that the call is recorded?
2. Refund & Cancellation Terms: Did the representative explain refund windows and cancellation rights if requested?
3. Recurring Billing: Did the representative clearly state billing terms and renewal mechanisms?
4. Prohibited Claims: Did the representative make unsubstantiated guarantees (e.g., "guaranteed 1000% ROI", "cannot fail", or hidden mandatory fees)?
Assign an objective compliance_score (0 to 100):
- 90-100: PASS (All mandatory disclosures made, zero deceptive claims)
- 70-89: WARNING (Minor omissions or unclear terminology, no intentional deceit)
- <70: VIOLATION (Missing recording consent, deceptive pricing, or prohibited guarantees)
- id: generate_compliance_report
type: io.kestra.plugin.scripts.python.Script
description: Parses structured audit metrics and generates markdown compliance
report artifact in execution storage.
taskRunner:
type: io.kestra.plugin.core.runner.Process
script: |
import json
raw_response = """{{ outputs.audit_call_transcript.text }}"""
audit = json.loads(raw_response)
verdict = audit.get("compliance_verdict", "UNKNOWN")
score = audit.get("compliance_score", 0)
recording = "YES" if audit.get("recording_consent_disclosed") else "NO (FLAGGED)"
refund = "YES" if audit.get("refund_policy_disclosed") else "NO (FLAGGED)"
billing = "YES" if audit.get("recurring_billing_disclosed") else "NO (FLAGGED)"
claims = ", ".join(audit.get("prohibited_claims_detected", [])) or "None detected"
notes = audit.get("auditor_notes", "")
report = f"""# CUSTOMER INTERACTION COMPLIANCE AUDIT
## Call Details
- **Call ID**: {{ inputs.call_id }}
- **Agent ID**: {{ inputs.agent_id }}
- **Verdict**: {verdict}
- **Compliance Score**: {score} / 100
## Disclosure Checklist
| Mandatory Requirement | Status |
|---|---|
| Recording Consent Disclosed | {recording} |
| Refund / Cancellation Policy Explained | {refund} |
| Recurring Billing Terms Stated | {billing} |
| Prohibited / Deceptive Claims | {claims} |
## Auditor Notes
{notes}
"""
with open("call-compliance-audit-report.md", "w") as f:
f.write(report)
print("Saved call-compliance-audit-report.md")
outputFiles:
- call-compliance-audit-report.md
- id: compliance_gate
type: io.kestra.plugin.core.flow.If
description: Evaluates compliance verdict and routes flagged interactions to
compliance officer Slack channel.
condition: "{{ json(outputs.audit_call_transcript.text).compliance_verdict ==
'PASS' }}"
then:
- id: log_compliant_audit
type: io.kestra.plugin.core.log.Log
description: Records passed audit log with compliance score.
message: "Call {{ inputs.call_id }} PASSED compliance audit with score {{
json(outputs.audit_call_transcript.text).compliance_score }}/100.
Archived."
else:
- id: escalate_compliance_violation
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: Alerts compliance officers of flagged disclosure omissions or
deceptive sales claims.
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "#compliance-escalations",
"text": "🚨 *Call Compliance Alert*: Call `{{ inputs.call_id }}` (Agent: `{{ inputs.agent_id }}`) failed regulatory audit.\n*Verdict*: *{{ json(outputs.audit_call_transcript.text).compliance_verdict }}* (Score: {{ json(outputs.audit_call_transcript.text).compliance_score }}/100)\n*Notes*: {{ json(outputs.audit_call_transcript.text).auditor_notes }}\nAudit report generated in Kestra execution storage."
}
errors:
- id: alert_on_failure
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: Alerts on-call engineering channel if transcript parsing or agent
audit fails unexpectedly.
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "#compliance-ops",
"text": "⚠️ *Pipeline Error*: Call compliance auditor flow `{{ flow.id }}` failed on execution `{{ execution.id }}`."
}