Hack 93. Automate Your Interactions with Telephone Systems
If you interact with automated telephone systems often (the "Press 6 to access your account" sort of thing) this hack will do the work of pressing the buttons for you. Works with: Windows version of Skype. They're the systems we all love to hate! Interactive Voice Response (IVR) systems can simplify life, or make life unbearable. From renewing a drug prescription to getting your bank balance over the phone, when they work they're a boon, and when they don't they're a bust. IVR systems respond to the keys you press (actually, the tones you hear when you press a key) on your phone's keypad (or on Skype's Dial tab) in response to voice prompts from a computer at the other end of the call. Menus for IVR systems are normally well defined and don't change often. So, grab a notepad and jot down your interactions at each step during an IVR call. Armed with this information, you're in a good position to automate the process the next time around Of course, in tribute to Murphy's Law, the menu option you most often want is buried so deep that it's a lot of key presses away. So, if you interact often with IVR systems, automate your interaction in whole, or in part, using this script, ivr.vbs. Note that you will have to be a subscriber to the SkypeOut service if you want to call regular phone numbers that operate IVR systems. ' File: ivr.vbs ' Invoke like this from the command-line: ' ivr +18005551212 ,,123,456,,78 ' ' Parameters: ' +18005551212 - number to call ' ,,123,456,,78 - keypad keys to press with 1 second pause for ' each comma ' Global variable Dim g_objShell ' Scripting shell object ' Dial number and send DTMF tones upon connection ' SkypeHandle = handle of Skype user or telephone number to call ' DTMF = string of DTMF values (0-9,#,* and ,) Sub DialDTMF(SkypeHandle, DTMF) Dim objSkypeAPI ' SkypeAPI object Dim objCall ' Call object Dim iStatus ' Call status Dim i ' Counter Dim strDigit ' DTMF digit ' Create the Skype interface object Set objSkypeAPI = WScript.CreateObject("SkypeAPI.Access") ' Place the call Set objCall = objSkypeAPI.PlaceCall(SkypeHandle) ' Loop until the call is cancelled, finished or in progress Do iStatus = objCall.Status ' If the call is in progress, then ' send the DTMF characters If iStatus = 5 Then For i = 1 to Len(DTMF) strDigit = Mid(DTMF, i, 1) Select Case strDigit Case "0", "1", "2", "3", _ "4", "5", "6", "7", _ "8", "9", "#", "*": ' Send the DTMF digit ' and wait 200 ms so ' that the digit ' registers properly objCall.SendDTMF strDigit ' If this pause isn't ' here, DTMF tones may ' play back too fast WScript.Sleep 400 Case ",": ' Interpret commas as ' 1 sec pauses WScript.Sleep 1000 End Select Next Else ' Wait for the call to be picked up ' or cancelled WScript.Sleep 500 End If Loop While (iStatus <> 3) and _ (iStatus <> 5) and _ (iStatus <> 11) End Sub ' Main script begins here Set g_objShell = WScript.CreateObject("WScript.Shell") ' Make sure the user is sending the correct number of parameters If WScript.Arguments.Length <> 2 Then g_objShell.Popup "Parameter 1: Skype Handle to Call" & _ vbCrLF & "Parameter 2: DTMF to Send", _ 0, "DialDTMF Script Usage", 64 Else DialDTMF WScript.Arguments(0), WScript.Arguments(1) End If |