Keep the called number when call busy and playing audio file

Hello everybody,
I’m having a little trouble with my dialplan.
When a call can’t be established, I want to play an audio message.

Here is my dialplan :

[DialStatus] ; if a call can not be established

exten => n-CHANUNAVAIL,1,PlayBack(custom/bonjour)
same = n,wait(0.3)
same = n,PlayBack(custom/numeroinvalide)
same = n,wait(0.3)
same = n,PlayBack(custom/bonnejournee)
same = n,Hangup()

exten => n-CONGESTION,1,PlayBack(custom/bonjour)
same = n,wait(0.3)
same = n,PlayBack(custom/numeroinvalide)
same = n,wait(0.3)
same = n,PlayBack(custom/bonnejournee)
same = n,Hangup()

exten => n-BUSY,1,PlayBack(custom/bonjour)
same = n,wait(0.3)
same = n,PlayBack(custom/busy)
same = n,wait(0.3)
same = n,PlayBack(custom/renouvelerappelplustard)
same = n,wait(0.3)
same = n,PlayBack(custom/bonnejournee)
same = n,Hangup()

exten => n-NOANSWER,1,PlayBack(custom/bonjour)
same = n,wait(0.3)
same = n,PlayBack(custom/numeronerepondpas)
same = n,wait(0.3)
same = n,PlayBack(custom/renouvelerappelplustard)
same = n,wait(0.3)
same = n,PlayBack(custom/bonnejournee)
same = n,Hangup()

[call]

exten => _+.,1,Dial(PJSIP/${EXTEN}@trunk)
same = n,Goto(n-${DIALSTATUS},1)
include => DialStatus

It works, no problem. But I lose the called number in the CDR file or in CDR functions.
If the call can’t be established, the CDR return n-BUSY for example as called number.
Am I missing something to keep the called number in the CDR?

Thanks

You’d need to force the CDR out, with ResetCDR before the GoTo. The CDR will contain the extension that was running when the CDR was output.

Thanks for your answer. Will test it tonight.
Is this the best way to play audio file when a call can’t be established ?

Your issue is with the decoding of the DIALSTATUS, not the playing of the audio file.

Macros are now deprecated, but you can use explicit tests on the original extension number, or have the decode subroutine do a fast lookup of the string, such that the call is unlikely to end whilst that is happening. You could also use the status code as part of the name of a (global) variable containing the name of the files.

I’d suggest it is better to use a silence recording rather than waits, so that you can have just one call of Playback.

I’d suggest that just allowing the call to end unanswered, and propagate the clearing cause backwards, avoids language issues and unnecessary charging of the caller. It also means machine callers (including other PABXes, know that the call has failed. Although probably not widely supported, sending the correct SIT tone, before the announcement, is probably better than going straight into the announcement.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.