msladecek | 2021-03-18 13:57:24 UTC | #1
Summary
Hello, I'm trying to capture changes in agents' presence and routing statuses in real time.
For this purpose, I consume messages from the notifications api. I subscribe to the topic v2.users.{id}.activity for each user.
The description of this topic (from GET /api/v2/notifications/availabletopics?expand=description):
...
{
"description": "Notification for changes to routing, presence, out of office, and active queues for a queue member",
"id": "v2.users.{id}.activity"
},
...
The messages from this topic obtain presence and routingStatus info, and based on the description, I assumed I would be notified whenever either presence or routingStatus of a particular user changes, but it seems that only presence changes actually trigger messages on this topic.
I believe I should be able to work around this using a combination of v2.users.{id}.presence and v2.users.{id}.routingStatus, I'm posting here mainly to check if this is a bug or intended behaviour.
Example
Initial state
Status via api
GET /api/v2/users/d556b969-bcfd-4758-8458-264cb22b543b?expand=presence,routingStatus
{
"id": "d556b969-bcfd-4758-8458-264cb22b543b",
"department": "developer",
...
"version": 19,
"routingStatus": {
"status": "OFF_QUEUE",
"startTime": "2021-03-18T13:12:09.764Z"
},
"presence": {
"source": "PURECLOUD",
"presenceDefinition": {
"id": "6a3af858-942f-489d-9700-5f9bcdcdae9b",
"systemPresence": "Available",
"selfUri": "/api/v2/presencedefinitions/6a3af858-942f-489d-9700-5f9bcdcdae9b"
},
"message": "",
"modifiedDate": "2021-03-18T13:12:09.745Z"
},
...
}
Cycle status "Available" -> "Meal" -> "Available"
Messages on websocket channel
v2.users.d556b969-bcfd-4758-8458-264cb22b543b.activity
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.activity",
"metadata": {
"CorrelationId": "bb735d61-82a8-450a-97a4-bfefbac24f5f"
},
"eventBody": {
"routingStatus": {
"status": "OFF_QUEUE",
"startTime": "2021-03-18T13:12:09.764Z"
},
"presence": {
"presenceMessage": "",
"presenceDefinition": {
"systemPresence": "MEAL",
"id": "3fd96123-badb-4f69-bc03-1b1ccc6d8014"
},
"modifiedDate": "2021-03-18T13:15:48.785Z"
},
"outOfOffice": {
"modifiedDate": "2018-07-18T12:39:32.451Z",
"active": false
},
"id": "d556b969-bcfd-4758-8458-264cb22b543b",
"dateActiveQueuesChanged": "2021-03-18T13:10:05.274Z",
"activeQueueIds": [
"29018a15-b04a-4107-b730-e3cefd834c20",
"8996298c-5fac-488f-af2f-faa2ec723dfe"
]
}
}
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.activity",
"metadata": {
"CorrelationId": "7ec97c35-574b-41e6-841c-43b8a00a7567"
},
"eventBody": {
"routingStatus": {
"status": "OFF_QUEUE",
"startTime": "2021-03-18T13:12:09.764Z"
},
"presence": {
"presenceMessage": "",
"presenceDefinition": {
"systemPresence": "AVAILABLE",
"id": "6a3af858-942f-489d-9700-5f9bcdcdae9b"
},
"modifiedDate": "2021-03-18T13:15:59.841Z"
},
"outOfOffice": {
"modifiedDate": "2018-07-18T12:39:32.451Z",
"active": false
},
"id": "d556b969-bcfd-4758-8458-264cb22b543b",
"dateActiveQueuesChanged": "2021-03-18T13:10:05.274Z",
"activeQueueIds": [
"29018a15-b04a-4107-b730-e3cefd834c20",
"8996298c-5fac-488f-af2f-faa2ec723dfe"
]
}
}
Nothing strange here, one message per presence transition, routingStatus stays "OFF_QUEUE" as expected.
Switch to "On Queue"
Messages on websocket channel
v2.users.d556b969-bcfd-4758-8458-264cb22b543b.activity
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.activity",
"metadata": {
"CorrelationId": "7ad41261-b658-4fe1-995b-4f71190d1b10"
},
"eventBody": {
"routingStatus": {
"status": "OFF_QUEUE",
"startTime": "2021-03-18T13:12:09.764Z"
},
"presence": {
"presenceMessage": "",
"presenceDefinition": {
"systemPresence": "ON_QUEUE",
"id": "e08eaf1b-ee47-4fa9-a231-1200e284798f"
},
"modifiedDate": "2021-03-18T13:18:36.213Z"
},
"outOfOffice": {
"modifiedDate": "2018-07-18T12:39:32.451Z",
"active": false
},
"id": "d556b969-bcfd-4758-8458-264cb22b543b",
"dateActiveQueuesChanged": "2021-03-18T13:10:05.274Z",
"activeQueueIds": [
"29018a15-b04a-4107-b730-e3cefd834c20",
"8996298c-5fac-488f-af2f-faa2ec723dfe"
]
}
}
Message indicates that presence was modified, but routingStatus was not. No additional messages were received.
Status via api
GET /api/v2/users/d556b969-bcfd-4758-8458-264cb22b543b?expand=presence,routingStatus
{
"id": "d556b969-bcfd-4758-8458-264cb22b543b",
"department": "developer",
...
"version": 19,
"routingStatus": {
"status": "IDLE",
"startTime": "2021-03-18T13:18:36.230Z"
},
"presence": {
"source": "PURECLOUD",
"presenceDefinition": {
"id": "e08eaf1b-ee47-4fa9-a231-1200e284798f",
"systemPresence": "On Queue",
"selfUri": "/api/v2/presencedefinitions/e08eaf1b-ee47-4fa9-a231-1200e284798f"
},
"message": "",
"modifiedDate": "2021-03-18T13:18:36.213Z"
},
...
}
This indicates that routingStatus changed to "IDLE" shortly after presence was updated. I was not notified about the routingStatus change on the v2.users.{id}.activity topic.
Cycle status "On Queue" -> "Meal" -> "Available"
Messages on websocket channel
v2.users.d556b969-bcfd-4758-8458-264cb22b543b.activity
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.activity",
"metadata": {
"CorrelationId": "f1bd3605-30e0-4b6f-880e-b29281ca3f3d"
},
"eventBody": {
"routingStatus": {
"status": "IDLE",
"startTime": "2021-03-18T13:18:36.230Z"
},
"presence": {
"presenceMessage": "",
"presenceDefinition": {
"systemPresence": "MEAL",
"id": "3fd96123-badb-4f69-bc03-1b1ccc6d8014"
},
"modifiedDate": "2021-03-18T13:21:05.283Z"
},
"outOfOffice": {
"modifiedDate": "2018-07-18T12:39:32.451Z",
"active": false
},
"id": "d556b969-bcfd-4758-8458-264cb22b543b",
"dateActiveQueuesChanged": "2021-03-18T13:10:05.274Z",
"activeQueueIds": [
"29018a15-b04a-4107-b730-e3cefd834c20",
"8996298c-5fac-488f-af2f-faa2ec723dfe"
]
}
}
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.activity",
"metadata": {
"CorrelationId": "56ed7a15-ec54-44a2-989d-e216b846e1cc"
},
"eventBody": {
"routingStatus": {
"status": "OFF_QUEUE",
"startTime": "2021-03-18T13:21:05.301Z"
},
"presence": {
"presenceMessage": "",
"presenceDefinition": {
"systemPresence": "AVAILABLE",
"id": "6a3af858-942f-489d-9700-5f9bcdcdae9b"
},
"modifiedDate": "2021-03-18T13:21:07.645Z"
},
"outOfOffice": {
"modifiedDate": "2018-07-18T12:39:32.451Z",
"active": false
},
"id": "d556b969-bcfd-4758-8458-264cb22b543b",
"dateActiveQueuesChanged": "2021-03-18T13:10:05.274Z",
"activeQueueIds": [
"29018a15-b04a-4107-b730-e3cefd834c20",
"8996298c-5fac-488f-af2f-faa2ec723dfe"
]
}
}
Once again cycling statuses to observe the behavior of the notification channel. These messages confirm that the routingStatus changes don't trigger messages on the v2.users.{id}.activity topic, so the routingStatus data from it may at any point be one update behind.
msladecek | 2021-03-18 15:27:19 UTC | #2
I believe I should be able to work around this using a combination of v2.users.{id}.presence and v2.users.{id}.routingStatus , I'm posting here mainly to check if this is a bug or intended behaviour.
Actually I'm having trouble with this now also. There seems to be some strange behavior when I'm subscribed to both v2.users.{id}.presence and v2.users.{id}.routingStatus.
I'm not receiving the routingStatus messages when subscribed to both.
Example
Cycling "On Queue" and "Off Queue" switch in the top right of the purecloud page (twice)
Subscribed only to v2.users.d556b969-bcfd-4758-8458-264cb22b543b.routingStatus
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.routingStatus",
"metadata": {
"CorrelationId": "b0ecd4ba-1549-460b-a053-b85a0b77c5db"
},
"eventBody": {
"routingStatus": {
"status": "OFF_QUEUE",
"startTime": "2021-03-18T15:13:50.231Z"
},
"id": "d556b969-bcfd-4758-8458-264cb22b543b"
}
}
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.routingStatus",
"metadata": {
"CorrelationId": "86a7f62a-0d6a-44d7-9073-46eec1972f42"
},
"eventBody": {
"routingStatus": {
"status": "IDLE",
"startTime": "2021-03-18T15:13:50.829Z"
},
"id": "d556b969-bcfd-4758-8458-264cb22b543b"
}
}
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.routingStatus",
"metadata": {
"CorrelationId": "fc892543-0a0e-40e5-994c-be8613023052"
},
"eventBody": {
"routingStatus": {
"status": "OFF_QUEUE",
"startTime": "2021-03-18T15:13:51.627Z"
},
"id": "d556b969-bcfd-4758-8458-264cb22b543b"
}
}
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.routingStatus",
"metadata": {
"CorrelationId": "f5ecf748-70c2-4071-ba38-759424fdc5b6"
},
"eventBody": {
"routingStatus": {
"status": "IDLE",
"startTime": "2021-03-18T15:13:52.358Z"
},
"id": "d556b969-bcfd-4758-8458-264cb22b543b"
}
}
All as expected
Subscribed only to v2.users.d556b969-bcfd-4758-8458-264cb22b543b.presence
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.presence",
"metadata": {
"CorrelationId": "c746671f-a01b-45ef-a3d0-6a78a73fab23"
},
"eventBody": {
"source": "PURECLOUD",
"primary": true,
"presenceDefinition": {
"systemPresence": "AVAILABLE",
"id": "6a3af858-942f-489d-9700-5f9bcdcdae9b"
},
"modifiedDate": "2021-03-18T15:16:11.015Z",
"message": ""
}
}
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.presence",
"metadata": {
"CorrelationId": "a7ed6ec3-f6a2-474f-aba7-04fa9e97c2bb"
},
"eventBody": {
"source": "PURECLOUD",
"primary": true,
"presenceDefinition": {
"systemPresence": "ON_QUEUE",
"id": "e08eaf1b-ee47-4fa9-a231-1200e284798f"
},
"modifiedDate": "2021-03-18T15:16:12.110Z",
"message": ""
}
}
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.presence",
"metadata": {
"CorrelationId": "625160db-c556-45c3-83c6-a8c57c9864e1"
},
"eventBody": {
"source": "PURECLOUD",
"primary": true,
"presenceDefinition": {
"systemPresence": "AVAILABLE",
"id": "6a3af858-942f-489d-9700-5f9bcdcdae9b"
},
"modifiedDate": "2021-03-18T15:16:12.948Z",
"message": ""
}
}
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.presence",
"metadata": {
"CorrelationId": "e41660ee-d30b-4093-aa8d-3a08a6d987da"
},
"eventBody": {
"source": "PURECLOUD",
"primary": true,
"presenceDefinition": {
"systemPresence": "ON_QUEUE",
"id": "e08eaf1b-ee47-4fa9-a231-1200e284798f"
},
"modifiedDate": "2021-03-18T15:16:13.841Z",
"message": ""
}
}
All as expected
Subscribed to both v2.users.{id}.presence and v2.users.{id}.routingStatus
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.presence",
"metadata": {
"CorrelationId": "9422693e-45b4-40bf-82fb-05c5427d4e01"
},
"eventBody": {
"source": "PURECLOUD",
"primary": true,
"presenceDefinition": {
"systemPresence": "AVAILABLE",
"id": "6a3af858-942f-489d-9700-5f9bcdcdae9b"
},
"modifiedDate": "2021-03-18T15:19:52.009Z",
"message": ""
}
}
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.presence",
"metadata": {
"CorrelationId": "98f0ec82-f6cd-4a65-bda1-fa65c0c45ad6"
},
"eventBody": {
"source": "PURECLOUD",
"primary": true,
"presenceDefinition": {
"systemPresence": "ON_QUEUE",
"id": "e08eaf1b-ee47-4fa9-a231-1200e284798f"
},
"modifiedDate": "2021-03-18T15:19:52.596Z",
"message": ""
}
}
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.presence",
"metadata": {
"CorrelationId": "22a97932-8760-4269-a6e8-a0872c196e32"
},
"eventBody": {
"source": "PURECLOUD",
"primary": true,
"presenceDefinition": {
"systemPresence": "AVAILABLE",
"id": "6a3af858-942f-489d-9700-5f9bcdcdae9b"
},
"modifiedDate": "2021-03-18T15:19:53.184Z",
"message": ""
}
}
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.presence",
"metadata": {
"CorrelationId": "4e6b085c-aa90-47de-b584-99341dc53644"
},
"eventBody": {
"source": "PURECLOUD",
"primary": true,
"presenceDefinition": {
"systemPresence": "ON_QUEUE",
"id": "e08eaf1b-ee47-4fa9-a231-1200e284798f"
},
"modifiedDate": "2021-03-18T15:19:53.780Z",
"message": ""
}
}
Only v2.users.d556b969-bcfd-4758-8458-264cb22b543b.presence events were received.
Subscribed to both using the combined topic v2.users.d556b969-bcfd-4758-8458-264cb22b543b?presence&routingStatus
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.presence",
"metadata": {
"CorrelationId": "94e2e02c-7ab0-4bc7-8e1e-ce74b6304a89"
},
"eventBody": {
"source": "PURECLOUD",
"primary": true,
"presenceDefinition": {
"systemPresence": "AVAILABLE",
"id": "6a3af858-942f-489d-9700-5f9bcdcdae9b"
},
"modifiedDate": "2021-03-18T15:22:57.014Z",
"message": ""
}
}
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.presence",
"metadata": {
"CorrelationId": "985ed738-452f-4126-82ba-b29205ceeb0b"
},
"eventBody": {
"source": "PURECLOUD",
"primary": true,
"presenceDefinition": {
"systemPresence": "ON_QUEUE",
"id": "e08eaf1b-ee47-4fa9-a231-1200e284798f"
},
"modifiedDate": "2021-03-18T15:22:57.760Z",
"message": ""
}
}
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.presence",
"metadata": {
"CorrelationId": "878b244a-325c-475c-9596-ba35f034f5eb"
},
"eventBody": {
"source": "PURECLOUD",
"primary": true,
"presenceDefinition": {
"systemPresence": "AVAILABLE",
"id": "6a3af858-942f-489d-9700-5f9bcdcdae9b"
},
"modifiedDate": "2021-03-18T15:22:58.514Z",
"message": ""
}
}
{
"version": "2",
"topicName": "v2.users.d556b969-bcfd-4758-8458-264cb22b543b.presence",
"metadata": {
"CorrelationId": "d3889212-9997-46ef-89a3-0a3dbc76c74c"
},
"eventBody": {
"source": "PURECLOUD",
"primary": true,
"presenceDefinition": {
"systemPresence": "ON_QUEUE",
"id": "e08eaf1b-ee47-4fa9-a231-1200e284798f"
},
"modifiedDate": "2021-03-18T15:22:59.324Z",
"message": ""
}
}
Still only presence events, no routingStatus events.
msladecek | 2021-03-18 15:37:33 UTC | #3
Actually, disregard this whole thing, the issue was in my application code (misuse of metadata.CorrrelationId.
I was running multiple concurrent websocket connections for the same topics to have some redundancy and I was deduplicating the messages based on metadata.CorrelationId. Turns out the activity topic will in fact produce two messages for each change, one for presence and another for routingStatus, but due to the deduplication, the routingStatus one was thrown away.
The issue described in my second comment was caused by the same thing.
Sorry for the noise.
system | 2021-04-18 15:37:33 UTC | #4
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: 10327