Shitian Long
2012-Nov-19 15:30 UTC
[asterisk-users] If would possible use a custom function in Asterisk Dialplan
Hello, If would be possible to use a "function concept" in side of Asterisk DialPlan For example: I have following logic in my dial plan remove country code a add an "0" before the rest of the numbers exten => _X.,1, NoOp( call ID ${CALLERID(num)} exten: ${EXTEN})) ; remove my country code exten => _X.,n, GotoIf($["${CALLERID(num):0:4}"="${country-code}"]?international-format:national-format) exten => _X.,n(international-format), Set(CALLERID(num)=0${CALLERID(num):4}) exten => _X.,n(national-format), NoOp(call ID: ${CALLERID(num)} exten: ${EXTEN})) Do you think if would be possible that I could write a function something like "REMOVEMYCOUNTRYCODE(${NUM})" with a return value of a number with out country code and with an "0" add in front of the rest of the numbers. like exten => _X.,1, NoOp( call ID ${CALLERID(num)} exten: ${EXTEN})) ; remove my county code exten => _X.n, Set(CALLERID(num=REMOVEMYCOUNTRYCODE(${CALLERID(num)} )); then I have to define this function in someway ?? I am trying to googling for a while but I did not find any idea to achieve this task. I would appreciate if someone have an idea? Thanks for your time in advance. longst
Danny Nicholas
2012-Nov-19 16:54 UTC
[asterisk-users] If would possible use a custom function in Asterisk Dialplan
You could do it as a function if you are C literate. The simpler way would be to do it as an AGI where you passed the ${EXTEN} value to the AGI and had the AGI pass the modified number back as a dialplan variable. -----Original Message----- From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Shitian Long Sent: Monday, November 19, 2012 9:31 AM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: [asterisk-users] If would possible use a custom function in Asterisk Dialplan Hello, If would be possible to use a "function concept" in side of Asterisk DialPlan For example: I have following logic in my dial plan remove country code a add an "0" before the rest of the numbers exten => _X.,1, NoOp( call ID ${CALLERID(num)} exten: ${EXTEN})) ; remove my country code exten => _X.,n, GotoIf($["${CALLERID(num):0:4}"="${country-code}"]?international-format:nati onal-format) exten => _X.,n(international-format), Set(CALLERID(num)=0${CALLERID(num):4}) exten => _X.,n(national-format), NoOp(call ID: ${CALLERID(num)} exten: ${EXTEN})) Do you think if would be possible that I could write a function something like "REMOVEMYCOUNTRYCODE(${NUM})" with a return value of a number with out country code and with an "0" add in front of the rest of the numbers. like exten => _X.,1, NoOp( call ID ${CALLERID(num)} exten: ${EXTEN})) ; remove my county code exten => _X.n, Set(CALLERID(num=REMOVEMYCOUNTRYCODE(${CALLERID(num)} )); then I have to define this function in someway .. I am trying to googling for a while but I did not find any idea to achieve this task. I would appreciate if someone have an idea. Thanks for your time in advance. longst -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Andrew White
2012-Nov-21 00:45 UTC
[asterisk-users] If would possible use a custom function in Asterisk Dialplan
Hey Longst, I'd recommend having a look into the LUA support Asterisk offers for its dialplans or AGI. These are the only realistic ways to add functions, unless you want to write your own C module and compile it in. Adhearsion is an option as well, if you are proficient with ruby. Cheers, Andrew -----Original Message----- From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Shitian Long Sent: Tuesday, 20 November 2012 2:31 AM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: [asterisk-users] If would possible use a custom function in Asterisk Dialplan Hello, If would be possible to use a "function concept" in side of Asterisk DialPlan For example: I have following logic in my dial plan remove country code a add an "0" before the rest of the numbers exten => _X.,1, NoOp( call ID ${CALLERID(num)} exten: ${EXTEN})) ; remove my country code exten => _X.,n, GotoIf($["${CALLERID(num):0:4}"="${country-code}"]?international-format:national-format) exten => _X.,n(international-format), Set(CALLERID(num)=0${CALLERID(num):4}) exten => _X.,n(national-format), NoOp(call ID: ${CALLERID(num)} exten: ${EXTEN})) Do you think if would be possible that I could write a function something like "REMOVEMYCOUNTRYCODE(${NUM})" with a return value of a number with out country code and with an "0" add in front of the rest of the numbers. like exten => _X.,1, NoOp( call ID ${CALLERID(num)} exten: ${EXTEN})) ; remove my county code exten => _X.n, Set(CALLERID(num=REMOVEMYCOUNTRYCODE(${CALLERID(num)} )); then I have to define this function in someway ...... I am trying to googling for a while but I did not find any idea to achieve this task. I would appreciate if someone have an idea... Thanks for your time in advance. longst -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users