Calling pipedrive to display a record using a URL
HI,
is it possible to call pipedrive to display a record?
Our phone system can make a single call, it has to be a URL, not a program.
I can call the API and get the JSON record, but can I call pipedrive just to display the record instead?
Using this will call, will display the JSON. How do I call it to get it to dsiaply?
https://api.pipedrive.com/v1/persons/search?term=PHONENUMBER&api_token=APIKEY
Ideally what I want is a call like this…bit this won't work
https://MY.pipedrive.com/persons/search?term=NUMBER&api_token=????
Any ideas?
Comments
-
Hi @Damian Scattergood using the URL to run a search as you described is not possible. You can use an API call as you mentioned, or the search bar within the Pipedrive app.
0 -
I found a solution. This way I can pass a single call to 3CX integration and it opens the pipedrive record for me
I created a local server using XAMPP.
I created code in python, that I can call that does 2 things.
- Calls Pipedrive API to lookup the record.
- Take the JSON response and extracts the customer record number, which I can then fire into a browser using CURL to launch at that record.
It is probably a heavy overhead to have a XAMPP installation just for this - but if you want the functionality - this works.
Here is the code if it is useful to anyone else.
Call it like this….
http://127.0.0.1/dashboard/LookupPhone.php?phone=%CallerNumber%
where %CallerNumber% is the number you want to look up.
<?php
// Get the phone number from the URL parameter
$phone_number = $_GET['phone'];
// Your Pipedrive API token
$api_token = 'YOURAPITOKEN';
// Construct the API URL with the phone number and API token
$api_url = "https://api.pipedrive.com/v1/persons/search?term=" . urlencode($phone_number) . "&api_token=" . $api_token;
// Initialize cURL session
$ch = curl_init();
// Set the URL and other options for the cURL session
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute the cURL session and get the response
$response = curl_exec($ch);
// Close the cURL session
curl_close($ch);
// Decode the JSON response
$response_data = json_decode($response, true);
// Check if the response contains the 'items' array
if (isset($response_data['data']['items']) && !empty($response_data['data']['items'])) {
// Get the first item from the 'items' array
$first_item = $response_data['data']['items'][0];
// Get the person's ID
$person_id = $first_item['item']['id'];
// Construct the new API URL with the person's ID
$person_url = "https://YOURPIPEDRIVENAME.pipedrive.com/person/" . $person_id;
// Command to open the URL in Google Chrome
$command = escapeshellcmd("google-chrome " . $person_url);
shell_exec($command);
// Output the new URL
echo "Person URL: " . $person_url;
} else {
echo "No person found with the given phone number.";
}
?>1 -
Here is the latest version - that doesn't require SHELL on the server
<?php
// Get the phone number from the URL parameter
$phone_number = $_GET['phone'];
// Your Pipedrive API token
$api_token = 'YOURAPITOKEN';
// Construct the API URL with the phone number and API token
$api_url = "https://api.pipedrive.com/v1/persons/search?term=" . urlencode($phone_number) . "&api_token=" . $api_token;
// Initialize cURL session
$ch = curl_init();
// Set the URL and other options for the cURL session
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute the cURL session and get the response
$response = curl_exec($ch);
// Close the cURL session
curl_close($ch);
// Decode the JSON response
$response_data = json_decode($response, true);
// Check if the response contains the 'items' array
if (isset($response_data['data']['items']) && !empty($response_data['data']['items'])) {
// Get the first item from the 'items' array
$first_item = $response_data['data']['items'][0];
// Get the person's ID
$person_id = $first_item['item']['id'];
// Construct the new API URL with the person's ID
$person_url = "https://YOURPIPEDRIVENAME.pipedrive.com/person/" . $person_id;
// Output the new URL
echo "Person URL: " . $person_url;
header("Location: " . $person_url);
exit();
} else {
echo "No person found with the given phone number.";
}
?>1