What is a violation?
A violation represents a detected event that breached a configured rule. For example:- A person detected in a restricted area
- Smoking detected in a no-smoking zone
- Equipment left unattended
- Safety gear not worn
Violation data model
A violation record contains the following fields:| Field | Type | Description |
|---|---|---|
id | string | Unique identifier |
branch_rule_id | string | Rule that triggered the violation |
started_at | string | When the violation started |
ended_at | string | When the violation ended |
main_attachment | string[] | Video clips or full images |
sub_attachment | string[] | Detection crops |
timestamp | string | Creation timestamp |
note | string | Additional context |
status | string | Current status |
created_at | string | Database creation time |
updated_at | string | Last update time |
Violation status workflow
Violations progress through several statuses as they’re processed and delivered:| Status | Arabic | Description |
|---|---|---|
| Created | - | Violation record created, attachments uploaded |
| Escalated | تأكيد | Ready for brand delivery |
| Uploaded | رفعت | Delivered to brand’s system |
| Closed | - | Violation resolved |
Creating violations
Violations are created by thecreate_violation business action. This action:
- Collects attachments from all previous detection actions
- Uploads attachments to Supabase storage
- Calls the
insert-violationedge function to create the record - Returns the violation IDs for subsequent actions
Attachment types
- Main attachments
- Sub attachments
Purpose: Full context of the violationCommon formats:
- Video clips (
.mp4,.webm) - typically 10-30 seconds - Full-frame images (
.jpg,.png)
violations bucketDelivery methods
RES supports multiple delivery channels for violations:1. Webhook delivery
Send violation data to an external API endpoint. The webhook payload includes:| Field | Description |
|---|---|
violation_id | Unique identifier |
branch_rule_id | Rule that triggered the violation |
timestamp | When the violation occurred |
main_attachment | Array of video/image URLs |
sub_attachment | Array of detection crop URLs |
rule_name | Human-readable rule name |
branch_name | Human-readable branch name |
2. Email delivery
Send formatted HTML email with embedded media. The email includes:- Violation alert header with rule name
- Embedded video or image
- Event timestamp
- Detection thumbnail
- Branch and brand information
3. Zoho Desk delivery
Create support tickets in the brand’s Zoho Desk. Tickets include:| Field | Value |
|---|---|
| Subject | Rule name |
| Description | HTML-formatted violation details with image |
| Department | Configured department ID |
| Contact | Configured contact ID |
| Category | Brand and branch identifier |
Configuration by brand
Each brand can configure different delivery methods in their brand settings:| Integration | Required configuration |
|---|---|
business_action_email - recipient email address | |
| Zoho | zoho.enabled, zoho.org_id, zoho.department_id, OAuth credentials |
| Webhook | webhook_url, optionally webhook_secret |
Violation retrieval flow
For brands with Zoho integration, violations go through a central RIME account:1
Violation created
Detection triggers
create_violation which stores the violation in the database.2
Ticket created in RIME Zoho
A ticket is created in RIME’s central Zoho account with status “Escalated”.
3
Retrieve and forward
The
retrieve_rmts_data action fetches escalated tickets, filters by branch, and creates tickets in the brand’s Zoho account.4
Mark as delivered
The original RIME ticket is updated to “Uploaded” status.
Best practices
Always include attachments
Violations without visual evidence are difficult to verify. Ensure detection actions produce both main and sub attachments.
Use descriptive notes
Include context in the violation note: zone name, detection type, confidence score.
Configure multiple channels
Set up both email and ticketing to ensure violations aren’t missed.
Monitor delivery failures
Track email bounces and Zoho API errors to catch delivery issues early.
Troubleshooting
Violations not being created
Violations not being created
Check:
- Did detection action return
is_success=true? - Did consolidation logic evaluate to
true? - Did attachment upload succeed?
insert-violation calls in the logs and “Successfully created X violation(s)” messages.Missing attachments
Missing attachments
Check:
- Did detection action save files to disk?
- Is Supabase storage accessible?
- Are file paths in results valid?
- Verify detection action is saving images
- Check Supabase bucket permissions
- Check network connectivity
Email not received
Email not received
Check:
- Is
business_action_emailconfigured on brand? - Did SMTP connection succeed?
- Is email in spam folder?
Zoho ticket not created
Zoho ticket not created
Check:
- Is
zoho.enabledset totrue? - Are OAuth credentials valid?
- Does department/contact exist?