{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://docs.testing.nairon.cloud/openapi/conversation-design.v1.schema.json",
  "title": "ConversationDesign (cd/1)",
  "description": "Public, versioned Conversation Design document (cd/1). A complete, lossless representation of an Advanced project's conversation flow. Beta (x-beta).",
  "x-beta": true,
  "type": "object",
  "properties": {
    "schemaVersion": {
      "type": "string",
      "const": "cd/1"
    },
    "entry": {
      "type": "object",
      "properties": {
        "stepId": {
          "type": "string",
          "minLength": 1
        },
        "alternates": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "required": [
        "stepId"
      ],
      "additionalProperties": false
    },
    "steps": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "minLength": 1
      },
      "additionalProperties": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "greeting"
              },
              "name": {
                "type": "string"
              },
              "introLine": {
                "type": "string"
              },
              "persona": {
                "type": "object",
                "properties": {
                  "whoAmI": {
                    "type": "string"
                  },
                  "purpose": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              },
              "on": {
                "type": "object",
                "properties": {
                  "next": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false
              }
            },
            "required": [
              "kind",
              "on"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "talk"
              },
              "name": {
                "type": "string"
              },
              "topic": {
                "type": "string"
              },
              "knowledgeRefs": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "strict": {
                "type": "boolean"
              },
              "on": {
                "type": "object",
                "properties": {
                  "done": {
                    "type": "string",
                    "minLength": 1
                  },
                  "offTopic": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false
              }
            },
            "required": [
              "kind",
              "topic",
              "on"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "route"
              },
              "name": {
                "type": "string"
              },
              "ask": {
                "type": "boolean"
              },
              "question": {
                "type": "string"
              },
              "options": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1
                    },
                    "title": {
                      "type": "string"
                    },
                    "description": {
                      "type": "string"
                    },
                    "target": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "id"
                  ],
                  "additionalProperties": false
                }
              },
              "on": {
                "type": "object",
                "properties": {
                  "default": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false
              }
            },
            "required": [
              "kind",
              "on"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "collect"
              },
              "name": {
                "type": "string"
              },
              "format": {
                "type": "string",
                "enum": [
                  "text",
                  "number",
                  "object"
                ]
              },
              "prompt": {
                "type": "string"
              },
              "variable": {
                "type": "string",
                "minLength": 1
              },
              "on": {
                "type": "object",
                "properties": {
                  "answered": {
                    "type": "string",
                    "minLength": 1
                  },
                  "fallback": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false
              }
            },
            "required": [
              "kind",
              "format",
              "prompt",
              "on"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "keypad"
              },
              "name": {
                "type": "string"
              },
              "prompt": {
                "type": "string"
              },
              "variable": {
                "type": "string",
                "minLength": 1
              },
              "timeoutSeconds": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              },
              "on": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "string",
                    "minLength": 1
                  },
                  "timeout": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false
              }
            },
            "required": [
              "kind",
              "prompt",
              "on"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "confirm"
              },
              "name": {
                "type": "string"
              },
              "prompt": {
                "type": "string"
              },
              "on": {
                "type": "object",
                "properties": {
                  "yes": {
                    "type": "string",
                    "minLength": 1
                  },
                  "no": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false
              }
            },
            "required": [
              "kind",
              "prompt",
              "on"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "recordingConsent"
              },
              "name": {
                "type": "string"
              },
              "prompt": {
                "type": "string"
              },
              "on": {
                "type": "object",
                "properties": {
                  "consent": {
                    "type": "string",
                    "minLength": 1
                  },
                  "decline": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false
              }
            },
            "required": [
              "kind",
              "prompt",
              "on"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "end"
              },
              "name": {
                "type": "string"
              },
              "summarize": {
                "type": "boolean"
              },
              "allowCancel": {
                "type": "boolean"
              },
              "on": {
                "type": "object",
                "properties": {
                  "cancel": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false
              }
            },
            "required": [
              "kind",
              "on"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "transfer"
              },
              "name": {
                "type": "string"
              },
              "target": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "internal",
                      "phone"
                    ]
                  },
                  "phoneNumber": {
                    "type": "string"
                  }
                },
                "required": [
                  "type"
                ],
                "additionalProperties": false
              },
              "timeoutSeconds": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              },
              "on": {
                "type": "object",
                "properties": {
                  "timeout": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false
              }
            },
            "required": [
              "kind",
              "target",
              "on"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "callback"
              },
              "name": {
                "type": "string"
              },
              "schedule": {
                "type": "string",
                "enum": [
                  "slots",
                  "asap"
                ]
              },
              "timeFrames": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "day": {
                      "type": "string",
                      "enum": [
                        "monday",
                        "tuesday",
                        "wednesday",
                        "thursday",
                        "friday",
                        "saturday",
                        "sunday"
                      ]
                    },
                    "startTime": {
                      "type": "string"
                    },
                    "endTime": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "day",
                    "startTime",
                    "endTime"
                  ],
                  "additionalProperties": false
                }
              },
              "askForName": {
                "type": "boolean"
              },
              "integrationRef": {
                "type": "string",
                "minLength": 1
              },
              "on": {
                "type": "object",
                "properties": {
                  "success": {
                    "type": "string",
                    "minLength": 1
                  },
                  "failure": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false
              }
            },
            "required": [
              "kind",
              "on"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "knowledge": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1
              },
              "kind": {
                "type": "string",
                "const": "knowledgeBase"
              },
              "knowledgeBaseId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "id",
              "kind",
              "knowledgeBaseId"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1
              },
              "kind": {
                "type": "string",
                "const": "text"
              },
              "text": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "kind",
              "text"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "variables": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "text",
              "number",
              "object"
            ]
          }
        },
        "required": [
          "id",
          "type"
        ],
        "additionalProperties": false
      }
    },
    "integrations": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "kind": {
            "type": "string",
            "enum": [
              "crm",
              "calendar",
              "knowledge"
            ]
          },
          "integrationId": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "id",
          "kind",
          "integrationId"
        ],
        "additionalProperties": false
      }
    },
    "hooks": {
      "type": "object",
      "properties": {
        "before": {
          "type": "object",
          "properties": {
            "rootNodeId": {
              "type": "string",
              "minLength": 1
            },
            "entryPoints": {
              "type": "object",
              "propertyNames": {
                "type": "string",
                "minLength": 1
              },
              "additionalProperties": {
                "type": "string",
                "minLength": 1
              }
            },
            "nodes": {
              "type": "object",
              "propertyNames": {
                "type": "string",
                "minLength": 1
              },
              "additionalProperties": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1
                  },
                  "name": {
                    "type": "string"
                  },
                  "next": {
                    "type": "object",
                    "properties": {
                      "hookNode": {
                        "type": "string",
                        "minLength": 1
                      },
                      "step": {
                        "type": "string",
                        "minLength": 1
                      },
                      "end": {
                        "type": "boolean",
                        "const": true
                      }
                    },
                    "additionalProperties": false
                  },
                  "webhook": {
                    "type": "object",
                    "properties": {
                      "url": {
                        "type": "string"
                      },
                      "headers": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      "secretHint": {
                        "type": "string"
                      },
                      "signatureHeader": {
                        "type": "string"
                      },
                      "payload": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "key": {
                              "type": "string"
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "variable",
                                "custom",
                                "ai"
                              ]
                            },
                            "systemVariable": {
                              "type": "string"
                            },
                            "variableId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "value": {
                              "type": "string"
                            },
                            "aiPrompt": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "key",
                            "source"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "timeoutSeconds": {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      "responseVariableId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "responsePath": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "url",
                      "payload"
                    ],
                    "additionalProperties": false
                  },
                  "fetch": {
                    "type": "object",
                    "properties": {
                      "url": {
                        "type": "string"
                      },
                      "method": {
                        "type": "string",
                        "enum": [
                          "GET",
                          "POST"
                        ]
                      },
                      "query": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      "headers": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      "body": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "key": {
                              "type": "string"
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "variable",
                                "custom",
                                "ai"
                              ]
                            },
                            "systemVariable": {
                              "type": "string"
                            },
                            "variableId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "value": {
                              "type": "string"
                            },
                            "aiPrompt": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "key",
                            "source"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "responseFormat": {
                        "type": "string",
                        "enum": [
                          "json",
                          "text"
                        ]
                      },
                      "responseMappings": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "variableId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "path": {
                              "type": "string"
                            },
                            "transform": {
                              "type": "string",
                              "enum": [
                                "auto",
                                "text",
                                "number",
                                "boolean",
                                "json"
                              ]
                            },
                            "defaultValue": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "variableId"
                          ],
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "url",
                      "method",
                      "responseMappings"
                    ],
                    "additionalProperties": false
                  },
                  "condition": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "mode": {
                            "type": "string",
                            "const": "logic"
                          },
                          "branches": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "label": {
                                  "type": "string"
                                },
                                "predicate": {
                                  "type": "object",
                                  "properties": {
                                    "variable": {
                                      "type": "object",
                                      "properties": {
                                        "systemVariable": {
                                          "type": "string"
                                        },
                                        "variableId": {
                                          "type": "string",
                                          "minLength": 1
                                        }
                                      },
                                      "additionalProperties": false
                                    },
                                    "operator": {
                                      "type": "string",
                                      "enum": [
                                        "eq",
                                        "neq",
                                        "exists",
                                        "not_exists",
                                        "gt",
                                        "lt",
                                        "contains"
                                      ]
                                    },
                                    "value": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "variable",
                                    "operator"
                                  ],
                                  "additionalProperties": false
                                },
                                "next": {
                                  "type": "object",
                                  "properties": {
                                    "hookNode": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "step": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "end": {
                                      "type": "boolean",
                                      "const": true
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "id",
                                "label",
                                "predicate",
                                "next"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "else": {
                            "type": "object",
                            "properties": {
                              "hookNode": {
                                "type": "string",
                                "minLength": 1
                              },
                              "step": {
                                "type": "string",
                                "minLength": 1
                              },
                              "end": {
                                "type": "boolean",
                                "const": true
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "mode",
                          "branches",
                          "else"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "mode": {
                            "type": "string",
                            "const": "ai"
                          },
                          "prompt": {
                            "type": "string"
                          },
                          "branches": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "label": {
                                  "type": "string"
                                },
                                "description": {
                                  "type": "string"
                                },
                                "next": {
                                  "type": "object",
                                  "properties": {
                                    "hookNode": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "step": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "end": {
                                      "type": "boolean",
                                      "const": true
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "id",
                                "label",
                                "description",
                                "next"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "else": {
                            "type": "object",
                            "properties": {
                              "hookNode": {
                                "type": "string",
                                "minLength": 1
                              },
                              "step": {
                                "type": "string",
                                "minLength": 1
                              },
                              "end": {
                                "type": "boolean",
                                "const": true
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "mode",
                          "prompt",
                          "branches",
                          "else"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  },
                  "setVariable": {
                    "type": "object",
                    "properties": {
                      "variableId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "value": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "variableId",
                      "value"
                    ],
                    "additionalProperties": false
                  },
                  "sendSms": {
                    "type": "object",
                    "properties": {
                      "to": {
                        "type": "object",
                        "properties": {
                          "systemVariable": {
                            "type": "string"
                          },
                          "variableId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "literalString": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false
                      },
                      "message": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "to",
                      "message"
                    ],
                    "additionalProperties": false
                  },
                  "crmLookup": {
                    "type": "object",
                    "properties": {
                      "integrationRef": {
                        "type": "string",
                        "minLength": 1
                      },
                      "matchBy": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "phone",
                            "email"
                          ]
                        }
                      },
                      "phoneSource": {
                        "type": "object",
                        "properties": {
                          "systemVariable": {
                            "type": "string"
                          },
                          "variableId": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "additionalProperties": false
                      },
                      "emailSource": {
                        "type": "object",
                        "properties": {
                          "systemVariable": {
                            "type": "string"
                          },
                          "variableId": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "additionalProperties": false
                      },
                      "fieldMappings": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "field": {
                              "type": "string"
                            },
                            "variableId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "defaultValue": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "field",
                            "variableId"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "includePrimaryDeal": {
                        "type": "boolean"
                      },
                      "onNotFound": {
                        "type": "object",
                        "properties": {
                          "hookNode": {
                            "type": "string",
                            "minLength": 1
                          },
                          "step": {
                            "type": "string",
                            "minLength": 1
                          },
                          "end": {
                            "type": "boolean",
                            "const": true
                          }
                        },
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "integrationRef",
                      "matchBy",
                      "fieldMappings"
                    ],
                    "additionalProperties": false
                  },
                  "crmWrite": {
                    "type": "object",
                    "properties": {
                      "integrationRef": {
                        "type": "string",
                        "minLength": 1
                      },
                      "contactIdSource": {
                        "type": "object",
                        "properties": {
                          "systemVariable": {
                            "type": "string"
                          },
                          "variableId": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "additionalProperties": false
                      },
                      "createContactIfMissing": {
                        "type": "boolean"
                      },
                      "operations": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "log_call",
                            "create_note",
                            "update_contact"
                          ]
                        }
                      },
                      "logCall": {
                        "type": "object",
                        "properties": {
                          "subjectTemplate": {
                            "type": "string"
                          },
                          "includeTranscript": {
                            "type": "boolean"
                          },
                          "includeSummary": {
                            "type": "boolean"
                          },
                          "includeRecordingUrl": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "includeTranscript",
                          "includeSummary",
                          "includeRecordingUrl"
                        ],
                        "additionalProperties": false
                      },
                      "createNote": {
                        "type": "object",
                        "properties": {
                          "bodyTemplate": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "bodyTemplate"
                        ],
                        "additionalProperties": false
                      },
                      "updateContact": {
                        "type": "object",
                        "properties": {
                          "propertyMappings": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "property": {
                                  "type": "string"
                                },
                                "propertyLabel": {
                                  "type": "string"
                                },
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "variable",
                                    "custom",
                                    "ai"
                                  ]
                                },
                                "systemVariable": {
                                  "type": "string"
                                },
                                "variableId": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "value": {
                                  "type": "string"
                                },
                                "aiPrompt": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "property",
                                "source"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "propertyMappings"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "integrationRef",
                      "contactIdSource",
                      "operations"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "id"
                ],
                "additionalProperties": false
              }
            }
          },
          "required": [
            "nodes"
          ],
          "additionalProperties": false
        },
        "after": {
          "type": "object",
          "properties": {
            "entryPoints": {
              "type": "object",
              "propertyNames": {
                "type": "string",
                "minLength": 1
              },
              "additionalProperties": {
                "type": "string",
                "minLength": 1
              }
            },
            "prematureHangupNodeId": {
              "type": "string",
              "minLength": 1
            },
            "nodes": {
              "type": "object",
              "propertyNames": {
                "type": "string",
                "minLength": 1
              },
              "additionalProperties": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1
                  },
                  "name": {
                    "type": "string"
                  },
                  "next": {
                    "type": "object",
                    "properties": {
                      "hookNode": {
                        "type": "string",
                        "minLength": 1
                      },
                      "step": {
                        "type": "string",
                        "minLength": 1
                      },
                      "end": {
                        "type": "boolean",
                        "const": true
                      }
                    },
                    "additionalProperties": false
                  },
                  "webhook": {
                    "type": "object",
                    "properties": {
                      "url": {
                        "type": "string"
                      },
                      "headers": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      "secretHint": {
                        "type": "string"
                      },
                      "signatureHeader": {
                        "type": "string"
                      },
                      "payload": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "key": {
                              "type": "string"
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "variable",
                                "custom",
                                "ai"
                              ]
                            },
                            "systemVariable": {
                              "type": "string"
                            },
                            "variableId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "value": {
                              "type": "string"
                            },
                            "aiPrompt": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "key",
                            "source"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "timeoutSeconds": {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      "responseVariableId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "responsePath": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "url",
                      "payload"
                    ],
                    "additionalProperties": false
                  },
                  "fetch": {
                    "type": "object",
                    "properties": {
                      "url": {
                        "type": "string"
                      },
                      "method": {
                        "type": "string",
                        "enum": [
                          "GET",
                          "POST"
                        ]
                      },
                      "query": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      "headers": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      "body": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "key": {
                              "type": "string"
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "variable",
                                "custom",
                                "ai"
                              ]
                            },
                            "systemVariable": {
                              "type": "string"
                            },
                            "variableId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "value": {
                              "type": "string"
                            },
                            "aiPrompt": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "key",
                            "source"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "responseFormat": {
                        "type": "string",
                        "enum": [
                          "json",
                          "text"
                        ]
                      },
                      "responseMappings": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "variableId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "path": {
                              "type": "string"
                            },
                            "transform": {
                              "type": "string",
                              "enum": [
                                "auto",
                                "text",
                                "number",
                                "boolean",
                                "json"
                              ]
                            },
                            "defaultValue": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "variableId"
                          ],
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "url",
                      "method",
                      "responseMappings"
                    ],
                    "additionalProperties": false
                  },
                  "condition": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "mode": {
                            "type": "string",
                            "const": "logic"
                          },
                          "branches": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "label": {
                                  "type": "string"
                                },
                                "predicate": {
                                  "type": "object",
                                  "properties": {
                                    "variable": {
                                      "type": "object",
                                      "properties": {
                                        "systemVariable": {
                                          "type": "string"
                                        },
                                        "variableId": {
                                          "type": "string",
                                          "minLength": 1
                                        }
                                      },
                                      "additionalProperties": false
                                    },
                                    "operator": {
                                      "type": "string",
                                      "enum": [
                                        "eq",
                                        "neq",
                                        "exists",
                                        "not_exists",
                                        "gt",
                                        "lt",
                                        "contains"
                                      ]
                                    },
                                    "value": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "variable",
                                    "operator"
                                  ],
                                  "additionalProperties": false
                                },
                                "next": {
                                  "type": "object",
                                  "properties": {
                                    "hookNode": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "step": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "end": {
                                      "type": "boolean",
                                      "const": true
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "id",
                                "label",
                                "predicate",
                                "next"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "else": {
                            "type": "object",
                            "properties": {
                              "hookNode": {
                                "type": "string",
                                "minLength": 1
                              },
                              "step": {
                                "type": "string",
                                "minLength": 1
                              },
                              "end": {
                                "type": "boolean",
                                "const": true
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "mode",
                          "branches",
                          "else"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "mode": {
                            "type": "string",
                            "const": "ai"
                          },
                          "prompt": {
                            "type": "string"
                          },
                          "branches": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "label": {
                                  "type": "string"
                                },
                                "description": {
                                  "type": "string"
                                },
                                "next": {
                                  "type": "object",
                                  "properties": {
                                    "hookNode": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "step": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "end": {
                                      "type": "boolean",
                                      "const": true
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "id",
                                "label",
                                "description",
                                "next"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "else": {
                            "type": "object",
                            "properties": {
                              "hookNode": {
                                "type": "string",
                                "minLength": 1
                              },
                              "step": {
                                "type": "string",
                                "minLength": 1
                              },
                              "end": {
                                "type": "boolean",
                                "const": true
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "mode",
                          "prompt",
                          "branches",
                          "else"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  },
                  "setVariable": {
                    "type": "object",
                    "properties": {
                      "variableId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "value": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "variableId",
                      "value"
                    ],
                    "additionalProperties": false
                  },
                  "sendSms": {
                    "type": "object",
                    "properties": {
                      "to": {
                        "type": "object",
                        "properties": {
                          "systemVariable": {
                            "type": "string"
                          },
                          "variableId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "literalString": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false
                      },
                      "message": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "to",
                      "message"
                    ],
                    "additionalProperties": false
                  },
                  "crmLookup": {
                    "type": "object",
                    "properties": {
                      "integrationRef": {
                        "type": "string",
                        "minLength": 1
                      },
                      "matchBy": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "phone",
                            "email"
                          ]
                        }
                      },
                      "phoneSource": {
                        "type": "object",
                        "properties": {
                          "systemVariable": {
                            "type": "string"
                          },
                          "variableId": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "additionalProperties": false
                      },
                      "emailSource": {
                        "type": "object",
                        "properties": {
                          "systemVariable": {
                            "type": "string"
                          },
                          "variableId": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "additionalProperties": false
                      },
                      "fieldMappings": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "field": {
                              "type": "string"
                            },
                            "variableId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "defaultValue": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "field",
                            "variableId"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "includePrimaryDeal": {
                        "type": "boolean"
                      },
                      "onNotFound": {
                        "type": "object",
                        "properties": {
                          "hookNode": {
                            "type": "string",
                            "minLength": 1
                          },
                          "step": {
                            "type": "string",
                            "minLength": 1
                          },
                          "end": {
                            "type": "boolean",
                            "const": true
                          }
                        },
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "integrationRef",
                      "matchBy",
                      "fieldMappings"
                    ],
                    "additionalProperties": false
                  },
                  "crmWrite": {
                    "type": "object",
                    "properties": {
                      "integrationRef": {
                        "type": "string",
                        "minLength": 1
                      },
                      "contactIdSource": {
                        "type": "object",
                        "properties": {
                          "systemVariable": {
                            "type": "string"
                          },
                          "variableId": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "additionalProperties": false
                      },
                      "createContactIfMissing": {
                        "type": "boolean"
                      },
                      "operations": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "log_call",
                            "create_note",
                            "update_contact"
                          ]
                        }
                      },
                      "logCall": {
                        "type": "object",
                        "properties": {
                          "subjectTemplate": {
                            "type": "string"
                          },
                          "includeTranscript": {
                            "type": "boolean"
                          },
                          "includeSummary": {
                            "type": "boolean"
                          },
                          "includeRecordingUrl": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "includeTranscript",
                          "includeSummary",
                          "includeRecordingUrl"
                        ],
                        "additionalProperties": false
                      },
                      "createNote": {
                        "type": "object",
                        "properties": {
                          "bodyTemplate": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "bodyTemplate"
                        ],
                        "additionalProperties": false
                      },
                      "updateContact": {
                        "type": "object",
                        "properties": {
                          "propertyMappings": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "property": {
                                  "type": "string"
                                },
                                "propertyLabel": {
                                  "type": "string"
                                },
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "variable",
                                    "custom",
                                    "ai"
                                  ]
                                },
                                "systemVariable": {
                                  "type": "string"
                                },
                                "variableId": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "value": {
                                  "type": "string"
                                },
                                "aiPrompt": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "property",
                                "source"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "propertyMappings"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "integrationRef",
                      "contactIdSource",
                      "operations"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "id"
                ],
                "additionalProperties": false
              }
            }
          },
          "required": [
            "nodes"
          ],
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "compliance": {
      "type": "object",
      "properties": {
        "aiDisclosure": {
          "type": "object",
          "propertyNames": {
            "type": "string",
            "minLength": 1
          },
          "additionalProperties": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "approved",
                  "rejected"
                ]
              },
              "checkedText": {
                "type": "string"
              },
              "reason": {
                "type": "string"
              }
            },
            "required": [
              "status",
              "checkedText"
            ],
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    "layout": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "minLength": 1
      },
      "additionalProperties": {
        "type": "object",
        "properties": {
          "x": {
            "type": "number"
          },
          "y": {
            "type": "number"
          }
        },
        "required": [
          "x",
          "y"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "schemaVersion",
    "entry",
    "steps"
  ],
  "additionalProperties": false
}
