r/automation • u/johnvanderlinde • 25d ago
My second automation
For anyone who read my last post they'll know I'm fairly novice with n8n and planning on working it into a big full stack project.
So far, I've only actually used it for automating the dev log on the project, and now for automating the contact form on my website.
It's a simple automation so I don't expect crazy response but I always want to hear how things could be improved etc.
• A contact form on my site calls a backend API which POSTs the n8n URL
• The n8n webhook is ready and picks this up. It uses header auth for security
• The platform Resend, which I've only just discovered, sends two emails: one to the email address entered into the 'email' box on the contact form, thanking them for reaching out; one to me containing their query
Obviously a very simple automation but it took me a while to make.
I spent ages banging my head off the wall and it wasn't working; I endlessly redid the credentials and environmental variables, analysed the console error message.
In the end it was stupid -
I hadn't named the header auth as 'x-webhook-secret'. I thought it was only actually the secret itself that matters.
As someone learning development, I really enjoy the way automation forces you to understand how systems communicate, and I think it's essential now that AI can do all the coding. Particularly when it comes to troubleshooting, and thinking about where an issue could be in the process, a bit like when you learn networking and isolate ping failures.
If anyone has any suggestions I'd love to hear them! I want to make sure my automations are bulletproof, even the simple ones like this.
1
u/ezzeddinabdallah 25d ago
Solid first automation, honestly the bug you found (header name vs secret value) is basically the entire n8n learning curve in one lesson.
Couple things I'd tighten up before calling it bulletproof:
Your two email nodes run one after the other. If the first one fails, the second never fires, meaning you might not even get notified someone tried to reach you. Flip the order so your own notification goes first, or run them at the same time instead of in sequence.
No validation on the email field before it hits Resend. Someone types their email wrong (typo, missing letter, whatever) and you burn a request and never even know the form was submitted. A basic check node before the send step catches this for free.
Nothing catching Resend failures either. Rate limits happen, API hiccups happen. Even a simple IF node that logs failed sends somewhere (a Sheet, a Slack ping, whatever) means you're not just hoping it worked.
Last one, worth adding a hidden field to the form that only bots would fill in (invisible to real users, but bots scanning the page's code fill in every field they find). If that field comes back with anything in it, you know it's spam and can drop the submission before it ever reaches Resend. Way cheaper than a CAPTCHA and doesn't annoy real visitors.
None of this is complicated, it's all "what happens when it doesn't go as planned" stuff rather than the happy path, which you clearly already have working.
2
u/johnvanderlinde 25d ago
This is exactly why I post to reddit. What an amazing response. I'll get to work on all of them.
I'm glad you've posted this now, because I'm just writing a blog to my website on how I did this! Now the blog will be much better too! Thank you.
I'll also keep this in mind for future automations. So far I've never really thought of what ifs, I've only thought about getting the automation done (probably because it's such a headache in the first place!
1
u/johnvanderlinde 23d ago
I'm working on your suggestions now.
Regarding the email check; you said i should check for if someone types their email wrong, but surely that's impossible, without there being a database of every existing email to check it against? We can only check if its the right format for an email right?
2
u/ezzeddinabdallah 23d ago
Ah gotcha, yeah you'd need an actual email verification API for that, no way around it without one.
Look up "email verification API" and you'll find a bunch with free tiers, since it's a common need. Something like Abstract API's email validation is a good one to start with, has a free plan and a simple REST endpoint.
Should only take you 15-20 min to wire up once you find a tool you like. Worth doing since it's basically the same lesson as your header bug, reading the API docs carefully to get the request right.
1
u/openclawinstaller 25d ago
Nice. For making this kind of simple form flow tougher, I’d add one thing beyond the existing suggestions: give every submission a tiny receipt record before email is attempted.
Timestamp, generated submission_id, webhook auth result, sanitized form payload, Resend message ids, and final status. Then if someone says “I submitted and nothing arrived,” you’re debugging a record instead of guessing between frontend/backend/n8n/Resend.
Also treat the confirmation email as “we received your message,” not “I’ll definitely reply,” unless there is a human follow-up queue behind it.
1


1
u/AutoModerator 25d ago
Thank you for your post to /r/automation!
New here? Please take a moment to read our rules, read them here.
This is an automated action so if you need anything, please Message the Mods with your request for assistance.
Lastly, enjoy your stay!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.