I’m trying to pull CSAT survey responses that are tied to specific interactions using the Genesys Cloud Quality API. The goal is to get the survey score and comments for a batch of conversation IDs we’ve flagged for review. We’ve got a Python script that first fetches the interaction details via /api/v2/analytics/conversations/details/query to get the externalConversationId and then tries to query the Quality API.
Here’s the basic flow in the code:
import requests
headers = {
'Authorization': f'Bearer {access_token}',
'Content-Type': 'application/json'
}
# Query Quality API for survey responses
payload = {
"dateFrom": "2024-01-01T00:00:00.000Z",
"dateTo": "2024-01-02T00:00:00.000Z",
"filter": {
"type": "survey",
"surveyType": "csat"
},
"groupBy": []
}
response = requests.post(
'https://api.mypurecloud.com/api/v2/analytics/conversations/details/query',
headers=headers,
json=payload
)
The issue is that even when I know for a fact that a CSAT survey was submitted for an interaction, the Quality API returns an empty results array. I’ve double-checked the date ranges and the surveyType parameter. I also tried using the /api/v2/quality/evaluations endpoint with a specific interaction ID filter, but that only returns manual QA evaluations, not the automated CSAT scores.
Is there a specific field I need to include in the filter to link the survey response back to the interaction? Or am I looking at the wrong endpoint entirely? The documentation mentions that survey results are part of the analytics data, but it’s not clear how to join them with the interaction metadata. We’re seeing a 200 OK response, just no data. It feels like the survey responses are stored in a different bucket or require a different query structure. Any pointers on how to structure this request correctly?
You’re likely running into a timing gap or a scope mismatch. The Quality API doesn’t always link the externalConversationId directly in the survey response payload the way you might expect, especially if the survey was triggered after the interaction closed.
The trick is to query the survey responses by externalInteractionId specifically, but you have to make sure the interaction has actually been processed into the Quality domain. There’s often a 15-30 minute lag. If you’re querying immediately after the call, you’ll get empty results.
Here’s how I structure the query in Python using the SDK. You need to use SurveyResponseQuery and filter by externalInteractionId.
from purecloudplatformclientv2 import QualityApi, SurveyResponseQuery, SurveyResponseFilter
quality_api = QualityApi(configuration=platform_client.configuration)
# Assuming you have a list of external IDs from your analytics query
external_ids = ["conv-123", "conv-456"]
# Build the filter
survey_filter = SurveyResponseFilter()
survey_filter.external_interaction_id = external_ids
# Set up the query
query = SurveyResponseQuery()
query.filter = survey_filter
# Execute
try:
result = quality_api.post_quality_surveys_responses_query(query)
print(f"Found {len(result.entities)} responses")
for response in result.entities:
print(f"Score: {response.score}, Comment: {response.comment}")
except Exception as e:
print(f"Error: {e}")
If you’re still getting nothing, check the surveyResponseId on the interaction details first. Sometimes the link is stored there, and you can fetch the individual response by ID instead of querying the batch. Also, verify that the survey is actually configured to link to the interaction. If it’s a generic post-interaction survey without the interaction binding enabled in Architect, the externalInteractionId won’t be populated in Quality.
Make sure your OAuth token has the quality:response:read scope. Missing that scope usually returns an empty array rather than a 403, which is annoying.