Loosing the CALLERID due to attend tranfer

Hello Guys, I see due to the Attend transfer the callerid on the phone “s” If I use sub-routine with exten “s” . I solved the issue by using “_X.” in sub-routing, but still thinking if it’s right or no, and probably there is a better solution. Probably, You can advices how to do it better.
The dialplan bellow:

[internal]
exten => 791,1,GoSub(sub-dial,s,1(${EXTEN},${INTERNAL_DIAL_TIME},${INTERNAL_DIAL_OPT}))
exten => 792,1,GoSub(sub-dial,s,1(${EXTEN},${INTERNAL_DIAL_TIME},${INTERNAL_DIAL_OPT}))
exten => 793,1,GoSub(sub-dial,s,1(${EXTEN},${INTERNAL_DIAL_TIME},${INTERNAL_DIAL_OPT}))
exten => 794,1,GoSub(sub-dial,s,1(${EXTEN},${INTERNAL_DIAL_TIME},${INTERNAL_DIAL_OPT}))


[sub-dial]
;ARG1 - exten, ARG2 - Dial Time, ARG3 - Dial Option
exten => s,1,NoOp("you are in sub-dial")
same => n,GoSub(sub-make-recording,s,1(${ARG1}))
same => n,GoSub(sub-make-dial,s,1(${ARG1},${ARG2},${ARG3}))

[sub-make-dial]
;ARG1 - EXTEN Number, ARG2-Dial time, ARG3 - Dial options
exten => s,1,NoOp('You are in sub-dial, arg3=${ARG3}')
same => n,Dial(PJSIP/${ARG1},${ARG2},${ARG3})
same => n,HangUp()

[sub-make-recording]
; {ARG1} - exten
exten => s,1,NoOp("lets recrord the phone ${ARG1}")
same => n,GotoIf($["${CALLERID(num)}"=""]?:named)
same => n,Set(CALLERID(all)=unknown)
same => n(named),GotoIf($["${DB(record_phone/${ARG1})}"="1"]?record)
same => n,GotoIf($["${DB(record_phone/${CALLERID(num)})}"="1"]?record:end)
same => n(record),StopMixMonitor()
same => n,Set(PATH=/var/spool/asterisk/monitor${STRFTIME(,,/%Y/%m/%d/%H:%M:%S-)}${CALLERID(num)}-${ARG1}-${UNIQUEID}.wav)
same => n,Set(CDR(file_path)=${PATH})
same => n,MixMonitor(${PATH},b)
same => n(end),Return()

Thank you in advance!

I don’t see how the extension would affect the caller ID, but you need to provide verbose logs, and any other evidence to show that someing is going wrong.

How is the attended transfer being initiated?

Hi david551,
I’m using *2 to make attended transfer:
here is some config from features.conf

[featuremap]
blindxfer => #1                
disconnect => *5               
;automon => *1                  
atxfer => *2                   ; Attended transfer  
parkcall => #72

The log descritption: from 415 calling to 792, from 792 doing attended transfer to 791, on the screen of the 791 phone, I see that the call comming from “s”

Here is some verbose log:

