Stopping Dial tone & playing message on onhook

Hi guys,
I ve a weird requirement.Here it goes.
When any Zap channel goes onhook,I wanted to play a message instead of dial tone.How do i retrieve onhook event of the channel in extensions.conf.
Please do suggest on this.

Thank you.

I assume you mean offhook! There’s no point playing a message when the phone’s onhook - as nobody will get to hear it!

Offhook = online
Onhook = offline.

(Think about the old type of phones where the microphone was on a sort of stick and the earpiece was separate, but was hung on a hook on the side of the stick when not in use.)

Yes, It is offhook.How do i stop dial tone when channel goes offhook.I wanted to play a message.
Basicallly i want to read offhook,onhook,flash events from the channels.