Automated emails are essential for communicating with your users. Whether you’re welcoming a new user, confirming an order, or resetting a password, these “transactional” emails are a core part of any application. In this tutorial, we will build a workflow that automatically sends a “Welcome!” email to a user immediately after they sign up. We will cover:
- Creating a dynamic Email Template with personalized content.
- Building a secure, server-side Function to handle the email sending.
- Triggering the Function from our existing Sign-Up workflow.
Part 1: Create a Dynamic Email Template
First, we need to design the email itself. We’ll create a template that can be personalized with the new user’s name.1
1. Navigate to Email Templates
In the Left Panel of the Visual Editor, navigate to the Email Templates tab.
2
2. Create a New Template
- Click to create a new template and give it a name, like
WelcomeEmail
. - You will be taken to an editor where you can design your email’s subject and body.
3
3. Add Dynamic Content
This is the key step. We need to define “placeholders” for the data that will be different for each user.
- Subject: Set the subject to something like
Welcome to Our App, <name>!
- Body: In the body of the email, you can write your welcome message. Where you want to display the user’s name, use the same placeholder syntax:
Hi <name>, we're so glad you've joined.
<name>
is a variable. We will provide a value for this variable when we send the email.Part 2: Build a Secure “Send Welcome Email” Function
Sending emails must be done on the server. A Server-side Function is the perfect, reusable tool for this job.1
1. Create the Server Function
- Go to Data → Functions.
- Create a new Server-side Function and name it
SendWelcomeEmail
.
2
2. Define the Function's Props (Inputs)
Our function needs to know who to send the email to and what name to use for personalization. Add two Props:
userEmail
(Data Type:Text
)userName
(Data Type:Text
)
3
3. Build the Function's Workflow
- Open the workflow editor for your
SendWelcomeEmail
function. - Add the “Send Email” action.
4
4. Configure the 'Send Email' Action
- Template: Select your
WelcomeEmail
template from the dropdown. - Send To: Bind this to the
userEmail
Prop of your function. - Display Name: Enter the “From” name for your app (e.g., “The Saasio Team”).
- Preview (Dynamic Data): This is where we provide the values for our placeholders.
- The key must match the variable name in your template (
name
). - The value should be bound to the
userName
Prop of your function.
- The key must match the variable name in your template (
Part 3: Trigger the Function After Sign-Up
The final step is to call our new function from our existing user registration workflow.- Navigate to your
signup
page. - Select the Sign-Up Form and open its “On Submit” workflow from the Logic tab.
- Find the successful sign-up path. Your workflow should have a “Sign up and Login” action. This action returns the newly created user object.
- Add the “Trigger Function” action immediately after the “Sign up and Login” action.
- Function: Select your
SendWelcomeEmail
function. - Props:
userEmail
: Bind this to theemail
from the Result of the “Sign up and Login” action.userName
: Bind this to thename
from the Result of the “Sign up and Login” action.
- Function: Select your
By placing this in the same workflow, the welcome email is sent instantly and
automatically the moment a new user successfully creates their account.
SendWelcomeEmail
function anywhere you need it.