How to collect the data from another app before it goes to the UI? I'm using an android app, it receives backend updates and displays on the UI.

How could an automation app, a script, or any solution read the updates received and to make some decisions/start other services before it is sent to UI?

Android at wi-fi with the weather forecast app.
App or service collecting the data stream in the backend.
Uses the data collected in the backend to automate decisions.

thanks.
The data once received by an app is protected by the Android sandboxing system that restricts/protects each app. Hence unless your device is rooted the received data (and the app does not provide a public interface to access the data) is inaccessible to any other app (hence also to any automation app).

The only chance to get some data would be on the transmission level by intercepting the connection between app and server. However nowadays this connections usually is a HTTPS connection which means that the app would no accept the presented server certificate of the man-in-the-middle proxy as apps only allow the default system certificates as root certificates. Here again rooting would be the only option to add a custom certificate to your device to make the weather app accept the custom server certificate.