Interrupting a call in progress?

Home » Asterisk Users » Interrupting a call in progress?
Asterisk Users No Comments

Is it possible to “butt in” on a call in progress and play a message to one
party, without disconnecting the call? (Anyone with fond [or not-so-fond]
memories of the old GPO payphones will remember the “pips” used to indicate
that a coin needed to be inserted to keep the call alive.)

Why do I want to do this? My phone company allows calls to landlines at a
flat rate for up to one hour, then begins charging per second *including* the
hour you’ve already used. If you hang up and redial anytime up to the 3599th
second, you get another hour for cheap; but if you go past the hour, you get
penalised. So what I want to do is, play an announcement to alert someone on
an internal extension (either SIP for my modern phones or DAHDI for my
antique ones) speaking to an external number (DAHDI) after 55 minutes.

I *could* just set an absolute timeout in my outgoing context, so calls get
cut off just before the 1 hour limit; but this is somewhat inelegant from the
user’s point of view.

I’m thinking I will need to run an AGI script once the call is bridged, to
capture the channel name; then schedule another job to start at a
predetermined time which will check to see if the channel is still active
and, if so, butt in with the announcement. So if there’s a method of
interjecting on a call from the Unix command line (or from within a Perl
script), I could take it the rest of the way from there.