# Get the last UPLINK message with filters

```javascript
//1
const now = moment.utc(FW.getEvent().computedDate);
const TenMinutesBefore = moment.utc(now).add(-10, 'minutes');
//2
const lastAll=(await FW.getEvents(FW.getEvent().reg, TenMinutesBefore, null, false, false, null, ['IFT_UPLINK'], 300));
//3
const lastITM=lastAll.filter(e=>e.tags.map(t=>t.id).includes('ATA78') && e.sumUp.match("RELAY[12]"));

FW.log(lastITM.map(e=>e.sumUp));
```

1. We create a timespan starting 10 minutes ago. The `now` is not the current UTC but is the currently processed message. It is important to use this timestamp as the occurence may be in the past when reparsing the messages or receiving it late.
2. We query the DB for the messages of the same fwot in the time window, filtering for the internal tag `IFT_UPLINK` that is automatically positionned when an uplink is trigged thru IFT. We limit to 300 events, which is totally arbitrary. referenced function: [FW.getEvents](/user-manual/designer-user-manual/edit-ifts/ift-v2/fw.getevents.md)
3. We filter the received results that matches a second tag `ATA78` and which `sumUp` matches RELAY1 or RELAY2


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flightwatching.com/user-manual/designer-user-manual/code-snippets/get-the-last-uplink-message-with-filters.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
