AppleScripts

Responding to Phone Amego Events


You can have Phone Amego launch an AppleScript for the following events:

  • call_from (phone_number)
  • will_dial (phone_number)
  • did_dial (phone_number)

  • out_of_range (phone_label)
  • in_range (phone_label)
  • on_hook (phone_label)
  • off_hook (phone_label)
  • incoming_call (phone_label)
  • call_answer (phone_label)
  • call_end (phone_label)

  • call_info (info)

For example, you could have Phone Amego pause iTunes when you answer a call, or tell your computer to activate a screen saver when you leave the area. AppleScripts are normally found in ~/Library/Scripts/

The "will_dial (n)" action allows you to intercept outgoing calls just before Phone Amego dials so you can pre-process the phone number if desired. The "Phone Amego will_dial.scpt" provides an example of how to do this.

The "call_from (n)" action allows you to intercept incoming Caller ID information just before it is displayed by Phone Amego. The included "Speak CallerID" example announces the callers name (similar to the built-in Speak Caller Name feature). You could also lookup private phone numbers in a company wide database if desired.

The "out_of_range (phone_label)" and "in_range (phone_label)" actions allow you to be notified when a specific telephone device moves in or out of range. The "Speak In Range.scpt" provides an example of how to use this.

The "call_info (info)" action is invoked when the user clicks on the rolodex card icon (if a script is specified). This allows your script to capture call information (name, phone number, time, and telephone device) for those calls you decide need some action.

Install DMG

To install these AppleScripts to an external location for editing, open the Phone Amego Disk Image (.dmg) file you downloaded and copy the "Phone Amego Scripts" folder to
~/Library/Scripts/ (PA 1.4.22 or earlier) or copy the scripts to ~/Library/Application Scripts/com.sustworks.PhoneAmego/ (PA 1.4.23 or later) on your hard drive. The new location is required for scripts to run from a sandboxed application.

Phone Amego includes some basic AppleScripts to pause iTunes playback, set your iChat status, or activate a screen saver when your phone moves out of range. These scripts are NOT copyrighted so you can use them as building blocks to publish your own.

Phone Amego Scripts

The
Bento Search script initiates a search to bring up the corresponding person record in FileMaker's Bento database. Bento does not provide any AppleScript support, so this script uses System Events to manipulate the user interface. To have Bento dial a phone number, you can add a <tel:number> URL field to each record, or select the phone number and click using PopClip.

The MS Outlook scripts are designed to work with call_from(phone_number) and did_dial(phone_number) to create a corresponding calendar entry for that call.

Getting Phone Amego to Dial


Phone Amego can be scripted using the GetURL AppleScript command like this:

tell application "Phone Amego"
GetURL "tel:401-333-XXXX"
end tell

Phone Amego recognizes and responds to these URLs:
<tel:1-777-5555555>
<phoneamego://1-777-5555555>
<clicktocall://1-777-5555555>
<callto://1-777-5555555;phoneIndex=48;phoneLine=2>
<sip:+1NPAN7775555555@sip.voice.google.com>
<touchtone:123#>
<sms:17775555555>
<sms:+1(777)555-5555;text=Sample%20text>
<endcall://>

"tel", "clicktocall", "callto", or "phoneamego" will cause Phone Amego to dial the requested number using the currently selected settings. "sip" can be used to dial a sip URI (a user's SIP phone number).

"sms" will tell Phone Amego to send an SMS to the requested number, bringing up the "Send SMS with Google Voice" window if needed.

These URLs can also be clicked on from a web browser


Since there is some risk of a web URL dialing an unknown number that incurs a toll or unexpected result, the "tel" or "phoneamego" URL will normally display an alert confirming the number to be dialed with an option to "Cancel" as shown below.

URL Alert

You can press "Esc" (Cancel) or "Return" (OK) without leaving the keyboard.

If you are scripting Phone Amego directly, you can avoid this alert by using the "ASGetURL" command in place of "GetURL" above. To turn off this alert, uncheck "Ask Before Dialing from a URL" under the More tab of the Phone Amego window.

tell application "Phone Amego"
ASGetURL "sms:+1(777)555-5555;text=Sample%20text"
end tell

These URLs can also be used remotely via HTTP


Phone Amego Pro includes a Local HTTP Server configured under the Caller ID tab. You can include any of the URLs above in an HTTP request as follows:

http://<host>:<port>/url?url=<paScriptingURL>


For example, a Safari bookmark on your iPad could tell your desktop IP phone to dial the corresponding number. A simple iOS application could be used to dial any phone controlled via Phone Amego.

Getting Phone Amego to Show Caller ID


Phone Amego can be scripted using the GetURL AppleScript command like this:

tell application "Phone Amego"
GetURL "callerid:401-555-5555"
end tell

Phone Amego recognizes and responds to these URLs:
<callerid:1-777-555-5555>
<callerid://1-777-555-5555;device=soft_phone>
<callerid:Caller%20Name%3A777-555-5555>

Notice the use of URL encoding "%20" for " " and "%3A" for ":".

Selecting Default Applications


Phone Amego registers to handle URLs of the form <tel:xxx-xxx-xxxx>, but other applications may register for these as well in which case Launch Services will decide which application to invoke. You can select which application you want to dial calls as follows:

- On Mac OS 10.10.x navigate to “
FaceTime > Preferences > Settings > Default for Calls” and select Phone Amego.

- On Mac OS 10.9 or below, you can select which application you want to launch by default for various URLs by installing a 3rd party preference pane called "Default Apps".  See
<http://www.macupdate.com/app/mac/14618/rcdefaultapp>.