How to send an email with OTP confirmation
Sometimes you might have to send emails to the chatbot users. To ensure the email is received to the intended user, you have to use an OTP to confirm the email address and then send the content in an email. The below articles explain how to send an email with OTP confirmation.
Â
In the below example, we have used the flow studio to define the logical flow that the chatbot takes.
Experience Designer flow
The Experience Designer flow is given below. PFA the exported json file of the below flow.
OTP Manager node
You can generate an OTP using the OTP Manager node.
Name - This field contains the name of the node (if given).
Digit - Specify how many digits the OTP should contain.
Type - You can choose between number, alphabet, or alphanumeric OTPs.
The output of the OTP manager node will be in the property msg.payload.otp
Send Email
You can send emails to the users using the Send Email node.
To - The email address of the recipient. You can use email ids or you can pass a dynamic value using mustache tags.
eg: You can use {{session.user.username}}
for a chatbot user that is already logged in.
You can email to more than one email account by putting a comma between emails.
Subject - The subject of the email.
eg: {{session.user.firstName}}
needs help.
Content - You can get the body content of the email from the content data.
Type - The keyname of the field.
Id - The Content’s document ID.
Message - The body part of the email.
The body of the email can be configured in the content data or in the message box of the node. If both are populated in the node, the Content data will take preference and will be sent to the user in the email.
Flow Studio
The flow studio flow is given below. PFA the exported json file of the below flow.
Once a user launches the chatbot, the chatbot requests the user for an email address. An OTP will be sent to the given email address and the chatbot requests the user to provide the OTP. If the given OTP matches the generated OTP, an email will be sent with custom content.
How to use