Genesys Cloud - Developer Community!

 View Only

Sign Up

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

    Posted 7 hours 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 6 hours 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 5 hours 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 2 hours ago
    Edited by Marcello Jabur 2 hours 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 an hour 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
    ------------------------------