CRM Server Side API enhance

Status
Not open for further replies.

icg1

Silver Partner
Advanced Certified
Joined
Sep 21, 2011
Messages
7
Reaction score
5
Hi,

We're trying to enhance the Server Side plugin for Bitrix24, to make it more usable, as for now it's only gets contact details from CRM, populates Caller Display Name and allows to click a tiny button in WebClient to go to contact details URL.

It would be more usable to show a build-in popup card in CRM, but we cannot do it by using a common scenario, as [Agent] variable is only available after the end of call.

It would be great to add an additional predefined scenario, which will run after a call was answered and [Agent] variable became available, then we can use Bitrix's "telephony.externalcall.register" method to open build-in call card in CRM with contact details and action buttons.

According to Call Journaling function and related "ReportCall" scenario, also would be useful to add CallRecordURL variable, that we can pass to the CRM to attach a call recording file to the call entity.

As AnsweredCall and ReportCall are related to each other it would be good to provide a possibility to setup ReportCall as a nested scenario to AnsweredCall, as well as nest multiple ReportCall scenarios.

To get a acceptable usability with Bitrix we would like to create the following flow:

Event: Call Recieved/Placed
-> Gets company, lead and contact info and populates it to standard variables for Caller name display before answering the call
Event: Call Answered
-> Initiates the Call entity in Bitrix using telephony.externalcall.register method
-> Populates Bitrix internal call ID into the variable
-> Popup call card in Bitrix
Event: Call Disconnected
-> Informs Bitrix that call is finished using telephony.externalcall.finish method, where we need to provide Bitrix internal call ID remembered during Call Answered step
-> Informs Bitrix to download recording file from 3CX PBX by URL to the entity of the call, or upload a file to Bitrix as Base64 encoded content.
 
Also I'd looked through the code of a Bitrix Server-side plug-in, and it seems it can be simplified by using telephony.externalCall.searchCrmEntities method instead of three consequent requests to crm.company/contact/lead.list methods. Our version provides the same results, but makes 30% less API requests. Maybe it can be usefull.

Here is an optimized version:

Code:
<?xml version="1.0"?>
<Crm xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Country="US" Name="Bitrix v2" Version="14">
  <Number Prefix="Plus" MaxLength="" />
  <Connection MaxConcurrentRequests="16" />
  <Parameters>
    <Parameter Name="WebHookUrl" Type="String" Title="Web Hook URL:" Default="https://example.bitrix24.com/rest/1/48zc6xffihng4ehe" />
    <Parameter Name="Domain" Type="String" Title="Domain:" Default="https://example.bitrix24.com" />
  </Parameters>
  <Authentication Type="No" />
  <Scenarios>
    <Scenario>
      <Request SkipIf="" Url="[WebHookUrl]/telephony.externalCall.searchCrmEntities.json?PHONE_NUMBER=[[Number].Replace(&quot;+&quot;,&quot;%2B&quot;)]" RequestType="Get" ResponseType="Json" />
      <Rules>
        <Rule Type="Any">result.CRM_ENTITY_ID</Rule>
      </Rules>
      <Variables>
        <Variable Name="Type">result.CRM_ENTITY_TYPE</Variable>
        <Variable Name="Id">result.CRM_ENTITY_ID</Variable>
      </Variables>
      <Outputs Next="GetDetails" AllowEmpty="false" />
    </Scenario>
    <Scenario Id="GetDetails">
      <Request SkipIf="" Url="[WebHookUrl]/crm.[Type].get.json?id=[Id]" RequestType="Get" ResponseType="Json" />
      <Rules>
        <Rule Type="Any">result.ID</Rule>
      </Rules>
      <Variables>
        <Variable Name="FirstName">result.NAME</Variable>
        <Variable Name="LastName">result.LAST_NAME</Variable>
        <Variable Name="PhoneBusiness" Path="result.PHONE.VALUE">
          <Filter>
            <Rule Type="Equals" Ethalon="WORK">result.PHONE.VALUE_TYPE</Rule>
          </Filter>
        </Variable>
        <Variable Name="PhoneMobile" Path="result.PHONE.VALUE">
          <Filter>
            <Rule Type="Equals" Ethalon="MOBILE">result.PHONE.VALUE_TYPE</Rule>
          </Filter>
        </Variable>
        <Variable Name="FaxBusiness" Path="result.PHONE.VALUE">
          <Filter>
            <Rule Type="Equals" Ethalon="FAX">result.PHONE.VALUE_TYPE</Rule>
          </Filter>
        </Variable>
        <Variable Name="PhoneHome" Path="result.PHONE.VALUE">
          <Filter>
            <Rule Type="Equals" Ethalon="HOME">result.PHONE.VALUE_TYPE</Rule>
          </Filter>
        </Variable>
        <Variable Name="Pager" Path="result.PHONE.VALUE">
          <Filter>
            <Rule Type="Equals" Ethalon="PAGER">result.PHONE.VALUE_TYPE</Rule>
          </Filter>
        </Variable>
        <Variable Name="PhoneOther" Path="result.PHONE.VALUE">
          <Filter>
            <Rule Type="Equals" Ethalon="OTHER">result.PHONE.VALUE_TYPE</Rule>
          </Filter>
        </Variable>
        <Variable Name="Email" Path="result.EMAIL.VALUE">
          <Filter>
            <Rule Type="Any" Ethalon="">result.EMAIL.VALUE_TYPE</Rule>
          </Filter>
        </Variable>
        <Variable Name="CompanyName" Path="result.TITLE" />
      </Variables>
      <Outputs Next="" AllowEmpty="false">
        <Output Type="FirstName" Value="[FirstName]" />
        <Output Type="LastName" Value="[IIf([LastName]==&quot;&quot;,[CompanyName],[LastName])]" />
        <Output Type="PhoneBusiness" Value="[PhoneBusiness]" />
        <Output Type="PhoneMobile" Value="[PhoneMobile]" />
        <Output Type="FaxBusiness" Value="[FaxBusiness]" />
        <Output Type="PhoneHome" Value="[PhoneHome]" />
        <Output Type="Pager" Value="[Pager]" />
        <Output Type="PhoneOther" Value="[PhoneOther]" />
        <Output Type="Email" Value="" />
        <Output Type="CompanyName" Value="[CompanyName]" />
        <Output Type="ContactUrl" Value="[Domain]/crm/[Type]/show/[Id]/" />
      </Outputs>
    </Scenario>
  </Scenarios>
</Crm>
 
Last edited:
  • Like
Reactions: rajkumarsolunki
Status
Not open for further replies.

Latest Posts

Forum statistics

Threads
112,323
Messages
591,896
Members
165,474
Latest member
costionofrei