user1946171
user1946171

Reputation: 61

How can I get the duration of call and save it to a variable in my dialplan?

exten => 3333,10,hangup

exten => 3333,11,Set(x=${CDR(billsec)})

exten => 3333,12,noop(${x})

Upvotes: 3

Views: 6252

Answers (1)

MichelV69
MichelV69

Reputation: 1212

The call dies with the "HangUp()" command, and call processing stops. As a result, priorities 11 and 12 are not reached. However, we can "prolong" the life of the call past the hangup condition with a special extension, "h". Please try changing your code as follows:

exten => 3333,10,HangUp()

exten => h,1,Set(x=${CDR(billsec)})
 same => n,NoOp(${x})

... and let me know if that works for you.

Recommended reading: https://wiki.asterisk.org/wiki/display/AST/Handling+Special+Extensions

Upvotes: 7

Related Questions