A static form that collects signatures to a petition using Cloudant and OpenWhisk
Clone or download
Latest commit 05372d6 Feb 22, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
css First form Jan 31, 2017
fonts First form Jan 31, 2017
img workflow3 Feb 8, 2017
js jquery version downgrade Jan 31, 2017
openwhisk tidy up Feb 9, 2017
.gitignore added openwhisk actions Feb 8, 2017
README.md Update README.md Feb 22, 2017
index.html more beauty Feb 8, 2017
verify.html Verify page Feb 8, 2017

README.md

Serverless online-petition system

Demo code to show how to create a web form that collects signatures for an online petition saving the data into a Cloudant database. It uses

  • GitHub Pages to serve out static content
  • OpenWhisk to handle the form submissions
  • IBM Cloudant to store the petition submission data
  • SendGrid to send transactional emails

One workflow handles the form submission itself:

schematic

Another handles what happens when the link on the confirmation is clicked:

schematic

All of the above can be deployed without having any fixed computing hardware dedicated to you.

All of the services can be started for free and operated (within time and load limits) for zero cost. To handle larger volumes of traffic, smaller fees or pay-as-you-go charges will apply.

OpenWhisk actions run singly or as a sequence of actions to handle form submissions and email verification links:

schematic

Read why and how we created this app. See the page in action at https://ibm-cds-labs.github.io/online-petition/

Sample deployment

Create a Cloudant database

  • Provision a Cloudant service instance in Bluemix using the web console or the Cloud Foundry CLI:
$ cf create-service cloudantNoSQLDB Lite serverless-demo
  • Create database named petitions in this Cloudant instance

Clone the sample repository

$ git clone https://github.com/ibm-cds-labs/online-petition.git
$ cd online-petition

Configure SendGrid

  • Sign-up for a SendGrid account (or log in)

  • Create an API token

    • Open the dashboard
    • Select Settings > API keys > Create API key
    • Name the API key and grant Full access to Mail send
    • Take note of the API Key ID (e.g. r9....OTQ)
  • Create a transactional email template

    • In the dashboard select Templates > Transactional

    • In the email body include the following text

        Click here [VERIFYURL] to confirm your email address.
      
  • Take note of the template id (e.g. b544f3c7-...d)

Deploy the OpenWhisk artifacts

$ deploy.sh
  • Take note of the displayed API URLs (e.g. https://1...9-gws.api-gw.mybluemix.net/petition/submit and https://1...9-gws.api-gw.mybluemix.net/petition/confirm)

Customize the petition web pages