Skip to main content
Version: v4 (Stable)

Sample scripts for transferring calls

How to use the ALERT IVR to transfer calls.

Call transfer using the telephony system

This script uses the text to speech engine.

The next script will be explained later.

Dim sCallerNum As String
Dim sCalledNum As String
Dim nRes As Integer
Dim nTransRes As Integer

sCallerNum = GETCALLERNUMBER()
sCalledNum = GETCALLEDNUMBER()

PLAYTEXT("Welcome on the transfer test system." , "en-us")
WAITENDOFPLAY(1000)

REQTELEPHONYTRANSFER(0, "1096", FALSE)

nRes = GETTRANSFERSTATUS(30000)
If nRes = 2 Then
PLAYTEXT("You will receive a call from " + sCallerNum + ". Press any key." , "en-us")
If GETKEY(10000) >= 0 Then
nTransRes = COMPLETETRANSFER(40000, TRUE)
If nTransRes = 2 Then
CANCELTRANSFER()
PLAYTEXT("The transfer is not yet started." , "en-us")
ElseIf nTransRes = 0 Then
PLAYTEXT("Sorry, the transfer failed." , "en-us")
Endif
Else
CANCELTRANSFER()
PLAYTEXT("Sorry, the remote party refused the call." , "en-us")
EndIf
ElseIf nRes = 0 Then
CANCELTRANSFER()
PLAYTEXT("The call has been refused." , "en-us")
ElseIf nRes = 1 Then
CANCELTRANSFER()
PLAYTEXT("Nobody answered the call..." , "en-us")
EndIf

WAITENDOFPLAY(500)
DISCONNECT()

The script plays first a welcome message with the PLAYTEXT function.

PLAYTEXT("Welcome on the transfer test system." , "en-us")

The script starts a call transfer to the "1096" with the function REQTELEPHONYTRANSFER. The transfer will be done by the telephony system (PBX, national telephony network...). The transfer type (0 here) is only used for CAPI connections (See function documentation).

REQTELEPHONYTRANSFER(0, "1096", FALSE)

The first call (incoming call) is put on hold.

The script is waiting for the new call pick-up (here the 1096) thanks to the function GETTRANSFERSTATUS.

nRes = GETTRANSFERSTATUS(30000)

Depending on the result, we can have different cases:

  • 2: The new call has been picked-up. The script is now connected on the second call. The first call remains on-hold.
  • 0: The new call has been refused or the remote party is busy. The transfer is still in progress. The first call remains on-hold. The transfer must be cancelled with CANCELTRANSFER to be able to play a new message.
  • 1: Nobody answered during the specified time. The transfer is still in progress. The first call remains on-hold. The transfer must be cancelled with CANCELTRANSFER to be able to play a new message.
  • -1: The first call has been hung-up.

When the second call has succeeded (return 2), we can play messages on the second call. The PLAYTEXT function is used as well.

PLAYTEXT("You will receive a call from " + sCallerNum + ". Press any key." , "en-us")

The script is waiting for a key to be pressed with GETKEY.

If GETKEY(10000) >= 0 Then

If no key is pressed, the first call remains on-hold. The transfer must be cancelled with CANCELTRANSFER to be able to play a new message.

To finalize the call transfer, call the function COMPLETETRANSFER.

nTransRes = COMPLETETRANSFER(40000, TRUE)

On success, the current script is stopped and the two calls are merged.

On failure, the transfer must be cancelled with CANCELTRANSFER to be able to play a new message.

Call transfer done by Alert (Flow to flow)

In this case, Alert will redirect the audio flows. This script uses the text to speech.

For this kind of transfer, we have different prerequisites:

  • For flow to flow transfer, Alert needs two communication ports. One port is for the incoming call, the second is for the outgoing call. Whatever the port type (COM, CAPI, SIP), Alert can redirect audio flows from one port to the other one.
  • Two scripts are mandatory: a script for the listening port, another for the outgoing call port.
  • An Alert user whose driver is the outgoing script.

The next scripts will be explained later.

The incoming call:

Dim nRes As Integer

PLAYTEXT("Welcome on the flow to flow transfer test" , "en-us")
WAITENDOFPLAY(1000)

REQFLOWTOFLOWTRANSFER(gnUserId)

nRes = GETTRANSFERSTATUS(30000)
If nRes = 2 Then
WAITENDFLOWTRANSFER(120)
Else
PLAYTEXT("Sorry, the transfer is not possible." , "en-us")
EndIf

WAITENDOFPLAY(500)
DISCONNECT()

The script plays first a welcome message with the PLAYTEXT function.

PLAYTEXT("Welcome on the flow to flow transfer test" , "en-us")

After the welcome message, the script waits 1 second with the function WAITENDOFPLAY.

WAITENDOFPLAY(1000)

Then we start the transfer to the Alert user whose OID is gnUserId. This is done by the REQFLOWTOFLOWTRANSFER function. The transfer is managed by Alert. This explains why we need an Alert user (with a vocal driver connected to the second script) and another port to place the new call.

REQFLOWTOFLOWTRANSFER(gnUserId)

The script waits for the called user to accept the transfer. The GETTRANSFERSTATUS function is waiting.

nRes = GETTRANSFERSTATUS(30000)

Depending on the result, we can have different cases:

  • 2: The second call has been picked-up and the user has accepted the transfer with ACCEPTTRANSFER in the second script.
  • 0: The call was refused or the number was busy.
  • 1: The transfer is still in progress (Waiting for answer or for transfer acceptance).
  • -1: Initial call is stopped.

When the transfer has been accepted (return 2), caller and callee are connected. The audio flows are redirected by ALERT.

Then the script waits until the end of the transfer using the function WAITENDFLOWTRANSFER.

WAITENDFLOWTRANSFER(120)

To finish, the call is disconnected.

Outgoing call script:

Dim bRes As Boolean
Dim nRet As Integer

bRes = ISTRANSFERCHILDPORT()
If bRes Then
ACCEPTTRANSFER(TRUE)
nRet = WAITENDFLOWTRANSFER(120)
Else
PLAYTEXT("It is not a call transfer, bye.", "en-us")
EndIf

WAITENDOFPLAY(1000)
DISCONNECT()

At first, we check if the current call is a transfer call with the ISTRANSFERCHILDPORT function.

bRes = ISTRANSFERCHILDPORT()

If the call has been initiated for a transfer, we accept the transfer. The function ACCEPTTRANSFER does this action.

ACCEPTTRANSFER(TRUE)

Once the transfer accepted, caller and callee are connected. The audio flows are redirected by ALERT.

Then the script waits until the end of the transfer using the function WAITENDFLOWTRANSFER.

WAITENDFLOWTRANSFER(120)

To finish, the call is disconnected.