This workflow follows the Emailsend → HTTP Request recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "Send OTP Verification",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "send-otp",
"responseMode": "responseNode",
"options": {}
},
"id": "webhook-2",
"name": "Webhook - Send OTP",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [
250,
300
]
},
{
"parameters": {
"functionCode": "// Generate 6-digit OTP\nconst otp = Math.floor(100000 + Math.random() * 900000).toString();\nconst contact = $json.contact;\nconst method = $json.method; // 'email' or 'phone'\nconst tokenNumber = $json.tokenNumber;\n\n// Store OTP in temp storage with expiry (5 minutes)\nconst expiryTime = Date.now() + (5 * 60 * 1000);\n\nreturn {\n otp: otp,\n contact: contact,\n method: method,\n tokenNumber: tokenNumber,\n expiryTime: expiryTime\n};"
},
"id": "code-4",
"name": "Generate OTP",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
450,
300
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "INSERT INTO otp_verification (token_number, contact, method, otp_code, expiry_time, created_at) VALUES ('{{ $json.tokenNumber }}', '{{ $json.contact }}', '{{ $json.method }}', '{{ $json.otp }}', to_timestamp({{ $json.expiryTime }}/1000), NOW()) ON CONFLICT (token_number, contact) DO UPDATE SET otp_code = EXCLUDED.otp_code, expiry_time = EXCLUDED.expiry_time, created_at = NOW()"
},
"id": "postgres-2",
"name": "Store OTP",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2,
"position": [
650,
300
],
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.method }}",
"value2": "email"
}
]
}
},
"id": "if-1",
"name": "Check Method",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
850,
300
]
},
{
"parameters": {
"fromEmail": "noreply@cybercrime.gov.in",
"toEmail": "={{ $json.contact }}",
"subject": "OTP Verification - Cyber Crime Portal",
"text": "Your OTP for complaint verification is: {{ $json.otp }}\n\nThis OTP is valid for 5 minutes.\n\nIf you did not request this, please ignore this email."
},
"id": "email-3",
"name": "Send OTP via Email",
"type": "n8n-nodes-base.emailSend",
"typeVersion": 2,
"position": [
1050,
200
],
"credentials": {
"smtp": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"url": "https://api.msg91.com/api/v5/flow/",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "mobile",
"value": "={{ $json.contact }}"
},
{
"name": "otp",
"value": "={{ $json.otp }}"
}
]
}
},
"id": "http-1",
"name": "Send OTP via SMS",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [
1050,
400
]
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ { \"success\": true, \"message\": \"OTP sent successfully\" } }}"
},
"id": "response-2",
"name": "Respond Success",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1,
"position": [
1250,
300
]
}
],
"connections": {
"Webhook - Send OTP": {
"main": [
[
{
"node": "Generate OTP",
"type": "main",
"index": 0
}
]
]
},
"Generate OTP": {
"main": [
[
{
"node": "Store OTP",
"type": "main",
"index": 0
}
]
]
},
"Store OTP": {
"main": [
[
{
"node": "Check Method",
"type": "main",
"index": 0
}
]
]
},
"Check Method": {
"main": [
[
{
"node": "Send OTP via Email",
"type": "main",
"index": 0
}
],
[
{
"node": "Send OTP via SMS",
"type": "main",
"index": 0
}
]
]
},
"Send OTP via Email": {
"main": [
[
{
"node": "Respond Success",
"type": "main",
"index": 0
}
]
]
},
"Send OTP via SMS": {
"main": [
[
{
"node": "Respond Success",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
postgressmtp
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Send OTP Verification. Uses postgres, emailSend, httpRequest. Webhook trigger; 7 nodes.
Source: https://github.com/Mazzz106/cyber-crime-portal/blob/ee4e96615077856570ea6f8c05a8b83b500ea8ee/n8n-workflows/2-send-otp.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
LogSentinel Workflow. Uses postgres, emailSend, httpRequest. Webhook trigger; 44 nodes.
This n8n workflow automates the transformation of raw text ideas into structured visual diagrams and content assets using NapkinAI.
Receive request via webhook with customer question Analyze sentiment and detect urgency using JavaScript Send urgent alerts to Slack for critical cases Search knowledge base and fetch conversation his
Criador de Empresa Geral. Uses httpRequest, emailSend, postgres. Webhook trigger; 15 nodes.
Send Invoice on Project Validated. Uses httpRequest, emailSend, postgres. Webhook trigger; 5 nodes.