Automation
Validate phone numbers and emails in Pipedream
Check emails and phone numbers in a Pipedream workflow with a Node.js code step, keep the key in an environment variable and branch on the result.
Updated 2026-11-26
This recipe validates the email and phone number that reach a Pipedream workflow, with a Node.js code step that calls the API, then branches on the answer. There is no native Qelka app in Pipedream: the code step uses plain fetch, and the built-in Send any HTTP Request action is the no-code alternative, covered at the end.
What you need
- A Pipedream account. Check your plan's limits on credits and execution time before you send real traffic.
- A Qelka API key. A
sk_test_key returns simulated results and never spends credits: see Test mode. - Something that sends the data: a web form, a CRM webhook or any app trigger Pipedream offers.
Steps
1. Store the key in an environment variable
In Pipedream, open Settings, then Environment Variables, and click New Variable. Name it QELKA_API_KEY and paste your key as its value. New variables are secret by default: Pipedream will not show the value again, and nobody can copy it from the workflow. To scope the key to one project, use the Variables page of that project instead.
Use a key dedicated to Pipedream and restrict it to /email and /phone in the dashboard, so a leak cannot start bulk jobs on your balance. See Restricted keys.
2. Add an HTTP trigger
Create a workflow and pick the HTTP / Webhook trigger with New Requests. Pipedream gives the workflow its own URL. Send it a test request:
curl -X POST "YOUR_WORKFLOW_URL" \
-H "Content-Type: application/json" \
-d '{"email": "jane@example.com", "phone": "(415) 555-0123", "country": "US"}'
A JSON body arrives parsed in steps.trigger.event.body. A form that posts multipart/form-data also arrives as an object, with one property per field. If your data comes from an app trigger instead, read the email and phone from that trigger's event in the next step.
3. Add the Node.js code step
Add a Node.js code step and rename it validate. Replace its code with:
const retryable = new Set([429, 500, 502])
async function callApi(path, payload) {
for (let attempt = 1; attempt <= 2; attempt += 1) {
let response
try {
response = await fetch(`https://api.qelka.com/v1${path}`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
signal: AbortSignal.timeout(8000),
})
} catch (error) {
console.log(`validation skipped: ${error.name}`)
return null
}
if (response.ok) return response.json().catch(() => null)
if (retryable.has(response.status) && attempt < 2) {
const retryAfter = Number(response.headers.get('Retry-After'))
await new Promise((resolve) => setTimeout(resolve, Math.min(retryAfter > 0 ? retryAfter : 1, 5) * 1000))
continue
}
const failure = await response.json().catch(() => ({}))
console.log(`validation skipped: ${failure.error?.type ?? response.status} request ${response.headers.get('X-Request-Id')}`)
return null
}
return null
}
export default defineComponent({
async run({ steps, $ }) {
const input = steps.trigger.event.body ?? {}
const email = typeof input.email === 'string' ? input.email.trim() : ''
const phone = typeof input.phone === 'string' ? input.phone.trim() : ''
const country = typeof input.country === 'string' && input.country.length === 2 ? input.country : undefined
const result = {
email_status: 'unchecked',
email_reason: null,
did_you_mean: null,
phone_status: 'unchecked',
e164: null,
line_type: null,
}
if (email) {
const answer = await callApi('/email', { email, mode: 'fast' })
if (answer) {
result.email_status = answer.status
result.email_reason = answer.reason
result.did_you_mean = answer.did_you_mean
}
}
if (phone) {
const answer = await callApi('/phone', country ? { phone, country } : { phone })
if (answer) {
result.phone_status = answer.status
result.e164 = answer.e164
result.line_type = answer.line_type
}
}
return result
},
})
Click Test. The returned object is available to later steps as steps.validate.$return_value.
mode: 'fast' runs the syntax, DNS, disposable and role checks and skips the mailbox check, so it never waits for a mail server you do not control. That keeps the step short inside an HTTP-triggered workflow. A full check can return deliverable; a fast one answers unknown with the reason smtp_not_checked when the other checks pass. See the email reference.
The country value is a two-letter code that tells the API how to read a number written without a +. Without it, (415) 555-0123 comes back unknown. See the phone reference.
The step never throws because of the API. A timeout, an unreachable network or an error answer leaves the field at unchecked, and the log line in the step's output carries the error type and the X-Request-Id, which is what support needs to find the call.
4. Branch on the result
Add an If/Else step after validate. Pipedream runs one branch per execution. Set the condition to steps.validate.$return_value.email_status equals undeliverable, and put what should happen to a bad address in that branch: tag the lead, notify your team, or write the row to a review sheet. The Else branch continues the normal flow.
email_status |
Meaning | Suggested action |
|---|---|---|
undeliverable |
Bad syntax, no such domain, or a domain that takes no mail | Stop or tag, and offer did_you_mean when it is set |
risky |
Disposable inbox, catch-all domain or full mailbox | Add to a review list |
deliverable |
The mail server accepted the mailbox (full mode only) | Continue |
unknown |
Not conclusive, smtp_not_checked in fast mode |
Continue, and confirm by email |
unchecked |
The API could not be reached or refused the call | Continue, and check again later |
For phones, branch on phone_status: valid means store e164, invalid means ask for a correction, unknown means the number had no + and no country. Read line_type before you send SMS: a landline usually cannot receive them.
To stop a run early instead of branching, add the End Workflow step, or call return $.flow.exit('undeliverable email') in a code step. The return matters: without it, the rest of the step still runs.
5. Answer the caller (optional)
When a form posts to the workflow and waits for a verdict, open the trigger and set its HTTP Response option to return a custom response from your workflow. Then end the validate step with a response before the return:
await $.respond({
status: 200,
headers: { 'Content-Type': 'application/json' },
body: {
ok: result.email_status !== 'undeliverable' && result.phone_status !== 'invalid',
did_you_mean: result.did_you_mean,
},
})
With that option on, a workflow that never calls $.respond answers 400 to the caller, so make sure every path reaches it. The step above always does, because callApi returns null instead of throwing. Send back only what the form needs, never the raw API answer.
6. No code: the Send any HTTP Request action
Pipedream's Send any HTTP Request action sends the same call without code:
| Field | Value |
|---|---|
| Method | POST |
| URL | https://api.qelka.com/v1/email |
| Headers | Authorization = Bearer {{process.env.QELKA_API_KEY}}, and Content-Type = application/json |
| Body | {"email": "[email from the trigger]", "mode": "fast"} |
Pick the email from the trigger with the object explorer, keeping the quotes. The response body is then available to later steps, and the If/Else condition reads its status.
Pipedream lists the trade-offs of that action itself: when the request fails, the whole workflow is cancelled, and you cannot set a fallback action for failures. A wrong key or an empty balance would stop every run, so prefer the code step when the workflow must keep going.
Handle errors and rate limits
No error is billed. 401 invalid_api_key and 403 forbidden mean a wrong or restricted key, 402 insufficient_credits an empty balance: the code step ends as unchecked for all three, so look for unchecked results and the logged error type, and fix the key or add credits. A 429 rate_limited is retried once after Retry-After, up to five seconds; 500 and 502 are retried once. See Errors.
A key allows 200 requests per 10 seconds, and every key of your organization shares one organization limit. A workflow that replays a few thousand events at once can pass it: process them in smaller batches, or send up to 100 values in one call to https://api.qelka.com/v1/batch, which counts as one request. See the batch reference and Rate limits.
Each email check costs 1 credit and each basic phone check 1. Store the result with the record and skip records that already have one, so a replayed event does not pay twice. For a whole export, a bulk file check is simpler than a workflow.
Related
Frequently asked questions
Is there a native Pipedream app?
Where should the API key go in Pipedream?
How long can the workflow wait for the API?
More in Automation
All integrationsPut this check in your product
Get an API key in under a minute. 100 free credits every month, no card required.
- 100 free credits a month
- No card
- Test keys spend nothing
- Cancel any time