Perform action instead of dialtone

I would like to know how I can automatically dial a number, play a message, or execute an IVR when an extension/handset is picked up.

For devices attached to FXS interfaces driven from DAHDI, use the immediate=yes option in chan_dahdi.conf. For SIP phones, you’ll have to see if your vendor supports some kind of “dial a number immediately when the handset is taken off-hook” option.