How to get the UserID based on the AgentId

Hi,

We are using the pure cloud JS sdk to connect our widget to the genesys chat.
We need to get the name of the agent that answered the chat conversation.

We currently get the agentID(memeberid for the agnet) at the start of the conversation, however this is not the same as the genesys user id.

We are trying to use https://developer.genesys.cloud/api/rest/client-libraries/javascript/UsersApi#getUser to get the agent name however we have no way to map the member id of the agent to the genesys user id. We already tested by copying the user id from genesys and the api is working.

So: how do we get the agent name for a conversation? Do we map the member id to userid and if so how or is there any other way?

Edit: fixed confusion between memberid and agentid

Thanks

Hello,

What do you mean by AgentID?
member.id in Guest Chat API, participantId in a conversation context (Conversations API), ...
I am asking as there is no attribute named agentID.

Regards,

by agent id i mean the member id of the agent. sorry for the confusion

You would have to retrieve the Conversation context (Platform API -> Conversations API) using a GET /api/v2/conversations/{conversationId} to get the conversation

NB: The conversationId corresponds to the id attribute you get in the response to the create chat (POST /api/v2/webchat/guest/conversations)

Once you have retrieved the conversation context (using GET /api/v2/conversations/{conversationId}), you can look for participant(s) with purpose attribute set to "agent" (in the participants attribute/array).
The memberId will appear in the chats array of a participant - it corresponds to the id of a chat (so you can select/find the right agent if multiple agents participated to the chat conversation).
The userId will be available in the participant object (that you can then leverage in the Users API to get the user).
Note that the name of the agent also appears in the participant structure (if this is all you need).

Regards,

1 Like

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