Skip to content

Calls & messaging

Show caller insights in Aircall with phone validation and FTC reports

Look up each inbound Aircall caller from a webhook: line type and location, FTC spam complaints for North American numbers, shown to agents as an insight card.

Updated 2026-11-26

This recipe shows agents who is calling before they pick up. When a call reaches your Aircall number, Aircall sends a call.created webhook to a small server of yours. The server checks the caller's number with POST /phone, adds the FTC complaint count for North American numbers with POST /phone/reports, and posts the result to the call as an Aircall insight card, which agents see in Aircall Workspace while the call is ongoing.

There is no Qelka app in the Aircall marketplace: the server below is the whole integration, about a hundred lines of Node.js.

What you need

  • An Aircall account where you can create an API key and a webhook, as an admin. Check that your plan includes Public API access.
  • A server reachable over HTTPS, with Node.js 20 or later and Express. Aircall only sends webhooks to https URLs.
  • A Qelka API key, restricted to /phone and /phone/reports: see Restricted keys. A sk_test_ key never spends credits: with it, +1 202-555-0143 is reported 5 times and every other North American number has no reports. See Test mode.

Steps

1. Create an Aircall API key

In the Aircall Dashboard, open your company's Settings page, find the API Keys section and click Add a new API key. Copy the api_id and the api_token right away: Aircall does not store the token in plain text and cannot show it again. The server uses them for HTTP Basic authentication on Aircall's Public API.

2. The server

Set QELKA_API_KEY, AIRCALL_API_ID and AIRCALL_API_TOKEN in the server's environment, then run this file (npm install express):

javascript
import express from 'express'
import { timingSafeEqual } from 'node:crypto'

const aircallAuth = Buffer.from(`${process.env.AIRCALL_API_ID}:${process.env.AIRCALL_API_TOKEN}`).toString('base64')
const handledCalls = new Set()

function tokenMatches(received) {
  const expected = process.env.AIRCALL_WEBHOOK_TOKEN
  if (typeof received !== 'string' || !expected) return false
  const receivedBytes = Buffer.from(received)
  const expectedBytes = Buffer.from(expected)
  return receivedBytes.length === expectedBytes.length && timingSafeEqual(receivedBytes, expectedBytes)
}

async function callApi(path, body) {
  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(body),
      signal: AbortSignal.timeout(4000),
    })
  } catch (error) {
    console.warn(`${path} skipped: ${error.name}`)
    return null
  }
  if (!response.ok) {
    const failure = await response.json().catch(() => ({}))
    console.warn(`${path} skipped: ${failure.error?.type ?? response.status} request ${response.headers.get('X-Request-Id')}`)
    return null
  }
  return response.json().catch(() => null)
}

function lineDetails(phone) {
  if (phone.status !== 'valid') {
    return [{ type: 'shortText', label: 'Number', text: 'Not valid in its numbering plan' }]
  }
  const lines = []
  const place = [phone.region, phone.country?.name].filter(Boolean).join(', ')
  if (place) lines.push({ type: 'shortText', label: 'Location', text: place })
  lines.push({ type: 'shortText', label: 'Line type', text: phone.line_type.replaceAll('_', ' ') })
  if (phone.carrier?.name) lines.push({ type: 'shortText', label: 'Carrier', text: phone.carrier.name })
  return lines
}

function reportDetails(reports) {
  if (reports.status === 'reported') {
    const people = reports.reports === 1 ? '1 consumer' : `${reports.reports} consumers`
    return [
      { type: 'shortText', label: 'FTC reports', text: `${people} reported this number to the FTC, last on ${reports.last_reported}` },
      { type: 'shortText', label: 'Note', text: 'Unverified complaints. Caller ID can be spoofed.' },
    ]
  }
  if (reports.status === 'not_reported' && reports.window) {
    return [{ type: 'shortText', label: 'FTC reports', text: `No reports in the last ${reports.window.days} days` }]
  }
  return []
}

async function buildCard(caller) {
  const phone = await callApi('/phone', { phone: caller })
  if (!phone) return null
  const contents = [{ type: 'title', text: 'Qelka caller check' }, ...lineDetails(phone)]
  if (phone.status === 'valid' && phone.country?.calling_code === '1') {
    const reports = await callApi('/phone/reports', { phone: phone.e164 })
    if (reports) contents.push(...reportDetails(reports))
  }
  return { contents }
}

