A Serverless service to handle form submissions using AWS Lambda.
A contact form usually email both Submitter and Form's Creator/Owner. This Serverless function handle sending of email to both parties.
Fill out the demo form with a real email and wait for result.
Result
S3 Trigger
Bot/Spam deterrent features
Dev Stack
Run Stack
To Test
npm install
./run-data-tests.sh
To Run/Deploy
cp env.yml.example env.yml
npm install
npm run deploy
demo/!config.json
https://{some-id}.execute-api.us-east-1.amazonaws.com/dev/form/demo
provider:
name: aws
runtime: nodejs8.10
stage: dev # change dev to prod
region: us-east-1
Because it is Serverless and event triggerable. SQS and SNS has a limit on message size.
You can use s3 event to trigger followup actions, such as Zapier callback, email subscription, etc... It can also store this data somewhere like on Amazon Aurora Serverless.
Usually, we want the form to be fast. The form is already doing a lot of work so we don't want to tack on any unnecessary work. The benefit of s3 event is to defer the work at a later time, allowing for faster response time.
Other things that can add more delays in the future is support of plugins like Payment Gateways, such as Stripe and/or Paypal. It may result in pushing email to a later s3 event trigger.
forms/ - example and for unit testing
lib/ - helpers
templates/ - email templates
tests/ - test data
handler.js - main form submit handler
env.yml - define environment variable such as FORMBUCKET
# on AWS s3 - bucket
form-id-folder/!config.json
form-id-folder/guid-guid-guid-guid.submit
form-id-folder/result-guid-result-guid.submit
use-random-guid-for-best-form-id-performance/!config.json
{
"name": "friendly form name, field can be use in email subject",
"form_id": "74d15a89-e358-4980-a29b-0c3daf7fcd95",
"form_creds": "protect form with: username,password",
"admin_creds": "protect form admin page with: username,password",
"smtp_host": "yourdomain.com",
"smtp_port": "587",
"smtp_user": "login@yourdomain.com",
"smtp_pass": "YourPassword",
"from_email": "provide this if smtp_user is not a valid email",
"recaptcha_field": "the form field name, default g-recaptcha-response",
"recaptcha_key": "the site key",
"recaptcha_secret": "the secret key",
"valid_origins": "a comma separated list of valid origins or * for all",
"honeypot_field": "honeypot form field name",
"redir": "https://www.yourdomain.com/thank-you-page",
"post_url": "url to post the result to",
"post_message": "thank you message",
"business_name": "this field can provide company name in email",
"business_url": "this field can provide link in email",
"image_url": "this field can provide logo in email",
"notify_email": "friends@yourdomain.com",
"notify_subject": "New form submit by {{ email }}",
"notify_body": "actual mjml template or empty to use fallback/owner.mjml",
"email_field": "identify the submitter's email, e.g. email field name on the form",
"email_subject": "{{ name }}, thank you for contacting us",
"email_body": "actual mjml template or empty to use fallback/submitter.mjml",
"pay_gateway": "stripe",
"pay_client_id": "stripe client id",
"pay_secret": "stripe secret",
"pay_public_key": "stripe public key",
"pay_connect_string": "additional connection string separate by semicolon",
"started_at": "yyyy-mm-dd when the form start",
"ended_at": "yyyy-mm-dd when the form end"
}
Since this is Serverless, this setup can really scale. It can be use as a component in your Software-as-a-Service SaaS platform, like a clone of wufoo. All you need is an Admin portal with a FormBuilder - hint - grapejs