Hello!
We’re trying to integrate our PBX system with Pipedrive and now we’ve facing an issue here.
When we receive a call from existing client, a new deal is created. That’s not correct — a new activity should be created in an existing deal (e.g. “missed call” category).
This happens when contact number is not on the first position in “Person” entity.
As you know, it is possible to assign several numbers to a Person, but activity is created in existing deal only when client calls form number, that is written down on the first position. When it’s not - a new deal is created. We use webhooks for send data.
I think I would need to see the exact coding you’re using in this case to get a better idea of what might be the issue. Can you share it here?
If not, can you send it to support@pipedrive.com and we can go through it there?
*/
public function createDeal($repeat = '0')
{
$dealData = array(
'title' => $this->personData['name'],
'person_id' => $this->personData['id']
);
if (!is_null($this->personData['org_id']) && isset($this->personData['org_id'])) {
$dealData['org_id'] = $this->personData['org_id'];
}
// Whom to assign the deal
if (!is_null($this->connectedWith)) {
$pipe_id = $this->getPipeID($this->pipeKey, $this->connectedWith);
if (!is_null($pipe_id)) {
$dealData['user_id'] = $pipe_id;
}
if (!is_numeric(($dealData['user_id']))) {
unset($dealData['user_id']);
};
}
// To which pipeline assign the deal
if ($this->type == 'in') {
$dealData['stage_id'] = $this->getDealStage($this->destinationID);
if (!is_numeric(($dealData['stage_id']))) {
unset($dealData['stage_id']);
};
}
// Redeclare the name of the deal to correct variable type
$dealData = $this->getCorrectNameOfTheDeal($repeat, $dealData);
// Taking custom fields
$dealData = $this->takingCustomFields($dealData);
// CURL Data
if (is_null($dealData['person_id'])) {
$this->grayLog('Deal was not created. Reason: empty person_id', $dealData);
return false;
}
$url = "https://api.pipedrive.com/v1/deals?api_token=" . $this->pipeKey;
$result = $this->sendPostCurl($url, $dealData);
// check if an id came back
if (!empty($result['data']['id'])) {
$this->data['deal_id'] = $result['data']['id'];
return true;
} else {
$this->grayLog('Deal was not created. Result: ' . $result, $dealData);
return false;
}
}
Talking to some of my team to get a better answer - but can you give some more details on how you’re using webhooks to send data when you receive a call?
Also, if you have the data on the Persons, can you check how many contact number the Person has? Any more context and details you can provide would be very beneficial.
@diego.mendez I don’t see how “Activity” creation could be the problem.
The issue is related to “Deal” creation.
Or maybe you mean “Activity” with “call” type?
Hi @modeb, in your first message you mentioned that an activity should be created within a deal, but in the code you shared there is no reference to this, I can only see a function for deal creation. But you mention that a new deal being created is not correct.
Thanks for your reply @modeb. What I’m failing to see is the part related to the logic that you have to do to find the Pipedrive person once you get a phone number. Since the problem happens in this step we should see it in details. So once you have a phone number what are you doing exactly to find the matching person? If you use https://developers.pipedrive.com/docs/api/v1/#!/SearchResults/get_searchResults_field you should be able to get results for secondary phone numbers too.
I tried to search persons using url you provided and id of person is only returned in case when I use primary phone number to search. For testing purposes I’m working on Pipedrive’s online API form. field_type is “personField” and field_key is “phone”, return_item_ids is “1”. Can you please tell me, what I’m missing here?
Hi @modeb right now the only way is to first search the person and then search the deals linked to this person. Or you could add a custom field for deals and store the phone there too.