This chapter is for those who wish to extend Intercom in ways for which it was not necessarily designed. In order to get the most from this chapter, you will want some experience with a programming or scripting language such as bash, PERL, or C. Any language should do as Intercom's callouts are general.
Intercom provides a way by which a shell command can decide what Intercom should do on a certain event. This allows the user to do things as simple as playing a sound when an Incoming call comes in or as complex as implementing time restrictions and blacklists. This chapter describes these methods and includes examples whenever possible.
![]() | The implementation should be fairly easy for any shell programmer to understand; however, I am a programmer and not a technical writer. If something is unclear, do not hesitate to contact me. |
Intercom can execute a given command when a certain event occurs. By command, I refer to an Intercom command and not a Unix shell command. Hooks are administered through the hook command and are automatically saved with the save command.
To add a command-hook, you pass the event type and the command to execute to the hook add command. The command you specify will be executed whenever that particular event is triggered. The currently defined event types are as follows.
call_incoming - Triggered on an Incoming call. At the point of the trigger, Intercom is ready to either accept or reject the call unless a previous hook of this type has changed the state
call_outgoing - Triggered when an outgoing call is placed. The event is triggered after a connection to the remote host has succeeded but before the call is actually answered or rejected by the called party.
call_connect - Triggered just as a call is connected. This event is triggered both when we are the caller or the call recipient.
hangup_lc - Event which is triggered when our end terminated an established call.
hangup_rmt - Triggered when the remote party has disconnected a call.
![]() | You can have more than one hook for an event type. Hooks are executed in the order in which they were added. |
As a simple example of a hook, we can automatically answer incoming calls unconditionally with the following command.
intercom: hook add call_incoming answer
Or, to reject all incoming calls, execute the following command.
intercom: hook add call_incoming hangup