Thursday, December 18, 2014

Asterisk Out Of Purpose Recording Extension

My clients sometimes take to order temporary messages on their outcry lines. For representative during the Christmas holidays or if everyone is away for a fellowship retreat.

This is a unproblematic edit to your dialplan, hence it should non hold out besides difficult.


On the incoming dialplan, add together the following

;Check if a greeting is enabled, if hence larn to "playback" inward the electrical flow context
same => n,GotoIf(${DB_EXISTS(greeting/enabled)}?playback)

;If greeting is non enabled, skip to "noplayback"
same => n,goto(noplayback)

;Play the recorded message as well as hence hang up
same => n(playback),Playback(temp-message)
same => n,HangUp()

;If message is non enabled, boot the bucket along amongst the residue of your incoming dialplan
same => n(noplayback),NoOp(Playback is non active)

Now, practise the next context as well as brand certain it is included inward your outgoing context.



[greeting]
;When the user dials 999 get-go the procedure to tape the temporary message
exten => 999,1,NoOp(Start Recording Message)

;Issue a vocalism teaching to the user, brand certain to upload the vocalism files from the extended vocalism pack for asterisk
same => n(record),Playback(after-the-tone&say-temp-msg-prs-pound)
;same => n,Playback(beep)

;Record the message, as well as play it dorsum to the user for approval
same => n,Record(temp-message.gsm)
same => n,Playback(playback&temp-message)

;Ask the user to approve the message yesteryear hanging up, or press cipher to re-record
same => n,Background(if-this-is-not-correct&press-0&otherwise&hangup)
same => n,Wait(10)
same => n,hangup

;If the user presses zero, provide to "record"
exten => 0,1,goto(greeting,999,record)

;When the user dials *999 toggle the message playback as well as prompt the user, brand certain to upload the appropriate promtps
exten => *999,1,NoOp(Toggle Greeting)
same => n,GotoIf(${DB_EXISTS(greeting/enabled)}?DisableGreeting)
same => n,Set(DB(greeting/enabled)=TRUE)
same => n,Playback(vm-tempgreetactive)
same => n,HangUp()
same => n(DisableGreeting),DBdel(greeting/enabled)
same => n,Playback(vm-tempremoved)
same => n,HangUp()