So I followed this tutorial (and then later went on to the docs) and I got the communication ID just fine (I saw a few posts about that so just thought I'd point out the links for people dealing w/that problem ). What I don't know is how to convert that URL into the data. That tutorial is for Node, which... I mean okay, if I were not running PHP on my server, it might be helpful, buuuut.... CORS kinda puts an epic Kai-Bosh on any attempt to just download from a URL. Makes sense in Node (or NW, or Electron) but not where most of us are running JavaScript (). Anyway, I went over the list of available API endpoints and couldn't find one equivalent - nothing that calls that URL, no SDK function like someObject.getDataAtURL etc... how exactly is this supposed to work? Another notification?
At this point, the only working theory I have is that maybe I'm supposed to shoot this URL over to PHP and have PHP run the Genesys CLI app (cuz cURL is not cursed by CORS ).
EDIT: I just found this. So at this point my best guess is that the process is as follows:
Subscribe to that notification.
Request the transcript URL.
Something in that request tells something on the Genesys back-end that it should send info in a notification.
The notification callback will receive and handle the transcript.
Still working different angles on depuzzling this. Found another page with info about how the notification works; though it looks like the notification might actually be specifically for getting transcripts for ongoing calls in near-real-time (which is awesome, but unrelated to what I'm trying to do ). So as I continue to hack'n'guess my way through this process, here is an example of what I have so far (for anyone else who is following this thread):
/**
* Gets the transcript for a conversation, if available
* @param {string} conversationID A 36-char UUID we got from Genesys
* @returns {Promise<object|null>} The data, or null if something goes wrong
* @remarks This resolves either way; yes I'm aware of the "reject" option, but
* I've seen it cause code to silently fail, which is annoying and not helpful.:D
* That vs. a simple if (someVariable == null) and I can handle it how I want.
* @examle var transcript = await getTranscript("your transcript ID");
*/
function getTranscript(conversationID) {
return new Promise(async function(resolve) {
try {
// Make sure I have permission to do this; note that this is unrelated to the
// main topic, so I won't explain my "canI" function here.
var allowed = await canI("conversation:transcription:view");
if (!allowed) {
// Currently falling into this if-statement; I've requested this permission from our
// Genesys admin, so once that's done I will update this post.
console.log("Sorry, I can't let you do that :)");
resolve(null);
return;
}
// Get the notification "channel"
var ch = await sys.notifications.postNotificationsChannels();
// Subscribe to that notification ("notifications" here is a platform.NotificationsApi object)
notifications.putNotificationsChannelSubscriptions(ch.id, [{ id: "v2.conversations." + conversationID + ".transcription" }]);
// Set up the event handler to give us the transcript when the notification is received
ws = new WebSocket(ch.connectUri);
ws.onmessage = async function(msg) {
// if (! it has the info I want) return; - haven't gotten here yet.
// That's to filter out "WebSocket heartbeat" and similar messages
resolve(msg);
ws.close();
};
} catch(wtf) {
console.error(wtf);
resolve(null);
}
});
}
Can you provide some details about where you're getting a CORS error? Showing the full URL you're attempting to retrieve, obscuring any private IDs or keys, will be helpful to know what's giving you the problem.
I can navigate there in my browser (pasting the URL into the address bar) but so far that has been literally the only way to see the transcript; I've played with all kinds of crazy ideas - iframes, PHP, etc. and nothing works. The only header passed in my Fetch request is the method - exactly as it appears in the docs. Now I could set access-control on the server-side... but from what I understand that is a for letting other domains request mine, not letting me request other domains.
Thanks for confirming the URL. This is a bug in the transcripts service as it needs to enable CORS support for web clients to be able to retrieve the content. Please open a case with Care to report this bug.
For a workaround, you will need to implement a proxy that can add the CORS headers you need to the response as it comes back to you; there's no way to work around CORS within the browser.