I have set up my react app to grab the data from the URL in the format
http://localhost:3000/confirm-email/[email protected]?code=469907
Is it possible to output the recipient's email in the sendgrid template.
The docs only show how to do this with only the code but it doesn't allow users to verify from another device like their phone without having to re-enter their email address.
It's not the biggest issue as I can check if the email parameter exists in the URL and add an input field if it does not have it from local storage but once again users would not be able to verify from a separate device.
I have figured it out after checking out the
https://www.twilio.com/code-exchange/one-click-email-verification-magic-links
Documentation. Although this solution was only in javascript and my backend is python/Django rest framework.
The only thing you need to do is set substitutions in JSON format in the client_configuration
def verifications(user_destination, via):
return client.verify \
.services(settings.TWILIO_VERIFICATION_SID) \
.verifications \
.create(
to=user_destination,
channel=via,
channel_configuration={
'substitutions': {
'email': user_destination
}
}
)
You can make any substitution into the sendgrid templates this way.
Here is a code example in flask https://github.com/digitaluniverse/digitaluniverse-magic_link_elasticBeanstalk