SmsPort Docs / WhatsApp

Expression Functions

Reference of supported predefined expression functions.

Math

add, sub, mul, div, round, min, max

  • add(a, b, ...): add numeric values. Use for totals and fee calculation.
  • sub(a, b): subtract second value from first. Use for remaining balance or difference.
  • mul(a, b): multiply values. Use for rate x quantity or percentage base math.
  • div(a, b): divide first value by second. Use for average/ratio calculations.
  • round(a): round to nearest integer. Use to clean decimal output for display.
  • min(a, b, ...): return smallest value. Use for lower-bound checks.
  • max(a, b, ...): return largest value. Use for top score/highest amount.
expression
add(10, 5)            // 15
sub(10, 5)            // 5
mul(4, 3)             // 12
div(22, 7)            // 3.142857...
round(12.6)           // 13
min(10, 3, 8)         // 3
max(10, 3, 8)         // 10

Text

concat, lower, upper, trim

  • concat(a, b, ...): join values into one string. Use to build reply text.
  • lower(text): convert text to lowercase. Use for normalization before comparisons.
  • upper(text): convert text to uppercase. Use for labels/codes formatting.
  • trim(text): remove leading/trailing spaces. Use before save/validation.
expression
concat("Hi ", {{name}})      // Hi Mithun
lower("HELLO")              // hello
upper("hello")              // HELLO
trim("  lead  ")            // lead

Logic

if, eq, ne, gt, gte, lt, lte, and, or, not

  • if(condition, trueValue, falseValue): choose output by condition result.
  • eq(a, b): check equality. Use for exact status/intent matching.
  • ne(a, b): check non-equality. Use for exclude cases.
  • gt(a, b): true if a is greater than b. Use for threshold checks.
  • gte(a, b): true if a is greater than or equal to b.
  • lt(a, b): true if a is less than b.
  • lte(a, b): true if a is less than or equal to b.
  • and(a, b, ...): true when all conditions are true.
  • or(a, b, ...): true when any condition is true.
  • not(a): reverse boolean value. Use to negate a condition.
expression
eq({{status}}, "ok")                 // true/false
gt({{score}}, 80)                    // true/false
and(gt({{score}}, 80), eq({{intent}}, "admission"))
if(gt({{score}}, 80), "hot", "warm")

Date/System

now, today, date_add_days, date_add_hours, date_diff_days, day_of_week, year, month, date_format, start_of_week, end_of_week, timezone_convert

  • now(): current date-time in ISO format. Use for audit timestamps.
  • today(): current date in YYYY-MM-DD. Use for date-only fields.
  • date_add_days(date, days): add days to a date. Use for follow-up date planning.
  • date_add_hours(date, hours): add hours to date-time. Use for short reminder scheduling.
  • date_diff_days(date1, date2): difference in days (date1 - date2). Use for SLA/age checks.
  • day_of_week(date): returns weekday name in lowercase (example: monday).
  • year(date): returns UTC year number.
  • month(date): returns UTC month number (1-12).
  • date_format(date, pattern): format date with supported patterns only.
  • start_of_week(date): returns Monday date of the same week (YYYY-MM-DD).
  • end_of_week(date): returns Sunday date of the same week (YYYY-MM-DD).
  • timezone_convert(date, timezone): converts date-time display to IANA timezone string.
expression
now()                                      // ISO datetime
today()                                    // YYYY-MM-DD
date_add_days(today(), 3)                  // YYYY-MM-DD (+3 days)
date_add_hours(now(), 2)                   // ISO datetime (+2h)
date_diff_days("2026-05-20", "2026-05-16") // 4
day_of_week("2026-05-16")                  // saturday
year("2026-05-16")                         // 2026
month("2026-05-16")                        // 5
date_format("2026-05-16T10:30:00Z", "DD/MM/YYYY") // 16/05/2026
start_of_week("2026-05-16")                // 2026-05-11
end_of_week("2026-05-16")                  // 2026-05-17
timezone_convert("2026-05-16T10:30:00Z", "Asia/Kolkata") // 2026-05-16 16:00:00

Supported date_format patterns: YYYY-MM-DD, DD-MM-YYYY, YYYY/MM/DD, DD/MM/YYYY, YYYY-MM-DD HH:mm:ss.