How to reset password using cloud function?

In my android app with kotlin am using phone number and password as a means of authenticating users. I first use OTP to verify users phone number before users can register and log in. So here email/password is set to “Automatically confirm users”. So far registration and logging in works perfectly. But password reset is a problem now. I want to use OTP to verify if user has initiated a password reset by sending a code to users phone and proceed with a new password.
Is there away to do this with cloud function since user is not receiving any link or token or token Id.