Create An Automation To Verify A User's Email Address

Creation date: 15/08/2023 09:48    Updated: 15/08/2023 10:05    email validation
You can use ThinkAutomation to quickly create an Automation that will validate a user's email address. This validation not only checks that the email itself is valid, but also checks that the user can receive it and respond. 

This can be done using the 'Create Passcode' and 'Wait For User Response' actions.

The Automation creates a unique passcode that is sent by email to the user's supplied email address. The email will contain a link to a unique 'Wait For User Response' web form. The user clicks the link and enters the passcode. The Automation pauses whilst waiting for the form to be completed. The results of the form are then passed back to the Automation and the Automation continues. The Automation checks the user-entered passcode against the generated one.

If the form is not completed within a certain time (the default is 48 hours but you can change this) - the Automation continues as if the passcode was not entered.

Example Automation:


PassCode =
Result =
CodeEntered  =

// Create a random passcode of 4 digits
PassCode = Create Passcode Of Numbers Containing 4 Characters

// Send a email with a link to a validation web form and wait for the user to complete the form
Result = Wait For User Response Email To %Msg_From% (On Timeout Continue) Set %CodeEntered% = Code

// The %Result% variable will be 'true' if the user clicked 'accept' or 'expired' if the form was not 
// completed before the timeout.

If %Result% Equal To true Then
   // check the user enter code against the generated one
   If %CodeEntered% Equal To %PassCode% Then
      // Perform any other 'valid email' actions (DB update etc)
      Send Email To %Msg_From% "Email Address Verified"
      Return validated
   End If
End If

// code entered did not match or form waited too long
// Perform any 'invalid email' actions
Send Email To %Msg_From% "Email address was not validated"

Return not validated


The 'Wait For User Response' action can be set to automatically send an email. We set the body of the email to something like:


Dear %Msg_FromName%,

Your one-time validation passcode is:

**%PassCode%**

Please click the link below to verify your email address:

[Click To Verify](%Msg_ValidationUrl%)



The %Msg_ValidationUrl% built-in variable contains the unique link to the validation web form. So we include this in the email body so the user can click it and complete the form.

In the 'Wait For User Response' action we set the 'Message' to something like "Please validate your email address". We add a single 'Survey Field' called 'Code' that takes text input. We set the label for this field to 'Please enter the passcode shown in the email'. We set the 'Assign Value To' of this survey field to the Automation variable %CodeEntered%. We can access this value in the Automation after the 'Wait For User Response' action.

The sample above is validating the incoming message 'from' address - but it could be any email field/variable. The Automation can be called from any type if incoming Message Source (Email, Web Form, Web Chat, Database etc) - or you could create a shared Automation in your Automation library and call it using the 'Call' action from any of your Automations.

The validation web form is hosted by the ThinkAutomation Public API Gateway - so it will work regardless of how your ThinkAutomation server is installed - your server does not need to be publicly accessible. The %Msg_ValidationUrl% is unique to the specific Automation execution and hashed with a secure hash, so user's could not change it to validate the wrong message.

Whilst the Automation is waiting for a specific user to respond, other Automations (even for the same message source) will execute. This 'waiting' phase does not use resources on your ThinkAutomation server - since the pending validation request is stored in your ThinkAutomation Message Store database.