How can I integrate Twilio’s API with Shopify to enable customer login via WhatsApp OTP?

Topic summary

A developer seeks to implement WhatsApp-based OTP login for a Shopify store using Twilio’s API, allowing customers to authenticate with their phone number instead of traditional email/password.

Key Challenge:
Shopify doesn’t natively support custom authentication flows, requiring workarounds through custom storefronts, headless architecture, or the Storefront/Customer API.

Proposed Solution Workflow:

  • Customer enters phone number on custom login page
  • Backend triggers Twilio API to send OTP via WhatsApp
  • User verifies with received code
  • System authenticates via Shopify Customer API or creates new account

Technical Implementation Steps:

  1. Frontend form to capture phone number
  2. Backend integration with Twilio’s WhatsApp messaging API
  3. OTP storage and verification (using Redis/database with expiration)
  4. Shopify customer authentication using customerAccessTokenCreate mutation
  5. Session management via secure cookies or JWT

Status: One respondent provided detailed technical guidance with code examples. The discussion remains open for additional input on best practices and existing apps that might simplify implementation.

Summarized with AI on October 28. AI used: claude-sonnet-4-5-20250929.

I’m trying to build a custom login on my Shopify store using Twilio’s API to send OTPs via WhatsApp. The goal is for customers to log in using their phone number and receive a verification code on WhatsApp to complete the login process.

Has anyone implemented this before?
I’m looking for any of the following:

  • Guidance on the best way to approach this

  • Example code for handling WhatsApp OTP verification and Shopify login

  • Best practices for managing sessions and authentication

  • Any existing apps that might help streamline or support this process

Any help or direction would be greatly appreciated!

Hi @Fatina ,

Solution Approach: Custom WhatsApp OTP Login on Shopify with Twilio

Objective:
Enable customers to log in using their phone number and verify via OTP sent on WhatsApp using Twilio’s API, bypassing the default Shopify email/password system.

  1. Understanding Shopify’s Limitations
    Shopify does not natively support custom authentication flows (like phone-based logins). However, it allows some workarounds via:

Custom storefronts using Shopify Storefront API
Headless Shopify architecture
Customer accounts API (Multipass or customer create/login endpoints)

  1. High-Level Architecture

Workflow:
User visits your custom login page.
Enters phone number.
Backend triggers Twilio API to send OTP via WhatsApp.
User enters OTP to verify.

On successful verification:
Log the user in using Shopify Customer API (if already registered).
Or redirect to registration/onboarding if new.

  1. Implementation Guidance

Step 1: Capture Phone Number (Frontend)
Create a custom login page:

html Code:

Send OTP

Step 2: Send OTP via Twilio WhatsApp (Backend)
javascript Code:
const twilio = require(‘twilio’);
const client = new twilio(accountSid, authToken);

await client.messages.create({
body: ‘Your login code is 123456’,
from: ‘whatsapp:+14155238886’,
to: whatsapp:+91XXXXXXXXXX,
});

Step 3: Verify OTP (Backend)
Maintain OTPs in Redis/DB with expiration. Match user input with stored OTP.

Step 4: Log In or Create Shopify Customer
Use Shopify Admin API:

graphql Code:

mutation customerAccessTokenCreate($input: CustomerAccessTokenCreateInput!) {
customerAccessTokenCreate(input: $input) {
customerAccessToken {
accessToken
expiresAt
}
userErrors {
field
message
}
}
}

Step 5: Set Session / Cookie
Use secure, HttpOnly cookies or JWT to maintain the session.

Hope this will help, Let me know if you need more guidance.

Regards,