Genesys Cloud - Main

 View Only

Discussion Thread View
Expand all | Collapse all

Last agent lookup

  • 1.  Last agent lookup

    Posted 02-22-2023 08:59

    Hi everyone, I wonder if someone can help

    I have implemented a data action that gets the last agent that took a call from an ANI (last 30 days) and adds the agent GUID returned as the preferred agent.  This works perfectly and as I want it to, but I have a situation where the last agent might have been moved away from that team and no longer has the skill and should not handle that call, but of course it will still route to them.

    I have a data action that gets a list of skills for an agent, but how do I check that the agent has the skill in the flow or a data action. I don't seem to be able to tie that part together or I cant get it in my head how to query them.

    Any help would be appreciated

    Andy


    #Routing(ACD/IVR)

    ------------------------------
    Andy Jackson
    Ten Lifestyle Management Limited
    ------------------------------


  • 2.  RE: Last agent lookup
    Best Answer

    Posted 02-27-2023 08:11

    If anyone is interested and wants to do the same, I did manage to get this working

    Data action - last agent on conversation

    Data action - list skills for the agent

    Flow - calculation, count skills from data action that match skill for incoming call (greater than maximum  IVR options you have)

    Decision that says use preferred or not



    ------------------------------
    Andy Jackson
    Ten Lifestyle Management Limited
    ------------------------------



  • 3.  RE: Last agent lookup

    Posted 03-18-2023 09:43

    Hi Andy,

    im looking at implementing this for inbound emails, can you tell me how you setup your data action to get the last agent?

    cheers 



    ------------------------------
    Paul Smith
    Essential Data & Voice
    ------------------------------



  • 4.  RE: Last agent lookup

    Posted 03-19-2023 00:55

    All good, i worked it out 



    ------------------------------
    Paul Smith
    Essential Data & Voice
    ------------------------------



  • 5.  RE: Last agent lookup

    Posted 03-20-2023 09:49

    Email should route to last agent anyway as its digital



    ------------------------------
    Andy Jackson
    Ten Lifestyle Management Limited
    ------------------------------



  • 6.  RE: Last agent lookup

    Posted 03-20-2023 17:06

    Not when you are using email flow 



    ------------------------------
    Paul Smith
    Essential Data & Voice
    ------------------------------



  • 7.  RE: Last agent lookup

    Posted 11-15-2024 13:31
    Edited by Varun Chauhan 11-20-2024 05:49
    Hi Paul,
     
    I'm currently implementing this for inbound emails as well, but I'm only getting the default output and no actual data. Could you please share the modifications you made in your script to achieve the desired output?
     

    ------------------------------
    Varun Chauhan
    ------------------------------



  • 8.  RE: Last agent lookup

    Posted 07-25-2023 10:05

    Hi Andy,

    we are looking this scenario for inbound calls, can you tell us how you configure the data actions to get the last agent?

    Many thanks!



    ------------------------------
    Giuseppe Cisternino
    ComApp S.r.l
    ------------------------------



  • 9.  RE: Last agent lookup

    Posted 07-25-2023 10:19

    Here is a screenshot, I have added you as a contact and am happy to send you my data action as an export

    you need to build a few attributes to get the period you want to cover off and to capture the customers ANI

    With this as the body

    {
      "interval": "${input.INTERVAL}",
      "order": "desc",
      "orderBy": "conversationStart",
      "paging": {
        "pageSize": 1,
        "pageNumber": 1
      },
      "segmentFilters": [
        {
          "type": "and",
          "predicates": [
            {
              "type": "dimension",
              "dimension": "mediaType",
              "operator": "matches",
              "value": "voice"
            },
            {
              "type": "dimension",
              "dimension": "purpose",
              "operator": "matches",
              "value": "agent"
            },
            {
              "type": "dimension",
              "dimension": "ani",
              "operator": "matches",
              "value": "tel:${input.CustomerPhoneNumber}"
            }
          ]
        }
      ]
    }

    Andy



    ------------------------------
    Andy Jackson
    Ten Lifestyle Management Limited
    ------------------------------



  • 10.  RE: Last agent lookup

    Posted 07-26-2023 09:22

    Hi Andy,

    many many thanks!

    I'll test that solutions

    Best regards

    Giuseppe



    ------------------------------
    Giuseppe Cisternino
    ComApp S.r.l
    ------------------------------



  • 11.  RE: Last agent lookup

    Posted 07-01-2024 23:55

    Hi,

    If you dont mind, may i have the export of the Data Action.

    You help is highly appreciated.

    Regards,

    LUQMAN



    ------------------------------
    Muhammad Luqman bin Abd Rahim
    Trisilco Radiance Communications Sd
    ------------------------------



  • 12.  RE: Last agent lookup

    Posted 01-12-2024 00:30

    Hi Andy, are you able to share your data action export to try this out? I've got a similar requirement try out.



    ------------------------------
    Hasitha Perera
    Ark Insights Co Ltd
    ------------------------------



  • 13.  RE: Last agent lookup

    Posted 09-25-2024 06:30

    Hi Andy,

    Can you please tell us which API did you use to search the ANI?

    Thank you,

    Varun



    ------------------------------
    Varun Chauhan
    IP Integration Limited
    ------------------------------



  • 14.  RE: Last agent lookup

    Posted 09-25-2024 06:48
    Edited by Andy Jackson 09-25-2024 06:48

    Nothing overly fancy, there is a bit of work in the flow to get "now" - 30 days to get the dates



    ------------------------------
    Andy Jackson
    Ten Lifestyle Management Limited
    ------------------------------



  • 15.  RE: Last agent lookup

    Posted 10-08-2024 12:08

    Hi Andy,

    Could you please tell us what you put in the response part of the body?

    Thank you,
    Varun



    ------------------------------
    Varun Chauhan
    IP Integration Limited
    ------------------------------



  • 16.  RE: Last agent lookup

    Posted 10-14-2024 11:07

    Hello Varun, 

    I don't know what Andy's response will be but making a post in the developer forum as this is where the developers live and they can provide a wealth of knowledge with developing a response body for data actions. 

    Cheers, 



    ------------------------------
    Cam
    Online Community Manager/Moderator
    ------------------------------



  • 17.  RE: Last agent lookup

    Posted 10-14-2024 11:27

    Hi

    As a JSON

    {
      "title": "List of last userIds / conversationIds ordered conversationStart desc",
      "type": "object",
      "properties": {
        "userId": {
          "description": "String array of userIds",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "conversationId": {
          "description": "String array of conversationIds",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": true
    }

    or

    The only trouble I have with it is if the call was transferred it causes an error as there are 2 agents in the conversation.  I havent worked out how to return just the last



    ------------------------------
    Andy Jackson
    Senior Unified Communications Engineer
    ------------------------------



  • 18.  RE: Last agent lookup

    Posted 10-14-2024 17:21

    Hi Andy, If you want the last item in an array, then in your translation map if you have the path $.conversation[] for example if you just add -1 to the index, eg  $.conversation[-1] this will retrieve the last item in the array. Doesn't work with tools like Jsonpath when validating though.



    ------------------------------
    Anton Vroon
    ------------------------------



  • 19.  RE: Last agent lookup

    Posted 10-16-2024 12:22

    Ah ha..That works when the agent hasn't transferred it, that's where I am getting stuck, that gets the last conversation, but I need to return the last agent in the array

    This is my JSON

    {
      "translationMap": {
        "userId": "$.conversations[-1].participants[?(@.purpose == 'agent')].userId",
        "conversationId": "$.conversations[?('agent' in @.participants[*].purpose)].conversationId"
      },
      "translationMapDefaults": {
        "userId": "[\"Not Found\"]",
        "conversationId": "[\"Not Found\"]"
      },
      "successTemplate": "{\n\t\"userId\": ${userId},\n \n\t\"conversationId\": ${conversationId}\n}"
    }



    ------------------------------
    Andy Jackson
    Senior Unified Communications Engineer
    ------------------------------



  • 20.  RE: Last agent lookup

    Posted 10-16-2024 23:30

    You may have to do that in the Architect Flow, get the array and in the Inbound Flow grab the last item, using count of items -1 to get the last index value and then get at that index.

    At least from my googling, doesn't look like you can use an index AND a filter together

    https://stackoverflow.com/questions/71655406/jsonpath-filter-array-and-get-only-the-first-element 



    ------------------------------
    Anton Vroon
    ------------------------------



  • 21.  RE: Last agent lookup

    Posted 10-17-2024 04:19

    Yes, I had a brain wave last night to grab last conversion in a data action then use the conversation found in another data action to get last agent



    ------------------------------
    Andy Jackson
    Senior Unified Communications Engineer
    ------------------------------



  • 22.  RE: Last agent lookup

    Posted 10-17-2024 04:49
    Edited by Varun Chauhan 10-17-2024 04:50
      |   view attached

    Hi Andy,

    Based on this response, I am receiving the raw data in JSON format. However, I am not getting any data in the input. I come as blank.

    Is this something I need to query in the Architect flow?

    Thank You,



    ------------------------------
    Varun Chauhan

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



  • 23.  RE: Last agent lookup

    Posted 10-18-2024 09:11

    Thank you, everyone. I was able to resolve the error I was encountering.



    ------------------------------
    Varun Chauhan
    na
    ------------------------------



  • 24.  RE: Last agent lookup

    Posted 10-21-2024 08:19

    Hi Varun,

    Glad you got the issue resolved.  Do you mind sharing the fix, it might help another community member in the future?



    ------------------------------
    Sam Jillard
    Online Community Manager/Moderator
    Genesys - Employees
    ------------------------------



  • 25.  RE: Last agent lookup

    Posted 11-15-2024 11:50

    Hi Samuel,

    The code was essentially the same, but there was a minor error in one of the lines. A couple of characters that should have been in lowercase were written in uppercase. Addressing this mistake resolved the issue.

    Thank you,
    Varun



    ------------------------------
    Varun Chauhan
    na
    ------------------------------



  • 26.  RE: Last agent lookup

    Posted 11-15-2024 11:57

    oooh, they are always tough ones.  Thanks for letting me know :D



    ------------------------------
    Sam Jillard
    Online Community Manager/Moderator
    Genesys - Employees
    ------------------------------



  • 27.  RE: Last agent lookup

    Posted 11-20-2024 05:48

    Hi Samuel,

    I would like to know if the same code can work for emails. I noticed that Paul has configured a similar setup for emails.

    I am currently implementing this for inbound emails, but I am only getting the default output without any actual data. Could you or someone on the team review my code and suggest if any modifications are required to achieve the desired output?

    This is what is have configured.
    >>>>>> Request Body Template <<<<<<<
     
    {
      "interval": "${input.Interval}",
      "order": "desc",
      "orderBy": "conversationStart",
      "paging": {
        "pageSize": 1,
        "pageNumber": 1
      },
      "segmentFilters": [
        {
          "type": "and",
          "predicates": [
            {
              "type": "dimension",
              "dimension": "mediaType",
              "operator": "matches",
              "value": "email"
            },
            {
              "type": "dimension",
              "dimension": "purpose",
              "operator": "matches",
              "value": "agent"
            },
            {
              "type": "dimension",
              "dimension": "addressTo",
              "operator": "matches",
              "value": "email:${input.CustomerEmail}"
            }
          ]
        }
      ],
      "select": [
        {
          "type": "dimension",
          "dimension": "selectedAgentId"
        },
        {
          "type": "dimension",
          "dimension": "userName"
        }
      ]
    }
     
     
     
     
    >>>>>> Response <<<<<<<
     
    {
      "translationMap": {
        "userId": "$.conversations[-1].participants[?(@.purpose == 'agent')].userId",
        "conversationId": "$.conversations[?('agent' in @.participants[*].purpose)].conversationId"
      },
      "translationMapDefaults": {
        "userId": "[\"NA\"]",
        "conversationId": "[\"NA\"]"
      },
      "successTemplate": "{\n\t\"userId\": ${userId},\n \n\t\"conversationId\": ${conversationId}\n}"
    }

    Thank you,

    Varun



    ------------------------------
    Varun Chauhan
    na
    ------------------------------



Need Help finding something?

Check out the Genesys Knowledge Network - your all-in-one access point for Genesys resources