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.
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