Missing EntityID in POST variable - V18

Status
Not open for further replies.

AdamTR

Free User
Joined
Mar 24, 2022
Messages
16
Reaction score
1
Hi All,

I'm having issues with seeing certain variables in the POST to our API since upgrading to V18.

I am aware that V18 does not support [Contact: XXXXXX] variables anymore, and therefore we need to use EntityID. So I've updated the XML to use EntityID instead, in both the Variables and outputs, however in the POST sent to our API the EntityID variable is just an empty string. Is there something I'm missing in order for this to pull through?


XML:
<Variables>
        <Variable Name="EntityId" Path="customer.Details.ID">
          <Filter />
        </Variable>
        <Variable Name="FirstName" Path="customer.Details.Name">
          <Filter />
        </Variable>
        <Variable Name="LastName" Path="customer.Details.Surname">
          <Filter />
        </Variable>
        <Variable Name="Email" Path="customer.Details.Email">
          <Filter />
        </Variable>
        <Variable Name="PhoneMobile" Path="customer.Telephone">
          <Filter />
        </Variable>

XML:
 <Outputs AllowEmpty="false">
        <Output Type="FirstName" Passes="0" Value="[FirstName]" />
        <Output Type="LastName" Passes="0" Value="[LastName]" />
        <Output Type="Email" Passes="0" Value="[Email]" />
        <Output Type="PhoneMobile" Passes="0" Value="[PhoneMobile]" />
        <Output Type="ContactUrl" Passes="0" Value="https://xxxxxx.co.uk/crm/customer/[EntityId]" />
        <Output Type="EntityId" Passes="0" Value="[EntityId]" />
      </Outputs>


XML:
<Outputs AllowEmpty="false">
        <Output Type="EntityId" Passes="0" Value="[EntityId]" />
        <Output Type="FirstName" Passes="0" Value="[FirstName]" />
        <Output Type="LastName" Passes="0" Value="[LastName]" />
        <Output Type="Email" Passes="0" Value="[Email]" />
        <Output Type="PhoneMobile" Passes="0" Value="[PhoneMobile]" />
        <Output Type="ContactUrl" Passes="0" Value="https://xxxxxx.co.uk/crm/customer/[EntityId]" />
      </Outputs>
    </Scenario>
    <Scenario Id="ReportCall" Type="REST">
      <Request SkipIf="[ReportCallEnabled]!=True||[CallType]!=Inbound" Url="https://xxxxxx.co.uk/api/events/new-event/?type=5" MessagePasses="0" RequestContentType="application/json" RequestEncoding="Json" RequestType="Post" ResponseType="Json">
        <PostValues Key="">
          <Value Key="duration" Passes="1" Type="String">[Duration]</Value>
          <Value Key="phone" Passes="1" Type="String">[Number]</Value>
          <Value Key="agent" Passes="1" Type="String">[Agent]</Value>
          <Value Key="callType" Passes="1" Type="String">[CallType]</Value>
          <Value Key="DateTime" Passes="1" Type="String">[DateTime]</Value>
          <Value Key="CustomerID" Passes="1" Type="String">[EntityId]</Value>
          <Value Key="EntityId" Passes="1" Type="String">[EntityId]</Value>
          <Value Key="CallStart" Passes="1" Type="String">[CallStartTimeUTC]</Value>
          <Value Key="CallEnd" Passes="1" Type="String">[CallEndTimeUTC]</Value>
        </PostValues>
      </Request>




However, when I use the Test CRM Integration functionality the EntityID field is populated with the customerID that I'm hoping to receive in our API. So i'm not sure what I'm missing for the POST to populate it in the same way.

JSON:
{"duration":"06:24","phone":"***********","agent":"1217","callType":"Inbound","DateTime":"24/03/2022 09:39","CustomerID":"","EntityId":"","CallStart":"24/03/2022 09:39:56","CallEnd":"24/03/2022 09:46:21"}


Any help would be greatly appreciated :)
 
