JABMenu Icon

Phone Number AppleScript

script prefs inserts phone

When using the “Dial with AppleScript” action for phone numbers or the “Dial Primary Number” action for the main contact name and one of these items is selected, if there is a viable phone number, that phone number (and the displayed name of the contact) is passed to an AppleScript for processing. You specify the AppleScript to use by clicking the AppleScript button that appears next to the phone selection action list when the “Dial with AppleScript” action is selected.

When you click the AppleScript button, the window will rotate to reveal an AppleScript editor where you can enter your script. You can enter any AppleScript you want but to access the contact name and number, you must use the data placeholders (%n for the contact name; %# for the contact number). Please be aware when entering these placeholders that the name and number are strings and will need to be quoted in your script to be properly executed.

To understand how this works, JABMenu contains several pre-configured scripts for sending the selected phone number to various external dialing applications (Dialectic, Macron Software’s ABDialer, & Sustainable Softworks’ Phone Amego) or to the Gizmo or Skype softphones.

You can use the Compile & Test buttons at the top of the editor to make sure that your script will function as you expect. When you are finished editing your script, click the “Return to Main Preferences” button and the window will rotate back to the main preferences view.

Advanced Scripters: You can use the placeholder %id to include the unique identifier of the selected contact within your script. You can then use this identifier to script the Contacts.app to gather information beyond the scope of the selected phone number. For instance, you could use the identifier to get other information about the contact (e.g., their department & job title) and include this in a dialog to remind you of these details for your call. To make the most of this, you may want to add code like the following to your script:

script icon
tell application "Contacts"
     --the %id placeholder will be updated with the unique id of the selected contact:
     set the_contact to person id "%id"
     --now that you have the contact, you can access its data like so:
     set contact_department to department of the_contact
     set contact_job_title to job title of the_contact
end tell

Was this page helpful? Were there errors, inaccuracies, or typos?
Could something have been explained better? If so, please let us know. 

Copyright © 2017 JNSoftware LLC. All Rights Reserved.
All other products mentioned are copyright of their respective owners.
No endorsement of or affiliation with any third-party product or service is implied.