{
    "start_node_id": "awaiting_call",
    "eligibility_rules": [
        {
            "type": "person_property_equals",
            "params": {
                "property": "role",
                "value": "guest"
            }
        }
    ],
    "nodes": {
        "awaiting_call": {
            "ui_hints": {
                "title": "Follow-up Call",
                "status": "active",
                "reason": "Awaiting follow-up call with the guest.",
                "next_step": "Log the outcome of the call.",
                "form_schema": [
                    { "name": "call_date", "label": "Call Date", "type": "datetime-local", "default": "now", "required": true },
                    {
                        "name": "outcome_status", 
                        "label": "Call Outcome", 
                        "type": "select",
                        "required": true,
                        "options": [
                            { "value": "", "label": "-- Select Outcome --" },
                            { "value": "no_answer", "label": "No Answer" },
                            { "value": "wants_to_join", "label": "Wants to Join" },
                            { "value": "declined", "label": "Declined" },
                            { "value": "call_later", "label": "Call Later" }
                        ]
                    },
                    { "name": "note", "label": "Notes", "type": "textarea" },
                    { "name": "next_contact_date", "label": "Next Contact Date", "type": "datetime-local", "condition": { "field": "outcome_status", "value": "call_later" }, "required": true }
                ]
            }
        },
        "outcome_router": { "ui_hints": { "status": "processing" } },
        "waiting_for_next_contact": {
            "ui_hints": {
                "title": "Waiting for Scheduled Call",
                "status": "paused",
                "reason": "Waiting until the scheduled date for the next call.",
                "next_step": "Resume contact on or after the scheduled date."
            }
        },
        "decide_after_no_answer": {
            "ui_hints": {
                "title": "No Answer",
                "status": "paused",
                "reason": "The guest did not answer the call.",
                "next_step": "Decide whether to try again or end the process."
            }
        },
        "end_positive": { "ui_hints": { "title": "Wants to Join", "status": "completed", "reason": "Guest wants to join. New member process started.", "next_step": "" } },
        "end_negative_declined": { "ui_hints": { "title": "Declined", "status": "terminated", "reason": "Guest declined to join.", "next_step": "" } },
        "end_negative_no_answer": { "ui_hints": { "title": "Process Ended", "status": "terminated", "reason": "Process ended after no answer.", "next_step": "" } },
        "end_negative_terminated": { "ui_hints": { "title": "Process Terminated", "status": "terminated", "reason": "Process manually terminated by user.", "next_step": "" } }
    },
    "transitions": [
        {
            "id": "submit_outcome",
            "from": "awaiting_call",
            "to": "outcome_router",
            "name": "Submit Outcome",
            "actions": [ 
                { "type": "set_data", "params": { "keys": ["call_date", "outcome_status", "note", "next_contact_date"] } } 
            ] 
        },
        {
            "id": "route_wants_to_join",
            "from": "outcome_router",
            "to": "end_positive",
            "name": "Route to Positive End",
            "condition": { "field": "outcome_status", "value": "wants_to_join" },
            "actions": [
                { "type": "start_process", "process_code": "obsluga-przyjecia-nowego-czlonka" }
            ]
        },
        {
            "id": "route_declined",
            "from": "outcome_router",
            "to": "end_negative_declined",
            "name": "Route to Declined",
            "condition": { "field": "outcome_status", "value": "declined" }
        },
        {
            "id": "route_no_answer",
            "from": "outcome_router",
            "to": "decide_after_no_answer",
            "name": "Route to No Answer",
            "condition": { "field": "outcome_status", "value": "no_answer" }
        },
        {
            "id": "route_call_later",
            "from": "outcome_router",
            "to": "waiting_for_next_contact",
            "name": "Route to Call Later",
            "condition": { "field": "outcome_status", "value": "call_later" }
        },
        { "id": "continue_attempts", "from": "decide_after_no_answer", "to": "awaiting_call", "name": "Try Again" },
        { "id": "end_attempts", "from": "decide_after_no_answer", "to": "end_negative_no_answer", "name": "End Process" },
        { "id": "resume_contact", "from": "waiting_for_next_contact", "to": "awaiting_call", "name": "Resume / Attempt Call" },
        {
            "id": "terminate_from_awaiting_call",
            "from": "awaiting_call",
            "to": "end_negative_terminated",
            "name": "Zakończ proces",
            "actions": [ { "type": "set_data", "params": { "keys": ["termination_note"] } } ],
            "form_schema": [ { "name": "termination_note", "label": "Reason for Termination (optional)", "type": "textarea" } ]
        },
        {
            "id": "terminate_from_decide",
            "from": "decide_after_no_answer",
            "to": "end_negative_terminated",
            "name": "Zakończ proces",
            "actions": [ { "type": "set_data", "params": { "keys": ["termination_note"] } } ],
            "form_schema": [ { "name": "termination_note", "label": "Reason for Termination (optional)", "type": "textarea" } ]
        },
        {
            "id": "terminate_from_waiting",
            "from": "waiting_for_next_contact",
            "to": "end_negative_terminated",
            "name": "Zakończ proces",
            "actions": [ { "type": "set_data", "params": { "keys": ["termination_note"] } } ],
            "form_schema": [ { "name": "termination_note", "label": "Reason for Termination (optional)", "type": "textarea" } ]
        }
    ]
}