Detect hung-up time for a call-file

I am using call files (to be put to /var/spool/asterisk/outgoing/) to automate a reminders system. So I do not use a “Dial()” command in my extension.
This is the extension I currently use:

[callout] exten => s,1,Set(LANGUAGE()=it) exten => s,n,Set(starttime="${STRFTIME(${EPOCH},GMT,%s)}") exten => s,n,Set(answered="no") exten => s,n,Answer exten => s,n,Wait(2) exten => s,n(play),Background(ks) exten => s,n,Wait(15) exten => 1,1,System(log "${starttime}" "${STRFTIME(${EPOCH},GMT,%s)}" "${ID}" "Y") exten => 1,n,Playback(my-thanks_yes-\${GENDER}) exten => 1,n,Playback(my-goodbye-\${GENDER}) exten => 1,n,Set(answered="yes") exten => 1,n,Hangup() exten => 2,1,System(log "${starttime}" "${STRFTIME(${EPOCH},GMT,%s)}" "${ID}" "N") exten => 2,n,Playback(my-thanks_no-\${GENDER}) exten => 2,n,Playback(my-goodbye-\${GENDER}) exten => 2,n,Set(answered="yes") exten => 2,n,Hangup() exten => 3,1,Goto(callout,s,play) exten => i,1,Playback(my-invalid-\${GENDER}) exten => i,n,Goto(callout,s,play) exten => t,1,System(log "${starttime}" "${STRFTIME(${EPOCH},GMT,%s)}" "${ID}" "T" "${REASON}" "${answered}") exten => t,n,Playback(my-goodbye-\${GENDER}) exten => h,1,System(log "${starttime}" "${STRFTIME(${EPOCH},GMT,%s)}" "${ID}" "H" "${REASON}" "${answered}") exten => failed,1,system(log "${starttime}" "${STRFTIME(${EPOCH},GMT,%s)}" "${ID}" "F" "${REASON}" "${answered}")
Would it be possible for my extension to detect the elapsed time (for not-answered calls) from the first ring to the hang-up?

I’m not sure if that’s the right way to achieve this, but you might try using local channels: Instead of originating a call to SIP/something (or whatever technology you’re using) you could originate with Local/exten@context and in that context dial the device you want.

Thanks for your answer.
Could you please clearify to me this approach? Or point me to some example of this? Or where can I find some documentation?
It sounds very promising to me…
Thanks again.

Marco

In a sample .call file you basically have:

Channel: SIP/peer Context: call Exten: 123

now instead of using SIP/peer you could use Local, like this:

Channel: Local/555@callfile Context: call Exten: 123

and then

[callfile]
exten => 555,1,Noop
exten => 555,n,Dial(SIP/peer)
exten => 555,n,...

I see, thanks!
I suppose, for “SIP/peer” in the call extension I will use a variable set in the call file with the real channel to call… Right?
And i do not fully understand “Context: call”, nor “Exten: 123”…

I will explain you how you do is, just little bit change.

now instead of using SIP/peer you could use Local, like this:
Call File

    Channel: Local/555@callfile
    Setvar:DNUM=9999

and then

Dialplan

    [callfile]
    exten => 555,1,Noop
    exten => 555,n,Dial(SIP/${DNUM})

Regards

Ketan

Thanks!
I have now a new problem… :frowning:
After I Dial(${NUM},10), and after the callee answers, I would like to playback a background voice message, asking to press #1, or #2, or #3, etc…
This is my extension:

[callfile]
exten => 555,1,Noop()
exten => 555,n,Set(LANGUAGE()=it)
exten => 555,n,Set(starttime="${STRFTIME(${EPOCH},GMT,%s)}")
exten => 555,n,Dial(${NUM},10)
exten => 555,n,Wait(2)
exten => 555,n(play),Background(my-message)
exten => 555,n,Wait(15)
exten => 1,1,System(log "${starttime}" "${STRFTIME(${EPOCH},GMT,%
exten => 1,n,Playback(my-thanks_yes-\${GENDER})
exten => 1,n,Playback(my-goodbye-\${GENDER})
exten => 1,n,Set(answered="yes")
exten => 1,n,Hangup()
exten => 2,1,System(log "${starttime}" "${STRFTIME(${EPOCH},GMT,%
exten => 2,n,Playback(my-thanks_no-\${GENDER})
exten => 2,n,Playback(my-goodbye-\${GENDER})
exten => 2,n,Hangup()
exten => 3,1,Goto(ks,555,play)
exten => i,1,Playback(ks-invalid-\${GENDER})
exten => i,n,Goto(ks,555,play)
exten => t,1,System(log "${starttime}" "${STRFTIME(${EPOCH},GMT,%
exten => t,n,Playback(my-goodbye-\${GENDER})
exten => h,1,System(log "${starttime}" "${STRFTIME(${EPOCH},GMT,%
exten => failed,1,system(log "${starttime}" "${STRFTIME(${EPOCH},

This is my call file:

Setvar: NUM=SIP/6001
Setvar: GENDER=F
Channel: Local/555@callfile
MaxRetries: 5
RetryTime: 3600
WaitTime: 45
Extension: 555
Priority: 1
Archive: No

Now what I get is: the number is called. When answered, I get a “free line” tone. When answering again, I hear a nice music playing… Sorry, I cant figure out what I’m missing…
Thanks again!

Make it like this:

Setvar: NUM=SIP/6001 Setvar: GENDER=F Channel: Local/555@callfile MaxRetries: 5 RetryTime: 3600 WaitTime: 45 Extension: message Priority: 1 Context: callfile Archive: No

exten => message,1,Wait(2)
exten => message,n,Answer
exten => message,n(play),Background(my-message)
exten => message,n,Wait(15)

Hi!
Why “555” in the “Channel” ?
But, above all, I already had a working configuration without the Dial() command, I asked how to use the Dial() command to have the ${DIALSTATUS} variable set, to be able to detect the time span since the answer to the hung-up…