How to log inbound caller ID?

The outbound context logs to the console nicely:

exten    =>    _1NXXNXXXXXX,1,NoOp()
exten    =>    _1NXXNXXXXXX,n,Set(CALLERID(name)=opm)
exten    =>    _1NXXNXXXXXX,n,Log(NOTICE, Dialing out from ${CALLERID(all)} to ${EXTEN:1} through ${TOLL})
exten    =>    _1NXXNXXXXXX,n,Dial(${TOLL}/${EXTEN:1},60)
exten    =>    _1NXXNXXXXXX,n,Playtones(congestion)
exten    =>    _1NXXNXXXXXX,n,Hangup()

but I can’t find the variable name to get the caller id for the inbound call:

exten    =>    _+1NXXNXXXXXX,1,NoOp()
;exten    =>    _+1NXXNXXXXXX,n,Log(NOTICE, blah )
exten    =>    _+1NXXNXXXXXX,n,Dial(SIP/thufir,60)
exten    =>    _+1NXXNXXXXXX,n,Hangup()

For an inbound channel, you can simply use the CALLERID function as you did previously. As an example:


exten => _X.,1,NoOp()
 same => n,Log(NOTICE, My CallerID is: ${CALLERID(all)})
 same => n,Answer()
 same => n,Echo()

And on the CLI:

    -- Executing [256xxxxxxx@from-dcs:1] NoOp("PJSIP/mjordan-00000838", "") in new stack
    -- Executing [256xxxxxxx@from-dcs:2] Log("PJSIP/mjordan-00000838", "NOTICE, My CallerID is: "" <mjordan>") in new stack
[Jul 20 09:45:32] NOTICE[28806][C-00000b60]: Ext. 2566986741:2 @ from-dcs:  My CallerID is: "" <mjordan>
    -- Executing [256xxxxxxx@from-dcs:3] Answer("PJSIP/mjordan-00000838", "") in new stack

Note that the From user for the inbound call was simply my name in this case, hence why there is no DID number associated with the Caller ID.

1 Like