PERIODIC_HOOK([[term:context|context]],[[term:extension|extension]],interval,hook_id)
For example, you could use this function to enable playing a periodic beep sound in a call.
same => n,Set(BEEPID=${PERIODIC_HOOK(hooks,beep,180)})
same => n,Set(PERIODIC_HOOK(${BEEPID})=off)
same => n,Set(PERIODIC_HOOK(${BEEPID})=on)
It is important to note that the hook does not actually run on the channelA single call leg passing through Asterisk. Channels represent connections to endpoints and are what dialplan applications act on. itself. It runs asynchronously on a new channel. Any audio generated by the hook gets injected into the call for the channel PERIODIC_HOOK() was set on.
The hook dialplanThe core call-routing configuration of Asterisk, written mostly in extensions.conf as contexts, extensions, and priorities that decide how every call is handled. Full definition → will have two variables available. HOOK_CHANNEL is the channel the hook is enabled on. HOOK_ID is the hook ID for enabling or disabling the hook.
contextrequired - (On Read Only) Context for the hook extension.extensionrequired - (On Read Only) The hook extension.intervalrequired - (On Read Only) Number of seconds in between hook runs. Whole seconds only.hook_idrequired - (On Write Only) The hook ID.
User Notes
Know a tip or gotcha for this topic? Share it below and help others.
Contribute a note
Share a tip, gotcha, or practical example. Keep it under 2000 characters. No questions (use the Asterisk community forums for support). Wrap code in backticks.