- Joined
- Jan 28, 2019
- Messages
- 154
- Reaction score
- 53
I've received some good advice and help in these forums over the past few months, so to give something back, here is a server-side CRM integration for Pipedrive. I am sorry I do not have the time to offer support. Everything below is built using the information freely available from 3CX CRM documentation and Pipedrive API.
Parameters:
APIKey - this is the API key you generate in Pipedrive for the user account you wish to use
Domain - this is the subdomain allocated to your instance of Pipedrive (e.g. yourdomain.pipedrive.com)
Other parameters are as per the 3CX CRM API documentation.
The Contact lookup works as per the API documentation.
The Call journaling is also fairly straightforward, but at the time of writing, there was no method in the Pipedrive API to search for an agent based upon their telephone number. Therefore, I created dummy contacts in Pipedrive for each user, with their phone number like "AgentExtension-1234" where 1234 is their 3CX extension number. Searching for the user this way then returns the user ID which can then be used to assign the call to the user in pipedrive. It's a fudge but it works.
Parameters:
APIKey - this is the API key you generate in Pipedrive for the user account you wish to use
Domain - this is the subdomain allocated to your instance of Pipedrive (e.g. yourdomain.pipedrive.com)
Other parameters are as per the 3CX CRM API documentation.
The Contact lookup works as per the API documentation.
The Call journaling is also fairly straightforward, but at the time of writing, there was no method in the Pipedrive API to search for an agent based upon their telephone number. Therefore, I created dummy contacts in Pipedrive for each user, with their phone number like "AgentExtension-1234" where 1234 is their 3CX extension number. Searching for the user this way then returns the user ID which can then be used to assign the call to the user in pipedrive. It's a fudge but it works.
XML:
<?xml version="1.0"?>
<Crm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Country="GB" Name="Pipedrive" Version="1">
<Number Prefix="Zeros" MaxLength="" />
<Connection MaxConcurrentRequests="16" />
<Parameters>
<Parameter Name="APIkey" Type="String" Parent="Settings" Editor="String" Title="API Key:" Default="" />
<Parameter Name="Domain" Type="String" Parent="Settings" Editor="String" Title="Domain Part:" Default="" />
<Parameter Name="CreateContactEnabled" Type="Boolean" Parent="Contact Creation" Editor="String" Title="Enable Contact Creation?" Default="True" />
<Parameter Name="CreateContactName" Type="String" Parent="Contact Creation" Editor="String" Title="New Contact Name:" Default="New Telephone Contact [Number]" />
<Parameter Name="ReportCallEnabled" Type="Boolean" Parent="Call Reporting" Editor="String" Title="Enable Call Journaling?" Default="True" />
<Parameter Name="InboundCallText" Type="String" Parent="Call Reporting" Editor="String" Title="Answered Inbound Call Descriptor:" Default="[[CallStartTimeLocal].ToString("t")]: answered incoming call (duration [Duration])" />
<Parameter Name="MissedCallText" Type="String" Parent="Call Reporting" Editor="String" Title="Missed Call Descriptor:" Default="[[CallStartTimeLocal].ToString("t")]: missed incoming call" />
<Parameter Name="OutboundCallText" Type="String" Parent="Call Reporting" Editor="String" Title="Answered Outbound Call Descriptor:" Default="[[CallStartTimeLocal].ToString("t")]: outgoing call (duration [Duration])" />
<Parameter Name="NotAnsweredOutboundCallText" Type="String" Parent="Call Reporting" Editor="String" Title="Unanswered Outbound Call Descriptor:" Default="[[CallStartTimeLocal].ToString("t")]: unanswered outgoing call" />
</Parameters>
<Authentication Type="No" />
<Scenarios>
<Scenario Type="REST">
<Request Url="https://api.pipedrive.com/v1/searchResults?term=[Number]&item_type=person&start=0&api_token=[APIkey]" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json" />
<Rules>
<Rule Type="Number">data.details.phone</Rule>
</Rules>
<Variables>
<Variable Name="Id" Path="data.id">
<Filter />
</Variable>
<Variable Name="Name" Path="data.title">
<Filter />
</Variable>
<Variable Name="WorkPhone" Path="data.details.phone">
<Filter />
</Variable>
<Variable Name="MobilePhone" Path="data.details.phone">
<Filter />
</Variable>
<Variable Name="Email" Path="data.details.email">
<Filter />
</Variable>
</Variables>
<Outputs Next="" AllowEmpty="false">
<Output Type="FirstName" Passes="0" Value="[Name]" />
<Output Type="PhoneMobile" Passes="0" Value="[MobilePhone]" />
<Output Type="PhoneBusiness" Passes="0" Value="[WorkPhone]" />
<Output Type="Email" Passes="0" Value="[Email]" />
<Output Type="ContactUrl" Passes="0" Value="https://[Domain].pipedrive.com/person/[Id]" />
<Output Type="ContactID" Passes="0" Value="[Id]" />
</Outputs>
</Scenario>
<Scenario Id="CreateContactRecord" Type="REST">
<Request SkipIf="[CreateContactEnabled]!=True" Url="https://api.pipedrive.com/v1/persons?api_token=[APIkey]" Message="" RequestEncoding="Json" RequestType="Post" ResponseType="Json">
<PostValues>
<Value Key="name" Passes="2" Type="String">[[CreateContactName]]</Value>
<Value Key="phone" Passes="1" Type="String">[Number]</Value>
</PostValues>
</Request>
<Rules>
<Rule Type="Any">data.id</Rule>
</Rules>
<Variables>
<Variable Name="Id" Path="data.id">
<Filter />
</Variable>
</Variables>
<Outputs AllowEmpty="false">
<Output Type="ContactUrl" Passes="0" Value="https://[Domain].pipedrive.com/person/[Id]" />
<Output Type="FirstName" Passes="0" Value="[CreateContactName]" />
<Output Type="PhoneBusiness" Passes="0" Value="[Number]" />
<Output Type="ContactID" Passes="0" Value="[Id]" />
</Outputs>
</Scenario>
<Scenario Id="ReportCall" Type="REST">
<Request SkipIf="[ReportCallEnabled]!=True" Url="https://api.pipedrive.com/v1/searchResults?term=AgentExtension-[Agent]&item_type=person&start=0&exact_match=1&api_token=[APIkey]" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json" />
<Rules>
<Rule Type="Any">data.id</Rule>
</Rules>
<Variables>
<Variable Name="CRMUserID" Path="data.id">
<Filter />
</Variable>
<Variable Name="CRMUserEmail" Path="data.details.email">
<Filter />
</Variable>
</Variables>
<Outputs Next="ReportCall-GetCRMUser" AllowEmpty="false" />
</Scenario>
<Scenario Id="ReportCall-GetCRMUser" Type="REST">
<Request SkipIf="" Url="https://api.pipedrive.com/v1/users/find?term=[CRMUserEmail]&search_by_email=1&api_token=[APIkey]" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json" />
<Rules>
<Rule Type="Any">data.id</Rule>
</Rules>
<Variables>
<Variable Name="CRMUserID" Path="data.id">
<Filter />
</Variable>
<Variable Name="CRMUserName" Path="data.name">
<Filter />
</Variable>
</Variables>
<Outputs Next="ReportCall-GetDeal" AllowEmpty="false" />
</Scenario>
<Scenario Id="ReportCall-AddActivity" Type="REST">
<Request Url="https://api.pipedrive.com/v1/activities?api_token=[APIkey]" Message="" RequestEncoding="Json" RequestType="Post" ResponseType="Json">
<PostValues>
<Value Key="subject" If="[CallType]==Inbound" Passes="2" Type="String">[[InboundCallText]]</Value>
<Value Key="subject" If="[CallType]==Missed" Passes="2" Type="String">[[MissedCallText]]</Value>
<Value Key="subject" If="[CallType]==Outbound" Passes="2" Type="String">[[OutboundCallText]]</Value>
<Value Key="subject" If="[CallType]==Notanswered" Passes="2" Type="String">[[NotAnsweredOutboundCallText]]</Value>
<Value Key="type" Passes="0" Type="String">Call</Value>
<Value Key="person_id" Passes="0" Type="Integer">[Contact::ContactID]</Value>
<Value Key="done" If="[CallType]!=Missed" Passes="1" Type="Integer">1</Value>
<Value Key="done" If="[CallType]==Missed" Passes="1" Type="Integer">0</Value>
<Value Key="user_id" Passes="0" Type="Integer">[CRMUserID]</Value>
<Value Key="deal_id" Passes="0" Type="String">[DealID]</Value>
</PostValues>
</Request>
<Variables />
<Outputs AllowEmpty="false" />
</Scenario>
<Scenario Id="ReportCall-GetDeal" Type="REST">
<Request Url="https://api.pipedrive.com/v1/persons/[Contact::ContactID]/deals?start=0&status=all_not_deleted&sort=id%20DESC&api_token=[APIkey]" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json" />
<Rules>
<Rule Type="Any">data.id</Rule>
</Rules>
<Variables>
<Variable Name="DealID" Path="data.id">
<Filter />
</Variable>
</Variables>
<Outputs Next="ReportCall-AddActivity" AllowEmpty="true" />
</Scenario>
<Scenario Id="ReportCall-GetContact" Type="REST">
<Request SkipIf="" Url="https://api.pipedrive.com/v1/searchResults?term=[Number]&item_type=person&start=0&api_token=[APIkey]" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json" />
<Rules>
<Rule Type="Number">data.details.phone</Rule>
</Rules>
<Variables>
<Variable Name="ContactID" Path="data.id">
<Filter />
</Variable>
</Variables>
<Outputs Next="" AllowEmpty="false" />
</Scenario>
</Scenarios>
</Crm>
Last edited: