My Collab Lab

mycollablab.org

Tropo Dialer POC

September 15, 2016 Voice

Quick and dirty Tropo dialer script triggered by a website with a list of numbers and a message to play. Built as a POC

Tropo Script


<?php

call('+1'.$dnis, array("from" => "+1".$ani));

$confirm = "0";
while ( $confirm == "0" && $currentCall->isActive() ) {
    $result = ask( $prompt, 
                    array( "choices" => "confirm( 1, confirm)") );
    if ($result->name=="choice")
    {
        if ($result->value == "confirm") 
        { 
            say( "Message receipt Confirmed." );

            $confirm = "1";
        }

    }
}

hangup();

?>

Server Script


<?php


echo<<<EOF

<html>
<head>
    <title>Outbound Dialer - Tropo</title>
</head>

<body bgcolor=#ffffff text=#000000>


EOF;


if ( ! isset($_POST['dnis_list']) ) {

echo<<<EOF

    <form method=post>
        <input type=text name=ani placeholder="10 digit Caller ID Number"><br>
        <textarea name=prompt cols=100 rows=3>Enter what you want to say here...
            </textarea><br>
        <textarea name=dnis_list cols=13 rows=20>Enter a list of 10 digit US numbers to call
            </textarea><br>

        <input type=submit value="Start Calling">

    </form>

EOF;

} else {
    $ani = $_POST['ani'];
    $dnis_array = preg_split('/[^0-9]/',$_POST['dnis_list']);
    $prompt = $_POST['prompt'];

    $tropo_token = "token=<token>";

    foreach ( $dnis_array as $dnis ) {
        if ( $dnis > 1 ) {

            $tropo_url  = "https://api.tropo.com/1.0/sessions?action=create&".$tropo_token."&dnis=".$dnis."&ani=".$ani."&prompt=".urlencode($prompt);

            $curl = curl_init();
            // Set some options - we are passing in a useragent too here
            curl_setopt_array($curl, array(
                CURLOPT_RETURNTRANSFER => 1,
                CURLOPT_URL => $tropo_url,
                CURLOPT_USERAGENT => 'calling Name'
            ));
            // Send the request & save response to $resp
            $response = curl_exec($curl);
            // Close request to clear up some resources
            curl_close($curl);
        }

    }
    echo "Calls sent.  There would be a link to a url to check the status of the calls if that were something I felt like doing";

}



echo "</body>\n";
echo "</html>";

?>

dialertropo

Get Device Registration Status

Update for Line Presence Appearance


Jon Snipes
LinkedIn

My career progressed from head butcher to Collaboration CCIE. There isn’t much technically that carries over between professions, but 8 years of direct customer service experience and squeezing margin out of processes provided a solid base and direction for the rest of my career. My focus today is deep into collaboration messaging, voice and video with the expertise to develop processes and programmatic solutions to complex business problems.

Principal Architect at Cloverhound
CCIE Collaboration 51786
Cisco Webex Expert
2018-2021 Cisco Champion

Categories
  • Cloud (4)
  • Contact Center (1)
  • Development (1)
  • PHP (10)
  • Python (3)
  • Uncategorized (1)
  • Video (2)
  • Voice (12)
  • Voicemail (5)
  • Webex (7)
Recent Posts
  • Azure OAuth2.0 User Authentication December 4, 2021
  • Pass-through Gateway Routing and Dial Peer Groups December 4, 2021
  • Get Started Coding with Python: System Setup and Running Scripts December 4, 2021
  • Exporting CUCM to an Offline Local DB with Python December 4, 2021
  • Connecting to UCCX INFORMIX DB with Python on Linux December 4, 2021
Proudly powered by WordPress | Theme: Doo by ThemeVS.