$deal_info = json_decode($deal_info, TRUE); if ($deal_info['data']['pipeline_id'] == "1") { $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
$apiCall = new callWebhook(); # Set default timezone date_default_timezone_set('America/New_York'); # receive the payload //Test Mode - Remove comment on Live $payload = file_get_contents('php://input'); $data = json_decode(@$payload, true); //Test Mode - Delete following static code //$payload1='{"v":1,"matches_filters":null,"meta":{"v":1,"action":"added","object":"activity","id":19126,"company_id":501009,"user_id":990918,"host":"sprout2.pipedrive.com","timestamp":1454411818,"permitted_user_ids":["*"],"trans_pending":false,"is_bulk_update":false},"retry":0,"current":{"id":19126,"company_id":501009,"user_id":990918,"done":false,"type":"text","reference_type":"none","reference_id":null,"due_date":"2016-02-02","due_time":"","duration":"","add_time":"2016-02-0211:16:58","marked_as_done_time":"","subject":"Dave Jay - (918)460-312","deal_id":4586,"org_id":4058,"person_id":4421,"active_flag":true,"update_time":"2016-02-0211:16:58","gcal_event_id":null,"google_calendar_id":null,"google_calendar_etag":null,"person_name":"DaveTest","org_name":"DaveTest","note":"Thisistest","deal_title":"DaveTestdeal","assigned_to_user_id":990918,"created_by_user_id":990918,"owner_name":"DaveJay(Programmer)","person_dropbox_bcc":"*****@*****.**","deal_dropbox_bcc":"*****@*****.**","participants":[],"updates_story_id":128972,"parties":[{"id":3108,"activity_id":19126,"party_id":3108,"active_flag":true,"add_time":"2016-02-0211:16:58","update_time":null,"name":"DaveJay(Programmer)","address":"*****@*****.**","person_id":null,"user_id":990918},{"id":3109,"activity_id":19126,"party_id":3109,"active_flag":true,"add_time":"2016-02-0211:16:58","update_time":null,"name":"DaveTest","address":"","person_id":4421,"user_id":null}]},"previous":null,"event":"added.activity"}'; //$data = json_decode($payload1,true); if ($data['meta']['host'] == 'api.pipedrive.com' || $data['current']['type'] != 'text' || $data['current']['subject'] == 'SMS - Replied By Customer') { die; } $activity_id = $data['meta']['id']; $person_id = $data['current']['person_id']; $person_data = $apiPD->getPersonInfo($person_id); $person_data = json_decode($person_data, true); $message = $data['current']['note']; $deal_id = $data['current']['deal_id']; $org_id = $data['current']['org_id']; $subject = $data['current']['subject']; $subject = preg_replace("/[^0-9]/", "", $subject); $activityLogArray = array(); if (strlen($subject) < 10) { $phone_value = isset($person_data['data']['phone'][0]['value']) ? $person_data['data']['phone'][0]['value'] : '-1'; } else { $phone_value = $subject; $activityLogArray['number_from_subject'] = '1'; } $activityLogArray['payload'] = $payload; $activityLogArray['activity_id'] = $activity_id;