when I am using the
https://{{host}}/api/public/bot/{{BotID}}/getAnalytics
API with the following status body:
{
“type”: “successintent”,
“filters”: {
“from”: “2024-04-08T17:25:09.698Z”,
“to”: “2024-05-15T17:25:09.698Z”,
“channel”: [
“hangoutchat”
]
}
}
the response for this request I am receiving is past 24hr data, but I want data for the time period which I will mention in above request. I need a solution for this query.
Hello Akash,
Thank you for reaching out to Kore.ai Community.
Please try using the below Curl and let us know if you are receiving the expected response.
curl --location 'https://bots.kore.ai/api/public/bot/bot-id/getAnalytics' \
--header 'Content-Type: application/json' \
--header 'auth: <Your JWT Token>' \
--data-raw '{
"type": "successtask",
"filters": {
"from": "2023-12-11",
"to": "2023-12-27",
"channel": [
"rtm",
"abcd@kore.com"
],
"isAmbiguous": false,
"isDeveloper": false,
"trained": false,
"userId": [
"u-dbe9d3f6-3b86-543f-82ad-f24312af4570"
]
},
"limit": 50
}'
Note:
Please replace the Bot ID, JWT Token, Type, Channel, email id, user-id as per your requirement and test the use case.
Hope this helps.
Thank you,
Srujan Madderla
Kore.ai Community Team
Hello Srujan,
I have changed the request body as per my requirement as below:
{
“type”: “successintent”,
“filters”: {
“from”: “2024-05-05”,
“to”: “2024-05-16”,
“channel”: [
“hangoutchat”
]
},
“limit”: 50
}
I checked the timestamp in response body as it is containing past 24hr data
It looks like the getAnalytics API is not respecting the from and to date range in your request. Here are a few things to check and potential solutions:
Possible Issues & Fixes
Verify Date Format
Ensure that the API expects the date format in ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ), which seems correct in your case.
Try explicitly setting UTC (Z) at the end if the API interprets it differently.
Check API Documentation
Some APIs have specific query parameters like useCustomDateRange: true or other flags that enable date filtering.
Look for any such options in the API documentation.
Confirm Server-Side Behavior
If the API always returns past 24-hour data, the server might have a default time range.
Try sending a request without the type field to see if that affects the behavior.
Test with a Different Time Range
Use a shorter or broader time range, like the last 3 days, to check if the API is filtering correctly.
Check Response Headers
Some APIs include headers that indicate what filters were applied.
Inspect them using a tool like Postman or a debugging proxy.
Try Sending a cURL Request
Use the following cURL request to debug:
curl -X POST “https://{{host}}/api/public/bot/{{BotID}}/getAnalytics”
-H “Content-Type: application/json”
-d ‘{
“type”: “successintent”,
“filters”: {
“from”: “2024-04-08T17:25:09.698Z”,
“to”: “2024-05-15T17:25:09.698Z”,
“channel”: [“hangoutchat”]
}
}’
If it still returns the past 24 hours, the API might be ignoring the filter.