Data Action - Return Boolean if agent in group or has specific skill

Is there a way to check if a user is in a group or has a specific skill assigned to them? I would like to run a data action from a script and have it return true or false. This would then allow my script to decide what should be shown to the agent

I would suggest starting with the API explorer to figure out if any routes exist that can get you what you need

For example, this route might be helpful:
GET /api/v2/routing/skillgroups/{skillGroupId}/members. Get skill group members

However, I would caution that you typically don't want to hit a 'configuration' endpoint as part of your production work, as they may not be fast enough to provide a good experience.

--Jason

I'm having a look at routing skills: /api/v2/users/{agent id}/routingskills which returns the following

{
  "entities.skillUri": [
    "/api/v2/routing/skills/ea77822d-c245-48c2-83df-4f79970ae6f8",
    "/api/v2/routing/skills/9ada3bfe-3000-4f9c-b84b-00b3404a8931"
  ],
  "entities.selfUri": [
    "/api/v2/users/bfad8bbc-e9ef-435e-ba8a-9b6479933413/routingskills/ea77822d-c245-48c2-83df-4f79970ae6f8",
    "/api/v2/users/bfad8bbc-e9ef-435e-ba8a-9b6479933413/routingskills/9ada3bfe-3000-4f9c-b84b-00b3404a8931"
  ],
  "entities.id": [
    "ea77822d-c245-48c2-83df-4f79970ae6f8",
    "9ada3bfe-3000-4f9c-b84b-00b3404a8931"
  ],
  "pageCount": 1,
  "pageNumber": 1,
  "firstUri": "/api/v2/users/bfad8bbc-e9ef-435e-ba8a-9b6479933413/routingskills?pageSize=25&pageNumber=1",
  "lastUri": "/api/v2/users/bfad8bbc-e9ef-435e-ba8a-9b6479933413/routingskills?pageSize=25&pageNumber=1",
  "selfUri": "/api/v2/users/bfad8bbc-e9ef-435e-ba8a-9b6479933413/routingskills?pageSize=25&pageNumber=1",
  "pageSize": 25,
  "entities.name": [
    "Vulnerable",
    "Vulnerable Customer"
  ],
  "total": 2,
  "entities.proficiency": [
    0,
    0
  ],
  "entities.state": [
    "active",
    "active"
  ]
}

Is there a way to pull out entities.name and then use Apache Velocity to loop through and check for a certain name?

My current response is:

{
  "translationMap": {
    "skillNames": "$.entities.name"
  },
  "translationMapDefaults": {},
  "successTemplate": "${skillNames}"
}

but it gives me the following error:
"message": "Failed while processing the translation map. Could not resolve value for the key: 'skillNames' and no default value was configured. Additional details: Expected to find an object with property ['name'] in path $['entities'] but found 'java.util.ArrayList'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.",

Apologies I'm new to Data Actions but eager to learn, I haven't been able to find any documentation or examples that handles an array of strings

You can have your translationMap look for an entry with the specific name that you are looking for.

So on this page: https://www.javainuse.com/jsonpath
f, for example filtering like this:
$.topping[?(@.id=="5001")].id

As to the error that you are getting, since entities is an array, you probably needed something like
$.entities[*].name

--Jason

1 Like

Yeah that worked:

{
  "translationMap": {
    "skillNames": "$.entities[?(@.name == 'SingleClientView')].name"
  },
  "translationMapDefaults": {
    "skillNames": "DefaultSkillName"
  },
  "successTemplate": "{\"Skill\": ${skillNames}}"
}

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.