Cisco Support Community
Showing results for 
Search instead for 
Did you mean: 

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Redirecting a call based on ANI

What I would like to do is handle calls in different ways based on the area code it is coming from.  Any tips?


Re: Redirecting a call based on ANI


You can use the Get Call Contact Info step to get the calling number of the triggering contact, after that you can use a java method to take from the calling number just the area code, or you can use and if step with the ".StartsWith(String)" method to catch the area code.


Re: Redirecting a call based on ANI

A large switch step would work too:

switch (calling_number.substring(0, 3)) {

     case '612':

          /* Minneapolis */


     case '305':

          /* Miami */



          /* Other */


But you also could use XML lookups, or DB lookups, or flat file lookups.  There are many choices.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
New Member

Re: Redirecting a call based on ANI

Thanks for the tips guys but I'm still not having much luck.  Essentially, what I would like to do is redirect a call coming from a certain area code and exchange (817-282-****).  I have a switch string in place that is working if I put in an entire number but I have not been able to make it work the way you guys have suggested.  Basically, if the callingnumber is 817-282-**** where the stars are wildcards, it will redirect the call.  What am I missing here?

Super Bronze

Re: Redirecting a call based on ANI


It's not so difficult, both the suggestions you've been given above are valid and pretty clear - basically in the 'Switch Value' field of the switch step, put in one of the fucntions suggested above. So if your variable containing the calling number is a String 'callingnumber', and it has no hyphens or other formatting, and you just want to switch based on a match of the first 6 digits:

callingnumber.substring(0,5)               <--- match the digits from positions 0 to 5

Under 'Cases:'

Values:          Connections

"817282"          Redirect

Then under 'whatever-you-like' add your redirect steps, and under default your default routing steps.

Perhaps have a go and post up your non-working script if you don't have any luck.



Aaron Please remember to rate helpful posts to identify useful responses, and mark 'Answered' if appropriate!
New Member

Re: Redirecting a call based on ANI

Thanks Aaron.  I tried what you suggested with no luck.  Here is the script.

Re: Redirecting a call based on ANI


Try a reactive debug so you can check if the substring method is really taking the first 6 digits of the calling number.


New Member

Re: Redirecting a call based on ANI

That did it.  The reactive script showed me that with using (0,5) I was only picking up the first 5 digits.  I changed it to (0,6) and the script worked.  Thank you.


Re: Redirecting a call based on ANI

The important facts about the Java substring function to remember are:

public String substring(int startIndex, int endIndex)

startIndex is inclusive

endIndex is exclusive