How to get OTP from SMS and set into Body request

I have endpoint for send OTP (Send OTP)

in other endpoint i want to use that OTP (login using OTP)

how I can get the OTP from SMS and put in on my body request?
anyone can give me solution?