{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/causeriebot-com/json-schema/causeriebot-com-conversation-schema.json",
  "title": "Conversation",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/causeriebot-com-openapi.json#/components/schemas/Conversation",
  "type": "object",
  "required": [
    "id",
    "chatbot",
    "source",
    "status",
    "is_lead",
    "started_at",
    "last_message_at",
    "lead",
    "messages"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "chatbot": {
      "$ref": "#/$defs/ChatbotRef"
    },
    "source": {
      "type": [
        "string",
        "null"
      ]
    },
    "status": {
      "type": [
        "string",
        "null"
      ]
    },
    "is_lead": {
      "type": "boolean"
    },
    "started_at": {
      "type": "string",
      "format": "date-time"
    },
    "last_message_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "lead": {
      "oneOf": [
        {
          "$ref": "#/$defs/ConversationLead"
        },
        {
          "type": "null"
        }
      ]
    },
    "messages": {
      "type": "array",
      "maxItems": 500,
      "items": {
        "$ref": "#/$defs/Message"
      }
    }
  },
  "$defs": {
    "ChatbotRef": {
      "type": "object",
      "required": [
        "id",
        "name"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "ConversationLead": {
      "type": "object",
      "required": [
        "id",
        "name",
        "email",
        "phone",
        "company",
        "source",
        "created_at"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "email": {
          "type": [
            "string",
            "null"
          ]
        },
        "phone": {
          "type": [
            "string",
            "null"
          ]
        },
        "company": {
          "type": [
            "string",
            "null"
          ]
        },
        "source": {
          "type": [
            "string",
            "null"
          ]
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "Message": {
      "type": "object",
      "required": [
        "id",
        "role",
        "content",
        "created_at"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "role": {
          "type": "string",
          "enum": [
            "visitor",
            "assistant"
          ]
        },
        "content": {
          "type": "string"
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    }
  }
}