We currently have a dialer application that connects to the AMI of the asterisk to ORIGINATE calls.
When originating the call we dial a LOCAL channel which goes into a context that subsequently dials an outbound sip call.
Once the call connects it gets bridged to another context that executes a playback to the sip channel.
Everything works perfect, the problem is obtaining variables from the SIP channel when it does not connect.
In other words, to do our accounting, we use the call-id to match to our Nextone server.
When the call connects we can easily access ${SIPCALLID} and save our CDR , BUT if the call fails for any reason,
the variable ${SIPCALLID} is empty together with all the other options empty as well.
We also tried calling
exten => _X.,n,Set(callid=${SIP_HEADER(Call-ID)})
but asterisk responds.
chan_sip.c:17441 func_header_read: This function can only be used on SIP channels.
How can we access the results of the dial command from a local channel?
Our extensions looks like this
[dialer-out]
exten => _X.,n,Set(CDR(accountcode)=${CAMP_ID})
exten => _X.,n,Set(CDR(userfield)=${OWNER})
exten => _X.,n,Set(WAITT=${MATH(${WAFA} + 0)})
exten => _X.,n,Set(MAX_CALL_DURATION=$[ ${MAX_DURATION} + 1 ])
exten => _X.,n,Dial(SIP/${EXTEN}@${PEER},${WAITT},S(${MAX_DURATION}))
exten => _X.,n,Noop(${SIPCALLID}) //This variable prints EMPTY
exten => _X.,n,Wait(1)
exten => _X.,n,Hangup()
exten => h,n,Hangup()
exten => h,n(end),Noop(${DIALSTATUS})
[dialer-voice-answered]
exten => dialer,1,Answer()
exten => dialer,n,Set(ST=${EPOCH})
exten => dialer,n,Wait(1)
exten => dialer,n,Playback(${AUDIO_FILE})
exten => dialer,n,Noop(${SIPCALLID}) //This variable prints out PERFECT
exten => dialer,n,Hangup()