Get intents and their queries (details)

User intents represent a grouping of user queries that share the same purpose or goal. In our platform, these intents are treated as aggregates. You can easily retrieve them using the get-interaction-aggregates endpoint.

Let’s suppose that we want to get the intents sorted by volume and paginated with a limit size of 10.

import requests

url = "https://backend.nebuly.com/api/external/get-interaction-aggregates"

payload = {
    "time_range": {
        "start": "2024-05-30",
        "end": "2024-05-01"
    },
    "filters": [],
    "limit": 10,
    "offset": 0,
    "group_by": {
        "kind": "user_intent"
    },
}
headers = {
    "Authorization": "Bearer <MyToken>",
    "Content-Type": "application/json"
}

response = requests.request("POST", url, json=payload, headers=headers)

The code snippet above, with a valid API key, will return the paginated version of the intents. Now, let’s get the user requests (queries) that belongs to the intent with the highest volume.

First we selected the intent and then we will use the get-interactions endpoint:

intent = response.json()["data"][0]

url = "https://backend.nebuly.com/api/external/get-interactions"

payload = {
    "time_range": {
        "start": "2024-05-30",
        "end": "2024-05-01"
    },
    "filters": [
        {
            "kind": "user_intent",
            "values": [intent]
        }
    ],
    "limit": 10,
    "offset": 0
}

interactions_response = requests.request("POST", url, json=payload, headers=headers)
interactions = interactions_response.json()["data"]