Overview

The OTP Link feature provides a secure verification method by sending clickable links via WhatsApp. Unlike traditional OTP codes, this approach allows users to verify their identity with a single tap, creating a smoother user experience while maintaining security.

How It Works

  1. Your application requests an OTP link to be sent to a user’s WhatsApp
  2. CrunchzApp generates a unique verification link and delivers it via WhatsApp
  3. The user clicks the link, which opens in their browser
  4. Upon successful verification, the user is redirected to your application or a callback URL is triggered

Available Methods

Send a standard verification link to a WhatsApp contact.
use CrunchzApp\CrunchzApp;

CrunchzApp::otp('link')
  ->contact('xxx@c.us')
  ->send();
By default, OTP links expire after 15 minutes and use a standard verification message.
Create a fully customized verification experience with custom prompts, messages, and callbacks.
use CrunchzApp\CrunchzApp;
use Illuminate\Support\Str;

$code = strtoupper(Str::random(6));
return CrunchzApp::otp('link')
  ->contact('xxx@c.us')
  ->prompt('Give me login code at MyRepublic')
  ->responseMessage(
    successResponse: 'This is your code, please make it safe and secure *##'.$code.'##*',
    failedResponse: 'Your phone number or your prompt are incorrect',
    expiredResponse: 'This link is expired, please try a new link',
  )
  ->callback(
    successCallback: 'https://github.com/crunchzApp/success-callback',
    failedCallback: 'https://github.com/crunchzApp/failed-callback'
  )
  ->send();
When using custom codes in your response messages, ensure they are properly formatted and highlighted (as shown with the ##code## syntax in the example).

Customization Options

The prompt() method allows you to customize the text shown to users when they click the verification link. This can be used to provide context about why they’re being asked to verify.
The responseMessage() method lets you define custom messages for different verification outcomes:
  • successResponse: Shown after successful verification
  • failedResponse: Shown after failed verification
  • expiredResponse: Shown when the link has expired
The callback() method allows you to specify webhook URLs that will be called when verification succeeds or fails:
  • successCallback: Called on successful verification
  • failedCallback: Called on failed verification

Common Use Cases

Send a verification link to users instead of requiring them to remember and enter passwords.
Provide a secure way for users to regain access to their accounts without complex recovery processes.
Verify user intent for sensitive operations like payments or account changes with a simple click.
Add an extra layer of security by requiring link verification in addition to password login.

Error Handling