Search code examples
sqlpowerapps

How to generate OTP in Power apps(OTP should appear in Phone Number) || instead of Phone number I tried using Email ID


I want to generate OTP of 4digits and One Time Password should come in registered Phone number.

I tried using 3rd party app but couldn't achieve this. My data source is SQL. Can't really able to do so, as I am unable to find the custom connector in power apps( I tried the steps generated on ChatGPT)


Solution

  • I tried to do this by self as I couldn't able to get any source of help. So I got to know that If we want to send the OTP through the Phone number then for that we need to get a paid service(might be I'm not correct in this), instead of that I tried to send the OTP through Email Id.

    Here are the steps if you want to achieve this -

    step 1- Create a Button in which you want to generate the OTP. And I gave the following codes -

    Reset(TextInput2_1); // resetting the text input which user will use for entering the OTP

    Set(Votp,Right(Rand(),5)); // I set a variable and generating the random number and taking only 5 digits using right()

    Gmail.SendEmail(DataCardValue6.Text,{Subject:"Put your subject name here", Body:"How you want your body should be put here "&Votp}); // this is the Email that you want to generate

    Navigate(OTPScrn) // Navigating to another screen

    Step -2 after that entering the OTP need to add another button for checking the Otp is correct or not then log in. In the Log in button I have added - If(Votp = TextInput2_1.Text, Navigate(HomePage), Notify("Invalid OTP", NotificationType.Error));

    Note- I've created two Screen in one only Email ID and Generate OTP button and in the 2nd Screen Otp input and log in button. I tried tried to insert the pictures as well but I'm new here so I couldn't able to it is asking some reputation.

    Hope you guys understand, If further any issue you're facing let me know here. Thank You.