How to read an OTP from Mail and pass it to OUR app

hi can any one guide me how to Switch between two apps

Step 1) Open my app, and click get OTP
Step 2) Open Chrome app and open some website and there it should Read OTP
Step 3) The OTP should pass in my First app.

Usually it is a bad idea to include such auth into automated tests, since providers have throttling and recognise automated clients as bots, which makes tests pretty unstable. Consider having auth backdoor for automation purposes available via API (without UI interactions). In case OTP retrieval via email is a hard requirement then it would make sense to implement a simple IMAP client in the test framework code (could also be unstable because of possible server side throttling) or use services like Mailtrap

Thanks for information.
I wanted to login to my app using OTP sent over email. what is best way to automate it.