5 thoughts on - make calls from DID

  • Look, I don’t mean to be a jerk. Most of the time you will need to add the
    info in sip.conf. You need all your info about your DID. Some of them don’t
    allow you to dial out. So it all just depends on what is allowed.
    calls

  • First of all, get your dialplan and zaptel configuration working to the extent
    as you can make SIP to SIP calls between extensions, and you can make
    outgoing calls on the PSTN by means of Zaptel or DAHDI — even if they show
    up anonymous at first.

    Second, in the dialplan context where incoming calls arrive (it’s specified
    in zapata.conf) the “extension” is the number that was dialled by the
    subscriber on the other end; possibly with the leading zero stripped from the
    STD code, or possibly with the whole STD code stripped, depending on the
    telco. So try something like this for a test (assuming the context is
    called “from-pstn”):

    [from-pstn]
    exten => _.,1,NoOp(${EXTEN})
    exten => _.,2,Hangup()

    Call one of your allocated inbound numbers from a mobile, and watch the
    console; the NoOp() will display the dialled number (it’s still considered
    to be an “extension” even though it’s a number on the PSTN) as Asterisk sees
    it modified by the telco.

    Now make a new from-pstn context which maps the extensions on inbound calls to
    your internal extensions. For example, if the telco sends “680661” (no STD
    code, just local part) for the number you want to map to internal extension
    261, then you want something like

    [from-pstn]
    exten => 680661,1,Dial(SIP/261)
    exten => 680661,2,Hangup()

    Obviously if the STD code is included by the telco, you will need to include
    this in the extension number. Reload your dialplan, dial your STD code
    followed by 680661 from your mobile, and extension 261 should ring.

    That’s the incoming side sorted 🙂 Now you also want each internal
    extension, when it makes an outgoing call, to set the caller ID to its DDI
    number.

    In the context through which extension 261 dials out (specified in sip.conf),
    you need to set your callerID to the DDI number (which may need the STD code
    prepending even if the telco strip it — be prepared to experiment a little.
    No decent telco will let you present a number that you haven’t the right to,
    so calls will appear anonymous if you get this wrong). I’m assuming
    variables STD and TRUNK are already defined earlier in your dialplan.

    [ext261-outgoing]
    exten => _0X.,1,Set(CALLERPRES()=allowed)
    exten => _0X.,2,Set(CALLERID(num)=${STD}680661)
    exten => _0X.,3,Dial(${TRUNK}/${EXTEN})
    exten => _0X.,4,Hangup()

    Spotted the problem with this yet? Each extension will needs its own context
    for outgoing calls, which will rapidly become unworkable.

    To avoid this situation, you just need to make sure there is an obvious
    mathematical relationship between internal extensions and external numbers.
    If 6806XX on the outside is equivalent to 2XX on the inside, then you could
    try

    [from-pstn]
    exten => _6806XX,1,Set(dest=2${EXTEN:-2)
    exten => _6806XX,2,Dial(SIP/${dest})
    exten => _6806XX,3,Hangup()

    1: Set “dest” to “2” followed by the last 2 digits of the dialled extension
    2: Dial “dest”
    3: Hangup

    [outgoing]
    exten => _0X.,1,Set(ident=6806${CALLERID(num):-2}
    exten => _0X.,2,Set(CALLERPRES()=allowed)
    exten => _0X.,3,Set(CALLERID(num)=${STD}${ident})
    exten => _0X.,4,Dial(${TRUNK}/${EXTEN})
    exten => _0X.,5,Hangup()

    1: set “ident” to “6806” followed by the last 2 digits of the caller ID of
    the originating extension
    2, 3: Set the displayed caller ID to the value of “STD” defined easrlier in
    the dialplan followed by the value of “ident” just calculated
    4: Call the outside-world number
    5: Hangup

    It will probably take some experimentation to get right; but once you manage
    it, it really will Just Work Forever. And once you have everything working
    correctly at the most basic level, *then* is the time to think about adding
    refinements. As restorers of old colour tellies like to say: First get it
    right in black and white. The same principle applies here.

    And be sure to save copies of all your *actually working* dialplans, peppered
    with comments, as you go along. (Sometimes I miss the automatic versioning
    filesystem of VAX/VMS …..)