Google Voice Call Forwarding Extender Tropo Script

By funnyboy243 on May 04, 2012

Screenshots

This script lets you forward to any SIP (or regular) number using a US number that you choose as a forwarding phone. I also added the ability to record outgoing calls, and automatic GV number verification, which can be used for people who don't have any US numbers to verify their new GV accounts. Also you can use this script to forward to numbers with extensions.

For detailed help on this script check the my instructions on Google Docs:
https://docs.google.com/document/pub?id=1PlVNLOH0n3gPt8w5subaEyPSSX88qFU9DJomwOFY_CA&pli=1

<?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();
        }
    }   
?>

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.