Alert based on a condition

Hello.

I am trying to set up an alert on the Kibana UI. Its is an elasticsearch query alert where I am matching an error message string. However, I would like only documents with unique device IDS so I have an aggregation in my elasticsearch query.
Here is an example of what I have so far:

GET /poller-logs-2025.02.13/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match_phrase": {
            "message": "Maximum retries reached for polling device"
          }
        },
        {
          "wildcard": {
            "message.keyword": "*IGW*"
          }
        }
      ]
    }
  },
  "aggs": {
    "unique_devices": {
      "terms": {
        "field": "device_id.keyword",
        "size": 20
      }
    }
  }
}

My issue is I would like this alert to be triggered if there are say 20 unique devices that match this condition. Can this be done on the Kibana UI. Or is there any other way to achieve this?

Edit: I am running Kibana version 8.3.1. I am also using index connector for my actions but am willing to use other connectors that can achieve this