IVR : Transfer a telephone call with PHP and VoiceXML

Written by on August 28, 2005 in PHP Voice, VoiceXML - 3 Comments

While developing IVR application with VoiceXML we need sometimes to offer a service of call transfer. And certainly you know how to transfer a call with VoiceXML using the tag “transfer”.

So I have written this PHP Voice module to make call transfer more easy using PHP VoiceXML class. A small sample usage could be :


$v = new gonx_vxml();
$v->start_vxml("", "", "", "", "", "2.0");
$v->load("transfer",array("123456789","please wait, transferring your call to 1 2 3 4 5 6 7 8 9 "));
$v->end_vxml();
$v->generate();

The example just allow to play a message to the user and then transfer the call to a specific number. I have setup a default message “Please wait while we transfer your call” so we keep the message optional. I have added another parameter which is the formid, which could be used if you want to link the transfer form to another application … etc.

The module code is listed below transfer.class.php


/**
* VoiceXML Telephone call transfer Module
*
* @author Ben Yacoub Hatem
* @version $Id: transer.class.php,v 1.0
*/
class transfer
{
/**
* @access private
* @var object
*/
var $obj;
/*
*
* Transfer a message
*
* @param number transfer number
* @param message message (optional)
* @param formid formid (optional)
*
*/
function transfer(&$obj,$params)
{
$this->obj = &$obj;
$number = $params[0];
$message = (trim($params[1])!='')?$params[1]:'Please wait while we transfer your call';
$formid = (trim($params[2])!='')?$params[2]:'transfer';
$this->obj->start_form($formid);
$this->obj->start_block();
$page->start_prompt();
$page->write($message);
$page->end_prompt();
$this->obj->end_block();
$page->transfer($number,'',false);
$this->obj->end_form();
return;
}
}

3 Comments on "IVR : Transfer a telephone call with PHP and VoiceXML"

  1. hien November 24, 2005 at 11:31 pm · Reply

    please sent a confirm to my mailbox if you receive this message.
    Thanks you.
    Hien

  2. Hatem November 25, 2005 at 5:14 am · Reply

    Hey hien :) we received your message. Just let me know if you have any question. thx

  3. manoj May 20, 2008 at 8:22 am · Reply

    hi
    i have to devlop a ivr by using php and mysql, if any one know how to do plz help me

Leave a Comment