Skip to main content

Method Signature

FAD_SDK.startVideoagreement(
  legend: string,
  configuration?: Configuration
): Promise<VideoagreementResponse>

Description

The startVideoagreement() method initiates the video agreement module, which records the user reading and accepting specific terms, conditions, or declarations. The text is displayed on screen for the user to read aloud while being recorded.

Parameters

legend
string
required
The text that the user must read aloud during the recording. This text will be displayed on screen for the user to follow.Example: “I, John Doe, with ID number 123456, declare that the information I have provided is true and accurate.”
configuration
Configuration
Optional configuration object for customizing the module’s behavior and appearance

Returns

VideoagreementResponse
Promise<object>
A promise that resolves with the video agreement module response

Code Example

import FadSDK from '@fad-producto/fad-sdk';

const TOKEN = 'YOUR_FAD_TOKEN';

const CONFIGURATION = {
  allowClose: true,
  views: {
    instructions: true,
    preview: true,
  },
  selfie: {
    captureSelfie: false,
    imageType: 'image/png',
    imageQuality: 1,
  },
  timer: {
    recording: { min: 5, max: 40 },
    faceUndetected: 5,
  },
  legend: {
    speed: FadSDK.Constants.Videoagreement.LegendSpeedMode.SLOW
  },
  customization: {
    fadCustomization: {
      colors: {
        primary: '#0066CC',
      },
      buttons: {
        primary: {
          backgroundColor: '#0066CC',
          labelColor: '#ffffff',
        },
      },
    },
    moduleCustomization: {
      legends: {
        buttonRecord: 'Start recording',
        buttonFinish: 'Finish',
        acceptancetInstruction: 'Record the following text clearly and loudly',
        recording: 'Recording',
        focusface: 'Frame your face within the guide',
      },
      legendsInstructions: {
        title: 'Video Agreement',
        subtitle: 'Confirm by voice your acceptance of the document',
        buttonNext: 'Continue',
      },
      legendsPreview: {
        title: 'Video Agreement',
        buttonRetry: 'Record again',
        buttonNext: 'Confirm recording',
      },
    },
  },
};

async function captureVideoAgreement() {
  const options = {
    environment: FadSDK.getFadEnvironments().UATHA
  };

  const FAD_SDK = new FadSDK(TOKEN, options);
  
  try {
    const LEGEND = 'I, John Doe, born on June 20, with voter ID number: 123456789, ' +
      'declare that I am Single, with monthly income of $15,667.21, ' +
      'I have my own house or apartment, I currently have credit cards, ' +
      'and I acknowledge that the information I have provided is truthful.';

    const videoagreementResponse = await FAD_SDK.startVideoagreement(
      LEGEND,
      CONFIGURATION
    );

    if (videoagreementResponse.event === FadSDK.Constants.EventModule.MODULE_CLOSED) {
      console.log('Module closed by the user');
      return;
    }

    // Process the results
    console.log('Video agreement captured successfully');

    // Create URL for the video blob
    const videoUrl = URL.createObjectURL(videoagreementResponse.data.video);
    console.log('Video URL:', videoUrl);

    // Display in HTML video element
    // document.getElementById('video-id').src = videoUrl;

  } catch (error) {
    if (error.code === FadSDK.Errors.Videoagreement.NOT_ACCEPT_CAMERA_PERMISSION) {
      console.error('Camera permission not granted');
    } else {
      console.error('Error:', error);
    }
  } finally {
    FAD_SDK.end();
  }
}

Error Handling

The method may throw errors that can be identified using FadSDK.Errors.Videoagreement:
  • NOT_ACCEPT_CAMERA_PERMISSION - Camera permission was not granted
See the Videoagreement Error Codes page for a complete list of error codes.
The video agreement module requires both camera and microphone permissions to function properly.
Always call FAD_SDK.end() in a finally block to properly clean up resources after the module completes or fails.

Build docs developers (and LLMs) love