Exemplo n.º 1
0
<?php

header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$apiPD = new apiPipeDrive();
$deal_source = qs("select pd_source_id from pd_sources where source_name like 'Hot Lead 2'");
$agent_numbers = $apiPD->getAgentByDealSource($deal_source['pd_source_id']);
if (count($agent_numbers) == 0) {
    ?>
    <Response>        
        <Say>Thank you for calling Lysoft dot Com. We are sorry for can't handle your call. Please Try Later.</Say>
    </Response>
<?php 
} else {
    ?>
    <Response>        
        <Say>Thank you for calling Lysoft dot Com.</Say>
        <Say>We are connecting to our agents. Please wait a moment.</Say>
        <Dial>
            <?php 
    foreach ($agent_numbers as $each_agent) {
        ?>
    
                <Number><?php 
        echo $each_agent;
        ?>
</Number>
            <?php 
    }
    ?>
        </Dial>
<?php

//Twilio Website Number: (516) 210-2005
$apiPD = new apiPipeDrive();
$agent_numbers = $apiPD->getAgentByDealSource(37);
$fields['from'] = $_REQUEST['From'];
$fields['CallSid'] = $_REQUEST['CallSid'];
$insertId = qi("website_number_dials", _escapeArray($fields));
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>

    <?php 
if (count($agent_numbers) == 0) {
    ?>
        <Say>Thank you for calling leadpropel.com</Say>
        <Say>Sorry, All agents are busy at the moment.</Say>
        <Say>We will call back later.</Say>
        <Say>Thank you</Say>
    <?php 
} else {
    ?>
        <Dial action="<?php 
    echo _U . "website_number_dial_status?params=" . $insertId . "--00--status";
    ?>
">
            <?php 
    foreach ($agent_numbers as $each) {
        ?>
                <Number url="<?php 
    $deal_info = $apiPD->modifyDeal($data['current']['id'], array("stage_id" => "1"));
}
// store into the database
//qi("pd_push_notification_log", array("payload" => _escape($payload)));
# now, identify if that is hot lead then get the number of customer and start calling the customer
# c2a6fc3129578b646ae55717ed15f03ce3ee4df0 - this is key for custom attribute/field - "Source"
$deal_source = $data['current']['c2a6fc3129578b646ae55717ed15f03ce3ee4df0'];
if (in_array($deal_source, array('37')) || 1) {
    # Get Person ID
    $person_id = $data['current']['person_id'];
    # Get Deal ID
    $deal_id = $data['current']['id'];
    # Get Person info
    $person_info = $apiPD->getPersonInfo($person_id);
    $person_info = json_decode($person_info, true);
    # Get Phone
    $phone = $person_info['data']['phone']['0'];
    $phone_label = $phone['label'];
    $phone_value = $phone['value'];
    # Get Email
    $email = $data['email']['0'];
    # Retrieve which agents we have to broadcast from source ( i.e. HotDeal, CCC, Dialer )
    $agent_numbers = $apiPD->getAgentByDealSource($deal_source);
    # Finally call the agents
    $apiCall->callNow($phone_value, $agent_numbers, $deal_id, "0", "A");
}
//15162004065 - dj
// 15165249063 - wayne
// 18664632339 - godaddy
// salesforce - 18006676389
die;