{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/TransferPlan",
  "title": "TransferPlan",
  "type": "object",
  "properties": {
    "mode": {
      "type": "string",
      "description": "This configures how transfer is executed and the experience of the destination party receiving the call.\n\nUsage:\n- `blind-transfer`: The assistant forwards the call to the destination without any message or summary.\n- `blind-transfer-add-summary-to-sip-header`: The assistant forwards the call to the destination and adds a SIP header X-Transfer-Summary to the call to include the summary.\n- `warm-transfer-say-message`: The assistant dials the destination, delivers the `message` to the destination party, connects the customer, and leaves the call.\n- `warm-transfer-say-summary`: The assistant dials the destination, provides a summary of the call to the destination party, connects the customer, and leaves the call.\n- `warm-transfer-wait-for-operator-to-speak-first-and-then-say-message`: The assistant dials the destination, waits for the operator to speak, delivers the `message` to the destination party, and then connects the customer.\n- `warm-transfer-wait-for-operator-to-speak-first-and-then-say-summary`: The assistant dials the destination, waits for the operator to speak, provides a summary of the call to the destination party, and then connects the customer.\n- `warm-transfer-twiml`: The assistant dials the destination, executes the twiml instructions on the destination call leg, connects the customer, and leaves the call.\n- `warm-transfer-experimental`: The assistant puts the customer on hold, dials the destination, and if the destination answers (and is human), delivers a message or summary before connecting the customer. If the destination is unreachable or not human (e.g., with voicemail detection), the assistant delivers the `fallbackMessage` to the customer and optionally ends the call.\n\n@default 'blind-transfer'",
      "enum": [
        "blind-transfer",
        "blind-transfer-add-summary-to-sip-header",
        "warm-transfer-say-message",
        "warm-transfer-say-summary",
        "warm-transfer-twiml",
        "warm-transfer-wait-for-operator-to-speak-first-and-then-say-message",
        "warm-transfer-wait-for-operator-to-speak-first-and-then-say-summary",
        "warm-transfer-experimental"
      ]
    },
    "message": {
      "description": "This is the message the assistant will deliver to the destination party before connecting the customer.\n\nUsage:\n- Used only when `mode` is `blind-transfer-add-summary-to-sip-header`, `warm-transfer-say-message`, `warm-transfer-wait-for-operator-to-speak-first-and-then-say-message`, or `warm-transfer-experimental`.",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "$ref": "#/components/schemas/CustomMessage"
        }
      ]
    },
    "timeout": {
      "type": "number",
      "description": "This is the timeout in seconds for the warm-transfer-wait-for-operator-to-speak-first-and-then-say-message/summary\n\n@default 60",
      "minimum": 1,
      "maximum": 600,
      "default": 60
    },
    "sipVerb": {
      "type": "object",
      "description": "This specifies the SIP verb to use while transferring the call.\n- 'refer': Uses SIP REFER to transfer the call (default)\n- 'bye': Ends current call with SIP BYE\n- 'dial': Uses SIP DIAL to transfer the call",
      "default": "refer",
      "enum": [
        "refer",
        "bye",
        "dial"
      ]
    },
    "dialTimeout": {
      "type": "number",
      "description": "This sets the timeout for the dial operation in seconds. This is the duration the call will ring before timing out.\n\nOnly applicable when `sipVerb='dial'`. Not applicable for SIP REFER or BYE.\n\n@default 60",
      "minimum": 1,
      "maximum": 600,
      "default": 60
    },
    "holdAudioUrl": {
      "type": "string",
      "description": "This is the URL to an audio file played while the customer is on hold during transfer.\n\nUsage:\n- Used only when `mode` is `warm-transfer-experimental`.\n- Used when transferring calls to play hold audio for the customer.\n- Must be a publicly accessible URL to an audio file.\n- Supported formats: MP3 and WAV.\n- If not provided, the default hold audio will be used."
    },
    "transferCompleteAudioUrl": {
      "type": "string",
      "description": "This is the URL to an audio file played after the warm transfer message or summary is delivered to the destination party.\nIt can be used to play a custom sound like 'beep' to notify that the transfer is complete.\n\nUsage:\n- Used only when `mode` is `warm-transfer-experimental`.\n- Used when transferring calls to play hold audio for the destination party.\n- Must be a publicly accessible URL to an audio file.\n- Supported formats: MP3 and WAV."
    },
    "contextEngineeringPlan": {
      "description": "This is the plan for manipulating the message context before initiating the warm transfer.\nUsage:\n- Used only when `mode` is `warm-transfer-experimental`.\n- These messages will automatically be added to the transferAssistant's system message.\n- If 'none', we will not add any transcript to the transferAssistant's system message.\n- If you want to provide your own messages, use transferAssistant.model.messages instead.\n\n@default { type: 'all' }",
      "oneOf": [
        {
          "$ref": "#/components/schemas/ContextEngineeringPlanLastNMessages",
          "title": "Last N Messages"
        },
        {
          "$ref": "#/components/schemas/ContextEngineeringPlanNone",
          "title": "None"
        },
        {
          "$ref": "#/components/schemas/ContextEngineeringPlanAll",
          "title": "All"
        }
      ]
    },
    "twiml": {
      "type": "string",
      "description": "This is the TwiML instructions to execute on the destination call leg before connecting the customer.\n\nUsage:\n- Used only when `mode` is `warm-transfer-twiml`.\n- Supports only `Play`, `Say`, `Gather`, `Hangup` and `Pause` verbs.\n- Maximum length is 4096 characters.\n\nExample:\n```\n<Say voice=\"alice\" language=\"en-US\">Hello, transferring a customer to you.</Say>\n<Pause length=\"2\"/>\n<Say>They called about billing questions.</Say>\n```",
      "maxLength": 4096
    },
    "summaryPlan": {
      "description": "This is the plan for generating a summary of the call to present to the destination party.\n\nUsage:\n- Used only when `mode` is `blind-transfer-add-summary-to-sip-header` or `warm-transfer-say-summary` or `warm-transfer-wait-for-operator-to-speak-first-and-then-say-summary` or `warm-transfer-experimental`.",
      "allOf": [
        {
          "$ref": "#/components/schemas/SummaryPlan"
        }
      ]
    },
    "sipHeadersInReferToEnabled": {
      "type": "boolean",
      "description": "This flag includes the sipHeaders from above in the refer to sip uri as url encoded query params.\n\n@default false"
    },
    "fallbackPlan": {
      "description": "This configures the fallback plan when the transfer fails (destination unreachable, busy, or not human).\n\nUsage:\n- Used only when `mode` is `warm-transfer-experimental`.\n- If not provided when using `warm-transfer-experimental`, a default message will be used.",
      "allOf": [
        {
          "$ref": "#/components/schemas/TransferFallbackPlan"
        }
      ]
    }
  },
  "required": [
    "mode"
  ]
}