# Wix form to collect Pii data, with OTP sms verification

**URL:** <https://forum.wixstudio.com/t/wix-form-to-collect-pii-data-with-otp-sms-verification/59601>\
**Category:** Ask the community\
**Tags:** wix-forms, api, wix-members-area, code\
**Created:** [May 30, 2024, 4:52pm UTC](https://forum.wixstudio.com/t/wix-form-to-collect-pii-data-with-otp-sms-verification/59601 "2024-05-30T16:52:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![user2387](https://avatars.discourse-cdn.com/v4/letter/u/bb73d2/32.png) [@user2387](https://forum.wixstudio.com/u/user2387)\
**Post date:** [May 30, 2024, 4:52pm UTC](https://forum.wixstudio.com/t/wix-form-to-collect-pii-data-with-otp-sms-verification/59601/1 "2024-05-30T16:52:34Z")

</div>

I will build a website for a community on Wix, and i need to collect sensitive data from members like the national id number, so i am thinking of making a form to collect data but i need a sort of a security wall before leting website visitors accessing the form, i need to make sure that they are real people, so i am thinking of a solution like asking them to provide their phone number and then send them a one time code that they need to enter before they proceed to the form. How can i achieve this in Wix taking into consideration that i am not good at coding.

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [July 4, 2024, 7:26pm UTC](https://forum.wixstudio.com/t/wix-form-to-collect-pii-data-with-otp-sms-verification/59601/3 "2024-07-04T19:26:30Z")

</div>

Well first of all, maybe you should just install the Wix-Members-Area, which will make sure that a person first has to register to your site and become a member.

Wouldn’t this already solve your problem ?

If not than your next step would be to generate a confirmation-process, like you already described above in your post by creting either a …

1. CONFIRMATION-EMAIL

…or…

1. CONFIRMATION-SMS

For the first one you will need to install/setup → Wix-Triggered-Emails and adding some more complex code onto your wix-website → **not for beginners!!!**

For the second one you could integrate some third-party-API, for example TWILIO and generate your SMS-CONFIRMATION-PROCESS…

For example…

### Create a Verification Process

1. **Design the Verification Workflow:**

- Add an initial form where users input their phone number.
- Use Wix Corvid (now Velo by Wix) to create a simple backend logic to handle verification.

1. **Add Custom Code:**

- Go to your Wix Editor and enable **Velo by Wix** (if not already enabled).
- Add the custom code to handle the verification process. Here’s a basic outline of the code:

javascript

Code kopieren

```javascript
// Import necessary modules
import {sendSMS} from 'backend/twilio'; // This would be a backend module you create to handle Twilio SMS

// Function to generate a random verification code
function generateVerificationCode() {
    return Math.floor(100000 + Math.random() * 900000).toString();
}

// Function to handle phone number submission
export function handlePhoneNumberSubmission(phoneNumber) {
    let verificationCode = generateVerificationCode();
    
    // Store the verification code temporarily
    wixStorage.local.setItem('verificationCode', verificationCode);

    // Send the verification code via SMS
    sendSMS(phoneNumber, verificationCode)
        .then(response => {
            console.log('SMS sent successfully');
        })
        .catch(error => {
            console.error('Error sending SMS:', error);
        });
}

// Function to verify the code entered by the user
export function verifyCode(inputCode) {
    let storedCode = wixStorage.local.getItem('verificationCode');
    return storedCode === inputCode;
}

```

1. **Backend Module for Twilio Integration:**

- Create a backend file (e.g., `twilio.jsw`) to handle communication with Twilio’s API.

javascript

Code kopieren

```javascript
import {fetch} from 'wix-fetch';

export function sendSMS(phoneNumber, verificationCode) {
    const accountSid = 'your_twilio_account_sid';
    const authToken = 'your_twilio_auth_token';
    const fromPhoneNumber = 'your_twilio_phone_number';

    const url = `https://api.twilio.com/2010-04-01/Accounts/${accountSid}/Messages.json`;

    const data = {
        To: phoneNumber,
        From: fromPhoneNumber,
        Body: `Your verification code is: ${verificationCode}`
    };

    const headers = {
        'Authorization': 'Basic ' + btoa(`${accountSid}:${authToken}`),
        'Content-Type': 'application/x-www-form-urlencoded'
    };

    return fetch(url, {
        method: 'POST',
        headers: headers,
        body: new URLSearchParams(data).toString()
    });
}

```

---

<div class="post-metadata">

**Author:** ![Ina\_Roettger](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ina_roettger/32/99750_2.png) [@Ina\_Roettger](https://forum.wixstudio.com/u/Ina_Roettger)\
**Post date:** [November 12, 2024, 3:46pm UTC](https://forum.wixstudio.com/t/wix-form-to-collect-pii-data-with-otp-sms-verification/59601/4 "2024-11-12T15:46:22Z")

</div>

Using a phone number verification step is smart to make sure real people are accessing the form. On Wix, there are apps and integrations that can help with that without needing coding skills. You might want to check out Wix Automations or third-party services that connect to Wix through Zapier or APIs. They can send out a one-time code for verification. Just keep in mind that some visitors might use a [temp mobile number](https://www.tardigrada.io/) from sites like Tardigrada if they’re cautious about privacy, which is great for them but might not be what you need for ID collection.
