Tcl/Tk API | Simple Gateway API

  1. callText
  2. callAudio
  3. callStatus
  4. callRemove
  5. callTillConfirm
  6. Source Code

Since all these functions are implemented as a HTTP client communicating directly with Voicent Gateway, they can be run on any machine that has a connection to the host running the gateway.

Work with Interactive Applications
For many applications, it is desirable to get responses from callees in addition to deliver a message. The interaction can be implemented by using the low level gateway VoiceXML interface. However, using the low level API is a time consuming and error prone task. A better solution is to utilize Voicent IVR Studio to create an interactive application, and use the extended Simple Call Interface to trigger a phone call.

Tcl/Tk IVR Interface

Call Text

Synopsis - callText

callText <phoneno> <text> <selfdelete> <gateway>

Description - callText

Objective

Make a phone call and play the specified text message. The text message is convert to voice by Voicent Gateway's text-to-speech engine.

Parameters
<phoneno> The phone number to call.
<text> The message for the phone call. This message will be converted to audio using Voicent's text-to-speech software.
<selfdelete> Ask the gateway to automatically delete the call request after the call is made if it is set to '1'.
<gateway> Installed Voicent Gateway. Defaults to 'http://localhost:8155'.
Returns
<reqId> The return value is the call request ID.

Example - callText


                        callText("123-4567", "Hello, how are you doing", "1")
                    

Makes a call to the phone number '123-4567' and says 'Hello, how are you doing'. Since the selfdelete bit is set to 1, the call request record in the gateway will be removed automatically after the call.



                        set reqId [callText "123-4567", "Hello, how are you doing", "0"]
                    

Make a call to phone number '123-4567' and say 'Hello, how are you doing'. Since the selfdelete bit is set to 0, the call request record in the gateway will not be removed after the call. You can then use callStatus to get the call status, or use callRemove to remove the call record.

Call Audio

Synopsis - callAudio

callAudio <phoneno> <text> <selfdelete> <gateway>

Description - callAudio

Objective

Make a phone call and play the specified audio message.

Parameters
<phoneno> The phone number to call.
<text> The message for the phone call. This message will be converted to audio using Voicent's text-to-speech software.
<selfdelete> Ask the gateway to automatically delete the call request after the call is made if it is set to '1'.
<gateway> Installed Voicent Gateway. Defaults to 'http://localhost:8155'.
Returns
reqId The return value is the call request ID.

Example - callAudio


                        callAudio "123-4567", "C:\my audios\hello.wav", "1"
                    

Makes a call to the phone number '123-4567' and says 'Hello, how are you doing'. Since the selfdelete bit is set to 1, the call request record in the gateway will be removed automatically after the call.



                        callAudio "123-4567", "C:\my audios\hello.wav", "0"
                    

Make a call to phone number '123-4567' and say 'Hello, how are you doing'. Since the selfdelete bit is set to 0, the call request record in the gateway will not be removed after the call. You can then use callStatus to get the call status, or use callRemove to remove the call record.

Call Status

Synopsis - callStatus

callStatus reqId gateway

Description - callStatus

Objective

Check the call status given the reqId.

Parameters
reqId The call request ID.
Returns
'Call Made' Returns the string 'Call Made' if the call was made.
'Call Failed' Returns the string 'Call Failed' if the call failed.
' ' Returns an empty string if the call is in progress or if the call was neither made or failed.

Example - callStatus


                        set status [callStatus 11234035434]
                    

Call Remove

Synopsis - CallRemove

callRemove <reqId> <gateway>

Description - CallRemove

Objective

Remove the call record given the reqId. If the call is not made yet, it will also be removed.

Parameters
<reqId> The call request ID.
<gateway> Installed Voicent Gateway. Defaults to 'http://localhost:8155'.

Example - CallRemove


                        callRemove "1234035434"
                    

Call Till Confirm

Synopsis - callTillConfirm

callTillConfirm <vcastexe> <vocfile> <wavfile> <ccode> <gateway>

Description - callTillConfirm

Objective

Keep calling a list of people until anyone enters the confirmation code. The message is the specified audio file. This is ideal for using it in a phone notification escalation process.

To use this feature, Voicent BroadcastByPhone Professional version has to be installed. This function is similar to the command line interface BroadcastByPhone has. But since the command cannot be invoked over a remote machine, this perl function uses the gateway to schedule an event, which in turn invokes the command on the gateway host.

