Hi all,
I am trying to pull real-time adherence data for our agents using the Python SDK. We’re on Genesys Cloud, obviously, and everything is in the Tokyo region. I need to show the team lead dashboard how many agents are logged in, on calls, in AUX, etc. right now. It’s… not working. I think.
I’ve been looking at the documentation, and it says to use the RealTimeMetrics endpoint, but I can’t seem to get any data back. It always returns an empty list. I checked the API explorer, and it shows some data, so the API itself is working. It’s probably something on my side. Sorry if this is very simple question.
I’m using the latest SDK version - I think it’s 4.1.0, I just did pip install genesys-cloud-sdk. Here’s the code I’m trying:
import genesyscloud
import datetime
# Replace with your credentials
genesyscloud.config.api_key = "YOUR_API_KEY"
genesyscloud.config.region = "ap-northeast-1"
real_time_metrics = genesyscloud.RealTimeMetrics()
now = datetime.datetime.utcnow()
start_time = now - datetime.timedelta(minutes=1) #check last minute
end_time = now
try:
metrics = real_time_metrics.get_metrics(
start_time=start_time,
end_time=end_time,
metric_type='AgentRealTimeMetrics'
)
for metric in metrics:
print(metric)
except Exception as e:
print(f"Error: {e}")
The metrics variable is always an empty list. I tried setting the interval parameter as well, like someone mentioned in another thread. It didn’t help. I also tried to use the get_metrics_aggregated function, but that returned an error. The error said I needed to add aggregation_type, but I couldn’t find what values are valid for that.
I saw a post that said you need to specify the agent ID, but the documentation doesn’t mention that for this endpoint. And I’m trying to get data for all agents, not just one. Is it because of the permissions? I’m using an API key that should have access to everything. I’m not sure. I also think my timezone might be wrong?
Can someone help me? I am very sorry to bother you with this.