Beta Feature: Computation custom fields are currently in beta. While fully functional, this feature may receive updates and improvements. Please test thoroughly before using in production environments.
What youโll learn: How to perform mathematical calculations and date manipulations directly within your custom fields using
mathutil
and dateutil
functions.What Are Computation Custom Fields?
Computation custom fields are advanced dynamic placeholders that can perform calculations and manipulations on your data in real-time. Instead of just inserting static values, these fields can:- Perform mathematical operations (addition, subtraction, multiplication, division)
- Calculate dates (add or subtract days, months, years, hours, minutes, seconds)
- Create dynamic values based on existing custom field data
Why Use Computation Custom Fields? ๐ฏ
The Problem:
- Need to calculate payment amounts with interest or fees
- Want to set reminder dates based on due dates
- Require dynamic pricing based on existing values
- Need follow-up dates calculated automatically
The Solution:
- Real-time calculations within your prompts
- No manual math or date calculations needed
- Dynamic values that update automatically
- Professional, accurate, and consistent results
Math Utility (mathutil) ๐ข
Themathutil
function lets you perform mathematical operations on numeric custom fields.
Basic Syntax
Supported Operations
Operation | Symbol | Description | Example |
---|---|---|---|
Addition | + | Add a number | {mathutil:{AmountDue}+50} |
Subtraction | - | Subtract a number | {mathutil:{AmountDue}-25} |
Multiplication | * | Multiply by a number | {mathutil:{AmountDue}*1.05} |
Division | / | Divide by a number | {mathutil:{AmountDue}/2} |
Math Examples
Adding Late Fees
Calculating Interest
Payment Plans
Discounts
Advanced Math Examples
Complex Financial Calculations
Pricing Adjustments
Date Utility (dateutil) ๐
Thedateutil
function lets you calculate dates by adding or subtracting time periods from existing dates.
Basic Syntax
Supported Time Units
Unit | Symbol | Description | Example |
---|---|---|---|
Days | d | Calendar days | +5d (5 days later) |
Months | m | Calendar months | -2m (2 months ago) |
Years | y | Calendar years | +1y (1 year later) |
Hours | h | Hours | +24h (24 hours later) |
Minutes | min | Minutes | +30min (30 minutes later) |
Seconds | s | Seconds | +3600s (1 hour later) |
Special Date References
Reference | Description | Usage |
---|---|---|
{today} | Current date/time | {dateutil:{today}+7d} |
{FieldName} | Any date field | {dateutil:{DueDate}+30d} |
Date Examples
Payment Reminders
Appointment Scheduling
Contract Periods
Advanced Date Examples
Debt Collection Timeline
Subscription Management
Combining Math and Date Utilities ๐
You can use both math and date utilities in the same prompt for complex calculations:Dynamic Payment Scheduling
Interest Calculations with Dates
Required Fields and Dependencies ๐
For Date Utilities:
Mandatory Fields for
dateutil
: When using any dateutil
operations, both {today}
and {time_zone}
fields are mandatory and must be included in your prompt. During testing or when uploading audience data, you must provide the time_zone
field, while today
will be filled automatically by Vodex.Required Fields:
today
- Current date/time (automatically provided by Vodex)raw_today
- Raw timestamp format (automatically provided)time_zone
- Userโs timezone (must be provided)
Valid Timezone Formats:
Important: The
time_zone
field must be a valid timezone. Invalid timezones will cause โSomething went wrongโ errors.The field
today
should be left blank when making calls via Agent Call, Campaign Run, or API. Vodex will fill it automatically using the time_zone
field. For more details about these base fields, see our Custom Fields Introduction.For Math Utilities:
- The referenced field must contain numeric data
- Field must exist in your custom fields data
- Values must be convertible to numbers
Error Handling and Validation โ ๏ธ
Common Math Errors
Error Scenario | Cause | Solution |
---|---|---|
Division by zero | {mathutil:{Amount}/0} | Use non-zero divisors |
Invalid operation | {mathutil:{Amount}%5} | Use supported operators (+, -, *, /) |
Non-numeric field | Field contains text | Ensure field has numeric data |
Missing field | Referenced field doesnโt exist | Verify field name and data |
Common Date Errors
Error Scenario | Cause | Solution |
---|---|---|
Missing today field | today not provided | Vodex provides this automatically |
Invalid timezone | Wrong timezone format | Use valid timezone strings |
Invalid date format | Canโt parse source date | Use standard date formats |
Missing time unit | {dateutil:{today}+5} | Include unit: +5d |
Error Examples
Math Error - Division by Zero:
Date Error - Missing Unit:
Field Missing Error:
Best Practices for Computation Fields ๐
1. Always Validate Your Data
- Ensure numeric fields contain valid numbers
- Verify date fields have proper date formats
- Test with sample data before going live
2. Use Descriptive Field Names
3. Handle Edge Cases
- Plan for missing data scenarios
- Consider what happens with zero values
- Test with various data types
4. Keep Calculations Simple
- Use straightforward operations when possible
- Break complex calculations into multiple fields
- Make calculations easy to understand and verify
5. Test Thoroughly
- Test with different numeric values
- Try various date scenarios
- Verify timezone handling
Real-World Use Cases ๐
Debt Collection Agency
Healthcare Appointment Reminders
Subscription Services
Real Estate Follow-ups
Testing Your Computation Fields ๐งช
Testing Checklist
- Math operations work correctly - Test all four operations
- Date calculations are accurate - Verify date arithmetic
- Field references resolve - Ensure all fields exist
- Error handling works - Test with invalid data
- Timezone handling correct - Test with different timezones
- Conversation flows naturally - Verify the computed values make sense
Sample Test Data
Expected Results
Troubleshooting Guide ๐ง
Math Issues
Problem: Field shows wrong calculation- Check field contains numeric data
- Verify operation syntax
- Test with simple values first
- Ensure youโre not dividing by zero
- Check for decimal vs integer division
- Verify the divisor value
Date Issues
Problem: Date calculation fails- Verify timezone is properly set
- Check source date format
- Ensure time unit is included
- Confirm timezone is correct
- Check if daylight saving affects calculation
- Verify source date is accurate
Next Steps ๐
Now that you understand computation custom fields:- Start with simple calculations - Begin with basic math operations
- Test thoroughly - Verify calculations with sample data
- Add date computations - Include timeline calculations
- Combine both features - Create sophisticated prompts
- Monitor and optimize - Track performance and accuracy
Ready to supercharge your custom fields? Computation fields unlock powerful dynamic capabilities that make your AI conversations more intelligent, accurate, and useful. Start implementing them today to create more sophisticated and helpful interactions.
Need the basics first? Check out our Custom Fields Introduction and Best Practices guides before diving into computation features.