{
  "draft_id": "22222222-2222-4222-8222-222222222222",
  "expected_revision": 1,
  "edits": [
    {
      "type": "agent.name",
      "name": "Equipment service coordination"
    },
    {
      "type": "channels.set",
      "channels": [
        "phone"
      ]
    },
    {
      "type": "languages.set",
      "languages": [
        "en",
        "es"
      ]
    },
    {
      "type": "agent.settings",
      "values": {
        "voiceSpeed": 1,
        "interruptionSensitivity": 0.8,
        "reminderTriggerMs": 10000,
        "reminderMaxCount": 2,
        "maxCallDurationMs": 600000,
        "endCallAfterSilenceMs": 30000,
        "openerWaitsForCallee": true,
        "voicemail": {
          "enabled": true,
          "action": "leave_message",
          "message": {
            "type": "static_text",
            "text": "Hello, this is Acme Equipment Care following up on your service request. Please call our service desk at four one five, five five five, zero one three two."
          }
        },
        "dataStorageSetting": "everything",
        "ivr": {
          "enabled": true,
          "action": "hangup",
          "detectionWindowMs": 180000
        },
        "screener": {
          "action": "play_line",
          "waitMs": 20000,
          "line": {
            "en": "Acme Equipment Care is following up on a requested service visit.",
            "es": "Acme Equipment Care llama sobre una visita de servicio solicitada."
          }
        }
      },
      "clear": []
    },
    {
      "type": "agent.analysis",
      "fields": [
        {
          "name": "next_step",
          "type": "string",
          "description": "The confirmed visit, dispatch outcome or outstanding follow-up"
        },
        {
          "name": "dispatch_requested",
          "type": "boolean",
          "description": "Whether the contact asked to speak with dispatch; transfer confirmation requires the native receipt"
        },
        {
          "name": "visit_id",
          "type": "string",
          "description": "Reservation identifier only if the business response confirmed it"
        }
      ]
    },
    {
      "type": "agent.recording",
      "value": {
        "required": true,
        "channels": "dual"
      }
    },
    {
      "type": "action.put",
      "action": {
        "name": "lookup_service_request",
        "description": "Check the service request and contact authorization before sharing site details",
        "channels": [
          "phone"
        ],
        "method": "POST",
        "url": "https://api.example.com/service/lookup_service_request",
        "headers": {},
        "auth": {
          "scheme": "bearer",
          "secret_ref": {
            "id": "business-api",
            "version": "1"
          }
        },
        "input_schema": {
          "type": "object",
          "properties": {
            "service_request_id": {
              "type": "string",
              "description": "Known service request"
            },
            "contact_reference": {
              "type": "string",
              "description": "Known contact reference"
            },
            "verification_answer": {
              "type": "string",
              "description": "Answer required by the service company"
            }
          },
          "required": [
            "service_request_id",
            "contact_reference",
            "verification_answer"
          ]
        },
        "output_schema": {
          "type": "object",
          "properties": {
            "authorized": {
              "type": "boolean"
            },
            "equipment_summary": {
              "type": "string"
            }
          },
          "required": [
            "authorized"
          ]
        },
        "idempotency": {
          "mode": "effect_key"
        },
        "timeout_ms": 5000,
        "on_uncertain": "failure_edge"
      },
      "response_variables": {
        "scheduling_authorized": "$.authorized",
        "equipment_summary": "$.equipment_summary"
      }
    },
    {
      "type": "action.put",
      "action": {
        "name": "find_service_slots",
        "description": "Read technician availability for the requested service area and time zone",
        "channels": [
          "phone"
        ],
        "method": "POST",
        "url": "https://api.example.com/service/find_service_slots",
        "headers": {},
        "auth": {
          "scheme": "bearer",
          "secret_ref": {
            "id": "business-api",
            "version": "1"
          }
        },
        "input_schema": {
          "type": "object",
          "properties": {
            "service_request_id": {
              "type": "string",
              "description": "Authorized service request"
            },
            "timezone": {
              "type": "string",
              "description": "IANA time zone"
            }
          },
          "required": [
            "service_request_id",
            "timezone"
          ]
        },
        "output_schema": {
          "type": "object",
          "properties": {
            "state": {
              "type": "string",
              "enum": [
                "available",
                "unavailable"
              ]
            },
            "slots": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "slot_id": {
                    "type": "string"
                  },
                  "starts_at": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "required": [
                  "slot_id",
                  "starts_at"
                ]
              }
            }
          },
          "required": [
            "state",
            "slots"
          ]
        },
        "idempotency": {
          "mode": "effect_key"
        },
        "timeout_ms": 5000,
        "on_uncertain": "failure_edge"
      },
      "response_variables": {
        "available_slots": "$.slots",
        "slots_state": "$.state"
      }
    },
    {
      "type": "action.put",
      "action": {
        "name": "reserve_service_visit",
        "description": "Reserve only the slot explicitly confirmed by the site contact",
        "channels": [
          "phone"
        ],
        "method": "POST",
        "url": "https://api.example.com/service/reserve_service_visit",
        "headers": {},
        "auth": {
          "scheme": "bearer",
          "secret_ref": {
            "id": "business-api",
            "version": "1"
          }
        },
        "input_schema": {
          "type": "object",
          "properties": {
            "service_request_id": {
              "type": "string",
              "description": "Authorized service request"
            },
            "slot_id": {
              "type": "string",
              "description": "Confirmed slot from availability"
            },
            "site_access_notes": {
              "type": "string",
              "description": "Agreed access instructions"
            }
          },
          "required": [
            "service_request_id",
            "slot_id",
            "site_access_notes"
          ]
        },
        "output_schema": {
          "type": "object",
          "properties": {
            "state": {
              "type": "string",
              "enum": [
                "confirmed",
                "unavailable",
                "pending"
              ]
            },
            "visit_id": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "state"
          ]
        },
        "idempotency": {
          "mode": "effect_key"
        },
        "timeout_ms": 5000,
        "on_uncertain": "failure_edge"
      },
      "response_variables": {
        "visit_state": "$.state",
        "visit_id": "$.visit_id"
      }
    },
    {
      "type": "action.put",
      "action": {
        "name": "record_service_followup",
        "description": "Create a service follow-up linked to the original call and its unresolved result",
        "channels": [
          "phone"
        ],
        "method": "POST",
        "url": "https://api.example.com/service/record_service_followup",
        "headers": {},
        "auth": {
          "scheme": "bearer",
          "secret_ref": {
            "id": "business-api",
            "version": "1"
          }
        },
        "input_schema": {
          "type": "object",
          "properties": {
            "service_request_id": {
              "type": "string",
              "description": "Service request reference"
            },
            "reason": {
              "type": "string",
              "description": "Why follow-up is needed"
            },
            "preferred_language": {
              "type": "string",
              "description": "English or Spanish"
            },
            "call_reference": {
              "type": "string",
              "description": "Business correlation reference supplied at admission"
            }
          },
          "required": [
            "service_request_id",
            "reason",
            "preferred_language",
            "call_reference"
          ]
        },
        "output_schema": {
          "type": "object",
          "properties": {
            "state": {
              "type": "string",
              "enum": [
                "accepted",
                "rejected",
                "pending"
              ]
            },
            "followup_id": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "state"
          ]
        },
        "idempotency": {
          "mode": "effect_key"
        },
        "timeout_ms": 5000,
        "on_uncertain": "failure_edge"
      },
      "response_variables": {
        "followup_state": "$.state",
        "followup_id": "$.followup_id"
      }
    },
    {
      "type": "component.create",
      "component": {
        "id": "service_booking",
        "startNodeId": "slots",
        "nodes": [
          {
            "id": "slots",
            "kind": "function",
            "edges": [
              {
                "destinationNodeId": "slots_result",
                "slot": "edges",
                "condition": {
                  "type": "always"
                }
              }
            ],
            "name": "Find technician availability",
            "toolId": "find_service_slots",
            "waitForResult": true,
            "speakDuringExecution": true,
            "executionMessage": {
              "type": "static_text",
              "text": "I am checking that now."
            }
          },
          {
            "id": "slots_result",
            "kind": "branch",
            "edges": [
              {
                "destinationNodeId": "choose_slot",
                "slot": "edges",
                "condition": {
                  "type": "equation",
                  "operator": "&&",
                  "equations": [
                    {
                      "left": "slots_state",
                      "operator": "==",
                      "right": "available"
                    }
                  ]
                }
              },
              {
                "destinationNodeId": "booking_review",
                "slot": "else_edge",
                "condition": {
                  "type": "always"
                }
              }
            ],
            "name": "Slots available?"
          },
          {
            "id": "choose_slot",
            "kind": "conversation",
            "edges": [
              {
                "destinationNodeId": "confirm_slot",
                "slot": "edges",
                "condition": {
                  "type": "prompt",
                  "prompt": "They select a returned slot"
                }
              },
              {
                "destinationNodeId": "booking_review",
                "slot": "edges",
                "condition": {
                  "type": "prompt",
                  "prompt": "No suitable slot or they decline"
                }
              },
              {
                "destinationNodeId": "dispatch_request",
                "slot": "edges",
                "condition": {
                  "type": "prompt",
                  "prompt": "They need urgent help or a dispatcher"
                }
              }
            ],
            "name": "Offer returned appointment times",
            "instruction": {
              "type": "prompt",
              "text": "Offer only returned slots in {{timezone}}. Ask which works and collect site-access instructions."
            }
          },
          {
            "id": "confirm_slot",
            "kind": "conversation",
            "edges": [
              {
                "destinationNodeId": "reserve",
                "slot": "edges",
                "condition": {
                  "type": "prompt",
                  "prompt": "They explicitly agree to these details"
                }
              },
              {
                "destinationNodeId": "choose_slot",
                "slot": "edges",
                "condition": {
                  "type": "prompt",
                  "prompt": "They change the time or access details"
                }
              },
              {
                "destinationNodeId": "booking_review",
                "slot": "edges",
                "condition": {
                  "type": "prompt",
                  "prompt": "They decline or cannot confirm"
                }
              }
            ],
            "name": "Confirm time and site access",
            "instruction": {
              "type": "prompt",
              "text": "Read back the selected time, time zone, service and site-access notes. Ask for explicit agreement before reserving."
            }
          },
          {
            "id": "reserve",
            "kind": "function",
            "edges": [
              {
                "destinationNodeId": "visit_result",
                "slot": "edges",
                "condition": {
                  "type": "always"
                }
              }
            ],
            "name": "Reserve the confirmed visit",
            "toolId": "reserve_service_visit",
            "waitForResult": true,
            "speakDuringExecution": true,
            "executionMessage": {
              "type": "static_text",
              "text": "I am checking that now."
            }
          },
          {
            "id": "visit_result",
            "kind": "branch",
            "edges": [
              {
                "destinationNodeId": "booking_done",
                "slot": "edges",
                "condition": {
                  "type": "equation",
                  "operator": "&&",
                  "equations": [
                    {
                      "left": "visit_state",
                      "operator": "==",
                      "right": "confirmed"
                    }
                  ]
                }
              },
              {
                "destinationNodeId": "booking_review",
                "slot": "edges",
                "condition": {
                  "type": "equation",
                  "operator": "&&",
                  "equations": [
                    {
                      "left": "visit_state",
                      "operator": "==",
                      "right": "unavailable"
                    }
                  ]
                }
              },
              {
                "destinationNodeId": "booking_review",
                "slot": "else_edge",
                "condition": {
                  "type": "always"
                }
              }
            ],
            "name": "Visit reservation confirmed?"
          },
          {
            "id": "booking_done",
            "kind": "conversation",
            "edges": [
              {
                "destinationNodeId": "booking_end",
                "slot": "edges",
                "condition": {
                  "type": "prompt",
                  "prompt": "They acknowledge"
                }
              }
            ],
            "name": "Read the confirmed visit receipt",
            "instruction": {
              "type": "prompt",
              "text": "Read back only the visit identifier and time returned by the reservation service."
            }
          },
          {
            "id": "booking_review",
            "kind": "conversation",
            "edges": [
              {
                "destinationNodeId": "booking_end",
                "slot": "edges",
                "condition": {
                  "type": "prompt",
                  "prompt": "Continue with follow-up"
                }
              }
            ],
            "name": "Explain the booking exception",
            "instruction": {
              "type": "prompt",
              "text": "Do not say a visit is booked. Explain that scheduling needs review; preserve the proposed slot for reconciliation."
            }
          },
          {
            "id": "dispatch_request",
            "kind": "extract_dynamic_variables",
            "edges": [
              {
                "destinationNodeId": "booking_end",
                "slot": "edges",
                "condition": {
                  "type": "always"
                }
              }
            ],
            "name": "Return a dispatch request",
            "variables": [
              {
                "name": "visit_state",
                "type": "enum",
                "description": "The contact requested dispatch instead of booking; return dispatch_requested",
                "choices": [
                  "dispatch_requested"
                ]
              }
            ]
          },
          {
            "id": "booking_end",
            "kind": "end",
            "edges": [],
            "name": "Return to service routing"
          }
        ],
        "tools": []
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "answer",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "greet",
            "slot": "skip_response_edge",
            "condition": {
              "type": "always"
            }
          }
        ],
        "name": "Neutral answer greeting",
        "instruction": {
          "type": "static_text",
          "text": "Hello, this is an automated service assistant on a recorded line."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "greet",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "verify_contact",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "The requested contact confirms and can talk"
            }
          },
          {
            "destinationNodeId": "purpose",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They ask why you are calling"
            }
          },
          {
            "destinationNodeId": "wrong_contact",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "Wrong person or number"
            }
          },
          {
            "destinationNodeId": "callback",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They cannot talk now"
            }
          },
          {
            "destinationNodeId": "language",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They prefer Spanish or another language"
            }
          },
          {
            "destinationNodeId": "dispatch_intro",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They request a dispatcher or urgent service"
            }
          }
        ],
        "name": "Confirm the requested contact",
        "instruction": {
          "type": "prompt",
          "text": "Hello, this is the automated service assistant for {{business_name}}. May I speak with {{contact_name}}? Do not disclose equipment or site details yet."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "purpose",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "verify_contact",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "The requested contact confirms"
            }
          },
          {
            "destinationNodeId": "clarify_contact",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They still ask who should take the call"
            }
          },
          {
            "destinationNodeId": "wrong_contact",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "Wrong contact"
            }
          },
          {
            "destinationNodeId": "callback",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They decline or are busy"
            }
          },
          {
            "destinationNodeId": "language",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They request another language"
            }
          },
          {
            "destinationNodeId": "dispatch_intro",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They request dispatch"
            }
          }
        ],
        "name": "Explain the call without site details",
        "instruction": {
          "type": "prompt",
          "text": "We are following up on a requested equipment-service visit. Ask whether the requested contact is available. Do not share the site or equipment details."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "clarify_contact",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "verify_contact",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "The requested contact confirms"
            }
          },
          {
            "destinationNodeId": "wrong_contact",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "Contact remains unconfirmed"
            }
          },
          {
            "destinationNodeId": "callback",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They request a later call"
            }
          }
        ],
        "name": "Clarify the contact once",
        "instruction": {
          "type": "prompt",
          "text": "Repeat the contact name and general purpose once. If the contact cannot be confirmed, end without discussing the service request."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "language",
        "kind": "extract_dynamic_variables",
        "edges": [
          {
            "destinationNodeId": "language_route",
            "slot": "edges",
            "condition": {
              "type": "always"
            }
          }
        ],
        "name": "Extract the requested language",
        "variables": [
          {
            "name": "preferred_language",
            "type": "enum",
            "description": "The language explicitly requested by the contact; unsupported for any language other than English or Spanish",
            "choices": [
              "en",
              "es",
              "unsupported"
            ]
          }
        ]
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "language_route",
        "kind": "branch",
        "edges": [
          {
            "destinationNodeId": "spanish_intro",
            "slot": "edges",
            "condition": {
              "type": "equation",
              "operator": "&&",
              "equations": [
                {
                  "left": "preferred_language",
                  "operator": "==",
                  "right": "es"
                }
              ]
            }
          },
          {
            "destinationNodeId": "verify_contact",
            "slot": "edges",
            "condition": {
              "type": "equation",
              "operator": "&&",
              "equations": [
                {
                  "left": "preferred_language",
                  "operator": "==",
                  "right": "en"
                }
              ]
            }
          },
          {
            "destinationNodeId": "unsupported_language",
            "slot": "else_edge",
            "condition": {
              "type": "always"
            }
          }
        ],
        "name": "Supported language?"
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "spanish_intro",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "verify_contact",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "Confirma que es el contacto solicitado"
            }
          },
          {
            "destinationNodeId": "wrong_contact",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "Persona equivocada"
            }
          },
          {
            "destinationNodeId": "callback",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "Solicita otra llamada"
            }
          },
          {
            "destinationNodeId": "dispatch_intro",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "Solicita un operador"
            }
          }
        ],
        "name": "Continue in Spanish",
        "instruction": {
          "type": "prompt",
          "text": "Continúa en español. Confirma si hablas con {{contact_name}} y si puede hablar ahora. No reveles detalles del equipo o del sitio."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "unsupported_language",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "dispatch_intro",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They agree to a handoff"
            }
          },
          {
            "destinationNodeId": "wrong_contact",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They decline"
            }
          }
        ],
        "name": "Offer dispatch for another language",
        "instruction": {
          "type": "prompt",
          "text": "Explain the supported languages and ask permission to try dispatch for language assistance."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "wrong_contact",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "bye",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "End the conversation"
            }
          }
        ],
        "name": "Close without disclosing the request",
        "instruction": {
          "type": "prompt",
          "text": "Thank them and end. Do not share the site, equipment or request details. Do not change the service contact without an authorized process."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "callback",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "followup",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They provide a window or decline further contact"
            }
          }
        ],
        "name": "Capture a requested callback window",
        "instruction": {
          "type": "prompt",
          "text": "Ask for a suitable callback window and time zone. Explain that it is a request until the service system accepts it."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "verify_contact",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "lookup",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They provide the required answer"
            }
          },
          {
            "destinationNodeId": "no_access",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They cannot or do not want to verify"
            }
          },
          {
            "destinationNodeId": "dispatch_intro",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They request an operator"
            }
          }
        ],
        "name": "Collect the business verification answer",
        "instruction": {
          "type": "prompt",
          "text": "Use the service company’s verification procedure. Collect only the required answer. A name match alone does not authorize access to site details."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "lookup",
        "kind": "function",
        "edges": [
          {
            "destinationNodeId": "authorization",
            "slot": "edges",
            "condition": {
              "type": "always"
            }
          }
        ],
        "name": "Check request and contact authorization",
        "toolId": "lookup_service_request",
        "waitForResult": true,
        "speakDuringExecution": true,
        "executionMessage": {
          "type": "static_text",
          "text": "I am checking that now."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "authorization",
        "kind": "branch",
        "edges": [
          {
            "destinationNodeId": "discover",
            "slot": "edges",
            "condition": {
              "type": "equation",
              "operator": "&&",
              "equations": [
                {
                  "left": "scheduling_authorized",
                  "operator": "==",
                  "right": "true"
                }
              ]
            }
          },
          {
            "destinationNodeId": "no_access",
            "slot": "else_edge",
            "condition": {
              "type": "always"
            }
          }
        ],
        "name": "Scheduling access authorized?"
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "no_access",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "bye",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "End without booking"
            }
          }
        ],
        "name": "Stop access to site details",
        "instruction": {
          "type": "prompt",
          "text": "Explain that you cannot confirm access to the service request. Offer the public service number without describing the equipment or site."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "discover",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "extract_service",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "Service need and access requirements are clear"
            }
          },
          {
            "destinationNodeId": "dispatch_intro",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They request urgent help or a dispatcher"
            }
          },
          {
            "destinationNodeId": "callback",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They need to discuss another time"
            }
          },
          {
            "destinationNodeId": "language",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They change language"
            }
          }
        ],
        "name": "Understand the service need",
        "instruction": {
          "type": "prompt",
          "text": "Use the authorized equipment summary. Ask what needs service, whether site access can be arranged and whether they need dispatch rather than a scheduled visit. Do not diagnose or give repair instructions."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "extract_service",
        "kind": "extract_dynamic_variables",
        "edges": [
          {
            "destinationNodeId": "service_route",
            "slot": "edges",
            "condition": {
              "type": "always"
            }
          }
        ],
        "name": "Extract service and access fields",
        "variables": [
          {
            "name": "service_issue",
            "type": "string",
            "description": "The equipment-service issue as stated by the contact; no inferred diagnosis"
          },
          {
            "name": "site_access",
            "type": "enum",
            "description": "Whether the contact can arrange technician access",
            "choices": [
              "confirmed",
              "unconfirmed"
            ]
          },
          {
            "name": "service_route",
            "type": "enum",
            "description": "dispatch for an urgent/operator request; scheduling only when standard service and access are confirmed; otherwise review",
            "choices": [
              "dispatch",
              "scheduling",
              "review"
            ]
          },
          {
            "name": "preferred_language",
            "type": "enum",
            "description": "The contact’s chosen supported language",
            "choices": [
              "en",
              "es"
            ]
          }
        ]
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "service_route",
        "kind": "branch",
        "edges": [
          {
            "destinationNodeId": "dispatch_intro",
            "slot": "edges",
            "condition": {
              "type": "equation",
              "operator": "&&",
              "equations": [
                {
                  "left": "service_route",
                  "operator": "==",
                  "right": "dispatch"
                }
              ]
            }
          },
          {
            "destinationNodeId": "book_visit",
            "slot": "edges",
            "condition": {
              "type": "equation",
              "operator": "&&",
              "equations": [
                {
                  "left": "service_route",
                  "operator": "==",
                  "right": "scheduling"
                },
                {
                  "left": "site_access",
                  "operator": "==",
                  "right": "confirmed"
                }
              ]
            }
          },
          {
            "destinationNodeId": "followup",
            "slot": "else_edge",
            "condition": {
              "type": "always"
            }
          }
        ],
        "name": "Dispatch, visit or review?"
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "book_visit",
        "kind": "component",
        "edges": [
          {
            "destinationNodeId": "outcome",
            "slot": "edges",
            "condition": {
              "type": "always"
            }
          }
        ],
        "name": "Schedule a technician visit",
        "componentId": "service_booking"
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "outcome",
        "kind": "branch",
        "edges": [
          {
            "destinationNodeId": "visit_recap",
            "slot": "edges",
            "condition": {
              "type": "equation",
              "operator": "&&",
              "equations": [
                {
                  "left": "visit_state",
                  "operator": "==",
                  "right": "confirmed"
                }
              ]
            }
          },
          {
            "destinationNodeId": "dispatch_intro",
            "slot": "edges",
            "condition": {
              "type": "equation",
              "operator": "&&",
              "equations": [
                {
                  "left": "visit_state",
                  "operator": "==",
                  "right": "dispatch_requested"
                }
              ]
            }
          },
          {
            "destinationNodeId": "followup",
            "slot": "else_edge",
            "condition": {
              "type": "always"
            }
          }
        ],
        "name": "What did scheduling return?"
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "visit_recap",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "bye",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They acknowledge the confirmed details"
            }
          },
          {
            "destinationNodeId": "dispatch_intro",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They now request a dispatcher"
            }
          }
        ],
        "name": "Confirm the recorded service visit",
        "instruction": {
          "type": "prompt",
          "text": "Summarize the confirmed visit and access instructions. Do not add unconfirmed arrival times or repairs."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "dispatch_intro",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "primary_transfer",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They agree to the transfer"
            }
          },
          {
            "destinationNodeId": "followup",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They prefer follow-up"
            }
          },
          {
            "destinationNodeId": "bye",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They decline further help"
            }
          }
        ],
        "name": "Ask permission to contact dispatch",
        "instruction": {
          "type": "prompt",
          "text": "Explain that you will try the service dispatcher. Ask for agreement; do not promise that someone is already connected."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "primary_transfer",
        "kind": "transfer_call",
        "edges": [
          {
            "destinationNodeId": "backup_intro",
            "slot": "edge",
            "condition": {
              "type": "always"
            }
          }
        ],
        "name": "Transfer to primary dispatch",
        "transfer": {
          "destination": {
            "type": "predefined",
            "number": "{{dispatch_primary}}"
          },
          "option": {
            "type": "cold_transfer"
          },
          "ignoreE164Validation": false
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "backup_intro",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "backup_transfer",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They agree to try the backup"
            }
          },
          {
            "destinationNodeId": "fallback",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They decline another transfer"
            }
          }
        ],
        "name": "Explain the failed first transfer",
        "instruction": {
          "type": "prompt",
          "text": "The first dispatch transfer did not complete. Ask whether you may try the backup line."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "backup_transfer",
        "kind": "transfer_call",
        "edges": [
          {
            "destinationNodeId": "fallback",
            "slot": "edge",
            "condition": {
              "type": "always"
            }
          }
        ],
        "name": "Transfer to backup dispatch",
        "transfer": {
          "destination": {
            "type": "predefined",
            "number": "{{dispatch_backup}}"
          },
          "option": {
            "type": "cold_transfer"
          },
          "ignoreE164Validation": false
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "fallback",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "followup",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They agree to follow-up"
            }
          },
          {
            "destinationNodeId": "bye",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They decline follow-up"
            }
          }
        ],
        "name": "Explain that dispatch is unavailable",
        "instruction": {
          "type": "prompt",
          "text": "Explain that the handoff did not complete. Give {{dispatch_callback_spoken}}. Offer a follow-up request; do not say a dispatcher received it."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "followup",
        "kind": "function",
        "edges": [
          {
            "destinationNodeId": "followup_result",
            "slot": "edges",
            "condition": {
              "type": "always"
            }
          }
        ],
        "name": "Record the requested service follow-up",
        "toolId": "record_service_followup",
        "waitForResult": true,
        "speakDuringExecution": true,
        "executionMessage": {
          "type": "static_text",
          "text": "I am checking that now."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "followup_result",
        "kind": "branch",
        "edges": [
          {
            "destinationNodeId": "followup_saved",
            "slot": "edges",
            "condition": {
              "type": "equation",
              "operator": "&&",
              "equations": [
                {
                  "left": "followup_state",
                  "operator": "==",
                  "right": "accepted"
                }
              ]
            }
          },
          {
            "destinationNodeId": "followup_unsaved",
            "slot": "else_edge",
            "condition": {
              "type": "always"
            }
          }
        ],
        "name": "Follow-up accepted?"
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "followup_saved",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "bye",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They acknowledge"
            }
          }
        ],
        "name": "Read the accepted follow-up reference",
        "instruction": {
          "type": "prompt",
          "text": "Give only the returned follow-up ID. Explain that the team still needs to act on it; do not promise a callback time."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "followup_unsaved",
        "kind": "conversation",
        "edges": [
          {
            "destinationNodeId": "bye",
            "slot": "edges",
            "condition": {
              "type": "prompt",
              "prompt": "They acknowledge"
            }
          }
        ],
        "name": "Explain that follow-up is unconfirmed",
        "instruction": {
          "type": "prompt",
          "text": "Say that you could not confirm the follow-up request. Give the public dispatch callback number. Do not promise that a ticket exists."
        }
      }
    },
    {
      "type": "node.create",
      "component_id": null,
      "node": {
        "id": "bye",
        "kind": "end",
        "edges": [],
        "name": "End the service call"
      }
    },
    {
      "type": "flow.configure",
      "changes": {
        "startNodeId": "answer",
        "startSpeaker": "agent",
        "globalPrompt": "Coordinate an existing equipment-service request. Use English or Spanish as requested. Check business authorization before site disclosure. Offer only returned appointment slots. Confirm a reservation only from its receipt. A failed transfer is not a handoff. Never diagnose equipment, promise a repair, or replay an uncertain write.",
        "defaultDynamicVariables": {
          "business_name": "Acme Equipment Care",
          "contact_name": "Alex",
          "service_request_id": "SR-DEMO-24",
          "contact_reference": "CONTACT-DEMO-24",
          "call_reference": "CALL-DEMO-24",
          "timezone": "America/New_York",
          "preferred_language": "en",
          "scheduling_authorized": "false",
          "visit_state": "not_reserved",
          "followup_state": "not_accepted",
          "dispatch_primary": "+14155550130",
          "dispatch_backup": "+14155550131",
          "dispatch_callback_spoken": "four one five, five five five, zero one three two"
        },
        "toolCallStrictMode": true
      }
    },
    {
      "type": "layout.set",
      "component_id": null,
      "nodes": {
        "answer": {
          "x": 0,
          "y": 0
        },
        "greet": {
          "x": 390,
          "y": 0
        },
        "purpose": {
          "x": 780,
          "y": 0
        },
        "clarify_contact": {
          "x": 1170,
          "y": 0
        },
        "language": {
          "x": 1560,
          "y": 0
        },
        "language_route": {
          "x": 0,
          "y": 300
        },
        "spanish_intro": {
          "x": 390,
          "y": 300
        },
        "unsupported_language": {
          "x": 780,
          "y": 300
        },
        "wrong_contact": {
          "x": 1170,
          "y": 300
        },
        "callback": {
          "x": 1560,
          "y": 300
        },
        "verify_contact": {
          "x": 0,
          "y": 600
        },
        "lookup": {
          "x": 390,
          "y": 600
        },
        "authorization": {
          "x": 780,
          "y": 600
        },
        "no_access": {
          "x": 1170,
          "y": 600
        },
        "discover": {
          "x": 1560,
          "y": 600
        },
        "extract_service": {
          "x": 0,
          "y": 900
        },
        "service_route": {
          "x": 390,
          "y": 900
        },
        "book_visit": {
          "x": 780,
          "y": 900
        },
        "outcome": {
          "x": 1170,
          "y": 900
        },
        "visit_recap": {
          "x": 1560,
          "y": 900
        },
        "dispatch_intro": {
          "x": 0,
          "y": 1200
        },
        "primary_transfer": {
          "x": 390,
          "y": 1200
        },
        "backup_intro": {
          "x": 780,
          "y": 1200
        },
        "backup_transfer": {
          "x": 1170,
          "y": 1200
        },
        "fallback": {
          "x": 1560,
          "y": 1200
        },
        "followup": {
          "x": 0,
          "y": 1500
        },
        "followup_result": {
          "x": 390,
          "y": 1500
        },
        "followup_saved": {
          "x": 780,
          "y": 1500
        },
        "followup_unsaved": {
          "x": 1170,
          "y": 1500
        },
        "bye": {
          "x": 1560,
          "y": 1500
        }
      },
      "start": {
        "x": -200,
        "y": 0
      }
    },
    {
      "type": "layout.set",
      "component_id": "service_booking",
      "nodes": {
        "slots": {
          "x": 0,
          "y": 0
        },
        "slots_result": {
          "x": 390,
          "y": 0
        },
        "choose_slot": {
          "x": 780,
          "y": 0
        },
        "confirm_slot": {
          "x": 0,
          "y": 300
        },
        "reserve": {
          "x": 390,
          "y": 300
        },
        "visit_result": {
          "x": 780,
          "y": 300
        },
        "booking_done": {
          "x": 0,
          "y": 600
        },
        "booking_review": {
          "x": 390,
          "y": 600
        },
        "dispatch_request": {
          "x": 780,
          "y": 600
        },
        "booking_end": {
          "x": 0,
          "y": 900
        }
      },
      "start": {
        "x": -200,
        "y": 0
      }
    }
  ]
}
