Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Display queue waiting time (tACD?) in the script

    Posted 20 days ago

    Hey all,

    I'm looking for a way to show agents the total wait time in their script. I have the "Queue Start Time" (from participant data) and the "Agent Start Time," but I can't find a function to subtract one from the other to get the duration.

    Has anyone successfully done this calculation in a script, or is there a better way to display this?

    Appreciate any help!


    #Scripts

    ------------------------------
    Yvgeni Liberman
    Solutions Architect

    Mobile +972 52-6344414
    Voice +972 3-9281514
    e-mail yvgeni_new@itnavpro.com
    ------------------------------


  • 2.  RE: Display queue waiting time (tACD?) in the script

    Posted 20 days ago

    Hi Yvgeni,

    I don't believe there is currently a native scripting function specifically for date/time subtraction or duration calculation directly inside the standard script expression engine.

    However, you can access built-in variables such as:

    {{Scripter.Customer Call Start Time}}
    {{Scripter.Agent Call Start Time}}

    The challenge is that these values are typically formatted datetime strings, and Scripts do not provide rich date manipulation functions similar to Architect.

    Because of that, most implementations I've seen calculate the wait duration outside the script itself, for example:

    • in Architect before routing to the agent
    • through a Data Action
    • via middleware/API
    • or by storing a precomputed wait time in participant data

    Then the script simply displays the already calculated value.

    For production scenarios, precomputing the queue wait time before the interaction reaches the script is usually the most reliable approach.



    ------------------------------
    Gabriel Garcia
    NA
    ------------------------------



  • 3.  RE: Display queue waiting time (tACD?) in the script

    Posted 20 days ago

    Gabriel,

    Many thanks for your answer. Do you have any working examples of a Data Action like this?

    Also, do you think we can retrieve the tACD directly from the interaction (by using Data Action)?

    Best Regards,



    ------------------------------
    Yvgeni Liberman
    Solutions Architect

    Mobile +972 52-6344414
    Voice +972 3-9281514
    e-mail yvgeni_new@itnavpro.com
    ------------------------------



  • 4.  RE: Display queue waiting time (tACD?) in the script

    Posted 20 days ago
    Edited by Marcello Jabur 20 days ago

    Hi Yvgeni, how are you?

    You should be able to retrieve it from an API (using a data action).
    If you want to try it, create a data action with this endpoint: GET /api/v2/analytics/conversations/{conversationId}/details

    You should be able to check the "participants" array for the participant with a "purpose" of "acd".
    Then there should be a "sessions" array, and inside of it a "metrics" array.
    Then you will find your "tAcd" in there.

    I don't have an already created Data Action to share, but it should be possible to create one.
    Be careful with scenarios where a call is transferred to a second queue for instance, as then you would have 2 participants on the call with purpose = "acd", so you might need to define in your data action if you are always checking for the first one, or last one, etc.

    --------------

    Also, if you want to work with the date/times that you have on variables, I believe there are a few functions that you could try to use for that.

    You can find all of those functions here: https://help.genesys.cloud/articles/additional-functions-to-use-in-dynamic-variables/

    So, for instance, let's say you have 2 variables in this format: YYYY-MM-DDThh:mm:ss. (Your queue start time, and the agent start time)
    I believe you can convert them into milliseconds using this: dateToMilliseconds(date) 
    Then you can subtract both milliseconds to get the difference. And with the resulting value you can use this: formatDuration(duration), to get a readable format as "00:00:00" (hh:mm:ss).

    There are a few more functions there, in case you haven't seen it before.



    ------------------------------
    Marcello Jabur
    ------------------------------



  • 5.  RE: Display queue waiting time (tACD?) in the script

    Posted 20 days ago

    Marcello,

    Many thanks,

    I will try both of them

    Best Regards,



    ------------------------------
    Yvgeni Liberman
    Solutions Architect

    Mobile +972 52-6344414
    Voice +972 3-9281514
    e-mail yvgeni_new@itnavpro.com
    ------------------------------



  • 6.  RE: Display queue waiting time (tACD?) in the script

    Posted 18 days ago

    Hi Yvgeni,

    Yes, the approach mentioned above should work well.

    You can retrieve the queue timing information using a Data Action calling:

    GET /api/v2/analytics/conversations/{conversationId}/details

    Inside the response:

    • look for the participant where:
    purpose = "acd"
    • then check:
    participants → sessions → metrics

    There you should find metrics such as:

    tAcd

    One important detail is handling transfers. If the interaction goes through multiple queues, you may have multiple ACD participants, so you'll need to decide whether to use:

    • first queue
    • last queue
    • longest queue segment
    • current queue

    depending on your use case.

    Also, regarding the timestamp calculation directly in Scripts, there are actually some useful dynamic variable functions available.

    For example:

    dateToMilliseconds(date)

    can convert your timestamps into milliseconds, allowing you to subtract them.

    Then you can format the result using:

    formatDuration(duration)

    to display something readable like:

    00:00:00

    So you may not even need an external middleware depending on how complex the logic becomes.



    ------------------------------
    Gabriel Garcia
    NA
    ------------------------------



  • 7.  RE: Display queue waiting time (tACD?) in the script

    Posted 18 days ago

    Gabriel ,

    Thank you,

    We will try to implement such Data Action

    Regards,



    ------------------------------
    Yvgeni Liberman
    Solutions Architect

    Mobile +972 52-6344414
    Voice +972 3-9281514
    e-mail yvgeni_new@itnavpro.com
    ------------------------------