Desktop User Guides > Professional > Interview scripting > Writing interview scripts > Interactive Voice Response interviews > Writing an IVR hand-off function
 
Writing an IVR hand-off function
The following example uses the SPSS Dialer methods that are available on the _Dialer and _Extension objects. For IVR information, see your dialer’s documentation.
Function TransferToIVR(IOM, _Dialer, _Extension)
Const IVR_NO = "02071234567"
Const SAMPKEY = "ID"

Dim DTMF, IVRCall
' The DTMF to the IVR system consists of the sample record ID
' and a # symbol requesting IVR to start the interview
DTMF = IOM.SampleRecord[SAMPKEY] + "#"

' Dial the IVR system with a 5 second time-out and send the
' DTMF tone when it connects
Set IVRCall = _Dialer.Groups["ivr_xfer"].DialCall(IVR_NO, , , , 5, , DTMF)

' Wait for the call to connect (2) or terminate (3)
While ((IVRCall.State <> 2) And (IVRCall.State <> 3))
Sleep(100)
End While

If (IVRCall.State = 2) Then
' Connection made. Transfer the call.
QsampExtension.Call.TransferToExtension(IVRCall.Extension.SlaveExtension)
' Wait until the transfer of the original call is complete (and it terminates (3))
While (_Extension.Call.State <> 3)
Sleep(20)
End While
TransferToIVR = True
Else
' No connection - something went wrong.
TransferToIVR = False
End If
End Function
See also
Dialing the IVR system
Passing information to the IVR system
Transferring the respondent to IVR
Dealing with failed calls
Interactive Voice Response interviews