Inbound routing: decide who answers each call
Once your numbers reach MoreVoice over a SIP line (see phone numbers and SIP), inbound routes decide who answers each call: an AI assistant, an IVR or AI flow, a queue of people, one person or a conference room. A route matches calls by the number that was dialled and the number that is calling, so one line can serve sales, support and an after-hours assistant at once.
Inbound routes
Section titled “Inbound routes”A route (a “rule” in the app) has:
| Field | What it does |
|---|---|
target |
Who answers: { "type": "assistant", "assistant_id": … }, or flow, queue, user or conference_room with its <type>_id. |
fallback_assistant_id |
The assistant that answers when the target can’t take the call (a queue that is switched off, a person who was deactivated). Not with an assistant target. |
match_did |
The dialled number: an exact number, a prefix ending in *, or empty for any number. |
match_caller |
The caller’s number, with the same three forms. |
connection_id |
Only calls on this connection; null for any connection. |
priority |
The order routes are checked in: lower first. 100 by default. |
enabled |
false keeps the route but skips it. |
name |
Your name for it. |
Patterns
Section titled “Patterns”match_did and match_caller take the same three forms. Spaces, dashes and brackets are ignored, so 03-555 0100 and 035550100 are the same number.
| Pattern | Matches | Example |
|---|---|---|
| Exact number | Only that number | +97235550100 |
Prefix ending in * |
Every number that starts with it | +9723* matches every Tel Aviv number |
| Empty | Any number |
The number is compared as the carrier sends it. If your carrier sends international format, write the patterns that way too (+9723*); if it sends local format, write 03*.
Targets
Section titled “Targets”target.type |
What happens |
|---|---|
assistant |
An AI assistant answers. |
flow |
A published flow runs: an IVR menu, or an AI conversation step by step. |
queue |
The call waits in a queue for a person, and can overflow to an AI assistant. |
user |
One person’s direct line: their own forwarding rules apply. |
conference_room |
The caller is asked for the room’s PIN, then joins the room. |
Create routes
Section titled “Create routes”The first route sends the sales line to a queue of people, with an assistant behind it; the second one answers every other Tel Aviv number with the assistant:
# Calls to the sales line wait for a person in the sales queue; when the queue can't take them, an assistant answers.curl https://api.morevoice.ai/v1/inbound_routes \ -H "Authorization: Bearer $MOREVOICE_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "name": "Sales line", "match_did": "+97231234567", "priority": 10, "target": { "type": "queue", "queue_id": "'"$SALES_QUEUE_ID"'" }, "fallback_assistant_id": "'"$ASSISTANT_ID"'" }'
# Every other number that starts with +9723 goes straight to the assistant.curl https://api.morevoice.ai/v1/inbound_routes \ -H "Authorization: Bearer $MOREVOICE_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "name": "Tel Aviv numbers", "match_did": "+9723*", "priority": 100, "target": { "type": "assistant", "assistant_id": "'"$ASSISTANT_ID"'" } }'import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // reads MOREVOICE_API_KEY
// Calls to the sales line wait for a person in the sales queue; when the queue can't take them, an assistant answers.const sales = await mv.inboundRoutes.create({ name: "Sales line", match_did: "+97231234567", priority: 10, target: { type: "queue", queue_id: process.env.SALES_QUEUE_ID! }, fallback_assistant_id: process.env.ASSISTANT_ID!,});
// Every other number that starts with +9723 goes straight to the assistant.const rest = await mv.inboundRoutes.create({ name: "Tel Aviv numbers", match_did: "+9723*", priority: 100, target: { type: "assistant", assistant_id: process.env.ASSISTANT_ID! },});console.log(sales.id, rest.id);import osimport uuid
import requests
API = "https://api.morevoice.ai/v1"HEADERS = {"Authorization": f"Bearer {os.environ['MOREVOICE_API_KEY']}"}
def create_route(route: dict) -> dict: response = requests.post(f"{API}/inbound_routes", headers={**HEADERS, "Idempotency-Key": str(uuid.uuid4())}, json=route, timeout=30) response.raise_for_status() return response.json()
# Calls to the sales line wait for a person in the sales queue; when the queue can't take them, an assistant answers.sales = create_route( { "name": "Sales line", "match_did": "+97231234567", "priority": 10, "target": {"type": "queue", "queue_id": os.environ["SALES_QUEUE_ID"]}, "fallback_assistant_id": os.environ["ASSISTANT_ID"], })
# Every other number that starts with +9723 goes straight to the assistant.rest = create_route( { "name": "Tel Aviv numbers", "match_did": "+9723*", "priority": 100, "target": {"type": "assistant", "assistant_id": os.environ["ASSISTANT_ID"]}, })print(sales["id"], rest["id"])A route takes effect with the next call: calls in progress are not affected, and the SIP connections are not restarted. An exact number that another organisation already routes on the same SIP provider is refused with 409 resource_conflict, with param set to match_did and details.reason set to did_taken.
How a call is routed
Section titled “How a call is routed”-
The routes are checked in order: by
priority, lowest first, and by age when two have the same priority. The first enabled route whose connection,match_didandmatch_callerall match the call is used. -
The route’s target answers. When it can’t take the call (the flow has no published version, the queue is switched off, the person was deactivated), its
fallback_assistant_idanswers. When the route has neither, MoreVoice moves on to the next matching route. -
If no route matches, the connection’s
inbound_assistant_idanswers (Default assistant for inbound calls in the app). If the connection has none, the most recently edited assistant answers. -
If there is still no one to answer, the call is refused with
480.
List and change routes
Section titled “List and change routes”GET /v1/inbound_routes lists your routes in the order they are checked:
# Your routes in the order they are checked: priority, then age. The first enabled route that matches a call wins.curl "https://api.morevoice.ai/v1/inbound_routes?limit=100" \ -H "Authorization: Bearer $MOREVOICE_API_KEY"import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // reads MOREVOICE_API_KEY
// Your routes in the order they are checked: priority, then age. The first enabled route that matches a call wins.for await (const route of mv.inboundRoutes.list({ limit: 100 })) { const target = route.target ? route.target.type : "the connection's assistant"; console.log(route.priority, route.enabled ? "on " : "off", route.match_did || "any number", "→", target);}import os
import requests
API = "https://api.morevoice.ai/v1"HEADERS = {"Authorization": f"Bearer {os.environ['MOREVOICE_API_KEY']}"}
# Your routes in the order they are checked: priority, then age. The first enabled route that matches a call wins.params = {"limit": 100}while True: response = requests.get(f"{API}/inbound_routes", headers=HEADERS, params=params, timeout=30) response.raise_for_status() page = response.json() for route in page["data"]: target = route["target"]["type"] if route["target"] else "the connection's assistant" print(route["priority"], "on " if route["enabled"] else "off", route["match_did"] or "any number", "→", target) if not page["has_more"]: break params["starting_after"] = page["next_cursor"]PATCH /v1/inbound_routes/{id} changes the fields you send. A new target replaces the old one, and an assistant target drops fallback_assistant_id. To stop a route for a while, set enabled: false; DELETE /v1/inbound_routes/{id} removes it for good.
# Point the sales line at a published IVR flow instead of the queue. The next call uses it.curl -X PATCH https://api.morevoice.ai/v1/inbound_routes/$ROUTE_ID \ -H "Authorization: Bearer $MOREVOICE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "target": { "type": "flow", "flow_id": "'"$FLOW_ID"'" } }'
# Or switch the route off without deleting it: calls fall through to the next matching route.curl -X PATCH https://api.morevoice.ai/v1/inbound_routes/$ROUTE_ID \ -H "Authorization: Bearer $MOREVOICE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "enabled": false }'import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // reads MOREVOICE_API_KEYconst routeId = process.env.ROUTE_ID!;
// Point the sales line at a published IVR flow instead of the queue. The next call uses it.await mv.inboundRoutes.update(routeId, { target: { type: "flow", flow_id: process.env.FLOW_ID! } });
// Or switch the route off without deleting it: calls fall through to the next matching route.const route = await mv.inboundRoutes.update(routeId, { enabled: false });console.log(route.enabled);import os
import requests
API = "https://api.morevoice.ai/v1"HEADERS = {"Authorization": f"Bearer {os.environ['MOREVOICE_API_KEY']}"}route_id = os.environ["ROUTE_ID"]
# Point the sales line at a published IVR flow instead of the queue. The next call uses it.response = requests.patch(f"{API}/inbound_routes/{route_id}", headers=HEADERS, json={"target": {"type": "flow", "flow_id": os.environ["FLOW_ID"]}}, timeout=30)response.raise_for_status()
# Or switch the route off without deleting it: calls fall through to the next matching route.response = requests.patch(f"{API}/inbound_routes/{route_id}", headers=HEADERS, json={"enabled": False}, timeout=30)response.raise_for_status()print(response.json()["enabled"])Routes are configuration: the same routes serve live and test mode.
Choose who answers, from your server
Section titled “Choose who answers, from your server”A route can ask your server who answers each call, and with which variables, before MoreVoice picks up: your CRM looks up the caller, sends a VIP straight to a queue, or picks the assistant and personalises its greeting. Set assistant_request_url on the route (an https URL) and, if you need more or less than 1.5 seconds, assistant_request_timeout_ms (200 to 5,000).
For each call the route matches, MoreVoice sends your URL a signed POST:
{ "type": "assistant.request", "id": "ar_7Rk2Xq9mL4pN8sT1vW3yZa", "created": "2026-11-03T09:14:22Z", "livemode": true, "route_id": "rte_5Hn8Kq2LmP9rS4tV7wX1yA", "call": { "id": "call_8tRPaZp5hLMbrGqdJ9AmNa", "direction": "inbound", "from": "+972501234567", "to": "+97237654321", "connection_id": "conn_3Lm9Qp2Rk7sT4vW8xY1zAb" }}Answer 200 with JSON. All the fields are optional:
| Field | What it does |
|---|---|
assistant_id, flow_id or queue_id |
Who answers: at most one. None: the route’s own target answers, with the fields below. |
variables |
Up to 50 values for the conversation’s {{variables}}. |
metadata |
Up to 50 key–value strings stored on the call, as with POST /v1/calls. |
first_message |
The assistant’s opening line for this call (up to 2,000 characters). |
// Choose who answers each call, from your server: MoreVoice asks before it picks up, and waits at most the route's// assistant_request_timeout_ms (1.5 s by default). Answer fast; anything else falls back to the route's own target.import { createServer } from "node:http";import { webhooks, WebhookVerificationError } from "@morevoice/sdk";
const secret = process.env.MOREVOICE_ASSISTANT_REQUEST_SECRET!; // whsec_…: the assistant-request signing secret
interface AssistantRequest { type: "assistant.request"; id: string; livemode: boolean; route_id: string; call: { id: string; direction: "inbound"; from: string | null; to: string | null; connection_id: string | null };}
createServer(async (req, res) => { const chunks: Buffer[] = []; for await (const chunk of req) chunks.push(chunk as Buffer); let request: AssistantRequest; try { request = JSON.parse(webhooks.verifySignature(Buffer.concat(chunks), req.headers, secret).payload) as AssistantRequest; } catch (err) { if (err instanceof WebhookVerificationError) return void res.writeHead(400).end(); throw err; } const customer = request.call.from ? await findCustomer(request.call.from) : null; const answer = customer?.vip ? { queue_id: "q_vip", metadata: { customer_id: customer.id } } // straight to people : { assistant_id: "asst_reception", variables: { first_name: customer?.firstName ?? "" } }; // {{first_name}} in the greeting res.writeHead(200, { "content-type": "application/json" }).end(JSON.stringify(answer));}).listen(3000);
// Your CRM lookup goes here: keep it well under the timeout.async function findCustomer(phone: string): Promise<{ id: string; firstName: string; vip: boolean } | null> { return phone.endsWith("4567") ? { id: "cus_42", firstName: "Dana", vip: false } : null;}The request is signed like a webhook, with webhook-id set to its id: check it with webhooks.verifySignature() or the steps for any language, using your organisation’s assistant-request signing secret. It is on the live path of a ringing call, so it can only improve the call, never drop it: a timeout, an error status, a body MoreVoice can’t read or an ID your organisation doesn’t have all fall back to the route’s own target. Each decision is sent as a call.routing_decided event, with source: assistant_request, or source: route and the reason.
Set it up in the app
Section titled “Set it up in the app”-
Open SettingsSIP / Phone. Under Inbound routing, add a Rule.
-
Pick the connection (or Any connection), enter the Dialled number (DID) and Caller number patterns, choose who answers in Answer with, and click Save rule.
-
Change the order with Move up and Move down: the order in the app is the API’s
priority. -
Call the number. The call appears under Live calls while it runs, and in the call log afterwards, with the route that answered it.