Get caller number, called Number and agent/extension

Discussion in 'Call Flow Designer' started by VictorSP, Dec 5, 2017.

Thread Status:
Not open for further replies.
  1. VictorSP

    Joined:
    Sep 6, 2016
    Messages:
    61
    Likes Received:
    12
    Hi team,

    I'm trying CFD but not very satisfied with my progress. I have the following scenario: on an incoming external call, I need to get the calling number, called number and agent/extension of the queue who pick up the call.

    Testing with session.ani and session.dnis seems a part of the info I need but I don't know how to get agent/extension that finally attends the call.

    After that, I need to send this information as a URL to CRM like this:

    http://192.168.1.1:8766/mainserv/callInfo?callerId=1231231&associationId=344&operatorId=3345

    • callerId
    • associationId (called number, DDI to queue)
    • operatorId (agent/extension)
    Could you help me?

    Bye
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,254
    Likes Received:
    97
    Hello @VictorSP,

    The caller ID is available in the "session.ani" variable.

    The variable "session.dnis" contains the number of the queue in which the CFD is running. Maybe you need the "session.did" variable, which contains the number dialed by the external user to reach 3CX.

    I assume that inbound calls are routed to this CFD app, and then you transfer them to a queue. In that case, when you transfer the call, you don't know yet which agent is going to pick up the call. So you need to wait until the call is transfered to an agent to get all the information. To do that, you will need to create a C# script and use the 3CX Call Control API from that script. You need to put this script in the Disconnect Handler flow, because it will be executed when the call is disconnected from the CFD app (because you transfer it to a queue), and then in this script you can loop and check the state of the ActiveConnection for the Call ID of the inbound call. When you see that the ActiveConnection is connected to an agent, you can return the info of the agent from the script, and then invoke the URL using an HTTP Request component.

    Kind regards.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    VictorSP likes this.
  3. VictorSP

    Joined:
    Sep 6, 2016
    Messages:
    61
    Likes Received:
    12
    Thanks @edossantos but about script with 3CX Call Control API, how do i take agent connected to the call? Checking CFD example I only see how to check status but not how to get agent/extension connected with that call.

    Code:
    using System;
    using TCX.Configuration;
    
    namespace OutboundDialerDemo
    {
      public class ExtensionStateHelper
      {
        public bool IsThereAnyFreeExtension()
        {
          return PhoneSystem.Root.GetDNByNumber("201").GetActiveConnections().Length == 0 ||
                 PhoneSystem.Root.GetDNByNumber("202").GetActiveConnections().Length == 0 ||
                 PhoneSystem.Root.GetDNByNumber("203").GetActiveConnections().Length == 0;
        }
      }
    }
    
    Regards,
    Víctor
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,254
    Likes Received:
    97
    Hello Victor,

    You need to use the method PhoneSystem.GetActiveConnectionsByCallID, which returns a Dictionary with every active all in the system. Then you can iterate that dictionary until you find the connection with the same Call ID that you had in the CFD app. Finally, the InternalParty or ExternalParty properties of the ActiveConnection object will have the queue extension while the call is in the queue, or the agent extension once it is connected.

    Please note that you need to create this script yourself, check the documentation in the ZIP that you can download from the Call Control API documentation page.

    Kind regards.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    VictorSP likes this.
  5. VictorSP

    Joined:
    Sep 6, 2016
    Messages:
    61
    Likes Received:
    12
    Thanks a lot for your help, @edossantos

    Just another doubt about 3CX, queues and PhoneSystem.GetActiveConnectionsByCallID: is it possible to retrieve which agent 3CX is trying to connect the call? We would need to send the URL also in that moment, during ringing time.

    Regards,
    Victor
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,254
    Likes Received:
    97
    Hello Victor,

    Yes, the method "PhoneSystem.GetActiveConnectionsByCallID" will give you all the active calls in the system. Filtering by Call ID you can identify the call you need, and checking the properties of the ActiveConnection object you will get the extension of the agent that is receiving the call.

    Kind regards.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    VictorSP likes this.
  7. VictorSP

    Joined:
    Sep 6, 2016
    Messages:
    61
    Likes Received:
    12
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Thread Status:
Not open for further replies.