Script to limit entry on a Typeform to one per email address.
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.
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
- Create a form if you don't have one.
- Add an email field if you don't have one already.
- Add a statement containing an explicit error message. We will display it when a user already filled the form.
- Add sample logic between the email block and statement.
- Get your typeform URL, and keep your form ID.
https://{ACCOUNT_NAME}.typeform.com/to/{FORM_ID}
- Hit
https://api.typeform.com/forms/{FORM_ID}
directly in the browser.
- Look at the JSON payload, under
fields
array and extract theid
andref
of both the field you want to use as a unique identifier (email block) and the statement block. - Finally get yourself a Typeform personal token here
- Clone repo locally
git clone https://github.com/picsoung/tf-lambda-limit-one-entry.git
cd tf-lambda-limit-one-entry.git
- run
npm install
- Open
serverless.yml
- Update environment variables with your own:
FORM_ID: 'YOUR_FORM_ID'
# Which form you want to updateFIELD_ID: 'YOUR_EMAIL_FIELD_ID'
# Id of the unique fieldFIELD_REF: 'YOUR_EMAIL_FIELD_REF'
# Ref of the unique fieldTF_TOKEN: 'TYPEFORM_PERSONAL_TOKEN
' #Typeform API tokenALREADY_FILLED_FIELD_REF: 'STATEMENT_BLOCK_FIELD_REF'
# Ref for the "already filled" statement block - Deploy function to production
sls deploy
- Test it live 🤩
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 😃
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.