Google Voice Call Forwarding Extender Tropo Script

Google Voice Call Forwarding Extender Tropo Script

I. Features of This Tropo Script

II. The Tropo Script Code

III. Setting up the Tropo Script

IV. Setting up and retrieving call recordings

V. Variables Usage

VI. Tips and Tricks

VII. Further Reading for used Tropo API Functions

I. Features of This Tropo Script

This Tropo Script includes the following features that extend/add to the current Google Voice feature-set:

II. The Tropo Script Code

Copy and paste this code into your favorite text editor (Notepad++, Windows Notepad, Mac OS X TextEdit, ect.) and change the settings to suit your needs.

If you have problems using the copied code (such as your Tropo number not properly forwarding calls) then you should download the code and open it in a text editor.

<?php

    //Main script settings

    $CALL_DEST = "sip:echo@iptel.org";

   

    $CALL_ERROR_MSG = "Sorry, but I could not connect to the Google Voice user. Please try again later";

    $HOLD_MUSIC = "http://www.jetcityorange.com/dtmf/DTMF-ringbackTone.mp3";

   

    //Activation Settings

    //Make sure you change IS_ACTIVATED var to true when your Tropo Num is activated on GV!!

    $IS_ACTIVATED = false;

    $ACT_CODE = "00";

   

    //Settings for call recording. Calls will be stored on your Tropo account.

    $RECORD_CALL = false;

    $TROPO_USERNAME = "username";

    $TROPO_PASSWORD = "password";

   

   

    //Script Code starts Below. DO NOT CHANGE IF YOU DON'T KNOW WHAT YOU ARE DOING!!

    //When a call transfer failure occurs

    function callFailure($event) {

            say($CALL_ERROR_MSG);

    }

   

    //Checks if activation is needed and plays DTMF tones for GV's two-digit actibvation code

    if ($IS_ACTIVATED == false) {

            $ActDigits = str_split($ACT_CODE,1);

            $d1 = $ActDigits[0];

            $d2 = $ActDigits[1];

            $ActDTMF1 = "";

            $ActDTMF2 = "";

           

            switch ($d1) {

                    case 0:

                            $ActDTMF1 = "http://www.jetcityorange.com/dtmf/DTMF-0.mp3";

                            break;

                    case 1:

                            $ActDTMF1 = "http://www.jetcityorange.com/dtmf/DTMF-1.mp3";

                            break;

                    case 2:

                            $ActDTMF1 = "http://www.jetcityorange.com/dtmf/DTMF-2.mp3";

                            break;

                    case 3:

                            $ActDTMF1 = "http://www.jetcityorange.com/dtmf/DTMF-3.mp3";

                            break;

                    case 4:

                            $ActDTMF1 = "http://www.jetcityorange.com/dtmf/DTMF-4.mp3";

                            break;

                    case 5:

                            $ActDTMF1 = "http://www.jetcityorange.com/dtmf/DTMF-5.mp3";

                            break;

                    case 6:

                            $ActDTMF1 = "http://www.jetcityorange.com/dtmf/DTMF-6.mp3";

                            break;

                    case 7:

                            $ActDTMF1 = "http://www.jetcityorange.com/dtmf/DTMF-7.mp3";

                            break;

                    case 8:

                            $ActDTMF1 = "http://www.jetcityorange.com/dtmf/DTMF-8.mp3";

                            break;

                    case 9:

                            $ActDTMF1 = "http://www.jetcityorange.com/dtmf/DTMF-9.mp3";

                            break;

            }

           

            switch ($d2) {

                    case 0:

                            $ActDTMF2 = "http://www.jetcityorange.com/dtmf/DTMF-0.mp3";

                            break;

                    case 1:

                            $ActDTMF2 = "http://www.jetcityorange.com/dtmf/DTMF-1.mp3";

                            break;

                    case 2:

                            $ActDTMF2 = "http://www.jetcityorange.com/dtmf/DTMF-2.mp3";

                            break;

                    case 3:

                            $ActDTMF2 = "http://www.jetcityorange.com/dtmf/DTMF-3.mp3";

                            break;

                    case 4:

                            $ActDTMF2 = "http://www.jetcityorange.com/dtmf/DTMF-4.mp3";

                            break;

                    case 5:

                            $ActDTMF2 = "http://www.jetcityorange.com/dtmf/DTMF-5.mp3";

                            break;

                    case 6:

                            $ActDTMF2 = "http://www.jetcityorange.com/dtmf/DTMF-6.mp3";

                            break;

                    case 7:

                            $ActDTMF2 = "http://www.jetcityorange.com/dtmf/DTMF-7.mp3";

                            break;

                    case 8:

                            $ActDTMF2 = "http://www.jetcityorange.com/dtmf/DTMF-8.mp3";

                            break;

                    case 9:

                            $ActDTMF2 = "http://www.jetcityorange.com/dtmf/DTMF-9.mp3";

                            break;

            }

           

            answer();

            sleep(1);

            say($ActDTMF1);

            say($ActDTMF2);

    }

   

    //Transfering the call to it's destination

    if ($IS_ACTIVATED == true) {

            if ($RECORD_CALL == true) {

                    startCallRecording("ftp://ftp.tropo.com/recordings/" . $currentCall->sessionId . ".wav", array(

    "format" => 'audio/wav',

    "recordUser" => $TROPO_USERNAME,

    "recordPassword" => $TROPO_PASSWORD));

            }

            transfer($CALL_DEST, array(

            "playvalue" => $HOLD_MUSIC,

            "playrepeat" => '99',

            "timeout" => ‘120’,

            "answerOnMedia" => true,

            "onTimeout" => "callFailure",

            "onCallFailure" => "callFailure"));

           

            if ($RECORD_CALL == true) {

                    stopCallRecording();

            }

    }    

