Google Apps Script for OTP Generation

I tried using a google apps script attached to a google form to generate OTP.

The script intends to make the respondent fill out the email id, leaving the OTP field blank. The submit button triggers the otp generation and will be sent to the email id keyed in. Then the respondent edits the response and keys in the otp and then submits. The latter submission triggers vefirication of otp and displays the success/failure message.

Could enyone help?