Chapter 5. Interfacing With Intercom

Table of Contents
Introduction to Hooks
Executing external programs
Conditionals
Putting it all Together

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.

Note

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.

Introduction to Hooks

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.

Note

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