6 Replies Latest reply: Sep 3, 2012 11:27 PM by willarr
JohnOfChocobo Level 1 (0 points)

Does anyone know what the service iMessages uses is called in iChat for applescript? I am using OSX 10.7.3 with Messages Beta installed.


I am trying to make an applescript whereby on an Event trigger my mac will send me a message to my phone to keep me updated, however applescript needs to know what "Service" Messages Beta uses in order to send the messages through iMessage. I have looked in the iChat dictionary within Applescript editor to try and find what the service is called but it isnt listed.


I have tried the following:


  • iMessage
  • Messages
  • iChat
  • iMessages


in the following code snippet:


set theBuddy to buddy "*****" of service "iMessage (this is the part where i am stuck)"


Whereby the variable "theBuddy" will be the contact that will be messaged, using the iMessage service. Unfortunately I cannot seem to find the name of the

service to tell the script to use it.

iMac, Mac OS X (10.7.3)
  • Camelot Level 8 (46,665 points)

    You're misinterpreting the dictionary (which is incredibly easy to do).

    What Messages wants is an identifier to help it locate the service you want. This could be as simple as the service name that you've defined in the accounts section. No one can tell you what the appropriate values are since they're unique to your machine/setup.


    For example, any of these will work (with the appropriate labels, of course):


    set theBuddy to buddy "*****" of service "My iCloud Account"

    set theBuddy to buddy "*****" of service "Yahoo!"




    If you're not sure of your service names, just ask Messages:


    tell application "Messages"

              get name of every service

    end tell


    and fill in the blanks.

  • JohnOfChocobo Level 1 (0 points)

    Thank you SO much!! That really helped me with my problem. I dont suppose you could help me with the final piece of my puzzle please? I have been stuck at it all night.


    all I get is

    error "iChat got an error: Can’t get buddy id \"0E20543C-A054-4DE8-9C5B-5D639E4105F4:(my full name)\"." number -1728 from buddy id "0E20543C-A054-4DE8-9C5B-5D639E4105F4:(my full name)"


    Im new to applescript and Im still trying to get used to programming


    using terms from application "iChat"

              tell application "iChat"

                        set theBuddy to buddy "(my name here, of which i have myself as a contact in address book)" of service "(The service)"

                        send ("You have new mail, John" as text) to theBuddy

              end tell

    end using terms from


  • Camelot Level 8 (46,665 points)

    The ID numbers in your error message are the same, which implies that you're trying to send the message to yourself, or some such. It's hard to diagnose from here without specifc examples... I can say that using a valid buddy name and service name works as expected on my machine.


    tell application "Messages"

              set theBuddy to buddy "camelot@mac.com" of service "iCloud"

              send "Hi there" to theBuddy

    end tell

  • JohnOfChocobo Level 1 (0 points)

    Thank you so much! You really helped on that one, all I had to do was not use my email but my phone number for the recipient of the messages and it worked!


    Thanks again,



  • Bernie_uk Level 1 (10 points)

    I was just trying to figure this out also, and ran into similar problems.


    The service was always a UUID character string, which had a property "service type" of either iMessage or Bonjour. I noticed that for the action "send to buddy", it sent a messages via Bonjour. I tried to swap the order of the services in Preferences, but this did not work.


    I finally go the message to go via iCloud by using the "text chat" object instead of "buddy":

         send "my message" to text chat "name@me.com"


    Hope that helps



  • willarr Level 1 (10 points)

    Sorry to piggyback, but it's mostly related.

    I am trying to create a service that grabs the URL of some link, then create a blank iMessage with that URL in the body. Basically, I want to recreate that Message share feature in Safari in Mountain Lion, but with Reeder.app, specifically. "Copy Link" from the context menu doesn't always work, esp. when sending to a iphone, the URL drops, and all you get is the alias.

    I've set up an Automator with Applescript, and I can definitely send a message to a buddy, if those things are specified. I'd prefer to populate that in iMessage, since I won't always be sending to the same person.

    Below works, using set input as a proxy for automator's url grabbing at the moment.

    set input to "http://aol.com"
    tell application
    set theBuddy to buddy "someemail@mac.com" of service "iCloud"
              send input to theBuddy
    end tell

    Also tried, but with errors

    tell application "Messages"
    set theBuddy to buddy "*" of service "iCloud"
    set input to invitation message of text chat of service "iCloud"
    end tell