?>

III. Setting up the Tropo Script

If you don’t already have a Tropo account go to www.tropo.com and sign up for a new account. Check your email for the verification link.

Under Account go to Your Applications page, click the Create New Application link then click Tropo Scripting.

Copy the Tropo Script Code and paste it into your favorite text editing program and change some of the initial settings (changing CALL_DEST is required).

Back on the Tropo site window, type whatever you want for the name of the Tropo Application, then click the Hosted File link.

Now click the Create a new file for this hosted application link.

For the file name enter a web-friendly file name (no spaces or special characters) followed by the .php file extension. Copy all the edited code of the script from your text editor to the File Text textbox.

Click the Create File button then click the Create Application button to create the Tropo application.

Now the application’s options pane will open up showing the application’s information (such as SIP Number, Skype Number, Phono App Address, ect.). To associate a phone number with the application click the Add a new phone number link to the right of the phone numbers section.

Now from the USA Domestic drop down list pick an area code for your Tropo number, then click the Plus Button next to the drop down list to add the phone number to your application.

Click the x Button on the Add a New Phone Number, then click the Update Application button to apply the changes to the application. Please note that it might take a while for the number to be fully activated.

On the Google Voice site click the Add Another Phone link on the Phones tab of the Settings page. You can also use the new Tropo number to on new Google Voice accounts as well.

Copy the phone number from the Tropo Application and paste it into Google Voice, give the number a name and type, then click Save.

Google will now pop up a box showing a verification code asking you to verify your number. Before connecting the call copy the verification code, then go to the Hosted Files page of your Tropo account and look for the script file name you used earlier, then click the Edit link. Look for the ACT_CODE variable and paste the verification code into the Script Code, then click the Update File button.

Google Voice will now call your Tropo number. Wait a few seconds for the number to be automatically verified. If it fails to automatically verify try again. If it still fails after many tries then manually verify the number by changing the IS_ACTIVATED variable to true at this step.

After successful activation.

IMPORTANT!!! Now that the Tropo number is verified you must change the IS_ACTIVATED variable to true so that you can receive calls.

Now, try sending a test call to the number.

IV. Setting up and retrieving call recordings

To set up call recording simply change the RECORD_CALL variable to true, enter your Tropo username for the TROPO_USERNAME variable and Tropo password for the TROPO_PASSWORD variable. Call recording uses FTP to save files and since Tropo comes with a FTP account you can use it to store recordings, however if you would like to store the recordings on your own FTP server change the FTP URL by the startCallRecording function.

To retrieve call recordings go to Your Hosted Files page, click the root link click the recordings folder. From this folder you can download your recorded calls.

(This only applies to calls being recorded on Tropo, not other FTP servers)

V. Variables Usage

VI. Tips and Tricks

VII. Further Reading for used Tropo API Functions