The Videoagreement module allows users to record video statements confirming their agreement to terms and conditions. The module displays a legend (text) that users must read aloud while being recorded, ensuring verifiable consent with face detection.
Import the FAD SDK and prepare the text users will read:
import FadSDK from '@fad-producto/fad-sdk';const TOKEN = 'YOUR_FAD_TOKEN';// Text that will be displayed and read by userconst LEGEND = 'I, [Full Name], with date of birth [DOB], ' + 'identification number [ID], declare that I am [Status], ' + 'with monthly income of [Amount], and acknowledge that ' + 'the information I have provided is true and accurate.';
2
Configure Module Options
Set up the configuration with timer and UI settings:
Choose speed based on text length and expected reading pace of your users.
Timer Settings
Configure recording duration:
timer: { recording: { min: 5, // Minimum recording duration (seconds) max: 40 // Maximum recording duration (seconds) }, faceUndetected: 5 // Timeout if face not detected (seconds)}
Selfie Capture
Optionally capture a selfie at the end:
selfie: { captureSelfie: true, // Enable selfie capture imageType: 'image/png', // Output format imageQuality: 1 // Quality: 0.0 to 1.0}
View Configuration
views: { instructions: true, // Show instruction screen preview: true // Show preview for confirmation},allowClose: true // Allow users to close the module
import FadSDK from '@fad-producto/fad-sdk';async function recordAgreement() { const FAD_SDK = new FadSDK(TOKEN, { environment: FadSDK.getFadEnvironments().UATHA, }); const agreementText = 'I agree to the terms and conditions...'; try { const response = await FAD_SDK.startVideoagreement( agreementText, CONFIGURATION ); if (response.event === FadSDK.Constants.EventModule.MODULE_CLOSED) { return null; } return response.data.video; } finally { FAD_SDK.end(); }}
async function handleVideoAgreement(agreementText, userId) { const FAD_SDK = new FadSDK(TOKEN, { environment: FadSDK.getFadEnvironments().UATHA, }); try { const response = await FAD_SDK.startVideoagreement( agreementText, CONFIGURATION ); if (response.event === FadSDK.Constants.EventModule.MODULE_CLOSED) { throw new Error('User cancelled agreement'); } // Upload to server const formData = new FormData(); formData.append('video', response.data.video); formData.append('userId', userId); formData.append('agreementText', agreementText); formData.append('timestamp', new Date().toISOString()); const uploadResponse = await fetch('/api/agreements', { method: 'POST', body: formData, }); return await uploadResponse.json(); } finally { FAD_SDK.end(); }}
function buildAgreementText(userData) { return `I, ${userData.fullName}, with date of birth ${userData.dob}, ` + `identification number ${userData.idNumber}, declare that I am ` + `${userData.maritalStatus}, with monthly income of $${userData.income}, ` + `and acknowledge that the information I have provided is true and accurate.`;}async function recordPersonalizedAgreement(userData) { const agreementText = buildAgreementText(userData); const FAD_SDK = new FadSDK(TOKEN, { environment: FadSDK.getFadEnvironments().UATHA, }); try { const response = await FAD_SDK.startVideoagreement( agreementText, CONFIGURATION ); return response.data.video; } finally { FAD_SDK.end(); }}