Created
March 9, 2023 16:54
-
-
Save zuzannamj/0cba709825633c0c24f7305e97e763b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%[ | |
IF RequestParameter("submitted") == true THEN | |
/* generate an OPT */ | |
set @num1 = 1000 | |
set @num2 = 9999 | |
set @OTP = random(@num1, @num2) | |
/* send a triggered email containing the opt */ | |
SET @ts = CreateObject("TriggeredSend") | |
SET @tsDef = CreateObject("TriggeredSendDefinition") | |
SET @ts_extkey = "43099" /* replace with ID of your Triggered Send */ | |
SET @ts_email = RequestParameter("email") | |
SetObjectProperty(@tsDef, "CustomerKey", @ts_extkey) | |
SetObjectProperty(@ts, "TriggeredSendDefinition", @tsDef) | |
SET @ts_sub = CreateObject("Subscriber") | |
SetObjectProperty(@ts_sub, "EmailAddress", @ts_email) | |
SetObjectProperty(@ts_sub, "SubscriberKey", @ts_email) | |
SET @attr = CreateObject("Attribute") | |
SetObjectProperty(@attr, "Name", "OTP") | |
SetObjectProperty(@attr, "Value", @OTP) | |
AddObjectArrayItem(@ts_sub, "Attributes", @attr) | |
AddObjectArrayItem(@ts, "Subscribers", @ts_sub) | |
SET @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode) | |
/* display a form where subscriber submits otp */ | |
]%% | |
<form action="%%=RequestParameter('PAGEURL')=%%" method="post"> | |
<label>OTP: </label><input type="text" name="OTP" required=""><br> | |
<input name="email" type="hidden" value="%%=RequestParameter("email")=%%"><br> | |
<input name="submittedOTP" type="hidden" value="true"><br> | |
<input type="submit" value="Submit"> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment