# Route Inbound Calls based on DID Numbers

When a call arrives on a trunk (the connection from your telephone provider), Cloud Voice can decide where to send it based on the DID number the caller dialed. DID stands for Direct Inward Dialing: it is the public phone number a caller dials to reach you directly. This routing is set on a trunk's inbound route, where the matching mode you choose decides how Cloud Voice reads the dialed number and which destination receives the call.

Choosing the right matching mode lets you point each number, block of numbers, or number pattern at the destination you want. This page introduces the four modes so you can pick the one that fits your numbering plan; step-by-step examples for each are covered in their own topics.

:::caution
Enter each DID number in the exact format your carrier delivers on the trunk (for example full E.164 such as `+15035551234`, or a plain 10-digit number). If the format you configure does not match what the carrier actually sends, no rule matches and the inbound call fails to connect.
:::

## DID matching modes

Cloud Voice gives you four ways to match a dialed number and route the call accordingly.

### Match DID Range to Extension Range

Map a contiguous block of DID numbers onto a contiguous block of extensions, one for one and in order. The first DID in the range reaches the first extension, the second DID reaches the second extension, and so on. This is the quickest option when your DIDs and extensions line up sequentially.

![A range of DID numbers mapped in order onto a matching range of extensions](/images/pbx/did-range-to-ext-range-pce.png)

:::caution
The DID range and the extension range must contain the same number of entries and be listed in the same order. If the two blocks are different sizes or fall out of sequence, calls reach the wrong extension or are not delivered at all.
:::

For the full walkthrough, see the example that routes calls to extension users by matching a DID range.

### Match DID Pattern to Extensions

Build a single DID pattern that carries the extension number inside it, using the `{{.Ext}}` variable to stand in for the extension digits. Cloud Voice reads the matched digits from the dialed number and delivers the call to the extension they represent, so one pattern can cover many extensions.

![A DID pattern containing the extension variable that resolves to individual extensions](/images/pbx/did-pattern-to-extensions-pce.png)

:::note
`{{.Ext}}` is a template placeholder, not a literal value you dial. Cloud Voice captures the extension digits from the dialed number wherever you place `{{.Ext}}` in the pattern, then routes the call to that extension. Make sure the digits it captures line up with real extension numbers, otherwise the matched call has nowhere to land.
:::

For the full walkthrough, see the example that routes calls to extension users by matching DID patterns.

### DID Number to Specific Extension

List specific DID numbers and pair each one with a specific extension. Every entry is a direct, one-to-one mapping, which is useful when the numbers you want to route do not form a tidy sequence.

![Individual DID numbers each paired with a specific extension](/images/pbx/did-number-to-extension-pce.png)

For the full walkthrough, see the example that routes calls to extension users by matching specific DID numbers.

### DID Pattern

Define one or more DID numbers or patterns and send every call that matches them to a single chosen destination. Unlike the other modes, the target here is not tied to an extension range, so you can route matching calls to any destination you configure.

![DID numbers and patterns routed to one shared destination](/images/pbx/did-pattern-to-destination-pce.png)

:::tip
Reach for this mode when the destination is not a single extension. Because you pick the target independently, you can send a whole set of matching numbers to one shared destination, such as a menu, a group, or a mailbox.
:::

For the full walkthrough, see the example that routes calls to different destinations by matching DID patterns.