type or p Accepting AUTHENTICATED call from 203.59.80.189:4569:
    --        > requested format = ulaw,
    --        > requested prefs = (ulaw|alaw),
    --        > actual format = ulaw,
    --        > host prefs = (ulaw|alaw),
    --        > priority = mine
    -- Executing [792@internal:1] Gosub("IAX2/mbmcctpbx3-3211", "sub-dial,s,1(792,20,tThHkK)") in new stack
    -- Executing [s@sub-dial:1] NoOp("IAX2/mbmcctpbx3-3211", ""you are in sub-dial"") in new stack
    -- Executing [s@sub-dial:2] Gosub("IAX2/mbmcctpbx3-3211", "sub-make-recording,s,1(792)") in new stack
    -- Executing [s@sub-make-recording:1] NoOp("IAX2/mbmcctpbx3-3211", ""lets recrord the phone 792"") in new stack
    -- Executing [s@sub-make-recording:2] GotoIf("IAX2/mbmcctpbx3-3211", "0?:named") in new stack
    -- Goto (sub-make-recording,s,4)
    -- Executing [s@sub-make-recording:4] GotoIf("IAX2/mbmcctpbx3-3211", "1?record") in new stack
    -- Goto (sub-make-recording,s,6)
    -- Executing [s@sub-make-recording:6] StopMixMonitor("IAX2/mbmcctpbx3-3211", "") in new stack
    -- Executing [s@sub-make-recording:7] Set("IAX2/mbmcctpbx3-3211", "PATH=/var/spool/asterisk/monitor/2019/09/26/11:50:57-415-792-1569487857.268.wav") in new stack
    -- Executing [s@sub-make-recording:8] Set("IAX2/mbmcctpbx3-3211", "CDR(file_path)=/var/spool/asterisk/monitor/2019/09/26/11:50:57-415-792-1569487857.268.wav") in new stack
    -- Executing [s@sub-make-recording:9] MixMonitor("IAX2/mbmcctpbx3-3211", "/var/spool/asterisk/monitor/2019/09/26/11:50:57-415-792-1569487857.268.wav,b") in new stack
    -- Executing [s@sub-make-recording:10] Return("IAX2/mbmcctpbx3-3211", "") in new stack
    -- Executing [s@sub-dial:3] Gosub("IAX2/mbmcctpbx3-3211", "sub-make-dial,s,1(792,20,tThHkK)") in new stack
    -- Executing [s@sub-make-dial:1] NoOp("IAX2/mbmcctpbx3-3211", "'You are in sub-dial, arg3=tThHkK'") in new stack
    -- Executing [s@sub-make-dial:2] Dial("IAX2/mbmcctpbx3-3211", "PJSIP/792,20,tThHkK") in new stack
    -- Called PJSIP/792
  == Begin MixMonitor Recording IAX2/mbmcctpbx3-3211
    -- PJSIP/792-0000005b is ringing
    -- PJSIP/792-0000005b is ringing
    -- PJSIP/792-0000005b answered IAX2/mbmcctpbx3-3211
    -- Channel PJSIP/792-0000005b joined 'simple_bridge' basic-bridge <6daeed81-67c2-49d9-894f-b18dacdfa08b>
    -- Channel IAX2/mbmcctpbx3-3211 joined 'simple_bridge' basic-bridge <6daeed81-67c2-49d9-894f-b18dacdfa08b>
    -- Channel PJSIP/792-0000005b: Started DTMF attended transfer.
    -- <PJSIP/792-0000005b> Playing 'pbx-transfer.ulaw' (language 'en')
    -- Started music on hold, class 'default', on channel 'IAX2/mbmcctpbx3-3211'
    -- Executing [791@phones:1] Gosub("Local/791@phones-0000000d;2", "sub-dial,s,1(791,20,tThHkK)") in new stack
    -- Executing [s@sub-dial:1] NoOp("Local/791@phones-0000000d;2", ""you are in sub-dial"") in new stack
    -- Executing [s@sub-dial:2] Gosub("Local/791@phones-0000000d;2", "sub-make-recording,s,1(791)") in new stack
    -- Executing [s@sub-make-recording:1] NoOp("Local/791@phones-0000000d;2", ""lets recrord the phone 791"") in new stack
    -- Executing [s@sub-make-recording:2] GotoIf("Local/791@phones-0000000d;2", "0?:named") in new stack
    -- Goto (sub-make-recording,s,4)
    -- Executing [s@sub-make-recording:4] GotoIf("Local/791@phones-0000000d;2", "0?record") in new stack
    -- Executing [s@sub-make-recording:5] GotoIf("Local/791@phones-0000000d;2", "0?record:end") in new stack
    -- Goto (sub-make-recording,s,10)
    -- Executing [s@sub-make-recording:10] Return("Local/791@phones-0000000d;2", "") in new stack
    -- Executing [s@sub-dial:3] Gosub("Local/791@phones-0000000d;2", "sub-make-dial,s,1(791,20,tThHkK)") in new stack
    -- Executing [s@sub-make-dial:1] NoOp("Local/791@phones-0000000d;2", "'You are in sub-dial, arg3=tThHkK'") in new stack
    -- Executing [s@sub-make-dial:2] Dial("Local/791@phones-0000000d;2", "PJSIP/791,20,tThHkK") in new stack
    -- Channel Local/791@phones-0000000d;1 joined 'simple_bridge' basic-bridge <d867fedd-2299-40fa-a6c5-08e63f20ea36>
    -- Called PJSIP/791
    -- Local/791@phones-0000000d;2 requested media update control 26, passing it to PJSIP/791-0000005c
    -- Channel PJSIP/792-0000005b left 'simple_bridge' basic-bridge <6daeed81-67c2-49d9-894f-b18dacdfa08b>
    -- Channel PJSIP/792-0000005b joined 'simple_bridge' basic-bridge <d867fedd-2299-40fa-a6c5-08e63f20ea36>
    -- PJSIP/791-0000005c is ringing
    -- PJSIP/791-0000005c is ringing
    -- Channel PJSIP/792-0000005b left 'simple_bridge' basic-bridge <d867fedd-2299-40fa-a6c5-08e63f20ea36>
    -- Channel Local/791@phones-0000000d;1 left 'simple_bridge' basic-bridge <d867fedd-2299-40fa-a6c5-08e63f20ea36>
    -- Channel Local/791@phones-0000000d;1 joined 'simple_bridge' basic-bridge <6daeed81-67c2-49d9-894f-b18dacdfa08b>
    -- Stopped music on hold on IAX2/mbmcctpbx3-3211
    -- PJSIP/791-0000005c answered Local/791@phones-0000000d;2
    -- Channel PJSIP/791-0000005c joined 'simple_bridge' basic-bridge <cd166b97-185f-42a5-b887-190fa743d764>
    -- Channel Local/791@phones-0000000d;2 joined 'simple_bridge' basic-bridge <cd166b97-185f-42a5-b887-190fa743d764>
    -- Channel IAX2/mbmcctpbx3-3211 left 'simple_bridge' basic-bridge <6daeed81-67c2-49d9-894f-b18dacdfa08b>
    -- Channel Local/791@phones-0000000d;2 left 'simple_bridge' basic-bridge <cd166b97-185f-42a5-b887-190fa743d764>
    -- Channel IAX2/mbmcctpbx3-3211 swapped with Local/791@phones-0000000d;2 into 'simple_bridge' basic-bridge <cd166b97-185f-42a5-b887-190fa743d764>
    -- Channel Local/791@phones-0000000d;1 left 'simple_bridge' basic-bridge <6daeed81-67c2-49d9-894f-b18dacdfa08b>
  == Spawn extension (sub-make-dial, s, 2) exited non-zero on 'Local/791@phones-0000000d;2'
    -- Executing [h@sub-make-dial:1] Hangup("Local/791@phones-0000000d;2", "") in new stack
  == Spawn extension (sub-make-dial, h, 1) exited non-zero on 'Local/791@phones-0000000d;2'
    -- Channel PJSIP/791-0000005c left 'simple_bridge' basic-bridge <cd166b97-185f-42a5-b887-190fa743d764>
    -- Channel IAX2/mbmcctpbx3-3211 left 'simple_bridge' basic-bridge <cd166b97-185f-42a5-b887-190fa743d764>
  == Spawn extension (sub-make-dial, s, 2) exited non-zero on 'IAX2/mbmcctpbx3-3211'
    -- Executing [h@sub-make-dial:1] Hangup("IAX2/mbmcctpbx3-3211", "") in new stack
  == Spawn extension (sub-make-dial, h, 1) exited non-zero on 'IAX2/mbmcctpbx3-3211'
    -- Hungup 'IAX2/mbmcctpbx3-3211'
  == MixMonitor close filestream (mixed)
  == End MixMonitor Recording IAX2/mbmcctpbx3-3211
aste code here

I’ve only used native SIP transfers, not features ones, but I suspect the problem isn’t with the transfer but with the original B side call.

I’d suggest investigating constructing your subroutines like the stdexten one in the sample configuration, and looking into connected line updates.

I’ve just found out the issue, I haven’t written callerid for endpoints in pjsip.conf. That’s why aster substituted callerid with EXTEN variable, as I understood. Anyway thanks for your help!