Routing by keywords in Caller ID names

I’ve been able to use the Dynamic Routes module to route by looking at part of a Caller ID Name that I added using the Set CallerID module. I am wondering if there is a way to route using just the inbound Caller ID and see if there are keywords in the name, such as “medical”, “doctor”, or “lawyer”.

I don’t see a way to search an Asterisk Variable for a keyword to match. That is what I would like to do.
Does anyone know of a way to do this?

We did this using the Asterisk Phonebook and turing superfecta lookup on the inbound route. It would change the CallerID(name) to what was in the phonebook. We then had a custom context that looked at the Callerid(name) and routed based on the value.

I believe the phonebook is deprecating, so you might want to use the contact manager instead.

You can do this with dynroutes using the Asterisk REGEX function. Using Asterisk Variable from dynroutes with an expression like:

${REGEX("^.*([mM]edical|[Ll]egal).*$" ${CALLERID(name)})}

The above expression will catch inbound callers with CID names that have the words Medical, medical, Legal or legal and return a 0 or 1 based on whether there’s a match. You can use the 0 or 1 to branch the call in dynroutes.

Match returns 1:
Family Medical Center
family legal center

No match returns 0:
FAMILY MEDICAL CENTER
family center

When doing caller ID name matches, I usually do

${TOLOWER(${CALLERID(name)})}
3 Likes

Clever. You can combine them with an expression like this:

${REGEX("^.*(medical|legal).*$" ${TOLOWER(${CALLERID(name)})})}

Which will catch all these cases:
Family Medical Center
family legal center
FAMILY MEDICAL CENTER

4 Likes

Awesome, these worked perfectly! Thank you guys so much!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.