AppleScript control over SKYPE – call & SMS/Text messsage automation

Originally posted: @photolifetoys.blogspot

We had an issue.

Delinquent clients would not answer their phones, and the reps had a hard time getting through to them.

So we decided to automate the process.

In combing through the Skype API, various inet resources, blogs, books, etc, the “skype call and sms via applescript.scpt” script was born.

The solution is that after setting up 5 parameters: # of attempts, name of person to be called, phone number, SMS message body text, and interval delay between attempts – the script will do the following:

1. Attempt to call the provided phone number (assuming no answer)
2. Send an SMS text message to that phone number asking to call back
3. Echo back to your skype account message recording the attempt.
4. Wait for the interval to expire and repeat.

Call answering is not checked for, so you need the manually halt the script in case you get an answer.

Further, this can be expanded to handle a sort of “mail merge”, or “call list message execution”. The Skype API allows for changing of audio in/outputs, meaning you should be able to route to “Soundflower”, take control of quicktime and playback a preset recording, and then route back for normal operation.

My apologies, but this seems to be a “mac only” solution. I’m sure that the Skype API calls can be referenced and a similar workflow can be created on Win and Linux.

There is no GUI attached – you need to open the script up in AppleScript Editor (should be present on every mac system), and setup the five “variables” as described above and in the body of the script.

Enjoy!

ps. if you copy/paste from below, make sure that the quotes don’t come up as “curly quotes” – if they do, you will need to do a search/replace in AppleScript Editor for this to work.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
######################################################################
########## SCRIPT TO CALL & SMS to a qualified number, i.e. +44.. at regular intervals ##############
######################################################################
# 13-Dec-2011, DMS.
#
# This script is for used for Skype control via AppleScript.  It is a combination and expansion on various
# resources found on internet and SKYPE api.
# It assumes that the current logged in skype account has "skype credit" and is able to
# normally send text messages and call out to mobile/land lines - via the Skype Out service.
# Please keep in mind, that normal Skype charges apply.
#
# The Script will make call attempts via skype, then followup with an SMS Text message.
# It will then report on the status back to you via SKYPE chat message.
#
# At present there is no functionality of checking on whether the phone was picked up, to halt script.
# This has to be done by hand by stopping the script.
#
######################################################################
#
#
# BEFORE USING - SET THE FOLLOWING VARIABLES:
#
#1. numberOfAttempts - The number of times you wish the loop to take place (#of calls & SMS messages).
#
#2. callToA - The Person's name the script will be calling / sms texting.
#
#3. callToAnumber - The phone number to use for the calls / sms.  Must be in qualified international
#    format: i.e. UK +44…  US +1…  France +33… (Followed by area code and phone number)
#
#4. SMSmessageBody - The text in the body of the SMS/Text message.
#    The Message body is combined from the following:
#          callToA - i.e. - "BOB"
#          SMSmessageBody - i.e. "! Please call me at +18005551212 as soon as possible to settle your debt. Reminder #"
#          AttemptPersonA - This is the counter of the loop in iterations.
#    The SMS.Text message sent on attempt #3 would be:
#          "BOB! Please call me at +18005551212 as soon as possible to settle your debt. Reminder #3"
## Most mobile phones will now recognize this format and allow one click call back from within the sms message.
#
#5. attemptInterval - # of seconds between call attempts - i.e. 3600=1 hour, 1800=30 mins
#
#
# SETUP VARIABLES
set numberOfAttempts to 6
set callToA to "BOB"
set callToAnumber to "+13105551212"
set SMSmessageBody to "! Please call DEAN @ +18005551212. Reminder #"
set attemptInterval to 1800
#
#
# BODY
set callAttemptsCounter to 1
set AttemptPersonA to 1
repeat numberOfAttempts times
    #
    # call attempt to PERSON
    tell application "Skype"
        send command "CALL " & callToAnumber script name "Call"
    end tell
    delay 90 #wait 90 seconds before sending SMS, allowing for call to be answered.
    say "call attempt to " & callToA & " completed, sending SMS reminder #" & AttemptPersonA
   
    # send SMS message after the call attempt
    set smstext to callToA & SMSmessageBody & AttemptPersonA as Unicode text
    tell application "Skype"
        set message to send command "CREATE SMS OUTGOING " & callToAnumber script name "SMS"
        set smsid to item 2 of every word of message
        send command "SET SMS " & smsid & " BODY " & smstext script name "SMS"
        set result to send command "ALTER SMS " & smsid & " SEND" script name "SMS"
        #display dialog "SMS send! Text: " & smstext
    end tell
   
    #send a skype message to Self with update!
    set messageText to "     Call attempted to " & callToA & "; and reminder #" & AttemptPersonA & " sent."
    tell application "Skype"
        send command "MESSAGE echo123" & messageText script name "messages"
    end tell
   
    # wait 30 mins (1800 seconds)
    delay attemptInterval
    #
    #display dialog "Call & SMS attempts: " & callAttempts
    set AttemptPersonA to AttemptPersonA + 1
    set attemptPersonB to attemptPersonB + 1
    set callAttemptsCounter to callAttemptsCounter + 1
end repeat