System information
If the call does not explicitly match our named extensions, the pattern match will be
utilized. Our pattern match of _[A-Za-z0-9]. matches any string starting with an al-
phanumeric character followed by one or more other characters.
The incoming string needs to be made safe, so we utilize the FILTER() function to re-
move nonalphanumeric characters, and assign the result to the FilteredExtension
channel variable.
The DIALPLAN_EXISTS() function will be used to see if the request matches anything in
the PublicExtensions context. This function will return either a 0 (if no match is
found) or a 1 (when a match is found) and assign the result to the
CheckPublicExtensionResult channel variable.
The next line is a GotoIf() that checks the status of the CheckPublicExtensionResult
variable. If the result returned was 0, the dialplan will continue at the CheckEmail
Lookup priority label. If the result was anything other than 0 (in this case, the other result
could have been a 1), the next line of the dialplan will be executed. This line will perform
a Goto() and continue execution in the PublicExtensions context (presumably to dial
our destination endpoint).
Assuming our CheckPublicExtensionResult variable was a 0, our dialplan will continue
at the CheckEmailLookup priority label, where we use the subroutine
subEmailToExtensionLookup via a GoSub().
#
We pass the value contained within the
FilteredExtension channel variable to the subroutine, but you’ll notice that we’ve
wrapped it in the TOLOWER() dialplan function (which expects your email addresses to
be stored in lowercase as opposed to mixed case).
Upon return from the subEmailToExtensionLookup subroutine, we check the
GOSUB_RETVAL channel variable (which was automatically set when the subroutine re-
turned). The result will be one of two things: the extension number that matches the
name that was passed to the subroutine, or the string NoResult. Our dialplan checks
${GOSUB_RETVAL}, and if it contains NoResult, the caller is passed to the i (invalid) ex-
tension, where we inform the caller that the extension dialed is invalid. If all is well,
the call will continue execution in the PublicExtensions context.
File parsing
This little trick will allow you to use the voicemail.conf file to look up valid usernames
against their email address. This could end up being kludgy, and it requires that the
email field in voicemail.conf is filled out and contains a username (before the @ symbol)
that you will support in your dialplan, but it’s simple to code in the dialplan, and if
nothing else it will give you some ideas of how you might handle providing a more
automated way of linking names to extension numbers for the purpose of SIP URI
dialing. Note that this method will not allow you to exclude some people from name
dialing. It’s all or nothing.
#We explain the use of subEmailToExtensionLookup in the following section.
242 | Chapter 12: Internet Call Routing