Step one: the outbound campaign needs to send the formatted number to the legacy SMS provider before the call connects, so we’re trying to do this purely in the Architect expression builder to avoid spinning up a Studio script for such a simple string manipulation. The raw number is coming in from the contact center as +12025550199, and the external API strictly requires (202) 555-0199.
Step two: tried building the expression using concat and substring to slice the string manually. The logic looks like concat("(", substring(contact.phoneNumber, 2, 3), ") ", substring(contact.phoneNumber, 5, 3), "-", substring(contact.phoneNumber, 8, 4)).
Step three: the validation passes green in the builder, but the runtime output hitting the webhook is (20) 25-550199. Something’s definitely off with the character offsets or how Architect counts the start index compared to standard zero-based indexing.
Step four: swapped to a replace approach hoping for regex support to handle the pattern matching automatically. The expression builder chokes on capture groups immediately. Getting a hard validation error: Invalid expression: replace function does not support regex capture groups.
Step five: tried chaining multiple replace calls to strip the + and 1 first, then inject the brackets, but the expression string is getting unwieldy and hard to maintain.
The Data Action JSON mapping looks like this: { "phoneNumber": "{{contact.phoneNumber}}" }. We’re trying to swap that value with the expression directly in the field editor. Also, the timezone is London, so maybe that affects string parsing? Probably not, but the docs mention locale sensitivity for some functions. Step six: checked the response from the legacy provider when the bad string hits. Getting a 400 Bad Request with the body { "error": "INVALID_PHONE_FORMAT", "details": "Expected parentheses around area code" }.
The flow is running in the London region, and the contact data is pulled from a custom attribute set. We’ve got roughly fifty thousand contacts moving through this queue per hour, so hitting a Studio script for every single record adds too much latency. The script would need to parse the attribute, run a regex replace, and push the result back to the conversation object before the Data Action triggers. That’s way too many hops.
Is there a nested function combination that actually works for this pattern? Maybe using indexOf to find the + and 1 dynamically before slicing? The expression builder keeps throwing syntax errors whenever we nest more than two functions deep. Also, the substring function reference is pretty sparse. Just says ‘returns a portion of the string’ without clarifying if the length includes the start character or not.
Tried a workaround using replace(contact.phoneNumber, "+", "") followed by replace(contact.phoneNumber, "1", ""), but that strips all ones from the number, which breaks the subscriber ID if there’s a one in the local number.
The expression editor UI is also lagging when we paste the long concatenated string, making it hard to debug. Just throwing this out there since the substring indices are completely broken for this use case.