Hack18.Use Caller IDs in AppleScripts

Hack 18. Use Caller IDs in AppleScripts

One of Phlink's AppleScript hooks occurs when incoming calls arrive, which means you can create actions to handle how those calls are handled.

If Phlink didn't have AppleScript support, it wouldn't be nearly as cool as it is. In fact, when I first fired up the Phlink application, I looked at the minimal interface and thought to myself, "Is that it?"

The fact is that Phlink's most awesome functionality is in its AppleScript object model. By using Phlink's functions in tandem with other AppleScript aware applications, you can do some very cool telephony automation, from music-on-hold to greeting callers with the Mac's speech synthesis in interactive stages. Anything you can retrieve into an AppleScript variable from other Mac apps, you can pass into Phlink functions for interaction with callers. The only limit, then, is your imagination.[1]

[1] For an unrelated affirmation of the limitlessness of the human spirit, visit http://www.zombo.com.

As I got into setting up these voice AppleScripts, I was reminded of the interprocess communication goodness of the vintage Arexx scripting language on my old Amiga 4000 computer. I got to thinkingwouldn't it be cool to do some voice hacks on that 25 MHz classic? Then I realized that the Amiga's pokey 680x0-vintage processors don't even have enough processing power to encode and decode modern audio codecs! My hopes of splashing the cover of O'Reilly's Make magazine with a really tasty Amiga VoIP hack were dashed, and I returned to the 21st century realm of VoIP Hacks.

A great place to start building Phlink AppleScript hacks is with caller ID. When Phlink receives an incoming call, the first script Phlink calls is ring, which you'll create in the /Library/Application Support/Phlink Items directory. The call doesn't have to be answered to execute this script; the line just needs to ring.

Now, while I'm not going to give you a full-blown explanation of AppleScript (O'Reilly's AppleScript: The Definitive Guide does a far better job than I could hope to, anyway), these examples should suffice to let you hack Phlink. Since we're starting out with the ring script, take a look at this example, which announces the caller ID of the call while it's ringing:

 on incoming_call given callername:theName if the Name is "" return true else say ("You are receiving a call from " & theName) as string return false end if return callAgain end incoming_call 

It will probably take two rings before caller ID information is transmitted from the phone company (it tends to come between rings), but Phlink calls the ring script until it returns false, as in the previous example. An even cooler use of the ring script is to retrieve the caller's Address Book entry based on the caller ID signals received:

 on incoming_call given callername:theName if the Name is "" return true else tell application "Address Book" set selectedPerson to (the name of the person \ whose name contains theName) end tell end if return callAgain end incoming_call 

VoIP Hacks
VoIP Hacks: Tips & Tools for Internet Telephony
ISBN: 0596101333
EAN: 2147483647
Year: 2005
Pages: 156

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net