Custom Attributes
Custom Attributes are the additional fields you can add to your contacts.
Custom Attributes are the additional fields you can add to your contacts in Chatbase. Each chatbot has its own custom attribute schema that defines what additional data can be stored for contacts.
Schema Management
Field Lifecycle
- Custom attributes, once created, cannot be deleted from the schema
- Fields can be archived to prevent new usage while preserving historical data
- When a field is archived:
- New contacts cannot be created with this field
- Existing contacts cannot update this field
- The field can only be set to null
- Existing values are preserved and still readable
Available Endpoints
The Custom Attributes API provides the following endpoints:
- List Custom Attributes: Retrieve all custom attributes for a chatbot
- Create Custom Attribute: Add a new custom attribute to a chatbot
Available Types
For storing text values
For storing numeric values
For storing true/false values
Data of type boolean passed to the contacts API will be coerced to a boolean.
For example, a string of value “true” will be converted to a true
.
And a string of value “false” will be converted to a false
.
Also, a number of value 0
will be converted to a false
.
And a number of value 1
will be converted to a true
.
For storing dates in ISO 8601 format
Data of type date passed to the contacts API will be coerced to a date.
Supporting formats exactly supported by Javascript Date.
Custom Attribute Object
The unique identifier for the custom attribute
The type of the attribute. One of: text
, number
, boolean
, date
The display label for the attribute
Description of the attribute
Whether the attribute is archived. If true, the attribute cannot be used for new or updated values
Using Custom Attributes
Once you’ve created custom attributes, you can:
- Add values for these attributes when creating contacts
- Update values through the update contact endpoint
- View values when listing contacts or getting a single contact
Example
Field Handling
Custom Attributes Validation
Fields under the custom_attributes
object go through the following validation:
- Field existence check against the schema, non-existent fields are silently removed
- Archival status check (archived fields are rejected)
- Type validation against the defined type in schema
- Value storage if all checks pass
Best Practices
- Choose descriptive names for your custom attributes
- Use appropriate types for your data
- Provide clear descriptions to help other team members understand the purpose of each attribute
- Keep the number of custom attributes manageable
- Plan your schema carefully as fields cannot be removed