Incident management with ServiceNow and Elasticsearch

I have followed part 1 and part 2 Everything works great. Only minor issue is its creating duplicate incidents. If i put throttle period then if some other app has status down , it wont trigger an incident :frowning:

if there any logic i can change in watcher which would to skip generating duplicate incidents for same app ?

if also tried

if (state == 'Resolved' || state == 'Closed' || state == 'Canceled' || state !== 'New') {
appsNeedingTicket.add(app.key);
}