Adding Area Code

Home » Asterisk Users » Adding Area Code
Asterisk Users 13 Comments

Hello,

I would like to add area code if clients dial 7 digits, it that possible? currently clients dial prefix 9 plus local number, however my SIP provider is requiring to dial 10 digits. is it possible to add area code?

Thanks, Motty

13 thoughts on - Adding Area Code

  • Quite simple – you need to match on NXXXXXXX and when passing it to the SIP provider, present ${AREACODE}${EXTEN}, having first defined AREACODE in [globals].

  • Thanks for your reply,

    [globals]
    AREACODE81

    [outbound]
    exten => _NXXXXXX,1,Dial(SIP/SIP-Provider/1${AREACODE}${EXTEN},80)

    did not work for me, any ideas?

    Thanks,

  • Motty

    Yes

    From your dial plan accept 9 + 7 digits then concat your dialed number together with your areacode.

    This s a brief example.

    exten => _9XXXXXXX,1,Set(l_HomeAreaCodeU5)
    exten => _9XXXXXXX,n,Set(dialnumber=${l_HomeAreaCode}${EXTEN-1}) ;; This line should combine your area code and the last 7 digits of your dialed phone number exten => _9XXXXXXX,n,Dial(SIP/${dialnumber},35)

    Thanks

    Bryant Zimmerman (ZK Tech Inc.)
    616-855-1030 Ext. 2003

    ————————————–

  • Thanks for your reply,

    [globals]
    AREACODE81

    [outbound]
    exten => _9XXXXXX,1,Dial(SIP/SIP-Provider/1${AREACODE}${EXTEN-1},80)

    did not work for me, any ideas?

    Thanks,

    Quite simple – you need to match on NXXXXXXX and when passing it to the SIP
    provider, present ${AREACODE}${EXTEN}, having first defined AREACODE in
    [globals].

  • here is what I have:

    exten => _9XXXXXXX,1,Set(l_HomeAreaCode81)

    exten => _9XXXXXXX,n,Set(dialnumber=${l_HomeAreaCode}${EXTEN:-1})

    exten => _9XXXXXXX,n,Dial(SIP/SIP-Provider/${dialnumber},80)

    not having success;

    “Got SIP reponse 503″ Service Unavailable”

  • No. I was so focused on the tree, I missed the forest 🙂

    ${EXTEN:-x} means ‘return the last x digits’

    ${EXTEN:x} means ‘return all but the first x digits’

    So, ${EXTEN:1} is correct for this use.

    Something like (tested!):

    exten = _9nxxxxxx,1, verbose(The ‘raw’ exten is ${EXTEN})
    same = n, set(MY-AREA-CODEv0)
    same = n, set(DNIS=${MY-AREA-CODE}${EXTEN:1})
    same = n, verbose(The full DNIS is ${DNIS})
    same = n, dial(sip/1${DNIS}@vitel-outbound,60,r)
    same = n, hangup()

    is closer to what the OP needs. Note the ‘n’ in the pattern.

  • this code worked for me,

    here is what I did and worked for me:

    exten => 1381+NXXXXXX,1,Set(CALLERID(number)817383444)

    exten => 1+NXXNXXXXXX,2,Dial(SIP/SIP-Provider/${EXTEN:1},80)

    Thanks for you help!

  • I find it hard to believe this is working.

    First, you don’t have a leading underscore on your patterns. Your users aren’t literally dialing the N’s and X’s are they?

    Second, what’s with the plus in the extension? You want your users to dial that?

    Third, that’s two different extensions, one with priority 1 and one with priority 2. The first one will set a variable and hangup, and the second…. there’s no priority 1 for that extension… I’ve never tried that… I’m assuming it just won’t work.

  • I apologize, I coppied the wrong code, here is the code I am using:

    ; Adding Area code and striping 9 for local numbers exten => _9XXXXXXX,n,Set(CALLERID(all)= <3817383444>)
    exten => _9XXXXXXX,n,Dial(SIP/intelepeer/1381${EXTEN:1},80)

    Thanks, motty