Vapi · Schema

VariableExtractionPlan

AIVoiceAgentsRealtimeCPaaS

Properties

Name Type Description
schema object This is the schema to extract. Examples: 1. To extract object properties, you can use the following schema: ```json { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "
aliases array These are additional variables to create. These will be accessible during the call as `{{key}}` and stored in `call.artifact.variableValues` after the call. Example: ```json { "aliases": [ { "key": "c
View JSON Schema on GitHub

JSON Schema

vapi-variableextractionplan-schema.json Raw ↑
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/VariableExtractionPlan",
  "title": "VariableExtractionPlan",
  "type": "object",
  "properties": {
    "schema": {
      "description": "This is the schema to extract.\n\nExamples:\n1. To extract object properties, you can use the following schema:\n```json\n{\n  \"type\": \"object\",\n  \"properties\": {\n    \"name\": {\n      \"type\": \"string\"\n    },\n    \"age\": {\n      \"type\": \"number\"\n    }\n  }\n}\n```\n\nThese will be extracted as `{{ name }}` and `{{ age }}` respectively. To emphasize, object properties are extracted as direct global variables.\n\n2. To extract nested properties, you can use the following schema:\n```json\n{\n  \"type\": \"object\",\n  \"properties\": {\n    \"name\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"first\": {\n          \"type\": \"string\"\n        },\n        \"last\": {\n          \"type\": \"string\"\n        }\n      }\n    }\n  }\n}\n```\n\nThese will be extracted as `{{ name }}`. And, `{{ name.first }}` and `{{ name.last }}` will be accessible.\n\n3. To extract array items, you can use the following schema:\n```json\n{\n  \"type\": \"array\",\n  \"title\": \"zipCodes\",\n  \"items\": {\n    \"type\": \"string\"\n  }\n}\n```\n\nThis will be extracted as `{{ zipCodes }}`. To access the array items, you can use `{{ zipCodes[0] }}` and `{{ zipCodes[1] }}`.\n\n4. To extract array of objects, you can use the following schema:\n\n```json\n{\n  \"type\": \"array\",\n  \"name\": \"people\",\n  \"items\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"name\": {\n        \"type\": \"string\"\n      },\n      \"age\": {\n        \"type\": \"number\"\n      },\n      \"zipCodes\": {\n        \"type\": \"array\",\n        \"items\": {\n          \"type\": \"string\"\n        }\n      }\n    }\n  }\n}\n```\n\nThis will be extracted as `{{ people }}`. To access the array items, you can use `{{ people[n].name }}`, `{{ people[n].age }}`, `{{ people[n].zipCodes }}`, `{{ people[n].zipCodes[0] }}` and `{{ people[n].zipCodes[1] }}`.",
      "allOf": [
        {
          "$ref": "#/components/schemas/JsonSchema"
        }
      ]
    },
    "aliases": {
      "description": "These are additional variables to create.\n\nThese will be accessible during the call as `{{key}}` and stored in `call.artifact.variableValues` after the call.\n\nExample:\n```json\n{\n  \"aliases\": [\n    {\n      \"key\": \"customerName\",\n      \"value\": \"{{name}}\"\n    },\n    {\n      \"key\": \"fullName\",\n      \"value\": \"{{firstName}} {{lastName}}\"\n    },\n    {\n      \"key\": \"greeting\",\n      \"value\": \"Hello {{name}}, welcome to {{company}}!\"\n    },\n    {\n      \"key\": \"customerCity\",\n      \"value\": \"{{addresses[0].city}}\"\n    },\n    {\n      \"key\": \"something\",\n      \"value\": \"{{any liquid}}\"\n    }\n  ]\n}\n```\n\nThis will create variables `customerName`, `fullName`, `greeting`, `customerCity`, and `something`. To access these variables, you can reference them as `{{customerName}}`, `{{fullName}}`, `{{greeting}}`, `{{customerCity}}`, and `{{something}}`.",
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/VariableExtractionAlias"
      }
    }
  }
}