SDK
Official EngageLab OTP Node.js and Python SDKs.
EngageLab provides official Node.js and Python SDKs to help you integrate OTP delivery, verification, and Webhook callback features with zero dependencies.
Node.js SDK
The official Node.js SDK supports Node.js 14+ and includes TypeScript declarations.
Installation
npm install engagelab-otp
Quickstart
const { OTPClient } = require('engagelab-otp');
const otp = new OTPClient(
process.env.ENGAGELAB_DEV_KEY,
process.env.ENGAGELAB_DEV_SECRET
);
// Platform-generated OTP — the simplest way
const { message_id } = await otp.send('+6591234567', 'your-template-id', {}, 'en');
const { verified } = await otp.verify(message_id, userTypedCode);
Webhook Callback (Express)
EngageLab signs callbacks using X-CALLBACK-ID (HMAC-SHA256). The SDK verifies the signature and parses the events for you.
const express = require('express');
const { WebhookVerifier } = require('engagelab-otp');
const app = express();
app.use(express.json());
const verifier = new WebhookVerifier({
username: process.env.ENGAGELAB_WEBHOOK_USERNAME,
secret: process.env.ENGAGELAB_WEBHOOK_SECRET,
});
app.post('/webhook', verifier.middleware(async (events) => {
for (const e of events) {
if (e.kind !== 'message_status') continue;
if (!e.is_terminal) continue; // In transit (e.g., retrying) — wait
if (e.status === 'delivered') await markDelivered(e.message_id);
else if (e.status === 'verified') await markVerified(e.message_id);
}
}));
For more examples, including custom OTP code sending and error handling, visit engagelab-otp on npm or the Github repository.
Python SDK
The official Python SDK supports Python 3.8+ and has zero external dependencies.
Installation
pip install engagelab-otp
Quickstart
import os
from engagelab_otp import OTPClient
otp = OTPClient(
os.environ["ENGAGELAB_DEV_KEY"],
os.environ["ENGAGELAB_DEV_SECRET"],
)
# Platform-generated OTP — the simplest way
result = otp.send("+6591234567", "your-template-id", {"name": "Alice"}, language="en")
check = otp.verify(result["message_id"], user_typed_code)
if check["verified"]:
print("Success!")
Webhook Callback (Flask)
The SDK provides a WebhookVerifier that automatically verifies the HMAC-SHA256 signature and parses the event payload.
import os
from flask import Flask
from engagelab_otp import WebhookVerifier, MessageStatusEvent
app = Flask(__name__)
verifier = WebhookVerifier(
username=os.environ["ENGAGELAB_WEBHOOK_USERNAME"],
secret=os.environ["ENGAGELAB_WEBHOOK_SECRET"],
)
def handle(events):
for e in events:
if not isinstance(e, MessageStatusEvent):
continue
if not e.is_terminal:
continue # In transit, wait
if e.status == "delivered":
mark_delivered(e.message_id)
elif e.status == "verified":
mark_verified(e.message_id)
app.add_url_rule(
"/webhook",
"engagelab_webhook",
verifier.flask_view(handle),
methods=["POST"],
)
For more examples, including custom OTP code sending and error handling, visit engagelab-otp on PyPI or the Github repository.










