Custom variables
# support
h
Hello, can i use custom variables during making call inside customer ? im calling in batches and can only add 1 assistantOverrides . Can i use variables inside customer, or can i add assistantOverrides inside customer?
Copy code
curl -X POST https://api.vapi.ai/call \
     -H "Authorization: Bearer f215f296-3be5-4021-9306-55137af2eb06" \
     -H "Content-Type: application/json" \
     -d '{
  "customers": [
    {
      "number": "13123123123",
      "name": "jon",
      "custom_lastname": "carpenter",
      "numberE164CheckEnabled": true
    },
    {
      "number": "13123423123123",
      "name": "jon1",
      "custom_lastname": "carpenter1",
      "numberE164CheckEnabled": true
    }
  ],
}'
or what can i do in this case, please help
v
Hi there! 👋 I'm unable to confirm if your exact batched call structure with the "customers" array is correct, but I can definitely help with your questions about custom variables and assistantOverrides! Based on the information I found, you cannot add custom variables directly inside the customer object, and you also cannot add assistantOverrides inside the customer object. Let me explain why and what alternatives you have. ## Custom Variables in the Customer Object According to information from [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1344652901791961211), the
customer
object has a limited set of predefined properties. When someone tried to add a custom property to the customer object, they received an error:
"customer.property company_name should not exist"
. The
CustomerUserEditable
class defines only these available fields: -
number
-
numberE164CheckEnabled
-
sipUri
-
name
-
extension
So your
custom_lastname
property would likely cause an error. ## AssistantOverrides Inside Customer Object The
assistantOverrides
and
customer
are separate entities in the API call structure and cannot be nested. They exist at the same level in the request body, not with one inside the other. ## How to Use Custom Variables The proper way to use custom variables is through the
assistantOverrides.variableValues
object at the top level of your request:
Copy code
json
{
  "assistantId": "your-assistant-id",
  "assistantOverrides": {
    "variableValues": {
      "lastname": "carpenter"
    }
  },
  "customer": {
    "number": "+1xxxxxxxxxx",
    "name": "jon"
  },
  "phoneNumberId": "your-phone-id"
}
Then in your assistant's prompts, you can use
{{lastname}}
to access this variable. ## Alternative Approaches For your batched calls scenario, you might consider:
1. Using
assistantOverrides.metadata
as a workaround to store additional customer information, though this won't be visible in the customer field in logs. 2. If you need different variables for each call, you might need to make separate API calls for each customer rather than using a batch approach. Is there anything specific about your use case that I can help clarify further? Sources: - [Discord discussion about customer object limitations](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1344652901791961211) - [Discord discussion about assistantOverrides.metadata](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341746304744685599) - [Vapi documentation on dynamic variables](https://docs.vapi.ai/assistants/dynamic-variables) - [Discord thread about customer object structure](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341746304744685599)
or you could just store it in the
customer.name
property, like
"John--carpenter"
and split by
--
though name is max 40 chars
h
when m making batch call , i can use 1 assistanOverrides for all customers in batch . how can i have different custom variables for each customer in batch ?
v
Hey Hackett, as of now, you can only pass a single record for a customer object. You cannot pass multiples, so you have to use a property named "customer" of type record only.