Git Product home page Git Product logo

serverless-contact-us-form's Introduction

Serverless Contact Us Form

The template: cloudformation.yml

Quickly deploy an endpoint to handle your contact us form on your static website. We don't want to have servers running just to handle our contact us form which rarely gets invoked. Oh, and we also need Captcha because we don't have time in our lives for spam.

You can get your reCAPTCHA secret here: https://www.google.com/recaptcha/admin#list

What AWS resources does this template use?

  • Lambda (API Function)
  • API Gateway (HTTP proxy to Lambda)
  • S3 (Lambda files)
  • SES (Send us the email)
  • CodeCommit (GIT repo)
  • CloudFormation (Infrastructure as Code)
  • IAM (AWS permissions & users)

HTML Form

<form action="<your api gateway url>" method="POST" id="contact-us-form">
    <div class="form-group">
        <label for="nameInputEmail1">Name</label>
        <input type="text" class="form-control" id="nameInputEmail1" name="name" placeholder="Full name">
    </div>
    <div class="form-group">
        <label for="exampleInputEmail1">Email address</label>
        <input type="email" class="form-control" id="exampleInputEmail1" name="email"
               placeholder="Enter email">
    </div>
    <div class="form-group">
        <label for="phoneInputEmail1">Phone number</label>
        <input type="text" class="form-control" id="phoneInputEmail1" name="phone"
               placeholder="Enter phone">
    </div>
    <div class="form-group">
        <label for="messageInputEmail1">Message</label>
        <textarea type="textarea" class="form-control" id="messageInputEmail1" name="message"
                  placeholder="Enter message"></textarea>
    </div>
    <p class="thanks">Thanks!  We'll contact you soon.</p>
    <button type="submit" class="btn btn-primary g-recaptcha"
      data-sitekey="6LdrWS0UAAAAAPAokGKpRhrObJkaaCX0EMsEiofN"
      data-callback="onContctUsSubmit" data-badge="inline" >Submit</button>
</form>

JQuery example...

$.post($("#contact-us-form").attr('action'), JSON.stringify({
    name: $("#contact-us-form input[name='name']").val(),
    email: $("#contact-us-form input[name='email']").val(),
    phone: $("#contact-us-form input[name='phone']").val(),
    message: $("#contact-us-form textarea[name='message']").val(),
    'g-recaptcha-response': $("#contact-us-form textarea[name='g-recaptcha-response']").val()
}), function (data) {
    $(".thanks").show();
    $("#contact-us-form button").hide();
}, 'json');

serverless-contact-us-form's People

Contributors

rgfindl avatar mehradoo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.