Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Current »


All the requests work as jobs, they can be requested then they are in the background generated and can be retrieved after through a download link in CSV format.

The contents of the analytics are explained here: Analytics

Access Token & URL

You can see here how to get an access token and the URL:

How to get a Token for our APIs

About these APIs

Clients or developers can use Unique internal APIs, but must not build any automation or integration with them. These APIs do not guarantee backward compatibility and are excluded from any Service Level Agreement (SLA). Unique will not roll back changes to fix broken integrations caused by updates to internal APIs. Consequently, reliance on these APIs for critical functions is strongly discouraged.

Learn more about the use of Internal APIs.

Start the job

Each job needs to define a startDate and endDate.

Only in that time interval data will be evaluated.

Chat Interactions:

curl '<HOST OF URL>/analytics/chat-interactions?startDate=2024-05-03&endDate=2024-06-02' \
  -X GET \
  -H 'content-type: application/json' \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' 

Active Users:

curl '<HOST OF URL>/analytics/active-users?startDate=2024-05-03&endDate=2024-06-02' \
  -X GET \
  -H 'content-type: application/json' \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'

Reference Statistics:

curl '<HOST OF URL>/analytics/reference-stat-export?startDate=2024-05-03&endDate=2024-06-02' \
  -X GET \
  -H 'content-type: application/json' \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'

Detailed user Interactions:

curl '<HOST OF URL>/analytics/chat-interactions-detailed?startDate=2024-05-03&endDate=2024-06-02' \
  -X GET \
  -H 'content-type: application/json' \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'


As response from each request you should get the the ID of the analytics order that you just placed. This Id you now need to check for the status until its finished.

The date range defaults to 1 day when no date parameters are provided.

Waiting on the job to finish

Regularly check if the job is finished. Please leave at least 10 sec between checks to not overtax the system.

There are 2 parameters skip and take to paginate through all the analytics jobs that have been ordered.

curl '<HOST OF URL>/grqphql' \
  -X POST \
  -H 'Content-Type: application/json' \
  -H 'authorization: Bearer <ACCESS_TOKEN>' \
  --data '{"query":"query AnalyticsOrders($orderBy: [AnalyticsOrderOrderByWithRelationInput!], $take: Int, $skip: Int) {\\n  analyticsOrders(orderBy: $orderBy, take: $take, skip: $skip) {\\n    updatedAt\\n    type\\n    stateUpdatedAt\\n    id\\n    state\\n    createdBy\\n    createdAt\\n    configuration\\n    companyId\\n  }\\n}","variables":{"orderBy":[{"createdAt":"desc"}],"skip":0,"take":20}}'

This is what is returned so you can check the state. You can not fetch the analytics until they are done.

{
    "data": {
        "analyticsOrders": [
            {
                "updatedAt": "2024-06-02T19:18:58.960Z",
                "type": "CHAT_INTERACTION",
                "stateUpdatedAt": "2024-06-02T19:18:58.959Z",
                "id": "analyticOrder_ltz4rirt5ej8v0yeu0owa5sg", <-- this is the OrderID
                "state": "DONE", <-- This is the state to check.
                "createdBy": "268834226248482823",
                "createdAt": "2024-06-02T19:18:57.753Z",
                "configuration": {
                    "endDate": "2024-06-02T21:59:59.999Z",
                    "startDate": "2024-05-02T22:00:00.000Z"
                },
                "companyId": "268834226248417287"
            }
        ]
    }
}

Download the finished Analytics:

curl '<HOST OF URL>/analytics/analytics-scheduler/download/<ORDER_ID>' \
  -X GET \
  -H 'Accept: text/csv' \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'

You can download the data as CSV.

Delete the requested jobs once downloaded:

To empty the list of completed jobs you can delete the ones that are already downloaded:

curl '<HOST OF URL>/graphql' \
  -X POST \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  --data '{"query":"mutation AnalyticsOrderDelete($orderId: String!) {\\n  analyticsOrderDelete(orderId: $orderId) {\\n    updatedAt\\n    type\\n    stateUpdatedAt\\n    state\\n    id\\n    createdBy\\n    createdAt\\n    configuration\\n    companyId\\n  }\\n}","variables":{"orderId":"<analyticOrderId>"}}'


  • No labels