Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twilio Verify: Email - Dynamic Template Data #641

Closed
roughpandaz opened this issue Dec 29, 2020 · 2 comments
Closed

Twilio Verify: Email - Dynamic Template Data #641

roughpandaz opened this issue Dec 29, 2020 · 2 comments
Labels
status: waiting for feedback waiting for feedback from the submitter type: getting started question while getting started

Comments

@roughpandaz
Copy link

Issue Summary

Verify sending email using SendGrid not working.
I am following this tutorial: https://www.twilio.com/docs/verify/email#send-an-email-verification
I am able to send emails through the Twilio Verify API using Dynamic Templates from Send Grid.

To customize the email, I tried substitution tags. However, it did not work.
I followed the following issue: sendgrid/sendgrid-nodejs#676

However, I am still unable to get emails to send with personalized messages.

Code Snippet

Server Code

client.verify
    .services(SERVICE_ID)
    .verifications.create({
      channelConfigurations: {
       // I tried: dynamicTemplateData and substitutions - none work
        dynamic_template_data: {
          name: "firstName",
          verification_url: "verificationURL"
        }
      },
      to: opt.email,
      channel: "email"
    })
    .then(verification => {
      console.log("verification", verification.sid);
      return verification;
    })
    .catch(err => {
      console.log(err);
      throw err;
    });

Dyanmic Template]]

<tr>
            <td align="left" bgcolor="#ffffff" style="padding: 24px; font-family: 'Source Sans Pro', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 24px;">
              <p style="margin: 0;">Hi {{name}}!</p>
              
              <p style="margin: 0;">Click the button below to confirm your email address.</p>
            </td>
          </tr>
 <tr>
       <td align="center" bgcolor="#1a82e2" style="border-radius: 6px;">
                          <a href="{{verification_url}}{{twilio_code}}" target="_blank" style="display: inline-block; padding: 16px 36px; font-family: 'Source Sans Pro', Helvetica, Arial, sans-serif; font-size: 16px; color: #ffffff; text-decoration: none; border-radius: 6px;">Confirm Email 👍</a>
       </td>
 </tr>

Technical details:

  • twilio-node version: "_id": "twilio@3.54.1",
  • node version: 10.23
@JenniferMah JenniferMah added status: waiting for feedback waiting for feedback from the submitter type: getting started question while getting started labels Jan 5, 2021
@JenniferMah
Copy link
Contributor

Hi @RongxinZhang
It looks like you are trying to call channelConfigurations instead you need to be calling channelConfiguration. The examples linked in the tutorial page are correct. You should be able to use substitutions to replace the the name and verification url.

client.verify.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
             .verifications
             .create({channelConfiguration: {
				//substitutions is the correct reference here
                substitutions: {
                  name: "firstName",
                  verification_url: "verificationURL"
                }
              }, to: 'recipient@foo.com', channel: 'email'})
             .then(verification => console.log(verification.sid));

@roughpandaz
Copy link
Author

Thank you! @JenniferMah , that was the issue 👍👍👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for feedback waiting for feedback from the submitter type: getting started question while getting started
Projects
None yet
Development

No branches or pull requests

3 participants