Basutkar_Avinash | 2023-03-15 11:53:01 UTC | #1
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['GENESYSCLOUDCLIENTID'] = "clientid" os.environ['GENESYSCLOUDCLIENTSECRET'] = "clientsecret"
region = PureCloudPlatformClientV2.PureCloudRegionHosts.eucentral1 PureCloudPlatformClientV2.configuration.host = region.getapihost() apiclient = PureCloudPlatformClientV2.apiclient.ApiClient().getclientcredentialstoken(os.environ['GENESYSCLOUDCLIENTID'], os.environ['GENESYSCLOUDCLIENTSECRET'])
apiinstance = PureCloudPlatformClientV2.SpeechTextAnalyticsApi() conversationid = 'conversationid' communicationid = 'communication_id'
try:
Get the pre-signed S3 URL for the transcript of a specific communication of a conversation
apiresponse = apiinstance.getspeechandtextanalyticsconversationcommunicationtranscripturl( conversationid, communicationid) pprint(apiresponse) except ApiException as e: print("Exception when calling GetSpeechandtextanalyticsConversationCommunicationTranscripturlRequest->getspeechandtextanalyticsconversationcommunication_transcripturl: %s\n" % e)
It gives the below error.
Exception when calling GetSpeechandtextanalyticsConversationCommunicationTranscripturlRequest->getspeechandtextanalyticsconversationcommunicationtranscripturl: (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.
tim.smith | 2023-03-15 14:14:27 UTC | #2
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:
Basutkar_Avinash, post:1, topic:18917
api_instance = PureCloudPlatformClientV2.SpeechTextAnalyticsApi()
Basutkar_Avinash | 2023-03-15 20:26:59 UTC | #3
Using this line gives the no attribute error
tim.smith | 2023-03-15 20:33:18 UTC | #4
Understood. Can you try it per the example I linked?
Basutkar_Avinash | 2023-03-15 20:38:59 UTC | #5
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(httpresp=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 [myuserid] from homeOrganizationId [ORGID] 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?
tim.smith | 2023-03-15 20:41:06 UTC | #6
Basutkar_Avinash, post:5, topic:18917
"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,"
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.
tim.smith | 2023-03-15 20:45:13 UTC | #7
Basutkar_Avinash, post:3, topic:18917
no attribute error
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
Basutkar_Avinash | 2023-03-15 21:46:22 UTC | #8
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?
- Pull report of available queues
- Get conversation, communication IDs of all interactions and generate transcript URLs
- Finally, download the transcripts and store them in a readable format.
Would appreciate any and all advice.
tim.smith | 2023-03-16 15:58:17 UTC | #9
Basutkar_Avinash, post:8, topic:18917
Pull report of available queues
Get a list of queues using GET /api/v2/routing/queues
Basutkar_Avinash, post:8, topic:18917
Get conversation, communication IDs of all interactions and generate transcript URLs
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.
Basutkar_Avinash, post:8, topic:18917
Finally, download the transcripts and store them in a readable format.
Use GET /api/v2/speechandtextanalytics/conversations/{conversationId}/communications/{communicationId}/transcripturl
system | 2023-04-16 15:58:27 UTC | #10
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: 18917