I'm happy to hear that the marshalling issue is fixed, and that you found more usable the tracingId
Original Message:
Sent: 04-25-2025 13:44
From: Benjamin Fowler
Subject: Web Messaging Java SDK 12.0: "tracingId" not exposed in most endpoints?
Thank you very much for your help Laurent!
I see that cloud.genesys:web-messaging-sdk:13.0.0 has been released. Thanks for that! You'll be happy to know that we've picked it up and tried it out and it not only now exposes `tracingId` in a more useful way, it also appears to have resolved the JSON marshalling issues we were seeing that broke marshalling of presence and typing events.
I do have a question about the API and how it's meant to work. Refer to the code snippet below:
- GenesysSessionListener exposes a set of callback methods to act on interesting outbound events, and we implement `presignedUrlResponse()`. The signature exposes the raw marshalled message itself and `presignedUrlResponse` is the object bound to the top-level `body` property. The `rawResponse` field is presumably included to give API users a way to access the entire message and not just the actual `PresignedUrlResponse` message itself.
- `PresignedUrlResponse` _and_ rawResponse both expose different `tracingId` fields. When I request an upload URL and get a response back, the _outer_ `tracingId` is populated, and not the inner one. Hence, I have to write a few more lines of code to extract the `tracingId` from the raw response.
I was wondering: is this meant to happen?
@Override public void presignedUrlResponse(PresignedUrlResponse presignedUrlResponse, String rawResponse) { // (this doesn't work) // final String attachmentId = presignedUrlResponse.getTracingId() final String attachmentId; final ObjectNode node; try { node = (ObjectNode) objectMapper.readTree(rawResponse); attachmentId = node.get("tracingId").asText(); } catch (JsonProcessingException e) { log.warn("Unable to parse tracingId out of Genesys presigned URL response", e); return; } if (!StringUtils.hasText(attachmentId)) { log.warn("This shouldn't happen.", customerContactId); return; } }
Here's what a sample raw message looks like -- note that the populated value for `tracingId` is _outside_ `body`:
{ "type": "response", "class": "PresignedUrlResponse", "code": 200, "body": { "attachmentid": "6877a231-2ec0-4976-b4a6-a11769d2f0e6", "headers": { "x-amz-tagging": "organizationId=REDACTED&originPlatform=PureCloud&role=foo&owner=Dev-CloudAppsFoo@genesys.com" }, "url": "https://fileupload.eu2.pure.cloud/webmessaging/uploads/REDACTED" }, "tracingId": "01966989-ca04-7c89-af63-eca465a602b6"}
Have a great weekend!
Cheers, Ben.
------------------------------
Benjamin Fowler
------------------------------
Original Message:
Sent: 04-04-2025 12:19
From: Laurent Rustuel
Subject: Web Messaging Java SDK 12.0: "tracingId" not exposed in most endpoints?
I now see more clearly what is missing for the tracingId thanks a lot.
For your workaround I have nothing more to add, if it works and let you go forward until we release a new version, then great.
Hopefuly this should be sorted out in coming weeks, the serialization problem still needs to be tracked down to a root cause
Regards,
Laurent
------------------------------
Laurent Rustuel
Lead Software Engineer
Original Message:
Sent: 04-04-2025 12:02
From: Benjamin Fowler
Subject: Web Messaging Java SDK 12.0: "tracingId" not exposed in most endpoints?
Hi Laurent,
I'm attempting to request a pre-signed upload URL using WebMessagingClient.attachment(String, String, String). See the method I'm invoking here:
https://github.com/MyPureCloud/web-messaging-sdk-java/blob/50728cce1740aa667298a41b92d5206d5d3fcc1c/build/src/main/java/cloud/genesys/webmessaging/sdk/WebMessagingClient.java#L552
Note the following:
- Per your documentation, the wire format _and_ the DTO class (GenerateUploadUrlRequest) support tracingId.
- The exposed attachment() method does not.
Since my last post, I came up with a reflection-based workaround against v9.0.0 of the API that is ugly and brittle, but works.
My code to send the upload URL request looks like the following:
/** * Re-implementation of GenesysClient.attachment() method to allow us to pass the tracingId * to the Genesys API. * * @param fileName upload filename * @param fileSize upload file size * @param fileType upload MIME type * @param tracingId Genesys tracing ID (correlation ID) * * FIXME: remove after Genesys fixes the API to support this. */ private void attachment(String fileName, int fileSize, String fileType, String tracingId) { final WebSocket webSocket; final String token; try { final Class<? extends WebMessagingClient> aClass = client.getClass(); final Field tokenField = aClass.getDeclaredField("token"); tokenField.setAccessible(true); token = (String) tokenField.get(client); final Field webSocketField = aClass.getDeclaredField("webSocket"); webSocketField.setAccessible(true); webSocket = (WebSocket) webSocketField.get(client); } catch (Exception e) { log.error("Failed to send attachment upload request to Genesys: failure to access required private WebMessagingClient internal state", e); return; } try { final GenerateUploadUrlRequest generateUploadUrlRequest = GenerateUploadUrlRequest.builder() // .token(token) // .action(RequestTypeGenerateUploadUrl.ONATTACHMENT) // .fileName(fileName) // .fileSize(fileSize) // .tracingId(tracingId) // .fileType(fileType) // .build(); final String payload = objectMapper.writeValueAsString(generateUploadUrlRequest); webSocket.sendText(payload, true); } catch (JsonProcessingException e) { log.warn("Failed to send attachment upload request to Genesys: failure to serialize JSON", e); } } /** * Request to Genesys to generate a presigned upload URL for the given attachment. * This is a re-implementation of the GenesysClient.attachment() method, but allows * us to pass the tracingId (correlation ID) to the Genesys API.<p> * * FIXME: remove after Genesys fixes the API to support this. */ @Data @Builder static class GenerateUploadUrlRequest implements Serializable { private RequestTypeGenerateUploadUrl action; private String token; private String attachmentId; private String tracingId; private String fileName; private String fileType; private Integer fileSize; private String fileMd5; }
My code to then read the response and extract the `tracingId` looks like the following:
@Override public void presignedUrlResponse(PresignedUrlResponse presignedUrlResponse, String rawResponse) { final String customerContactId = returnCustomerContactId(); // FIXME: "tracingId" (correlation ID) is not yet supported by the API, but _is_ supported // by the underlying messaging protocol. We hack around this by parsing the 'tracingId' // (CMC attachment ID) out of the raw response JSON. This is a temporary workaround until // Genesys fixes the API to support this. final ObjectNode node; final String cmcAttachmentId; try { node = (ObjectNode) objectMapper.readTree(rawResponse); cmcAttachmentId = node.get("tracingId").asText(); } catch (JsonProcessingException e) { log.warn("Unable to parse tracingId out of Genesys presigned URL response", e); return; } if (!StringUtils.hasText(cmcAttachmentId)) { log.warn("No CMC attachment ID found for customer contact ID [{}]. This shouldn't happen.", customerContactId); return; } // download file from attachments store // ...
There is a decent chance that I'm "holding it wrong" and that there is a way to feed a `tracingId` through the attachment() method, but I haven't spotted it yet.
Let me know what you think.
Thank you very much for your help -- much appreciated!
Cheers, Ben.
------------------------------
Benjamin Fowler
Original Message:
Sent: 04-03-2025 11:10
From: Laurent Rustuel
Subject: Web Messaging Java SDK 12.0: "tracingId" not exposed in most endpoints?
Hello Benjamin,
> just got a new `tracingId` field, but it's not exposed in the API yet.
I'm not sure to see where it's not exposed yet. Could you point me where you gathered this information ?
The documentation here https://developer.dev-genesys.cloud/commdigital/digital/webmessaging/websocketapi#request-a-presigned-url describe the "tracingId" for that request, as well as https://mypurecloud.github.io/web-messaging-sdk-java/GenerateUploadUrlRequest
Regards,
Laurent
------------------------------
Laurent Rustuel
Lead Software Engineer