Deepak | 2018-12-06 10:24:01 UTC | #1
Team,
I using the following code retrieve total calls came to the ivr, offered and answered. But unfortunately TIvr is missing the output metrics. But when i run the same through analytics query builder i am getting the Tivr metric. Please help me fix this issue.
lblStatus.Text = ""; rpt.DataSource = null;
var result = new List<AnalyticsConversation>(); var api = new AnalyticsApi();
var body = new AggregationQuery { Interval = interval.ToString()
};
AnalyticsQueryFilter aqf = new AnalyticsQueryFilter(AnalyticsQueryFilter.TypeEnum.And); List<AnalyticsQueryClause> aqcList = new List<AnalyticsQueryClause>(); List<AnalyticsQueryPredicate> aqpQueueList = new List<AnalyticsQueryPredicate>(); List<AnalyticsQueryPredicate> aqpList = new List<AnalyticsQueryPredicate>(); AnalyticsQueryClause aqcQueue = null; string selectedQueues = Request.Form["selectQueues"]; if (selectedQueues.Contains(",")) {
foreach (string queue in selectedQueues.Split(',')) { aqpQueueList.Add ( new AnalyticsQueryPredicate() { Dimension = AnalyticsQueryPredicate.DimensionEnum.Queueid, _Operator = AnalyticsQueryPredicate.OperatorEnum.Matches, Value = queue, } );
} aqcQueue = new AnalyticsQueryClause(AnalyticsQueryClause.TypeEnum.Or, aqpQueueList); } else {
aqpQueueList.Add ( new AnalyticsQueryPredicate() { Dimension = AnalyticsQueryPredicate.DimensionEnum.Queueid, _Operator = AnalyticsQueryPredicate.OperatorEnum.Matches, Value = selectedQueues, } ); aqcQueue = new AnalyticsQueryClause(AnalyticsQueryClause.TypeEnum.Or,aqpQueueList); } aqcList.Add(aqcQueue); aqf.Clauses = aqcList; aqf.Predicates = new List<AnalyticsQueryPredicate>() { new AnalyticsQueryPredicate() { Dimension = AnalyticsQueryPredicate.DimensionEnum.Direction, _Operator = AnalyticsQueryPredicate.OperatorEnum.Matches, Value = "inbound", } }; body.Filter = aqf; body.GroupBy = new List<AggregationQuery.GroupByEnum>() { AggregationQuery.GroupByEnum.Queueid, AggregationQuery.GroupByEnum.Dnis }; body.Metrics = new List<AggregationQuery.MetricsEnum>() { AggregationQuery.MetricsEnum.Tivr, AggregationQuery.MetricsEnum.Noffered, AggregationQuery.MetricsEnum.Tanswered};
var pageResult = api.PostAnalyticsConversationsAggregatesQuery(body);
System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add("queueid", typeof(string)); dt.Columns.Add("dnis", typeof(string)); dt.Columns.Add("calls", typeof(long)); dt.Columns.Add("offered", typeof(long)); dt.Columns.Add("answered", typeof(long)); dt.Columns.Add("answeredp", typeof(double));
System.Data.DataRow dr = null; Dictionary<string, string> userList = new Dictionary<string, string>();
if (pageResult.Results != null) { string previousUser = string.Empty; string currentUser = string.Empty; foreach (AggregateDataContainer adc in pageResult.Results) { dr = dt.NewRow(); dr["queueid"] = adc.Group["queueId"]; dr["dnis"] = adc.Group["dnis"]; dr["answeredp"] = 0.0;
foreach (StatisticalResponse sr in adc.Data) { foreach (AggregateMetricData amd in sr.Metrics) { if (amd.Metric == AggregateMetricData.MetricEnum.Tivr) { dr["calls"] = Convert.ToInt64(amd.Stats.Count); } if (amd.Metric == AggregateMetricData.MetricEnum.Noffered) { dr["offered"] = Convert.ToInt64(amd.Stats.Count); } if (amd.Metric == AggregateMetricData.MetricEnum.Tanswered) { dr["answered"] = Convert.ToInt64(amd.Stats.Count); } }
} dt.Rows.Add(dr); }
rpt.DataSource = dt; rpt.DataBind();
Regards Deepak
tim.smith | 2018-12-06 15:43:41 UTC | #2
Please provide the JSON query you're sending. You can get it from AggregationQuery.ToJson().
Deepak | 2018-12-09 07:04:56 UTC | #3
{ "interval": "2018-11-01T00:00:00.0000000/2018-11-15T10:37:00.0000000", "granularity": "P1D", "groupBy": [ "queueId", "dnis" ], "filter": { "type": "and", "clauses": [ { "type": "or", "predicates": [ { "dimension": "queueId", "operator": "matches", "value": "5d12aaa0-cd20-45af-b575-0ba33285be3d" }, { "dimension": "queueId", "operator": "matches", "value": "a7659d7a-4e27-49bc-87cd-1be49e201e22" } ] } ], "predicates": [ { "dimension": "direction", "operator": "matches", "value": "inbound" } ] }, "metrics": [ "tIvr", "nOffered", "tAnswered" ]}"
Deepak | 2018-12-10 10:50:10 UTC | #4
any update on the below ??
tim.smith | 2018-12-10 16:40:30 UTC | #5
The only difference I see between your JSON and what the dev tools would produce is that your code is missing the property type=dimension on the predicates. Also, keep in mind that if there isn't any data for a metric, it won't be returned. So when comparing your code's results to the dev tools results, be sure the interval matches.
Deepak | 2018-12-11 10:27:59 UTC | #6
We are not getting the TIvr metric when we include a queue in the filter (clause). This is when we tried from the developer tools. Please check.
{
"interval": "2018-10-31T20:00:00.000Z/2018-11-30T20:00:00.000Z",
"groupBy": [
"dnis",
"queueId"
],
"filter": {
"type": "and",
"clauses": [
{
"type": "or",
"predicates": [
{
"type": "dimension",
"dimension": "queueId",
"operator": "matches",
"value": "a7659d7a-4e27-49bc-87cd-1be49e201e22"
}
]
}
],
"predicates": [
{
"type": "dimension",
"dimension": "mediaType",
"operator": "matches",
"value": "voice"
},
{
"type": "dimension",
"dimension": "direction",
"operator": "matches",
"value": "inbound"
}
]
},
"views": [],
"metrics": [
"tIvr",
"nOffered"
]
}
tim.smith | 2018-12-11 14:36:34 UTC | #7
Can you provide correlation IDs from the dev tools response and from the SDK response? I'll see if there's anything I can glean from the logs before referring this to Care. (I don't have access to your data to verify it, only Care does).
Deepak | 2018-12-11 16:15:27 UTC | #8
The issue is we are not getting the tivr metric in the developer tool itself. This happens when we include queue filter. This has nothing to do with the SDK, please check.
tim.smith | 2018-12-11 16:29:34 UTC | #9
If a requested metric is not returned in the response, it's typically because there is no data for that metric for the given filter and interval. If you are sure that there was data that should be counted in tIvr for your filter and interval, please open a case with PureCloud Care to investigate why the data is missing.
system | 2019-01-11 16:29:39 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: 4131