# Asterisk Project : Asterisk 13 Function_PERIODIC_HOOK

Created by wikibot on Aug 08, 2014

# PERIODIC_HOOK()

### Synopsis

Execute a periodic dialplan hook into the audio of a call.

### Description

For example, you could use this function to enable playing a periodic `beep` sound in a call.

To turn on:

Set(BEEPID=${PERIODIC_HOOK(hooks,beep,180)})

To turn off:

Set(PERIODIC_HOOK(${BEEPID})=off)

To turn back on again later:

Set(PERIODIC_HOOK(${BEEPID})=on)

It is important to note that the hook does not actually run on the channel 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 dialplan 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.

### Syntax

    PERIODIC_HOOK(context,extension,interval,hook_id)

##### Arguments

- `context` - (On Read Only) Context for the hook extension.
- `extension` - (On Read Only) The hook extension.
- `interval` - (On Read Only) Number of seconds in between hook runs. Whole seconds only.
- `hook_id` - (On Write Only) The hook ID.

### See Also

### Import Version

This documentation was imported from Asterisk Version SVN-branch-13-r420538