Quick question about writing an Architect expression that formats a phone number from +1XXXXXXXXXX to (XXX) XXX-XXXX.
I am building a data action to normalize outbound dial strings before passing them to a CTI connector. The source data comes in E.164 format via a REST proxy, but the legacy PBX requires NANP.
I tried this expression in the Assign step:
assign:
- name: formatted_phone
value: "{{REGEX_REPLACE(contact.phone, '(\\+1)(\\d{3})(\\d{3})(\\d{4})', '($2) $3-$4')}}"
It fails with a REGEX MISMATCH error. The engine seems to choke on the parentheses or the escape sequences. I know I can do this in the GraphQL gateway layer using JS, but the requirement is to handle it at the Architect level to keep the gateway logic clean.
How do I structure the regex correctly for the Architect expression evaluator? I need to strip the +1 and inject the formatting characters.
- Input:
+14165550199 - Expected Output:
(416) 555-0199
Any working examples?