Search code examples
macossmsapplescriptosx-yosemite

send text message with applescript


I would like to automate sending a text message to a special uncle of mine using AppleScript and iCal on OS X Yosemite. Is this possible? This is the AppleScript I wrote:

using terms from application "Messages"
on service_type with SMS
    send this_Message to this_buddy with this_Chat
    set this_name to the name of this_buddy
    if the name of this_buddy is in {Uncle, Jose} then
        set canned_responses to {Happy, Birthday, Uncle, Hose}
        set this_messsage to canned_responses
    end if
end service_type

end using terms from

Will this work? It isn't his birthday yet so I really can't run the script, I mean I can but it doesn't give any feedback. Any help would be appreciated.


Solution

  • tell application "Messages"
        -- Create variable containing the name of how your uncle is listed in your contacts
        set theBuddy to buddy "Contact name"
    
        -- Send the text. Change "Text message" to your own message
        send "Text message" to theBuddy
    end tell