Jaime_Perez | 2022-05-20 15:30:22 UTC | #1
Hello,
Is there an API that returns the Agent's "division"? If so, can someone provide some guidance on how I can accomplish this? We just need to know the Agent's division if it is part of the conversation attributes.
Thank you.
John_Carnell | 2022-05-20 18:19:15 UTC | #2
Hi Jamie,
You can use GET /api/v2/users endpoint. Division id is returned as part of the payload. In addition, you can use the gc users get *user guid* or gc users list command to return a users object using this API and see the division information returned.
Thanks, John Carnell Manager, Developer Engagement
Jaime_Perez | 2022-05-20 18:42:30 UTC | #3
Hi @John_Carnell! Thanks for the information. Do you know if there is a Genesys Cloud - Custom Data action configured already that I can use? Or, do you have an example of one that you can share?
John_Carnell | 2022-05-20 19:03:04 UTC | #4
Hi Jamie,
I do not have one specifically for just retrieving a user and their division. Here is one you could use as an example for retrieving user presence. You could probably modify it to get user division. I hope this helps. I can ping my team and see if anyone has some bandwidth to try and put one together for user division. Can't promise anything, but let me see what I can do.
Thanks, John Carnell Manager, Developer Engagement
` { "name": "Get User Presence - Exported 2022-05-20 @ 15:00", "integrationType": "purecloud-data-actions", "actionType": "static", "config": { "request": { "requestUrlTemplate": "/api/v2/users/${input.USER_ID}/presences/PURECLOUD", "requestType": "GET", "headers": { "UserAgent": "PureCloudIntegrations/1.0", "Content-Type": "application/x-www-form-urlencoded" }, "requestTemplate": "${input.rawRequest}" }, "response": { "translationMap": { "presence": "$.presenceDefinition.systemPresence" }, "translationMapDefaults": {}, "successTemplate": "{\n \"presence\": ${presence}\n}" } }, "contract": { "input": { "inputSchema": { "$schema": "http://json-schema.org/draft-04/schema#", "title": "UserIdRequest", "description": "A user ID-based request.", "type": "object", "required": [ "USER_ID" ], "properties": { "USER_ID": { "type": "string", "description": "The user ID." } } } }, "output": { "successSchema": { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Get User Presence Response", "description": "Returns a user’s presence.", "type": "object", "properties": { "presence": { "type": "string", "title": "Presence", "description": "The user’s presence, which indicates whether the user can be reached." } } } } }, "secure": false }`
Jaime_Perez | 2022-05-20 19:17:36 UTC | #5
Thank you @John_Carnell! If they can put one together, that would be helpful. I'll look at the one you shared as well and attempt to modify it on Monday. I appreciate the support! Have a good weekend.
charaf_ch | 2022-05-23 11:11:49 UTC | #6
Hi @Jaime_Perez ,
Below you find a Data Action I built that retrieves the division based on a user ID given as an input.
{ "name": "Get User Division, "integrationType": "purecloud-data-actions", "actionType": "custom", "config": { "request": { "requestUrlTemplate": "/api/v2/users?id=${input.USERID}&expand=division", "requestType": "GET", "headers": {}, "requestTemplate": "${input.rawRequest}" }, "response": { "translationMap": { "Division": "entities[0].division.name" }, "translationMapDefaults": { "Division": "\"\"" }, "successTemplate": "{\"Division\": ${Division}}" } }, "contract": { "input": { "inputSchema": { "type": "object", "properties": { "USERID": { "type": "string" } }, "additionalProperties": true } }, "output": { "successSchema": { "type": "object", "properties": { "Division": { "type": "string" } }, "additionalProperties": true } } }, "secure": false }
I hope that helps :slight_smile:
Kind Regards,
Charaf
Jaime_Perez | 2022-05-23 12:26:16 UTC | #7
Good morning @charaf_ch, thank you for putting this together and sharing. I will review and let you know if I run into any issues. I appreciate it!
John_Carnell | 2022-05-23 12:54:06 UTC | #8
Hi @Charaf,
Thanks so much for contributing. I am going to open a ticket and have this data action definition added to your new CX as Code remote module repository.
Thanks again for contributing, John Carnell
Jaime_Perez | 2022-05-23 16:08:16 UTC | #9
@JohnCarnell & @charafch, the data action works. I'm pulling the Agent ID first using the conversation attributes. Then, I am running the data action @charaf_ch shared and it works perfectly. I appreciate the help!
charaf_ch | 2022-05-25 12:52:52 UTC | #10
I'm glad that works for you :slight_smile:
Kind Regards,
Jaime_Perez | 2022-05-31 13:58:55 UTC | #11
@charafch, @JohnCarnell - The data action is working but we are running into an issue when a call is not answered by the first agent. Is there a way to return the last Agent ID when there are multiple Agents in the conversation?
John_Carnell | 2022-06-02 15:04:52 UTC | #12
Hi Jaime,
Sorry I needed a couple of days to talk with a few other devs. At this point if you want to find the last agent your best bet is to:
- Write your own rest service or lambda. If you have an AWS account, I would personally go with a Lambda. A simple Python or Go-based Lambda can save you a significant amount of time trying to bang your head trying to figure out how to do something in Velocity.
- Pass the conversation id of the call in and grab all of the participants via the conversations API, filter out everyone but the agents and then sort by date the last agent talked to and return the agent id from the Lambda call.
- Data actions are good at pulling apart a REST endpoint and grabbing data, but become extremely complicated once you start drilling down on a complex call and performing sorting and filtering actions.
I know you were hoping for a simpler solution, but I think this is the one you are going to need to look at.
Thanks, John Carnell Manager, Developer Engagement
system | 2022-07-03 15:05:14 UTC | #13
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 14826