I am trying to flatten out the response I get when running this api from VS code using Python.
I am having a hard time importing it into a Pandas Dataframe and am not sure how to approach this.
Currently I am only running this api with one QueueID, but in the future I will be exporting this data to a SQL table so that I can create a dashboard off of it and will need a more tabular view of all QueueIDs for a given date range.
I am new to Python, has anyone else encountered this issue?
Below is the Python I am running to pull data from the api:
def conversation_aggregates_get_interval_string():
# Gets an ISO-8601 interval from now for the last x days
now = datetime.now().replace(microsecond=0)
week_ago = (now - timedelta(days=7)).replace(microsecond=0)
return f"{ week_ago.isoformat() }/{ now.isoformat() }"
print("----------------------------------------------------------------------------------")
print("- Querying Que Historical Statistics for Conversation Aggregate Query - ")
print("----------------------------------------------------------------------------------")
api_client = PureCloudPlatformClientV2.api_client.ApiClient() \
.get_client_credentials_token(CLIENT_ID, CLIENT_SECRET)
Genesys Cloud Objects
routing_api = PureCloudPlatformClientV2.RoutingApi(api_client)
analytics_api = PureCloudPlatformClientV2.AnalyticsApi(api_client)
Get "Support" queue by name
try:
queue_data = routing_api.get_routing_queues(name='TEST Service')
except ApiException as e:
print("Exception when calling RoutingApi->get_routing_quest: {e}")
sys.exit()
print(f"queueData: {queue_data}")
Store queue ID
queue_id = queue_data.entities[0].id
Build analytics query
query = PureCloudPlatformClientV2.ConversationAggregationQuery()
query.interval = conversation_aggregates_get_interval_string()
query.group_by = ['queueid']
query.metrics = ['nOffered','nTransferred','tAcw','tConnected','tHeld','tWait','nTransferred','nOutbound']
query.filter = PureCloudPlatformClientV2.ConversationAggregateQueryFilter()
query.filter.type = 'and'
query.filter.clauses = [PureCloudPlatformClientV2.ConversationAggregateQueryClause()]
query.filter.clauses[0].type = 'or'
query.filter.clauses[0].predicates = [PureCloudPlatformClientV2.ConversationAggregateQueryPredicate()]
query.filter.clauses[0].predicates[0].dimension = 'queueId'
query.filter.clauses[0].predicates[0].value = queue_id
print(f"query: {query}")