Historical Adherence and Websockets

Are there any examples about how to setup/connect a websocket to allow utilizing Notification Api. I am trying to get historical adherence data to track Agents queue status, and I have no been able to do this properly. I also cant find what the endpoint would be for connecting to genesys cloud if that makes sense.

If there is a method that does not require having to use a websocket to get notifications for Historical Data, that would be a great alternative.

See the front page of the SDK docs in the Using NotificationHandler for documentation and code examples: https://developer.genesys.cloud/devapps/sdk/docexplorer/pureclouddotnet/#notificationhandler-helper-class. There's also a guide User Presence with Notifications Guide that demonstrates this. It's only in Java and JavaScript, but the principles are the same regardless of the implementation language. https://developer.genesys.cloud/useragentman/presence/user-presence-guide

Do you mean the API hostname? Documented per region here: https://developer.genesys.cloud/platform/api/ and for the SDK here: https://developer.genesys.cloud/devapps/sdk/docexplorer/pureclouddotnet/#setting-the-environment.

See the Analytics documentation https://developer.genesys.cloud/analyticsdatamanagement/analytics/

thank you for all the replies. One concern I have is that I can't add subscriptions using my user account. I am authenticating myself using Client ID and Secret Password, and per the NotificationHandler guide I need to use my user account id. I receive this error when I call the usersApi.GetUsersMe() method.

"This request requires a user context. Client credentials cannot be used for requests to this resource"

Popping in to add:
There is a tutorial here for getting historical adherence and subscribing to the notifications. Notifications are the preferred way for getting historical adherence data as it doesn't rely on inefficient polling. However, there is also now a GET route that you can hit to fetch the result should you miss the notification here.

Separately there is a new "bulk" historical adherence route here if you don't need agent actuals. The only significant difference in the process is the notification topic is different (v2.users.{requestingUserId}.workforcemanagement.adherence.historical.bulk) and the route to fetch results if you miss the completion notification is documented here

Note for topic subscriptions if you're subscribing via an oauth client rather than directly as a logged in user, you'll just substitute the oauth client ID for the user ID in either of the adherence topics.

So I did actually use that java version and converted it to C# to work but Im running into the problem of add a subscription for a user to the notification handler.

I replaced the oauth client with the user id I want to run the report on, but I am getting this error

GetAgentAdherence() Error :: PureCloudPlatform.Client.V2.Client.ApiException: Error calling PostNotificationsChannelSubscriptions: {"message":"Subscriptions to topic [v2.users.[UserID].workforcemanagement.historicaladherencequery] are restricted to the target user
only.

Is this because the AuthTokenInfo was created using the client id/secret password?

Sorry if I wasn't clear.
The user ID in the topic has to either be your user ID (if you're logged in and authorized) or the oauth client ID of the client attempting to subscribe. IE, current logged in user/oauth client for the session. The notifications are designed to be delivered only to the person or client making the initial request.

So to summarize: You subscribe with current userID or client ID.
The request body that you send on your initial request controls which agent or agents you get back in the response.
Let me know if you need more clarification

ahh now I understand what you're saying. I would have to use the client id, because I use client id/secret pass for getting a token. There is no "user id" using this method

1 Like

Correct, when operating in the context of an oauth client's token there is no "requesting user", just a "requesting oauth client". However in this specific case the two can be conflated. The userId(s) you want to actually report on you specify in the request body, the subscription is who the report is delivered to. And for accesss control reasons, you can only subscribe to your own userID/clientID

So I have successfully been able to get the downloadUrls but I am having issues trying toextract that data from the AWS link. When I try to download link its coming back as these characters. Is there some specific way I need to do this?

Im trying methods like this and Im still getting that result

var response = await httpClient.GetAsync(url).ConfigureAwait(false);
response.EnsureSuccessStatusCode();
var json = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

"\u001f�\b\0\0\0\0\0\0��T���0\u0010�\u0017��ʀ�1�j����j�$����\u001e\u0012�Ď�I\u001bE��\u001aإ�n��'��{o�\a�\u0004mh�����\u0018��B���j�%�h!APθ�xUk!\u0004�\u0011\u0003\u0001H��L�\u0016�@T�1Ȅ��\b\u0017\u0015�20\u0014Q�\IȌ���\a\vk�NJKۄ��S#�h\n\+ʍ�)HYQ���b\f�byd�\u0001|������4�,�\t[�I��2�ߥ��\u0016ah�KP�\n��\u000f�C�,�ֺ\u001f����x\b��\u000f�v�ڪ7y���7�\u001d�����S]�\u0018�؇ٌ�٠G�q�7h�\u001dN\u0019������νס�ݔ�\u001a�s�\r\u007f��;\u000f�s\u0002�F��Y3FڧJ�h�a�ˡȟ�T�<�̮�\u001a���7Q䙼��S�\u007fY�'�p��{�9�/�.r�Ο"\u007fᡱ�]O��?��\u001e�~T��m�ð��ym��NV⚾\bJ���:n���/\u001dv����\r�^㺶Poj/-\u001c��A�Û�B]�.r��e�\u000f{��|�^\r�\u001f�9Σ$U^�BhNs\u001d\u007f\u0011�\u0006E\u0001�\u0004�*�\n&��\f䈾��@���\v��\r5�\u0004\0\0"

Progress! The data coming back from the download URL should include the content-encoding:gzip header, . Most browsers will automatically expand the gzip-encoded data, but you may have to configure your code to do so.

Once you've decoded the data you can deserialize the string into the schema provided in the SDK for the historical adherence route you called (the schema contains the appropriate object for that purpose).

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