ComplianceEngine
is highly extensible, allowing you to create custom rules that cater to your organization’s unique compliance, policy, and quality assurance requirements. This guide will walk you through the process of creating, adding, and managing custom compliance rules.
Why Create Custom Rules?
While the SDK comes with built-in rules for common banking regulations (PII, Fair Lending, etc.), you may need custom rules to:- Enforce internal company policies.
- Monitor for brand voice and tone consistency.
- Check for adherence to specific product disclosure requirements.
- Detect keywords related to upselling or cross-selling for quality review.
- Implement compliance checks for regulations specific to your region.
Structure of a Compliance Rule
A compliance rule is an object with a specific structure. Let’s break down each property:ruleFunction
, which takes an InteractionContext
and returns a ComplianceResult
.
- InteractionContext: Contains the data about the interaction, such as
agentResponse
,userMessage
,toolsUsed
, etc. - ComplianceResult: An object indicating if the interaction was compliant, a list of any violations found, a calculated risk score, and whether it requires manual review.
Example 1: Product Disclosure Rule
Let’s create a rule to ensure that whenever a “mortgage” product is mentioned, a specific disclosure about interest rates is included in the agent’s response.1
Define the Rule Object
2
Implement the ruleFunction
3
Add the Rule to the Compliance Engine
Example 2: Brand Voice and Tone Rule
Let’s create a rule to prevent the agent from using overly casual language, ensuring it maintains a professional tone.Managing Custom Rules
You can dynamically manage your custom rules at runtime.Removing a Rule
Deactivating a Rule
Listing Rules
Best Practices for Custom Rules
Keep Rules Focused
Keep Rules Focused
Each rule should have a single, clear purpose. Instead of one giant “policy” rule, break it down into smaller, more manageable rules (e.g., one for disclosures, one for tone, one for specific product details). This makes them easier to test and maintain.
Use Descriptive IDs and Names
Use Descriptive IDs and Names
Use a consistent naming convention for your rule IDs (e.g., [category]-[specific-check]). This makes it easier to identify and manage rules in logs and dashboards.
Optimize Performance
Optimize Performance
Rule functions are executed on agent interactions, so they need to be performant. Avoid complex, long-running operations. Use efficient regular expressions and cache patterns if necessary.
Provide Actionable Recommendations
Provide Actionable Recommendations
The recommendation field in a violation is crucial. It should provide clear, actionable advice for developers or compliance officers on how to fix the issue.
Test Thoroughly
Test Thoroughly
Before deploying a new rule, test it against a wide range of both compliant and non-compliant interactions to ensure it behaves as expected and doesn’t generate excessive false positives. See our Testing Guide for more details.