{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/service-cloud/json-schema/service-cloud-init-message-envelope-schema.json",
  "title": "InitMessageEnvelope",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/service-cloud-bot-api-openapi.yml#/components/schemas/InitMessageEnvelope",
  "type": "object",
  "properties": {
    "externalSessionKey": {
      "$ref": "#/$defs/ExternalSessionKey"
    },
    "message": {
      "$ref": "#/$defs/TextInitMessage"
    },
    "forceConfig": {
      "$ref": "#/$defs/ForceConfig"
    },
    "responseOptions": {
      "$ref": "#/$defs/ResponseOptions"
    },
    "tz": {
      "description": "Client timezone where the customer starts the chat.",
      "type": [
        "string",
        "null"
      ]
    },
    "variables": {
      "$ref": "#/$defs/Variables"
    },
    "referrers": {
      "description": "Array of referrers of transferring the session to another bot.",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/Referrer"
      }
    }
  },
  "required": [
    "forceConfig",
    "externalSessionKey"
  ],
  "additionalProperties": false,
  "$defs": {
    "BooleanVariable": {
      "type": "object",
      "properties": {
        "name": {
          "description": "API name of a variable defined in the bot definition.",
          "type": "string"
        },
        "type": {
          "description": "Variable type of a boolean variable.",
          "type": "string",
          "enum": [
            "boolean"
          ]
        },
        "value": {
          "description": "Boolean value.",
          "type": [
            "boolean",
            "null"
          ]
        }
      },
      "required": [
        "name",
        "type",
        "value"
      ],
      "additionalProperties": false
    },
    "DateTimeVariable": {
      "type": "object",
      "properties": {
        "name": {
          "description": "API name of a variable defined in the bot definition.",
          "type": "string"
        },
        "type": {
          "description": "Variable type of a datetime variable.",
          "type": "string",
          "enum": [
            "dateTime"
          ]
        },
        "value": {
          "description": "Datetime in format ISO_LOCAL_DATE_TIME 'YYYY-MM-DDTHH:MM:SS'.",
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "name",
        "type",
        "value"
      ],
      "additionalProperties": false
    },
    "DateVariable": {
      "type": "object",
      "properties": {
        "name": {
          "description": "API name of a variable defined in the bot definition.",
          "type": "string"
        },
        "type": {
          "description": "Variable type of a date variable.",
          "type": "string",
          "enum": [
            "date"
          ]
        },
        "value": {
          "description": "Date in format ISO_LOCAL_DATE 'YYYY-MM-DD'.",
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "name",
        "type",
        "value"
      ],
      "additionalProperties": false
    },
    "ExternalSessionKey": {
      "description": "UUID in string format for the conversation. You can use this parameter to trace the conversation in your bot's event logs.",
      "type": "string"
    },
    "ForceConfig": {
      "type": "object",
      "description": "API configuration parameters.",
      "properties": {
        "endpoint": {
          "description": "Instance URL of your Salesforce org. You can find the value in the **ForceConfig Endpoint** field of the **Add Connection** dialog when you add the connected app to the bot (see [Get Started with Einstein Bot API](https://developer.salesforce.com/docs/service/einstein-bot-api/guide/prerequisites.html)).",
          "type": "string"
        }
      },
      "required": [
        "endpoint"
      ],
      "additionalProperties": false
    },
    "ListVariable": {
      "type": "object",
      "properties": {
        "name": {
          "description": "API name of a variable defined in the bot definition.",
          "type": "string"
        },
        "type": {
          "description": "Object variable that contains a list.",
          "type": "string",
          "enum": [
            "list"
          ]
        },
        "value": {
          "description": "Array of objects.",
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "object"
          }
        }
      },
      "required": [
        "name",
        "type",
        "value"
      ],
      "additionalProperties": false
    },
    "MoneyVariable": {
      "type": "object",
      "properties": {
        "name": {
          "description": "API name of a variable defined in the bot definition.",
          "type": "string"
        },
        "type": {
          "description": "Variable type of a money variable storing the currency and amount.",
          "type": "string",
          "enum": [
            "money"
          ]
        },
        "value": {
          "description": "Money in format '3_LETTER_CURRENCY_CODE AMOUNT'.",
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "name",
        "type",
        "value"
      ],
      "additionalProperties": false
    },
    "NumberVariable": {
      "type": "object",
      "properties": {
        "name": {
          "description": "API name of a variable defined in the bot definition.",
          "type": "string"
        },
        "type": {
          "description": "Variable type of a number variable.",
          "type": "string",
          "enum": [
            "number"
          ]
        },
        "value": {
          "description": "Variable value in number format.",
          "type": [
            "number",
            "null"
          ]
        }
      },
      "required": [
        "name",
        "type",
        "value"
      ],
      "additionalProperties": false
    },
    "ObjectVariable": {
      "type": "object",
      "properties": {
        "name": {
          "description": "API name of a variable defined in the bot definition.",
          "type": "string"
        },
        "type": {
          "description": "Variable type of an object variable.",
          "type": "string",
          "enum": [
            "object"
          ]
        },
        "value": {
          "description": "Variable value is an object.",
          "allOf": [
            {
              "$ref": "#/$defs/Variables"
            }
          ]
        }
      },
      "required": [
        "name",
        "type",
        "value"
      ],
      "additionalProperties": false
    },
    "RefVariable": {
      "type": "object",
      "properties": {
        "name": {
          "description": "API name of a variable defined in the bot definition.",
          "type": "string"
        },
        "type": {
          "description": "Variable type of a reference ID variable.",
          "type": "string",
          "enum": [
            "ref"
          ]
        },
        "value": {
          "description": "Variable value in reference ID format.",
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "name",
        "type",
        "value"
      ],
      "additionalProperties": false
    },
    "Referrer": {
      "type": "object",
      "properties": {
        "type": {
          "description": "Referrer type.",
          "type": "string",
          "enum": [
            "Salesforce:Core:Bot:Id",
            "Salesforce:BotRuntime:Session:Id"
          ]
        },
        "value": {
          "type": "string",
          "description": "ID of referrer."
        }
      },
      "required": [
        "type",
        "value"
      ]
    },
    "ResponseOptions": {
      "type": "object",
      "description": "Configuration of additional information returned in the response payload.",
      "properties": {
        "variables": {
          "$ref": "#/$defs/ResponseOptionsVariables"
        },
        "metrics": {
          "type": "boolean",
          "description": "Indicates whether to include metrics in the response."
        },
        "intents": {
          "type": "boolean",
          "description": "Indicates whether to include all intents detected when processing the current request."
        },
        "entities": {
          "type": "boolean",
          "description": "Indicates whether to include all entities detected when processing the current request."
        }
      },
      "additionalProperties": false
    },
    "ResponseOptionsVariables": {
      "type": "object",
      "description": "Variables returned in the response.",
      "properties": {
        "include": {
          "type": "boolean",
          "description": "Indicates whether to include variables in the response."
        },
        "filter": {
          "type": [
            "array",
            "null"
          ],
          "description": "Filter the returned variables. If missing, null, or empty, no filtering is applied.",
          "items": {
            "type": "string",
            "description": "Variable name to filter the returned variables on."
          }
        },
        "onlyChanged": {
          "type": "boolean",
          "description": "Indicates whether the response contains only changed variables."
        }
      },
      "required": [
        "include",
        "onlyChanged"
      ],
      "additionalProperties": false
    },
    "TextInitMessage": {
      "type": "object",
      "properties": {
        "text": {
          "description": "Initial message from the customer to the bot to begin a session.",
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "TextVariable": {
      "type": "object",
      "properties": {
        "name": {
          "description": "API name of a variable defined in the bot definition.",
          "type": "string"
        },
        "type": {
          "description": "Variable type of a text variable.",
          "type": "string",
          "enum": [
            "text"
          ]
        },
        "value": {
          "description": "Variable value in text format.",
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "name",
        "type",
        "value"
      ],
      "additionalProperties": false
    },
    "Variables": {
      "type": [
        "array",
        "null"
      ],
      "description": "Array of custom and context variables passed to the bot when initiating a session (see [What’s a Variable?](https://help.salesforce.com/s/articleView?id=sf.bots_service_whats_a_variable.htm&type=5&_ga=2.50520745.1281711304.1657558186-1967832163.1652719780)).",
      "items": {
        "anyOf": [
          {
            "$ref": "#/$defs/BooleanVariable"
          },
          {
            "$ref": "#/$defs/DateVariable"
          },
          {
            "$ref": "#/$defs/DateTimeVariable"
          },
          {
            "$ref": "#/$defs/MoneyVariable"
          },
          {
            "$ref": "#/$defs/NumberVariable"
          },
          {
            "$ref": "#/$defs/TextVariable"
          },
          {
            "$ref": "#/$defs/ObjectVariable"
          },
          {
            "$ref": "#/$defs/RefVariable"
          },
          {
            "$ref": "#/$defs/ListVariable"
          }
        ]
      }
    }
  }
}