Parameters
<vcast prog> The BroadcastByPhone program. It is usually C:\Program Files\Voicent\BroadcastByPhone\bin\vcast.exe on the gateway host.
<vcast doc> The BroadcastByPhone call list to use.
<wavfile> The audio file to use for the broadcast.
<ccode> The confirm code to use for the broadcast.
<gateway> Installed Voicent Gateway. Defaults to 'http://localhost:8155'.

Example - callTillConfirm


                        callTillConfirm("C:\Program Files\Voicent\BroadcastByPhone\bin\vcast.exe","C:\My calllist\escalation.voc","C:\My calllist\escalation.wav","911911");
                    

Source Code


                        package require http


                        proc callText { phoneno text selfdelete {gateway "http://localhost:8155"} } {   set url "$gateway/ocall/callreqHandler.jsp"

                        set plist [list info "simple text call" \
                        phoneno $phoneno \
                        firstocc 10 \
                        txt $text \
                        selfdelete $selfdelete]
                        set param [eval ::http::formatQuery $plist]

                        set token [::http::geturl $url -query $param]
                        set rcstr [::http::data $token]
                        ::http::cleanup $token

                        return [getReqId $rcstr]
                        }

                        proc callAudio {phoneno filename selfdelete {gateway "http://localhost:8155"}} {   set url "$gateway/ocall/callreqHandler.jsp"

                        set plist [list info "simple audio call" \
                        phoneno $phoneno \
                        firstocc 10 \
                        audiofile $filename \
                        selfdelete $selfdelete]
                        set param [eval ::http::formatQuery $plist]

                        set token [::http::geturl $url -query $param]
                        set rcstr [::http::data $token]
                        ::http::cleanup $token

                        return [getReqId $rcstr]
                        }

                        proc callStatus {reqId {gateway "http://localhost:8155"}} {   set url "$gateway/ocall/callstatusHandler.jsp"

                        set plist [list reqid $reqId]
                        set param [eval ::http::formatQuery $plist]

                        set token [::http::geturl $url -query $param]
                        set rcstr [::http::data $token]
                        ::http::cleanup $token

                        if { [string first "^made^" $rcstr] != -1 } {
                        return "Call Made"
                        }

                        if { [string first "^failed^" $rcstr] != -1 } {
                        return "Call Failed"
                        }

                        if { [string first "^retry^" $rcstr] != -1 } {
                        return "Call Will Retry"
                        }

                        return ""
                        }

                        proc callRemove {reqId {gateway "http://localhost:8155"}} {   set url "$gateway/ocall/callremoveHandler.jsp"

                        set plist [list reqid $reqId]
                        set param [eval ::http::formatQuery $plist]

                        set token [::http::geturl $url -query $param]
                        set rcstr [::http::data $token]
                        }

                        proc callTillConfirm { vcastexe vocfile wavfile ccode {gateway "http://localhost:8155"}} {   set url "$gateway/ocall/callreqHandler.jsp"

                        set cmdline "\"$vocfile\" -startnow -confirmcode $ccode -wavfile \"$wavfile\""
                        set plist [list info "simple call till confirm" \
                        phoneno "1111111" \
                        firstocc 10 \
                        startexec $vcastexe \
                        cmdline $cmdline \
                        selfdelete "0"]
                        set param [eval ::http::formatQuery $plist]

                        set token [::http::geturl $url -query $param]
                        set rcstr [::http::data $token]
                        ::http::cleanup $token

                        return [getReqId $rcstr]
                        }

                        proc getReqId { rcstr } {   set index1 [string first "\[ReqId=" $rcstr]
                        if { $index1 == -1 } {
                        return ""
                        }
                        set rcstr [string range $rcstr [expr $index1 + 7] end]

                        set index2 [string first "\]" $rcstr]
                        if { $index2 == -1 } {
                        return ""
                        }

                        return [string range $rcstr 0 [expr $index2 - 1]]
                        }

                        # Sample usage

                        # replace with your own number
                        set phoneno "1112222"

                        #set reqId [callText $phoneno "Hello, how are you" "1"]
                        #puts $reqId

                        #set reqId [callAudio $phoneno "C:/Program Files/Voicent/MyRecordings/sample_message.wav" "0"]
                        #puts $reqId

                        #while { 1 } {
                        # after 10000
                        # set status [callStatus $reqId]
                        # if { $status != "" } {
                        # puts $status
                        # break
                        # }
                        #}

                        #callRemove $reqId

                        #callTillConfirm "C:/Program #Files/Voicent/BroadcastByPhone/bin/vcast.exe" \
                        #"C:/temp/testctf.voc" \
                        #"C:/Program Files/Voicent/MyRecordings/sample_messages.wav" \
                        #"1234"