egress call handling

The concept of egress modules preparing calls from the local users to go out to SIP trunks or ISDN trunks is also introduced in the section called “Routing calls within a site”.

The egress stage should convert the destination number into the format expected by the telephone company or trunking provider. For example, they may require a 00 prefix on all numbers qualified with a country code.

The egress stage is also a good place to set the caller ID. Some trunking providers automatically set the caller ID for you. Some allow you to specify the caller ID in the From header, as long as the value you use is an inbound number that you have purchased from the same company. If you try to use any other number, it is likely the will replace it with one of your numbers selected at random. ISDN trunks attached to a soft PBX or media gateway also permit the caller ID number to be set on a per-call basis.

Setting the caller ID to a constant value is relatively easy within an Asterisk extension as demonstrated in Example 18.1, “Asterisk extensions.conf for specifying caller ID”.

Example 18.1. Asterisk extensions.conf for specifying caller ID

exten => _X.,1,Set(CALLERID(name)=00442071358378)
exten => _X.,2,Set(CALLERID(number)=00442071358378)

Instead of hard-coding a constant value, if the users have their own direct phone numbers, a CSV file or Asterisk Realtime SQL lookups could be used to map individual SIP usernames to personal caller-ID values.