Legacy Dev Forum Posts

 View Only

Sign Up

How to get call transcript in a browser?

  • 1.  How to get call transcript in a browser?

    Posted 06-05-2025 18:25

    LighthouseMike | 2023-05-04 17:54:33 UTC | #1

    Hey again,

    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 :smiley:). 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 (:laughing:). 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 :laughing: ).

    EDIT: I just found this. So at this point my best guess is that the process is as follows:

    1. Subscribe to that notification.
    2. Request the transcript URL.
    3. Something in that request tells something on the Genesys back-end that it should send info in a notification.
    4. The notification callback will receive and handle the transcript.

    Getting warmer?


    LighthouseMike | 2023-05-10 14:48:27 UTC | #2

    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 :laughing:). 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);
    		}
    	});
    }

    tim.smith | 2023-05-10 14:53:51 UTC | #3

    LighthouseMike, post:1, topic:19749
    CORS

    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.


    LighthouseMike | 2023-05-10 14:58:52 UTC | #4

    Will do! I have a meeting here shortly, but I'll rework my code to show the error again and get u that info. Thanks for the quick response! :smiley:


    LighthouseMike | 2023-05-10 15:22:54 UTC | #5

    URL: https://prod-us-west-2-transcript.s3.us-west-2.amazonaws.com…478a3f3b550b0127e6729bf1d4a34cd822a76c0c9d0e99a04f0ca6aa24af

    Error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://prod-us-west-2-transcript.s3.us-west-2.amazonaws.com/transcriptsCache/4408a8d1-78f0-43f2-adc4-df8bb82f8499/3526458a-4cb9-4f69-bb5b-cc0cdb262322/884687b3-12b6-4dca-a67a-d5997b9e781b-transcripts?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEHcaCXVzLXdlc3QtMiJHMEUCIQCo8dmeMR0nGZSwxFjcZyuYwHnhST5VyurIF%2FaGocAREDACT-SENSITIVE-INFORMATION-PLEASE!!!!!2FQv2&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230510T151550Z&X-Amz-SignedHeaders=host&X-Amz-Expires=600&X-Amz-Credential=ASIA3EQYLGB7VWBKEQVT%2F20230510%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Signature=REDACT-SENSITIVE-INFORMATION-PLEASE. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200

    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.


    tim.smith | 2023-05-10 15:21:51 UTC | #6

    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.


    system | 2023-06-10 15:21:56 UTC | #7

    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: 19749