mozziemozz / M365CallFlowVisualizer

Reads a config from Microsoft 365 Phone System and renders them visually into a mermaid-js flowchart.
MIT License
95 stars 27 forks source link

White spaces in ID string for external phone numbers #45

Closed shappee747 closed 2 months ago

shappee747 commented 2 months ago

HI,

some of our AutoAttendants/CallQueues have a forwarding to external phone, either as IVR Menu Option or as an exception action. For these nodes the phone number is used as ID in the flowchart. Microsoft does some enforced number formatting on these numbers, so they will always contain white spaces. This leads to mermaid syntax errors. Example:

Error: Parse error on line 4: ...Target) --> +49**** *** ***(External Num -----------------------^

Number is anonymized.

I did the following changes to circumvent the issue:

`3822,3823c3822,3823 < < $CqOverFlowActionFriendly = "cqOverFlowAction$($cqCallFlowObjectId)(TransferCallToTarget) --> $($cqOverFlowPhoneNumber)(External Number
$cqOverFlowPhoneNumber)"

            $cqOverFlowPhoneNumberId = $cqOverFlowPhoneNumber -replace "\s+", ""
            $CqOverFlowActionFriendly = "cqOverFlowAction$($cqCallFlowObjectId)(TransferCallToTarget) --> $($cqOverFlowPhoneNumberId)(External Number <br> $cqOverFlowPhoneNumber)"

4357,4358c4357,4358 <
< $CqTimeoutActionFriendly = "cqTimeoutAction$($cqCallFlowObjectId)(TransferCallToTarget) --> $($cqTimeoutPhoneNumber)(External Number
$cqTimeoutPhoneNumber)"

            $cqTimeoutPhoneNumberId = $cqTimeoutPhoneNumber  -replace "\s+", ""
            $CqTimeoutActionFriendly = "cqTimeoutAction$($cqCallFlowObjectId)(TransferCallToTarget) --> $($cqTimeoutPhoneNumberId)(External Number <br> $cqTimeoutPhoneNumber)"

4922,4923c4922,4924 <
< $CqNoAgentActionFriendly = "cqNoAgentActionTransferCallToTarget$($cqCallFlowObjectId)(TransferCallToTarget) --> $($cqNoAgentPhoneNumber)(External Number
$cqNoAgentPhoneNumber)"

            $cqNoAgentPhoneNumberId = $cqNoAgentPhoneNumber -replace "\s+", ""
            Write-Host ("Replaced {0} with {1}" -f $cqNoAgentPhoneNumber, $cqNoAgentPhoneNumberId)
            $CqNoAgentActionFriendly = "cqNoAgentActionTransferCallToTarget$($cqCallFlowObjectId)(TransferCallToTarget) --> $($cqNoAgentPhoneNumberId)(External Number <br> $cqNoAgentPhoneNumber)"

`

mozziemozz commented 2 months ago

When did you save the config of your AAs/CQs? I tried to reproduce this with a German and a Swiss number but when I check the AA/CQ config in PowerShell, the number is listed as tel:+49xxxxxxxxxxx without any white spaces. Same for the Swiss number. To me, it wouldn't make any sense if the number was stored including white spaces in the config of the AA/CQ. Have you tried to save your config again and check if it's saved without whitespaces afterwards?

I think someone reported this a while ago but I haven't heard of any new cases since. And I was never able to reproduce this. All external numbers always show up without white spaces.

But of course, your regular expression works to get rid of the white spaces. There's actually already a function called Optimize-DisplayName which replaces all other characters in display names which cause issues with Mermaid syntax.

Please check the configs of your AAs and CQs with PowerShell and if they return the value for the Id of the external phone number with white spaces, I'll think about including code to circumvent this in the main version of the script.

Thanks.

shappee747 commented 2 months ago

You are right. I can't reproduce the whitespaces either. I think there was a time in the past were MS enforced these entering numbers in the Teams Admin center. I guess you can close this issue.

I did the sensible thing and removed the white spaces in the Teams configuration. Now I can use your original script again. Good work, btw. Very impressive.

BR

mozziemozz commented 2 months ago

Thanks for checking and confirming. Initially, you could not choose the country prefix from the dropdown. I think MS added that to force people to enter numbers in E.164. Maybe it was possible to enter/paste numbers with whitespaces before and it worked anyway, as the whitespaces get stripped from the number when a call is made anyway.