" /> How to find the prefix of a phone Number in a list of prefixes - Genesys CTI User Forum

Author Topic: How to find the prefix of a phone Number in a list of prefixes  (Read 1435 times)

Offline rolf_b

  • Newbie
  • *
  • Posts: 20
  • Karma: 0
Advertisement
Hello,

in a IRD routing strategy, I need to know if an ANI starts with a prefix from a list of prefixes (I need to handle some groups of DNs differently). I want the list to be easily configurable, and I don't want to delegate that check to a service (stored procedure in database or web service).

My current approach is a List in Config-Server, like this:

[Prefixes]
00049123=1
00049456=2
000497789=3

In reality, there are more entries. I don't want to loop over all keys and check if any of them is a prefix of the ANI. That's quite tedious in IRD.

In my sample, I have prefixes with 8 and 9 digits, so my solution is to simply take the 1st 8 digits of the ANI and try to read a list entry. If it fails, I retry with 9 digits. In my production case, I need to try 3 lengths: 11, 12 and 13, for about 20 list entries. I made an assumption about the length values that can occur, and programmed just 3 checks.

But now my assumptions begin to fall apart, I am getting entries with 14 and 15 digits, too, so now I'd have to update my strategy and make 5 checks for every ANI. And sometime later, 10 or 16 digits might appear, and I need to update again. Worse - the list is not maintained by me, and I'm quite certain that those WHO maintain it will forget the length restrictions and then complain that their configuration fails.

Is there any builtin feature in URS that performs this type of check? I need to find the correct prefix, and I need the value that is associated to that prefix. The only remaining precondition is that I check ANIs, and that no entry in my list can be a prefix of another entry (keys like 00049123 and 000491234 would violate that and cannot happen).

Rolf

Offline terry

  • Sr. Member
  • ****
  • Posts: 328
  • Karma: 35
Re: How to find the prefix of a phone Number in a list of prefixes
« Reply #1 on: July 10, 2017, 09:53:51 PM »
Basically you can write needed logic with java script (IRD macros) where probably looping through KVList list can be easier.

Other alternatives:
  - store list of prefixes in regexp format (ORing all possible prefixes) and use StrMatch[ANI[], regexp] to check for mapping.

  - store list of prefixes in bit different format (put prefixes as values not as keys and store prefixes as search patterns with wild chars)
    List object CheckList:
        [Prefixes]
          1.any=00049123*
          2.any=00049456*
          3.any=000497789*

  SetRunTimeMode[RunTimeModeWildChars]
  list= ListGetDataCfg['CheckList','Prefixes','*']  - list here variable of type LIST, will store all prefixes as result of this function
  list2= KVListFindPairsEx[list, Cat['any:', ANI[]], '', 1]  - will return which exactly pair from profiles match to calls ANI.





   


Offline rolf_b

  • Newbie
  • *
  • Posts: 20
  • Karma: 0
Re: How to find the prefix of a phone Number in a list of prefixes
« Reply #2 on: July 11, 2017, 07:15:25 AM »
Hello terry,

thanks a lot, I will look into that.

But now I am quite annoyed  - again - about the Genesys Docs. Neither StrMatch nor KVListFindPairsEx are documented or reported by the search function. IRD (8.1.400.25) doesn't list them. But they are in compilers.dat, even with some notes about usage, and IRD compiles them.

Rolf

Offline terry

  • Sr. Member
  • ****
  • Posts: 328
  • Karma: 35
Re: How to find the prefix of a phone Number in a list of prefixes
« Reply #3 on: July 11, 2017, 05:38:22 PM »
Basically IRD doesn't list them simply because in compiler.dat for this functions both Category and Mask set to 0.