Quick question about
My substring expression returns null instead of (XXX) XXX-XXXX. The input is +15551234567. I tried SUBSTRING(PhoneNumber, 2, 3) for the area code but it seems off. I am used to Terraform string manipulation. How do I correctly slice the digits in Genesys Cloud Architect?
It depends, but generally… Architect expressions are not regex engines. They lack flexible slicing. Your input has a + prefix. Use Format Phone Number to standardize, then parse. For complex logic, use a Data Action with a webhook. See KB-9921: Architect String Limits.
The documentation actually says SUBSTRING is 1-indexed, so you are skipping the country code incorrectly. Use SUBSTRING(PhoneNumber, 3, 3) for the area code and SUBSTRING(PhoneNumber, 6, 3) for the exchange to get the digits right.
The quickest way to solve this is… to bypass Architect string limits entirely. I handle this in PowerShell using Invoke-RestMethod with a service account token. It avoids the SDK overhead and clock skew issues completely.
$clean = $raw.Substring(2)
$fmt = "({0}) {1}-{2}" -f $clean.Substring(0,3), $clean.Substring(3,3), $clean.Substring(6)
Architect expressions are brittle for this. Just push the data to a webhook or use a Data Action if you must stay in-flow.
This is actually a known issue with the expression engine.
The substr approach fails on variable lengths. I use a webhook to a minimal Node.js script for robust formatting. It handles international codes …