Requesting help with downloading Transcripts

I'm obviously making noob mistake here and requesting to point me in the right direction. I'm trying to download Transcripts using the below script

import PureCloudPlatformClientV2
from PureCloudPlatformClientV2.rest import ApiException
from pprint import pprint
import os

os.environ['GENESYS_CLOUD_CLIENT_ID'] = "client_id"
os.environ['GENESYS_CLOUD_CLIENT_SECRET'] = "client_secret"

region = PureCloudPlatformClientV2.PureCloudRegionHosts.eu_central_1
PureCloudPlatformClientV2.configuration.host = region.get_api_host()
apiclient = PureCloudPlatformClientV2.api_client.ApiClient().get_client_credentials_token(os.environ['GENESYS_CLOUD_CLIENT_ID'], os.environ['GENESYS_CLOUD_CLIENT_SECRET'])

api_instance = PureCloudPlatformClientV2.SpeechTextAnalyticsApi()
conversation_id = 'conversation_id'
communication_id = 'communication_id'

try:
# Get the pre-signed S3 URL for the transcript of a specific communication of a conversation
api_response = api_instance.get_speechandtextanalytics_conversation_communication_transcripturl(
conversation_id, communication_id)
pprint(api_response)
except ApiException as e:
print("Exception when calling GetSpeechandtextanalyticsConversationCommunicationTranscripturlRequest->get_speechandtextanalytics_conversation_communication_transcripturl: %s\n" % e)

It gives the below error.

Exception when calling GetSpeechandtextanalyticsConversationCommunicationTranscripturlRequest->get_speechandtextanalytics_conversation_communication_transcripturl: (401)
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Content-Length': '201', 'Connection': 'keep-alive', 'Date': 'Wed, 15 Mar 2023 11:45:04 GMT', 'ININ-Correlation-Id': '4916a5bc-b52a-4e8a-943c-9f1d949e7709', 'Strict-Transport-Security': 'max-age=600; includeSubDomains', 'Cache-Control': 'no-cache, no-store, must-revalidate', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 57de08f1507f15361979f2f024f6cb40.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'HYD50-C2', 'X-Amz-Cf-Id': 'fCVKsYE5sZJKT4Y59AGZJrR9yJMms8kqEWN0iLxZ-SNOGeBLpHpiFQ=='})
HTTP response body: {"message":"No authentication bearer token specified in authorization header.","code":"authentication.required","status":401,"contextId":"4916a5bc-b52a-4e8a-943c-9f1d949e7709","details":[],"errors":[]}

I tried understanding how Auth works but couldn't figure out. Would appreciate any and all help.

Check the code example here: https://developer.genesys.cloud/devapps/sdk/docexplorer/purecloudpython/#client-credentials-grant

You have to pass the API Client instance into your API instance like the example:

authApi = PureCloudPlatformClientV2.AuthorizationApi(apiclient)

as opposed to your example that passes nothing for the api client:

Using this line gives the no attribute error

Understood. Can you try it per the example I linked?

Thank you for quick response, Tim. I'm actually trying various things and it seemed to work when I use
api_instance = PureCloudPlatformClientV2.SpeechTextAnalyticsApi()
without passing anything in there.

Although, I have a new question, in spite of having Admin & other required roles, I get the below error when tried to generate the transcript URL

raise ApiException(http_resp=r)

PureCloudPlatformClientV2.rest.ApiException: (403)
Reason: Forbidden
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Content-Length': '682', 'Connection': 'keep-alive', 'Date': 'Wed, 15 Mar 2023 20:30:35 GMT', 'ININ-Correlation-Id': '3a181016-72ca-469a-a4a2-43b3f3b4ce02', 'Strict-Transport-Security': 'max-age=600; includeSubDomains', 'Cache-Control': 'no-cache, no-store, must-revalidate', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 c3c13380d1c5bf8586d7fd3d4dbe9502.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'HYD50-C2', 'X-Amz-Cf-Id': 'ZCC20exPlfoyMbeb87B9XBxFYNjhpCbT3nldEITMQwXEerrDZ8x9UQ=='})
HTTP response body: {"message":"An error has occurred, please contact support. Message: Forbidden: The user 9aae7ed2-bd45-4bd3-9c7d-1532a222c0ba from homeOrganizationId dcf8e475-80f7-4dd4-b187-4ffd0be48a9a do not have access to the conversation 0f9cceca-356f-4e13-b8a7-3c849b9cc0fb","code":"forbidden","status":403,"messageWithParams":"An error has occurred, please contact support. Message {message}","messageParams":{"message":"Forbidden: The user [my_user_id] from homeOrganizationId [ORG_ID] do not have access to the conversation 0f9cceca-356f-4e13-b8a7-3c849b9cc0fb"},"contextId":"3a181016-72ca-469a-a4a2-43b3f3b4ce02","details":[],"errors":[]}

What's interesting is, it does generate the transcript URL in the API explorer. Any silly mistake I'm doing here?

As the error states, the user you're using to make the request isn't allowed to access the conversation. Note that if you're using client credentials, there is no user so this is indeed accurate. If this is a user and you believe you should have access to the conversation, please open a case with Genesys Cloud Care to investigate.

There are some issues with the embedded examples. Best to follow the ones here as they actually match the source code: https://developer.genesys.cloud/devapps/sdk/docexplorer/purecloudpython/SpeechTextAnalyticsApi

Thank you for your help so far, Tim.

I want to be able to do the following items and I just know Python basics as of now.
Could you please suggest best way to approach it?

  1. Pull report of available queues
  2. Get conversation, communication IDs of all interactions and generate transcript URLs
  3. Finally, download the transcripts and store them in a readable format.

Would appreciate any and all advice.

Get a list of queues using GET /api/v2/routing/queues

Not sure exactly what you want from this, but look at the analytics APIs as well as filter API Explorer for the word "transcript" as there are a few categories with endpoints relating to transcripts.

Use GET /api/v2/speechandtextanalytics/conversations/{conversationId}/communications/{communicationId}/transcripturl

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