Destination Number Validation

Is there any way to pre-validate the destination number user input to make sure it’s a good number before sending it to the rate table?

Currently, ASTPP will process any garbage number and send it out on the trunks like 1212344, 01149, 332072, etc… As long as it finds a match in the origination and termination rate tables for the rate prefix, the call is processed.

However, in my old system, we screened the calls and did not allow destination numbers less than 11 digits, or malformed numbers like 11212 (11 is wrong) or 0111 or 000 etc…

Just wondering if there is any way in astpp to do this.

I changed the destination number input function in astpp.callingcard.functions.lua to enforce a minimum destination number length of 11 digits

function process_destination(userinfo)
call_direction = ‘outbound’
local origination_dp_string

local destination = session:playAndGetDigits(1, 35, 3, config[‘calling_cards_dial_input_timeout’], “#”, “astpp-phonenum.wav”, “astpp-badphone.wav”, ‘^([1-9]|\\d{11,})$’)

This prevents astpp from sending incomplete numbers like 1416 or 011498945 to the termination providers. It’s a simple change and improves my ASR by 10%. What do you guys think?

What if they try to dial numbers outside of NANP?


allows 11 digit nanp numbers and any other number > 11 digits i.e. overseas numbers starting with 011 or 00 prefix. As long as the number is equal or larger than 11 digits, the number is passed along to the astpp origination rates for validation.

My problem was that users were entering 1416 (Toronto) or 0114989 (Munich) and then pausing for some reason to enter the rest of the number and by the time they were ready to proceed, the string was already validated by astpp and passed to the termination provider which of course failed. So far I haven’t noticed any issues with this change.

1 Like

You could also use this library to validate phone numbers.