Trying to clean up incoming caller ID data in Architect. The source system passes E.164 format like “+14155552671”. Need it formatted as “(415) 555-2671” for display on the agent desktop.
Tried using the standard string manipulation functions. The expression looks like this:
format("(%s) %s-%s", right(substring(caller_id, 2, 3), 3), right(substring(caller_id, 5, 3), 3), right(substring(caller_id, 8, 4), 4))
Wait, that syntax is wrong for Architect. Actually tried:
concat("(", substring(caller_id, 2, 3), ") ", substring(caller_id, 5, 3), "-", substring(caller_id, 8, 4))
Getting a “Expression evaluation error” in the debug log. The variable caller_id definitely contains the string. Checked the data type, it’s a string.
Also tried using replace to strip the plus sign first:
replace(caller_id, "+", "")
Then applying the substring logic. Still fails. The error message just says “Invalid expression” without pointing to the specific token.
Is there a built-in function for phone number formatting? Don’t want to write a complex regex if there’s a simpler way. The format function in Architect seems limited compared to standard programming languages. Can’t find docs on supported format specifiers.
Also tried this approach:
left(substring(caller_id, 2), 3)
To get the area code. Works in isolation. But chaining it with concat breaks.
Any ideas on the correct syntax? Or is there a better way to handle this in the flow before the IVR starts? The data comes from the SIP header, so it’s raw.