The Captcha module presents a CAPTCHA challenge during onboarding to verify human interaction and reduce automated abuse. It then returns the user's response to your app.
In Dashboard, Captcha isn't a standalone module. Instead, enable "OTP configuration" in the module settings when adding the Email or Phone module. How you use this module depends on your integration pattern. In Patterns 1 and 2, you add the module to a FlowConfig in code as shown on this page. In Pattern 3, you define your modules and configuration in Dashboard as a Flow or Workflow and reference it by ID with startFlow() or startWorkflow() as shown on Run Flows Configured in Dashboard.
Add Captcha
Add the module with addCaptcha().
flowConfigBuilder.addCaptcha()
flowConfigBuilder.addCaptcha();
Example
The example below adds Captcha as the only step in the flow and listens for the result through onCaptchaCollected().
val flowConfig = FlowConfig.Builder()
.addCaptcha()
.build()
val onboardingListener = object : OnboardingListener() {
override fun onCaptchaCollected(captchaResult: CaptchaResult) {
// CAPTCHA step completed. Process the result.
}
}
IncodeWelcome.getInstance()
.startOnboarding(activityContext, sessionConfig, flowConfig, onboardingListener)
FlowConfig flowConfig = new FlowConfig.Builder()
.addCaptcha()
.build();
IncodeWelcome.OnboardingListener onboardingListener = new IncodeWelcome.OnboardingListener() {
@Override
public void onCaptchaCollected(@NonNull CaptchaResult captchaResult) {
// CAPTCHA step completed. Process the result.
}
};
IncodeWelcome.getInstance()
.startOnboarding(activityContext, sessionConfig, flowConfig, onboardingListener);
Configuration Options
Captcha has no configurable options. It is added with addCaptcha() and has no Builder. For the class reference, see Captcha in API Reference.
Result
Captcha delivers a CaptchaResult to the onCaptchaCollected(CaptchaResult) callback on the OnboardingListener. This callback is declared by CaptchaListener. Key fields include:
captchaResponse: The CAPTCHA response string. Can benullwhenresultCodeis notSUCCESS.- Fields inherited from
BaseResult:resultCode: TheResultCodefor this result.error: WhenresultCodeisERROR, theThrowablethat caused it; otherwise,null.deviceStats: TheDeviceStatssnapshot of the device state when the result was produced.motionStatus: Device motion assessment during capture. One of the following:UNCLEAR: Motion could not be determined; the default.PASS: Device motion was within acceptable limits.FAIL: Excessive device motion was detected.
Errors surface via OnboardingListener.onError(Throwable). Captcha does not define a module-specific exception subtype. Failures are reported with the generic Throwable carried in CaptchaResult.error. This same Throwable is also available on the shared onError path.
For all fields, see CaptchaResult in API Reference.