REST API - How to get 'Agent' before call ends

Status
Not open for further replies.

HD_IT

Free User
Joined
Jun 5, 2023
Messages
4
Reaction score
0
Hi,

We've had a CRM integration with 3cx for the last 18 months or so, and due to the purposes of our integration we need to display calls while they are occurring rather than just recording information once the call is done.
Up until now have been limited to only offering it to our customers who have a single location linked to their 3cx management account, as we haven't had a way on our end to determine which call belonged to which location. We've now got a solution for this on our end, but it relies on us knowing the 'agent' for a call before the call ends. We receive the GET request for contact lookup and then get a POST request for contact creation, and then after the call ends we receive a POST request based on whether the call was answered/missed etc. Currently we receive the AGENT during the final Call Record POST request, but not before that. Is there any way in which we can find out which agent a call is directed to before the call has ended? Would this change if the call goes through a more complex call journalling process (our test setup is quite simple, but in the real situations we're trying to handle the would be directed to one particular extension per location and then picked up by an agent, even accessing the number for that first extension rather than the final agent would be sufficient)

Our template XML includes the following for Contact Creation, but 'agent' is blank in the actual request body


Code:
<Scenario Id="CreateContactRecord" Type="REST">
      <Request SkipIf="[CreateContactEnabled]!=True||[IIf([CreateOnCallDirection]==Inbound,[CallDirection]!=Inbound,False)]==True" Url="[our base url]/api/caller_id/incoming_calls" MessagePasses="0" RequestContentType="application/json" RequestEncoding="Json" RequestType="Post" ResponseType="Json">
        <PostValues Key="">
          <Value Key="phone_number" Passes="1" Type="String">[Number]</Value>
          <Value Key="call_direction" Passes="1" Type="String">[CallDirection]</Value>
     <Value Key="agent" Passes="1" Type="String">[Agent]</Value>
        </PostValues>
      </Request>
      <Rules>
        <Rule Type="Any">contact.id</Rule>
      </Rules>
      <Variables>
        <Variable Name="ContactID" Path="contact.id">
          <Filter/>
        </Variable>
        <Variable Name="CompanyName" Path="contact.company">
          <Filter/>
        </Variable>
        <Variable Name="PhoneBusiness" Path="contact.businessphone">
          <Filter/>
        </Variable>
        <Variable Name="ContactUrl" Path="contact.url">
          <Filter/>
        </Variable>
      </Variables>
      <Outputs AllowEmpty="false">
        <Output Type="ContactID" Passes="0" Value="[ContactID]"/>
        <Output Type="CompanyName" Passes="0" Value="[CompanyName]"/>
        <Output Type="PhoneBusiness" Passes="0" Value="[PhoneBusiness]"/>
        <Output Type="ContactUrl" Passes="0" Value="[ContactUrl]"/>
        <Output Type="EntityId" Passes="0" Value="[ContactID]"/>
        <Output Type="EntityType" Passes="0" Value="Contacts"/>
      </Outputs>
    </Scenario>

Request body:
Code:
{
  "phone_number"=>"0412345678",
  "call_direction"=>"Inbound",
  "agent"=>"",
  "controller"=>"api/caller_id/incoming_calls",
  "action"=>"create",
  "incoming_call"=>{
    "phone_number"=>"0412345678",
    "call_direction"=>"Inbound",
    "agent"=>""
  }
}

Any advice on how we might be able to identify the extension/agent before the calls ends greatly appreciated.
 
The agent is only available at the end of the call. No way to change that.
 
  • Like
Reactions: edossantos
Something you could do is launching a program when the Desktop App receives an inbound call. Your agents would need to use this client. Then, you can make another POST to your CRM in that case to inform that the call is being handled by that agent.
 
Hi,

We've had a CRM integration with 3cx for the last 18 months or so, and due to the purposes of our integration we need to display calls while they are occurring rather than just recording information once the call is done.
Up until now have been limited to only offering it to our customers who have a single location linked to their 3cx management account, as we haven't had a way on our end to determine which call belonged to which location. We've now got a solution for this on our end, but it relies on us knowing the 'agent' for a call before the call ends. We receive the GET request for contact lookup and then get a POST request for contact creation, and then after the call ends we receive a POST request based on whether the call was answered/missed etc. Currently we receive the AGENT during the final Call Record POST request, but not before that. Is there any way in which we can find out which agent a call is directed to before the call has ended? Would this change if the call goes through a more complex call journalling process (our test setup is quite simple, but in the real situations we're trying to handle the would be directed to one particular extension per location and then picked up by an agent, even accessing the number for that first extension rather than the final agent would be sufficient)

Our template XML includes the following for Contact Creation, but 'agent' is blank in the actual request body


Code:
<Scenario Id="CreateContactRecord" Type="REST">
      <Request SkipIf="[CreateContactEnabled]!=True||[IIf([CreateOnCallDirection]==Inbound,[CallDirection]!=Inbound,False)]==True" Url="[our base url]/api/caller_id/incoming_calls" MessagePasses="0" RequestContentType="application/json" RequestEncoding="Json" RequestType="Post" ResponseType="Json">
        <PostValues Key="">
          <Value Key="phone_number" Passes="1" Type="String">[Number]</Value>
          <Value Key="call_direction" Passes="1" Type="String">[CallDirection]</Value>
     <Value Key="agent" Passes="1" Type="String">[Agent]</Value>
        </PostValues>
      </Request>
      <Rules>
        <Rule Type="Any">contact.id</Rule>
      </Rules>
      <Variables>
        <Variable Name="ContactID" Path="contact.id">
          <Filter/>
        </Variable>
        <Variable Name="CompanyName" Path="contact.company">
          <Filter/>
        </Variable>
        <Variable Name="PhoneBusiness" Path="contact.businessphone">
          <Filter/>
        </Variable>
        <Variable Name="ContactUrl" Path="contact.url">
          <Filter/>
        </Variable>
      </Variables>
      <Outputs AllowEmpty="false">
        <Output Type="ContactID" Passes="0" Value="[ContactID]"/>
        <Output Type="CompanyName" Passes="0" Value="[CompanyName]"/>
        <Output Type="PhoneBusiness" Passes="0" Value="[PhoneBusiness]"/>
        <Output Type="ContactUrl" Passes="0" Value="[ContactUrl]"/>
        <Output Type="EntityId" Passes="0" Value="[ContactID]"/>
        <Output Type="EntityType" Passes="0" Value="Contacts"/>
      </Outputs>
    </Scenario>

Request body:
Code:
{
  "phone_number"=>"0412345678",
  "call_direction"=>"Inbound",
  "agent"=>"",
  "controller"=>"api/caller_id/incoming_calls",
  "action"=>"create",
  "incoming_call"=>{
    "phone_number"=>"0412345678",
    "call_direction"=>"Inbound",
    "agent"=>""
  }
}

Any advice on how we might be able to identify the extension/agent before the calls ends greatly appreciated.
Perhaps the following third-party and unofficial functionality will help you. At the moment of receiving the call and at the moment of picking up the handset, you will receive webhook events and records in the same records in the database.
In other words, get information during the call who owns the call.


for example
{
"event": "ringing",
"callerid": "420774897465",
"user": "201",
"usertype": "ext",
"did": "",
"id": "230604192654_4-0"
}
 
Status
Not open for further replies.

Forum statistics

Threads
111,973
Messages
590,079
Members
164,897
Latest member
ferpeba83