What you'll learn

  • How to send users emails within your Alexa skill
  • How to use variables from your Alexa skill in your emails

Video tutorial

Email block overview
The email block allows you to send emails to your users when the block is activated. This can be useful when the user would like a copy of the information presented in your skill. 

For example, if your skill helps users pick a travel location, you can send them a personalized email with the different options of hotels you have located, and the pricing.

Creating emails to send to users

Voiceflow contains a built-in HTML email template editor which allows you to create your email templates right within Voiceflow. To access the email editor, click on the 'Business' tab within your Voiceflow menu.

Once on the Business Tab, you'll have access to the 'Email' section. To create a template, click on the 'Create a Template' button.

Let's do that now.

Here, you can see you can name your email template, set a new subject line, and form the body of your email.

On the left side within HTML code, you can copy/paste in a fully flushed out HTML email template, or create your own from scratch. If you do not want to write the HTML yourself, you can use an HTML email generator using tools like Sendgrid or Topol.

Below, we used Topol to generate our HTML template, and have now copied it over into our HTML Code section on Voiceflow. We can see a live preview of our email template on the right hand side.

And we're done! We can save our template and begin to use it within our Alexa skills. 

Selecting the template to send

Each Mail block can send one email to one user, using a template specific to that particular mail block. Your skill can send many different emails, but each mail block only sends one.

To choose which email template your mail block sends, within the mail block hit the 'Select template' button to access the list of available templates you have built.

Once you select the template you want to send, all we have to do now is choose where to send the email.

Selecting where to send the email

To send an email to the user, we have get the user's email in a variable, enter the user's email manually (mainly for testing purposes), or use a Permissions block.

Manually entering an email
If you would like emails to be sent to the same address every time you can do so by using the 'defined email' button on the email block. This scenario could be used for testing with your own email, or for your own personal skill where you use the same email address every time.

Using a variable
If we already have a user's email stored in an external database or Google sheet/form, we can pull that user's email into our project using a variable. For example, you could use the API block to call an external API to get the user's email, and store that email in a variable. 

Then, in the 'defined' email section, you can enter the variable storing the user's email.

Requesting and using a new user's email
Using the permissions block, you can request a user's email automatically and send them an email. To do this, request email permissions using the permissions block. If the user has agreed to permitting email permissions, then all you have to do with the email block is hit the 'user email' option, and the user will automatically be sent an email when the block is hit.

Using variables within our emails

With Voiceflow we can use the variables from our Alexa skill within our emails to more personalize the experience for our users. 

To use variables within our emails, we must first set the variable within the email template. To do this, anywhere within the template use curly braces to wrap the name of the variable we want to use. 

Above, we have added the variable {name} to our email template. Let's save this template and go back to the canvas screen for our Skill.

Now, within the mail block we want to send the email from, we need to select the mail template with the variable we just added.

You'll see a tab pop up below when you select a template with variables in it. Here, we can 'map' one of our project variables into the {name} variable within our email template. I'm going to map the {name} variable in our project to the {name} variable within the email template.

Done! Our Voiceflow Alexa skill can now send customized emails to our users. You may add as many variables to your email template as you would like.

Still have questions? Be sure to message us on our helpline (blue bubble in the bottom right of the page).

Did this answer your question?