cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
325
Views
10
Helpful
2
Replies

IPCC script and Area Code

mserwon
Level 1
Level 1

I need to direct calls from an 800 number to different extensions, not agents, based upon area code. I can see how to use "get call contact info" to get the calling number, but how do I take apart the calling id string to get the area code. Once I have the area code only I can go against a database and get the extension.

Is there another way to get the area code only of the calling number?

Thanks

2 Replies 2

jasyoung
Level 7
Level 7

Use an 'Execute Java Method' step to call Java's String methods to parse out the first three characters of the caller ID string.

http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html#substring(int,%20int)

Assuming two string variables, 'callerID' which contains the calling number from your Get Call Contact Info step, and 'areacode', which will store the area code computed from this step. Add an Execute Java Method step to your script. Get the properties. On the Explore tab, set the variable to 'callerID'. On the Explore Class Information tab, on the Method drop-down select 'public String substring(int,int)'. Make sure you select the variant with two int parameters. Set argument 0 to 0, and argument 1 to 2. For assign to variable, pick your 'areacode' variable. This stores the first three characters of 'callerID' into 'areacode' (character numbering starts with 0).

When you are finished, your App Editor should show you a line that looks like: "AC = callerID.substring(0,2)".

To anticipate another possible question, if your database stores the area code as an integer instead of a string: do all of the above, and then create an Integer-type destination variable, and call the parseInt(string) method on it to convert the AC variable using the same steps we went through above.

http://java.sun.com/products/jdk/1.2/docs/api/java/lang/Integer.html#Integer(java.lang.String)

Try to make sure you have a valid callerID string before you start; I'm not sure you can handle the exceptions these functions may throw if their input is malformed.

e-mail me at adignan@berbee.com if you would like a tid bit of code that does what jasyoung is talking about.

adignan - berbee