{
        "description": "Notify administrators when TaxCore submission fails after multiple attempts",
        "priority": 8,
        "condition": "status = 'failed' AND attempts >= 3",
        "steps": [
            {
                "step": 1,
                "action": "query",
                "name": "get_submission_details",
                "query": "SELECT s.*, c.org_tin FROM taxcore_submissions s LEFT JOIN taxcore_configurations c ON s.org_id = c.org_id WHERE s.submission_id = ${record.submission_id}",
                "required": true
            },
            {
                "step": 2,
                "action": "query",
                "name": "get_admin_emails",
                "query": "SELECT email FROM users WHERE role = 'admin' AND org_id = ${step1.result[0].org_id} AND is_active = true",
                "required": true
            },
            {
                "step": 3,
                "action": "email",
                "name": "send_alert_email",
                "to": "${step2.result.map(u => u.email).join(',')}", 
                "subject": "TaxCore Submission Failed - ${step1.result[0].submission_type} #${step1.result[0].invoice_number}",
                "template": "taxcore_failure_alert",
                "data": "${step1.result[0]}"
            },
            {
                "step": 4,
                "action": "insert",
                "name": "create_notification",
                "query": "INSERT INTO notifications (user_id, title, message, type, data) SELECT user_id, 'TaxCore Submission Failed', 'Failed to submit ${step1.result[0].submission_type} after 3 attempts', 'error', ${step1.result[0]}::jsonb FROM users WHERE role = 'admin' AND org_id = ${step1.result[0].org_id}",
                "required": false
            },
            {
                "step": 5,
                "action": "notify",
                "name": "websocket_alert",
                "channel": "websocket",
                "event": "taxcore:alert:failed",
                "room": "org:${step1.result[0].org_id}",
                "data": "${step1.result[0]}"
            }
        ]
    }