Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Custom Data Action to get last user ID in a conversation

    Posted 20 days ago
      |   view attached

    Hi,

    Does anyone have a working custom data action that fetches the last user ID in a conversation? (eg. when there are multiple agents in an interaction via transfers or other reasons).

    Attaching a working version of this that gets the first agent in a conversation, but have tried multiple times and also raised Care case, we could not get a working version that gets the last agent instead.


    #DataActions

    ------------------------------
    John Carlo Labitag
    Platform Improvement Analyst
    ------------------------------


  • 2.  RE: Custom Data Action to get last user ID in a conversation

    Posted 20 days ago

    Hey John,

    I noticed that you used "firstFromArray" on your Data Action to get the first agent.

    Unfortunately as far as I remember there is no equivalent to get the last one.

    What I usually do when I need something like this is simply getting all the IDs in an array variable, and then getting the last index on Architect (assuming you are trying to execute that Data Action in an Architect flow).

    Does that help you in any way?

    If it does, just build a Data Action to get all the agent IDs, and then on architect you can check the number of IDs by using Count(your_array_variable).

    Then let's say the Count returns 5... You should then access index 4 (since it starts at 0), to get the last one. Which would look like: your_array_variable[4].



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



  • 3.  RE: Custom Data Action to get last user ID in a conversation

    Posted 19 days ago

    Thank you for that idea Marcello. Will try it out. Will need to also make if dynamic (eg. in an interaction, we won't know how many agents would be handling it)

    Will be doing some tests



    ------------------------------
    John Carlo Labitag
    Platform Improvement Analyst
    ------------------------------



  • 4.  RE: Custom Data Action to get last user ID in a conversation

    Posted 18 days ago

    No worries John, and yes it should be dynamic in the way I mentioned.

    When you use the Count() function it will return the number of agents in the array

    And for you to read the last agent ID you can simply read the index that is "Count -1".

    So for example, let's say there were 3 agent Ids on your array.
    You will use the Count(your_variable) function, and this will return 3.
    Then you can access the value of the index equivalent to the count (3) minus 1, which would be 2 in this example. 2 would be the last index (0,1,2).

    So you just build it dynamically to subtract 1 from the total count, and with that result you can read the necessary index.



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