Hi Edos & greychain, thanks for this - Unfortunately still not seeing customerID in any of the POSTs to our API. Here's my current template because a few changes had been made since the earlier post in this thread:

XML:
<?xml version="1.0"?>
<Crm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Country="US" Name="TestTemplate" Version="1" SupportsEmojis="false">
  <Number Prefix="Zeros" MaxLength="[MaxLength]" />
  <Connection MaxConcurrentRequests="2" />
  <Parameters>
    <Parameter Name="APIkey" Type="String" Parent="General Configuration" Editor="String" Title="API Key:" />
    <Parameter Name="CreateContactEnabled" Type="Boolean" Editor="String" Title="Enable Contact Creation" Default="False" />
    <Parameter Name="CreateContactFirstName" Type="String" Parent="CreateContactEnabled" Editor="String" Title="New Contact First Name:" Default="New" />
    <Parameter Name="CreateContactLastName" Type="String" Parent="CreateContactEnabled" Editor="String" Title="New Contact Last Name:" Default="3CX Contact [Number]" />
    <Parameter Name="ReportCallEnabled" Type="Boolean" Editor="String" Title="Enable Call Journaling" Default="False" />
    <Parameter Name="Subject" Type="String" Parent="ReportCallEnabled" Editor="String" Title="Call Subject:" Default="3CX PhoneSystem Call" />
    <Parameter Name="InboundCallText" Type="String" Parent="ReportCallEnabled" Editor="String" Title="Answered Inbound Call:" Default="[DateTime]: Answered incoming call from [Number] to [Agent] ([Duration])" />
    <Parameter Name="MissedCallText" Type="String" Parent="ReportCallEnabled" Editor="String" Title="Missed Call:" Default="[DateTime]: Missed call from [Number] to [Agent]" />
    <Parameter Name="OutboundCallText" Type="String" Parent="ReportCallEnabled" Editor="String" Title="Answered Outbound Call:" Default="[DateTime]: Answered outgoing call from [Agent] to [Number] ([Duration])" />
    <Parameter Name="NotAnsweredOutboundCallText" Type="String" Parent="ReportCallEnabled" Editor="String" Title="Unanswered Outbound Call:" Default="[DateTime]: Unanswered outgoing call from [Agent] to [Number]" />
  </Parameters>
  <Authentication Type="Basic">
    <Value>[APIkey]:X</Value>
  </Authentication>
  <Scenarios>
    <Scenario Id="" Type="REST">
      <Request Url="https://xxxxxxxxxx/api/phone/search/?number=[Number]" MessagePasses="0" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json" />
      <Rules>
        <Rule Type="Any">customer</Rule>
      </Rules>
      <Variables>
        <Variable Name="CustomerID" Path="customer.Details.ID">
          <Filter />
        </Variable>
        <Variable Name="FirstName" Path="customer.Details.Name">
          <Filter />
        </Variable>
        <Variable Name="LastName" Path="customer.Details.Surname">
          <Filter />
        </Variable>
        <Variable Name="Email" Path="customer.Details.Email">
          <Filter />
        </Variable>
        <Variable Name="PhoneMobile" Path="customer.Telephone">
          <Filter />
        </Variable>
      </Variables>
      <Outputs AllowEmpty="false">
        <Output Type="FirstName" Passes="0" Value="[FirstName]" />
        <Output Type="LastName" Passes="0" Value="[LastName]" />
        <Output Type="Email" Passes="0" Value="[Email]" />
        <Output Type="PhoneMobile" Passes="0" Value="[PhoneMobile]" />
        <Output Type="EntityId" Passes="0" Value="[CustomerID]" />
        <Output Type="EntityType" Passes="0" Value="Contacts" />
        <Output Type="ContactUrl" Passes="0" Value="https://xxxxxxxxx/crm/customer/[CustomerID]" />
      </Outputs>
    </Scenario>
    <Scenario Id="CreateContactRecord" Type="REST">
      <Request SkipIf="[CreateContactEnabled]!=True" Url="https://xxxxxxxxx/api/events/new-event/?type=4" MessagePasses="0" RequestContentType="application/json" RequestEncoding="Json" RequestType="Post" ResponseType="Json">
        <PostValues Key="">
          <Value Key="firstname" Passes="1" Type="String">Customer</Value>
          <Value Key="phone" Passes="1" Type="String">[Number]</Value>
        </PostValues>
      </Request>
      <Rules>
        <Rule Type="Any">customer</Rule>
      </Rules>
      <Variables>
        <Variable Name="FirstName" Path="customer.Details.Name">
          <Filter />
        </Variable>
        <Variable Name="LastName" Path="customer.Details.Surname">
          <Filter />
        </Variable>
        <Variable Name="Email" Path="customer.Details.Email">
          <Filter />
        </Variable>
        <Variable Name="PhoneMobile" Path="customer.Telephone">
          <Filter />
        </Variable>
     <Variable Name="CustomerID" Path="customer.Details.ID">
          <Filter />
        </Variable>
      </Variables>
      <Outputs AllowEmpty="false">
        <Output Type="FirstName" Passes="0" Value="[FirstName]" />
        <Output Type="LastName" Passes="0" Value="[LastName]" />
        <Output Type="Email" Passes="0" Value="[Email]" />
        <Output Type="PhoneMobile" Passes="0" Value="[PhoneMobile]" />
        <Output Type="EntityId" Passes="0" Value="[CustomerID]" />
        <Output Type="EntityType" Passes="0" Value="Contacts" />
        <Output Type="ContactUrl" Passes="0" Value="https://xxxxxxxxxxx/crm/customer/[CustomerID]" />
      </Outputs>
    </Scenario>
    <Scenario Id="ReportCall" Type="REST">
      <Request SkipIf="[ReportCallEnabled]!=True||[CallType]!=Inbound" Url="https://xxxxxxxxxxx/api/events/new-event/?type=5" MessagePasses="0" RequestContentType="application/json" RequestEncoding="Json" RequestType="Post" ResponseType="Json">
        <PostValues Key="">
          <Value Key="duration" Passes="1" Type="String">[Duration]</Value>
          <Value Key="phone" Passes="1" Type="String">[Number]</Value>
          <Value Key="agent" Passes="1" Type="String">[Agent]</Value>
          <Value Key="callType" Passes="1" Type="String">[CallType]</Value>
          <Value Key="DateTime" Passes="1" Type="String">[DateTime]</Value>
          <Value Key="CustomerID" Passes="1" Type="String">[EntityId]</Value>
          <Value Key="CallStart" Passes="1" Type="String">[CallStartTimeUTC]</Value>
          <Value Key="CallEnd" Passes="1" Type="String">[CallEndTimeUTC]</Value>
        </PostValues>
      </Request>
      <Variables />
      <Outputs Next="ReportCallMissed" AllowEmpty="true" />
    </Scenario>
    <Scenario Id="ReportCallMissed" Type="REST">
      <Request SkipIf="[ReportCallEnabled]!=True||[CallType]!=Missed" Url="https://xxxxxxxxxxx/api/events/new-event/?type=5" MessagePasses="0" RequestContentType="application/json" RequestEncoding="Json" RequestType="Post" ResponseType="Json">
        <PostValues Key="">
          <Value Key="duration" Passes="1" Type="String">[Duration]</Value>
          <Value Key="phone" Passes="1" Type="String">[Number]</Value>
          <Value Key="agent" Passes="1" Type="String">[Agent]</Value>
          <Value Key="callType" Passes="1" Type="String">[CallType]</Value>
          <Value Key="DateTime" Passes="1" Type="String">[DateTime]</Value>
          <Value Key="CustomerID" Passes="1" Type="String">[EntityId]</Value>
          <Value Key="CallStart" Passes="1" Type="String">[CallStartTimeUTC]</Value>
          <Value Key="CallEnd" Passes="1" Type="String">[CallEndTimeUTC]</Value>
        </PostValues>
      </Request>
      <Variables />
      <Outputs Next="ReportCallOutbound" AllowEmpty="true" />
    </Scenario>
    <Scenario Id="ReportCallOutbound" Type="REST">
      <Request SkipIf="[ReportCallEnabled]!=True||[CallType]!=Outbound" Url="https://xxxxxxxxxxx/api/events/new-event/?type=5" MessagePasses="0" RequestContentType="application/json" RequestEncoding="Json" RequestType="Post" ResponseType="Json">
        <PostValues Key="">
          <Value Key="duration" Passes="1" Type="String">[Duration]</Value>
          <Value Key="phone" Passes="1" Type="String">[Number]</Value>
          <Value Key="agent" Passes="1" Type="String">[Agent]</Value>
          <Value Key="callType" Passes="1" Type="String">[CallType]</Value>
          <Value Key="DateTime" Passes="1" Type="String">[DateTime]</Value>
          <Value Key="CustomerID" Passes="1" Type="String">[EntityId]</Value>
          <Value Key="CallStart" Passes="1" Type="String">[CallStartTimeUTC]</Value>
          <Value Key="CallEnd" Passes="1" Type="String">[CallEndTimeUTC]</Value>
        </PostValues>
      </Request>
      <Variables />
      <Outputs Next="ReportCallNotanswered" AllowEmpty="true" />
    </Scenario>
    <Scenario Id="ReportCallNotanswered" Type="REST">
      <Request SkipIf="[ReportCallEnabled]!=True||[CallType]!=Notanswered" Url="https://xxxxxxxxxxx/api/events/new-event/?type=5" MessagePasses="0" RequestContentType="application/json" RequestEncoding="Json" RequestType="Post" ResponseType="Json">
        <PostValues Key="">
          <Value Key="duration" Passes="1" Type="String">[Duration]</Value>
          <Value Key="phone" Passes="1" Type="String">[Number]</Value>
          <Value Key="agent" Passes="1" Type="String">[Agent]</Value>
          <Value Key="callType" Passes="1" Type="String">[CallType]</Value>
          <Value Key="DateTime" Passes="1" Type="String">[DateTime]</Value>
          <Value Key="CustomerID" Passes="1" Type="String">[EntityId]</Value>
          <Value Key="CallStart" Passes="1" Type="String">[CallStartTimeUTC]</Value>
          <Value Key="CallEnd" Passes="1" Type="String">[CallEndTimeUTC]</Value>
        </PostValues>
      </Request>
      <Variables />
      <Outputs AllowEmpty="false" />
    </Scenario>
  </Scenarios>
