Overview
Not every caller deserves the same experience. Registered customers should reach your support team instantly; unknown numbers should go to a general queue. Managing routing rules in the phone system by hand does not scale — and it breaks the moment your CRM data changes.
This guide shows you how to use Web Service-Based Smart Routing to query your CRM in real time before the call is answered and return a routing decision.
How it works
When a call comes in, Hipcall's Smart Routing feature calls your HTTP endpoint with the caller's phone number. Your server looks the number up in your CRM and responds with an extension number. Hipcall routes the call accordingly — all of this happens within milliseconds, before the caller hears a single ring.
Architecture
flowchart TD
A[Incoming call] --> B[Hipcall Smart Routing steps in]
B --> C[POST sent to your endpoint\nwith the caller's number]
C --> D{Found in CRM?}
D -- Yes --> E[Return the VIP extension\ne.g. 1093]
D -- No --> F[Return the general extension\ne.g. 1094]
E --> G[Call is routed to the VIP queue]
F --> H[Call is routed to the general queue]
Step 1: Configure Smart Routing in Hipcall
- In your Hipcall dashboard, go to Settings > Phone System > Smart Routing.
- Click New and select Web Service as the route type.
- Enter your endpoint URL (e.g.
https://your-server.example.com/api/smart-ivr). - Save the rule and assign it to the phone number or IVR menu you want to control.
Local development: Use ngrok to expose your local server. Run the
ngrok http 5008command and use the generated URL as your endpoint.
Step 2: Receive the webhook
As soon as the call arrives, Hipcall sends a POST request to your endpoint, along with the caller's phone number.
Example request from Hipcall:
{
"caller": "90543XXXXXXX",
"number": "+90850XXXXXXX",
"timestamp": 1719843672,
"uuid": "564aff1e-2141-4925-9c2e-b7dd28b87c16"
}
- caller: your customer's number
- number: your number in Hipcall
- timestamp: Unix timestamp of the operation
- uuid: the call's unique UUID
Thecallerfield contains the caller's phone number in E.164 format. Your endpoint must respond within the timeout period — keep your CRM lookup fast.
Step 3: Look up the caller
Normalize the phone number to match your database format, then query your CRM.
Example normalization (Python):
def normalize_phone(phone):
# Remove non-numeric characters
phone = ''.join(filter(str.isdigit, phone))
# Handle Turkish local formats
if phone.startswith('0') and len(phone) == 11:
phone = '9' + phone
elif len(phone) == 10:
phone = '90' + phone
return phone
Query your database using the normalized number:
caller = data.get('caller')
normalized = normalize_phone(caller)
customer = db.execute(
'SELECT id FROM customers WHERE phone = ?',
(normalized,)
).fetchone()
Step 4: Return the routing decision
Respond with a JSON object containing the extension value the call should be routed to. Use one extension for registered customers and another for unknown callers.
Registered customer:
{ "extension": "1093" }
Unknown caller:
{ "extension": "1094" }
Hipcall reads the extension value and transfers the call to that extension immediately. The caller experiences no delay.
Tools used
| Tool | Purpose |
|---|---|
| Web Service-Based Smart Routing | Triggers your endpoint on incoming calls and routes them based on the response |
Next steps
- Smart Routing documentation — Configure route types, timeouts, and fallback behavior
- How To Get A Hipcall API Key And Make Your First Request — Secure your endpoint with API keys or Basic Authentication
- Webhooks documentation — Combine it with call events for post-call logging and analytics