Giter VIP home page Giter VIP logo

tf-lambda-limit-one-entry's Introduction

tf-lambda-limit-one-entry

Script to limit entry on a Typeform to one per email address.

What does it do?

You want to avoid people filling twice the same Typeform? Using this serverless function we will update logic block on a typeform. It adds a new constraint every time someone fills the form for the best time. If they try again they will be redirected to an error screen.

How to use it?

Pre-requesites:

  • a Typeform account, create one here
  • an AWS account, create one here
  • aws-cli installed and configured, instructions
  • Serverless framework installed locally - npm install -g serverless

Get Typeform ready

  1. Create a form if you don't have one.
  2. Add an email field if you don't have one already.
  3. Add a statement containing an explicit error message. We will display it when a user already filled the form.
  4. Add sample logic between the email block and statement.
  5. Get your typeform URL, and keep your form ID. https://{ACCOUNT_NAME}.typeform.com/to/{FORM_ID}
  6. Hit https://api.typeform.com/forms/{FORM_ID} directly in the browser.

payload from Typeform API for form definition

  1. Look at the JSON payload, under fields array and extract the id and ref of both the field you want to use as a unique identifier (email block) and the statement block.
  2. Finally get yourself a Typeform personal token here

Setup the function

  1. Clone repo locally git clone https://github.com/picsoung/tf-lambda-limit-one-entry.git
  2. cd tf-lambda-limit-one-entry.git
  3. run npm install
  4. Open serverless.yml
  5. Update environment variables with your own: FORM_ID: 'YOUR_FORM_ID' # Which form you want to update FIELD_ID: 'YOUR_EMAIL_FIELD_ID' # Id of the unique field FIELD_REF: 'YOUR_EMAIL_FIELD_REF' # Ref of the unique field TF_TOKEN: 'TYPEFORM_PERSONAL_TOKEN' #Typeform API token ALREADY_FILLED_FIELD_REF: 'STATEMENT_BLOCK_FIELD_REF' # Ref for the "already filled" statement block
  6. Deploy function to production sls deploy
  7. Test it live ๐Ÿคฉ

Contribute

Something is mispelled, the code could be optimized, you want to add features...? Feel free to fork this repo and summit a pull request.

First timers welcome ๐Ÿ˜ƒ

Build your own

This is a showcase of what's doable to enrich your typeform fields with data. Using this function as an example you build more complex interactions.

Let us know if you are building something.

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.