</Crm>
 
Also, now when I use the Test functionality on the 3CX platform, I receive this message:

"CRM Integration is working OK but contact number does not exist. Check log for more info or try a different number."

Previously this would work as expected and my only issue was in the POST received in our API.
 
Most probably the Rule you're defining to identify the record is wrong. It seems you changed the JSON response returned by the server. What does this JSON look like now? Probably the path for the Rule should be set to customer.Details.ID and not just customer, but it's better to check the JSON to tell you exactly how you need to set that.
 
  • Like
Reactions: AdamTR
Thanks Edos, was indeed the rule in the end - We'd flattened the object that we respond with and I hadn't updated that in the XML in this case, but it looks like the main culprit was the EntityId line in the "ContactURL" section.

Still getting a couple (very small amount) come through with no CustomerID but now the vast majority of the POSTs received via our API contain the CustomerID.

Many thanks!
 
  • Like
Reactions: edossantos
The ReportCall scenario will be invoked even without an EntityId. You might want to check that, and skip the invocation in that case. You can check how we do this in the standard templates we provide (select a template from the 3CX Console > Settings > CRM > Show template).

I would bet that this happens for calls that are not being matched to a CRM contact. You should check the contact creation scenario for that, maybe you have the same issue there. You need to ensure that you return the created contact from there.
 
Status
Not open for further replies.

Latest Posts

Forum statistics

Threads
112,323
Messages
591,896
Members
165,473
Latest member
NathanMitchell