AWS Cognito WhatsApp OTP Integration

Easily configure AWS Cognito to send One-Time Passwords (OTPs) via WhatsApp for user verification during sign-up or Multi-Factor Authentication (MFA) challenges.

AWS Cognito
User Login
WhatsApp OTP
Verified

Your Open-Source Edge with AWS Cognito

Our AWS Cognito integration is fully open-source with ready implementation in Node.js and React.js and Next.js Frontend.

WhatsApp Only Authentication

Phone number-based authentication with WhatsApp OTP. Great for authentication use-cases related to B2C mobile applications. Perfect for MFA and SMS Fallback as well.

WhatsApp + Email Authentication

Dual-channel authentication with both WhatsApp and email verification. Enhanced security through multiple verification channels ensuring maximum account protection.

Node.js Implementation

Complete working Lambda functions and backend implementation. Server-side code ready for production deployment with full AWS Cognito custom sender integration.

React Next.js Frontend

Complete working frontend to check end-to-end integration. Pre-built authentication flows and UI components ready for immediate implementation and testing.

Integrating SendZen with AWS Cognito

Our open-source project guides you step-by-step to set up WhatsApp OTP for your Cognito User Pools. Here's the high-level process:

1

Clone Our Repo

Grab the open-source AWS Cognito Custom Sender code from our GitHub repository.

Go to GitHub
2

Configure AWS Lambda

Deploy our provided Lambda function (Node.js) as your Cognito Custom Message Sender.

3

Connect SendZen API

Connect your WhatsApp number and get your SendZen API key to set it in the Lambda environment variables.

Get API Key
4

Test OTP Flow

Initiate a user sign-up or login to experience instant WhatsApp OTP delivery via Cognito.

Complete Implementation Guide

Follow these detailed steps to implement WhatsApp OTP authentication with AWS Cognito and SendZen. Our comprehensive guide ensures a smooth setup process.

1

Obtain and Secure Your SendZen API Key

Setup

To send messages via WhatsApp, you need API credentials from SendZen.

Create an account

Register for a free account at SendZen

Register your number

Follow the process to link your mobile number, which registers it with Meta for use with the WhatsApp Business API

Retrieve your API Key

Once registered, SendZen will generate an API key

Store the key securely

It is a security best practice to store this key in AWS Secrets Manager. The Lambda function will be configured to fetch the key from there rather than having it hardcoded

For details on the API endpoints, refer to the SendZen API Documentation
2

Deploy the Backend Infrastructure

Deployment

The open-source repository contains a serverless deployment script to provision all the required AWS resources.

Clone the repository

Get the source code containing the Lambda functions and deployment configuration

Run the deployment script

The script automates the following actions:

  • Configures the Cognito User Pool: Sets up a user pool to use a custom authentication flow
  • Deploys Lambda Triggers: Creates and deploys the five Lambda triggers required for the custom auth challenge cycle
  • Links Resources: Associates the Lambda triggers with the Cognito User Pool and grants necessary permissions

Lambda Triggers Deployed:

Define Auth Challenge
Create Auth Challenge
Verify Auth Challenge Response
Pre Sign-up
Post Confirmation
The Lambda functions are available in both C# and Node.js. During deployment, you will need to configure the function to access the SendZen API key from AWS Secrets Manager.
3

Implement the Client-Side Logic

Integration

Your client-side application must interact with the custom Cognito flow.

Initiate the flow

The user enters their phone number. Your application calls the Cognito InitiateAuth API action with the CUSTOM_AUTH flow type. This invokes the "Define" and "Create" Lambda triggers on the backend, which sends the WhatsApp OTP

Handle the challenge

Cognito returns a challenge to the client, prompting for the OTP. Your UI should now display an input field for the user to enter the code they received

Respond to the challenge

After the user submits the OTP, your application calls the RespondToAuthChallenge API action, sending the user's input. This invokes the "Verify" Lambda trigger, which validates the code and, upon success, issues authentication tokens

Our open-source repository includes a complete React/Next.js reference application that demonstrates this entire client-side flow.

Key Benefits for Your Cognito Authentication

Supercharge your AWS Cognito user experience with the power and reliability of WhatsApp for OTP.

Robust & Secure Cognito MFA

Leverage WhatsApp's end-to-end encryption for OTP delivery, adding an extra layer of trust and security to your AWS Cognito multi-factor authentication setup.

Global Reach & Deliverability

Ensure consistent OTP delivery worldwide, overcoming regional SMS challenges. Essential for global applications built on AWS.

Fully AWS-Native Experience

Our open-source Custom Sender seamlessly extends Cognito, letting you manage your authentication entirely within the AWS ecosystem.

Start Enhancing Cognito for Free

Begin building with our open-source Cognito integration today. No credit card required, ample messages to get you started.

Free Tier

600 Free WhatsApp Messages/Month

Test, integrate, and deploy your Cognito OTP solution without commitment. Our generous free tier ensures you can build and iterate with ease.

Open-Source Project

Full Source Code for Cognito Integration

Gain full transparency and control with our dedicated AWS Cognito WhatsApp OTP integration repository. Fork it, customize it, and deploy it with confidence.

Beyond Cognito: Explore More API Integrations

SendZen's flexible API powers WhatsApp messaging for a wide array of platforms and languages. Find your perfect fit.

Programming Language / Framework

Our comprehensive REST API and SDKs make integration straightforward for Java, C#, PHP, Ruby, Go, and more.

Need a Different Integration?

We're constantly expanding our integration ecosystem. Don't see your preferred auth platform? Let us help you build a custom solution.

Book a Demo - Let's Build It Together

Frequently Asked Questions about Cognito & WhatsApp OTP

Find answers to common questions about implementing WhatsApp OTP with AWS Cognito and SendZen.

Ready to upgrade your Cognito Authentication?

Explore our open-source solution, sign up for SendZen's free tier, and start delivering secure WhatsApp OTPs today.

WhatsApp OTP Authentication with AWS Cognito | SendZen | SendZen