Overview
In this lesson, you will learn how to build your first automation workflow in n8n that sends personalized welcome emails automatically whenever a user submits a form. We will use a webhook to trigger the workflow from a Google Form submission, then send an email via Amazon SES, and finally extend the workflow to handle corporate user sign-ups differently by logging them into a Google Sheet. This tutorial covers setting up triggers, action nodes, dynamic expressions, and conditional logic in n8n.
If you are new to n8n, you might find it helpful to review the n8n Quick Start Workflow to get familiar with basic workflow creation.
Step 1: Setting Up the Webhook Trigger
What is a Webhook?
A webhook is a way for your workflow to listen for external events—like a form submission—so it can trigger automation immediately. In this example, the webhook will listen for data sent from a Google Form.
Creating the Webhook Node in n8n
Open your n8n workspace and create a new workflow.
Add a new node by clicking the plus button (
+).Search for and select the
Webhooknode.Configure the webhook:
- HTTP Method: Select
POST. - Path: Leave blank or customize if desired.
- Response Mode: Leave as
Respond Immediately.
- HTTP Method: Select
Click the Listen for Test Events button to start listening for incoming webhook requests.
Copy the Webhook URL
- Copy the Test URL from the webhook node configuration.
- This URL will be used in your Google Form to send data to n8n.
For more details on webhook configuration, see the Webhook Node Documentation{:target="_blank"}.
Step 2: Integrating Google Forms with the Webhook
Google Forms does not natively support webhooks, so you need to use Google Apps Script to send form submissions to your webhook URL.
Setting Up Google Apps Script
- Open your Google Form.
- Click the three dots in the top-right corner and select Script editor.
- In the Apps Script editor, paste the following sample code:
var postUrl = 'PASTE_YOUR_WEBHOOK_TEST_URL_HERE';
function onFormSubmit(e) {
var formData = e.namedValues;
var payload = {
firstName: formData['First Name'][0],
lastName: formData['Last Name'][0],
email: formData['Email'][0],
role: formData['Role'][0]
};
var options = {
method: 'post',
contentType: 'application/json',
payload: JSON.stringify(payload)
};
UrlFetchApp.fetch(postUrl, options);
}
- Replace
'PASTE_YOUR_WEBHOOK_TEST_URL_HERE'with your webhook test URL. - Save the script.
- Set up the trigger:
- Go to Triggers (clock icon in Apps Script).
- Click Add Trigger.
- Select
onFormSubmitfunction. - Event source:
From form. - Event type:
On form submit.
- Save the trigger to enable sending data on form submission.
Testing the Webhook Integration
- Submit the Google Form with test data.
- Ensure your webhook node in n8n is still listening.
- You should see the form data appear in the webhook node’s output.
If you want to try out this integration quickly, check out the n8n try it out guide{:target="_blank"} for more hands-on examples.
Step 3: Adding the Email Action Node
Once the webhook receives the form data, the next step is to send a personalized welcome email.
Choose Your Email Sending Method
You can use various nodes to send emails in n8n:
Send Emailnode (requires SMTP credentials)Gmailnode (Google account integration)AWS SESnode (Amazon Simple Email Service)
In this tutorial, we’ll use the AWS SES node for better deliverability and professional setup.
Configuring the AWS SES Node
- Add a new node by clicking the plus button (
+). - Search for and select the
AWS SESnode. - Set the Operation to
Send Email. - Select or create credentials with your AWS access key and secret key.
- Configure the email parameters:
- From Email: Your verified sender email address (preferably a branded domain).
- To Email: Use an expression to dynamically use the email submitted in the form.
- Subject: Example:
Welcome to Our Service! - Body: Personalize with the user's first name from the form data.
Using Expressions for Dynamic Content
- Click the gears icon next to the field (e.g., To Email).
- Select Add Expression.
- Use the following expression to access the webhook data:
{{$json["body"]["email"]}}
- Similarly, for the email body, you can write:
Hello {{$json["body"]["firstName"]}}, welcome to our service!
This dynamically inserts the user's email and first name into the email.
For more details on configuring this node, refer to the AWS SES Node Documentation{:target="_blank"}.
Step 4: Connecting the Nodes
- Connect the Webhook node output to the AWS SES node input.
- This ensures that once the webhook receives the form submission, the email will be sent automatically.
Step 5: Testing the Workflow
- Make sure the webhook node is listening for test events.
- Submit the Google Form with valid data.
- Check if the email was sent successfully.
- Review the execution in n8n to verify the flow.
If you encounter issues during testing, consider reviewing Understanding Data in n8n to better grasp how data flows through your workflow.
Step 6: Adding Conditional Logic for Corporate Users
To extend the workflow, you might want to identify if a user is a corporate customer based on their email domain.
Adding an IF Node
- Add a new node and select the
IFnode. - Connect the output of the AWS SES node to the IF node.
- Configure the IF node with the following conditions:
- Mode: Multiple Conditions (Any)
- Condition 1:
- Property:
{{$node["Webhook"].json["body"]["email"]}} - Condition:
does not end with - Value:
gmail.com
- Property:
- Condition 2:
- Property:
{{$node["Webhook"].json["body"]["email"]}} - Condition:
does not end with - Value:
hotmail.com
- Property:
This checks if the email is not a common free email provider, assuming such emails belong to corporate users.
Step 7: Logging Corporate Users in Google Sheets
For corporate users (true branch of the IF node), you can append their data to a Google Sheet for follow-up.
Setting Up Google Sheets Node
- Add a new node and select the
Google Sheetsnode. - Set the operation to
Append Row. - Connect the True output of the IF node to this Google Sheets node.
- Configure the Google Sheets node:
- Authenticate with your Google account.
- Select the spreadsheet and sheet where you want to append data.
- Map columns to the webhook data:
| Sheet Column | Expression |
|---|---|
| First Name | {{$node["Webhook"].json["body"]["firstName"]}} |
| Last Name | {{$node["Webhook"].json["body"]["lastName"]}} |
{{$node["Webhook"].json["body"]["email"]}} |
|
| Role | {{$node["Webhook"].json["body"]["role"]}} |
For more on Google Sheets integration, see the Google Sheets Node Documentation{:target="_blank"}.
Common Mistakes and Troubleshooting
- Webhook Not Listening: Ensure you click Listen for Test Events before submitting the form. Without this, n8n will reject incoming requests.
- Incorrect Webhook URL: Use the Test URL during testing and switch to Production URL in live environments. Update the Google Apps Script accordingly.
- Email Not Sent: Verify your SMTP or AWS SES credentials are correct and that the sender email is verified.
- Dynamic Expressions Not Working: Make sure you are referencing the correct node and property in your expressions. Use the expression editor to avoid syntax errors.
- Google Apps Script Permissions: When deploying the script, grant all necessary permissions for the script to run and send HTTP requests.
- Google Sheets Authentication: Ensure that your Google Sheets credentials are authorized and have write access to the target sheet.
For making your workflow more reliable, consider learning about Master Error Handling in n8n.
Additional Tips
- Use HTML Body in the email node if you want to send rich-text emails with formatting.
- For production, consider adding error handling nodes to manage failures gracefully.
- Use regular expressions in the IF node for more robust email domain checking.
- Store sensitive credentials securely using n8n’s credential system.
Useful n8n Documentation Links
Quick Reference Cheat Sheet
| Step | Node Type | Key Settings/Expressions |
|---|---|---|
| Trigger on form submission | Webhook | HTTP Method: POST; Listen for Test Events |
| Send welcome email | AWS SES | To: {{$json["body"]["email"]}}; Body: Hello {{$json["body"]["firstName"]}} |
| Check corporate email | IF | Email does not end with gmail.com or hotmail.com |
| Log corporate users | Google Sheets | Append Row; map columns to webhook JSON body |
By following the steps above, you will have built a fully automated workflow that triggers on Google Form submissions, sends personalized welcome emails, and logs corporate users for further action, all within n8n’s powerful automation platform.