async function postInsightCard(callId, card) {
  const response = await fetch(`https://api.aircall.io/v1/calls/${callId}/insight_cards`, {
    method: 'POST',
    headers: {
      Authorization: `Basic ${aircallAuth}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(card),
    signal: AbortSignal.timeout(5000),
  })
  if (response.status !== 201) console.warn(`insight card refused: ${response.status} for call ${callId}`)
}

const app = express()
app.use(express.json({ limit: '1mb' }))

app.post('/aircall/webhook', (req, res) => {
  const payload = req.body ?? {}
  if (!tokenMatches(payload.token)) return res.sendStatus(401)
  res.sendStatus(200)

  const call = payload.data ?? {}
  if (payload.event !== 'call.created' || call.direction !== 'inbound') return
  if (!call.raw_digits || call.raw_digits === 'anonymous') return
  if (handledCalls.has(call.id)) return
  handledCalls.add(call.id)
  setTimeout(() => handledCalls.delete(call.id), 10 * 60 * 1000).unref()

  buildCard(call.raw_digits)
    .then((card) => card && postInsightCard(call.id, card))
    .catch((error) => console.error(`insight card skipped: ${error.message}`))
})

app.listen(3000)

What each part does:

  • It answers Aircall first. Aircall times out a webhook request after 5 seconds, retries failed deliveries, and disables a webhook that keeps failing. The route answers 200 as soon as the token matches, then does the lookups.
  • It only handles inbound calls with a number. call.created also fires for outbound calls. raw_digits holds the caller's number in international format, such as +1 800-123-4567, or anonymous for a hidden number. The international format includes the +, so POST /phone needs no country.
  • It skips repeats. Aircall delivers each event at least once, and an IVR linked to both a parent and a child number sends two call.created events for one call. The set of handled call ids absorbs both.
  • It never blocks the call. If a lookup fails, the card simply does not appear, and the log line carries the error type and the X-Request-Id.

3. Register the webhook

In the Aircall Dashboard, open the Integrations and API section, search for "Webhook" and select the Webhook integration. Click Install Integration, give it a name, enter https://your-server.example/aircall/webhook, select the call.created event and click Add Webhook. Aircall starts sending events right away.

Each webhook has a unique token that Aircall puts in every payload. Read it from the Public API:

bash
curl https://api.aircall.io/v1/webhooks \
  -u "$AIRCALL_API_ID:$AIRCALL_API_TOKEN"

Copy the token of your webhook into AIRCALL_WEBHOOK_TOKEN and restart the server. Until then, the server refuses every event with 401.

4. Test it

Call your Aircall number from a phone. While it rings, the agent sees a card titled "Qelka caller check" with the location, the line type and, for a North American number, the FTC report line. With a test key, the region and the carrier stay empty, but the country and the line type are real: test keys parse numbers for real.

To test the server alone, post a fake event to it with your token. The lookups run, and Aircall answers 404 for the made-up call id, which the server logs as insight card refused: 404:

bash
curl -i http://localhost:3000/aircall/webhook \
  -H "Content-Type: application/json" \
  -d '{"resource":"call","event":"call.created","timestamp":1795452309,"token":"'"$AIRCALL_WEBHOOK_TOKEN"'","data":{"id":1,"direction":"inbound","raw_digits":"+1 202-555-0143"}}'

Show reports fairly

The FTC does not verify the complaints behind POST /phone/reports, and a caller can display a number that is not theirs. The card follows the rules of the phone reports reference:

status What the card says What it does not say
reported "5 consumers reported this number to the FTC, last on 2026-11-17", plus a note that complaints are unverified That the caller is a scammer
not_reported "No reports in the last N days", from the data window That the number is safe
unsupported Nothing, for a number outside the North American Numbering Plan Anything

The lookup only covers numbers of the North American Numbering Plan, so the server calls it when the caller's calling code is 1. A reported or not_reported lookup costs 1 credit; unsupported numbers are never billed. Train agents to read the line as a reason for care, such as verifying identity before discussing an account, not as a reason to hang up.

Handle errors and rate limits

No API error is billed. 401 invalid_api_key and 403 forbidden mean a wrong or restricted key, 402 insufficient_credits an empty balance: the card stops appearing and the server logs the type, so alert on skipped lines. A 422 unprocessable_input from /phone/reports means the number is not in the NANP format; the card then shows the line details alone. The lookups are not retried: a call rings for seconds, and a late card is useless. See Errors.

Each inbound caller costs one basic phone check, 1 credit, plus one reports lookup for North American callers. A key allows 200 requests per 10 seconds, far above the call volume of most teams. On Aircall's side, its documentation sets a limit of 120 Public API requests per minute per company, which is theirs and may change; the server makes one Aircall request per inbound call.

The basic level never sends the number outside our systems, and the reports lookup keeps only the country code and the last two digits in its request log. See Data and privacy.

Frequently asked questions

Which Aircall event should trigger the lookup?
call.created. For inbound calls, Aircall sends it when the call hits an Aircall number, which leaves time to post the card while the call rings. Insight cards are only shown on ongoing calls and are not stored after the call ends, so a lookup triggered by call.ended would come too late.
How do I know a webhook really comes from Aircall?
Aircall does not sign its webhooks, and it does not publish static IP addresses to allow. Each webhook has its own token, which Aircall puts in the token field of every payload. Compare it in constant time with the token of your webhook, which the Public API returns from GET /v1/webhooks, and ignore requests that do not match.
Does a reported number mean the caller is a scammer?
No. The reports are consumer complaints to the U.S. Federal Trade Commission, which the FTC does not verify, and caller ID can be spoofed, so the number on a complaint may belong to someone who never made the call. Show the count as what it is, let the agent decide, and never label the caller. A number without reports is not proof that it is safe either.

More in Calls & messaging

All integrations

Put 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