Tenant Maintenance Triage and Dispatch State Machine Script
Build an intelligent agent script to parse tenant maintenance tickets, verify emergency parameters, and automate vendor dispatch within budget limits.
Use this template when implementing an automated property management agent for residential or commercial properties. It produces a state-driven script that categorizes issues, checks emergency SLAs, dispatches approved contractors, and verifies spending limits.
Role: Lead Conversational AI and Workflow Engineer specializing in residential property operations and automated incident triage.
Context
- Property management organization: {{property_management_co}}
- Managed property portfolio type: {{property_portfolio_type}}
- Designated emergency classifications: {{emergency_categories}}
- Vendor dispatch gateway: {{vendor_dispatch_api}}
- Autonomous spending authorization limit: {{spend_approval_limit}}
- Urgent response SLA: {{after_hours_sla_minutes}}
Task
Design a resilient agent state-machine script in TypeScript/Node.js or Python that receives tenant maintenance inquiries for {{property_management_co}}, categorizes requests against {{emergency_categories}}, validates repair estimates against {{spend_approval_limit}}, and triggers automated vendor dispatch via {{vendor_dispatch_api}} under a {{after_hours_sla_minutes}}-minute SLA.
Method
- Define state machine states: Intake, Classification, SeverityAssessment, VendorMatching, AuthorizationCheck, Dispatch, and HumanHandoff.
- Ingest inbound tenant maintenance report text, extracting reported failure type, location, and tenant presence constraints.
- Evaluate extracted data against {{emergency_categories}} for {{property_portfolio_type}} units to assign urgency tier.
- Route non-emergency requests to standard queuing and schedule during normal operating hours.
- For emergency items, query {{vendor_dispatch_api}} to locate on-call trade specialists capable of meeting {{after_hours_sla_minutes}}.
- Evaluate vendor call-out estimate against {{spend_approval_limit}}.
- Auto-authorize and dispatch ticket if estimate is within limit; transition to HumanHandoff if threshold is exceeded.
- Send confirmation update to tenant with technician ETA and safety precautions.
Constraints
- MUST implement deterministic state transitions with zero uncaught exception paths.
- MUST NOT auto-dispatch unverified vendors not registered within the dispatch API.
- The script MUST log every state transition with timestamped ISO telemetry for audit purposes.
- Tenant communication strings MUST enforce standardized compliance and safety phrasing.
Output format
- State Machine Definition and Type Interfaces
- Intent Classification and Severity Evaluation Agent Nodes
- Vendor Dispatch API Integration Functions
- Main Execution Workflow Loop with Fallback Handlers
- Example Input/Output Execution Scenario
Self-review
- Confirm inclusion and active logical usage of all variables: {{property_management_co}}, {{property_portfolio_type}}, {{emergency_categories}}, {{vendor_dispatch_api}}, {{spend_approval_limit}}, {{after_hours_sla_minutes}}.
- Validate that emergency branch guarantees SLA enforcement logic under {{after_hours_sla_minutes}}.
- Ensure spend threshold guardrails cannot be bypassed by malformed input data.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.