# Set Up Communication from Headquarters PBX to Branch PBX

Once a trunk links your headquarters Cloud Voice system to a branch PBX (Private Branch Exchange, the phone system that serves a single site), the two systems can exchange signaling, but calls will not flow until each side knows what to do with them. This page covers the two routes that make headquarters-to-branch calling work: an outbound route on the headquarters Cloud Voice system that pushes calls onto the trunk, and an inbound route on the branch PBX that receives those calls and delivers them to the right extension.

## How the call is routed

Two pieces work together, one on each system:

| System | What you build |
| --- | --- |
| Headquarters Cloud Voice | An outbound route that sends matching calls out over the trunk |
| Branch PBX | An inbound route that accepts the calls and points them at the branch extensions |

The diagram below traces a single call from a headquarters extension, across the trunk, to its destination in the branch office.

:::note
This page assumes the inter-office trunk between the two systems is already built and online. The routes here only tell each system what to do with calls once that trunk exists. Both routes reference that same trunk: the outbound route selects it on the headquarters side, and the inbound route selects it on the branch side.
:::

![Cloud Voice, call flow from a headquarters extension out through the inter-office trunk to a branch extension](/images/pbx/pce-pbxa-outbound-to-pbxb.png)

## Set up the outbound route on headquarters Cloud Voice

The outbound route decides which dialed numbers leave over the branch trunk and which extension users are allowed to use it.

1. Sign in to the PBX web portal of the headquarters Cloud Voice system and go to **Call Control > Outbound Route**.
2. Click **Add**.
3. Fill in the route:
   1. Under **General**, give the route a name you will recognize later.
   2. Under **Dial Pattern**, set the dial rules that decide which numbers use this route. For this example, leave the defaults in place.

      :::caution
      The dial pattern is the filter that decides whether a call uses this route at all. It must permit the branch's extension numbers (for example `2000-2050`). If the pattern does not match what your users dial, the call never reaches the trunk and headquarters-to-branch calling silently fails.
      :::

   3. Under **Trunk**, move the trunk you created for the branch PBX from the **Available** box to the **Selected** box.

      ![The Trunk section of the outbound route with the branch trunk moved into the Selected box](/images/pbx/pce-select-trunk-in-outbound-route.png)

   4. Under **Extension/Extension Group**, move every extension from the **Available** box to the **Selected** box so that all of your headquarters users can dial the branch.

      :::tip
      Only the extensions and groups you move into **Selected** can use this route. If only some staff should be able to reach the branch, move just those extensions or groups instead of all of them.
      :::

4. Click **Save**, then **Apply**.

   :::caution
   Changes are not live until you click **Apply**. Saving alone stores the route but does not activate it, so calls will not use it until you apply. This applies to both procedures on this page.
   :::

## Set up the inbound route on the branch PBX

The inbound route on the branch side catches the incoming calls, reads the dialed number, and hands each call to the matching branch extension.

1. Sign in to the PBX web portal of the branch PBX and go to **Call Control > Inbound Route**.
2. Click **Add**.
3. Fill in the route:
   1. Under **General**, give the route a name you will recognize later.
   2. Under **DID Pattern**, define how dialed numbers map to extensions. DID (Direct Inward Dialing) is the number the caller actually dialed, which here is a branch extension number.

      ![DID Pattern configured to match a DID range to the branch extension range 2000-2050](/images/pbx/match-did-to-branch-extensions.png)

      - **DID Matching Mode**: Choose **Match DID Range to Extension Range**.
      - **DID Range**: Enter the branch extension range. In this example, that is `2000-2050`.

      :::note
      With range matching, a dialed number that falls inside the DID range is delivered straight to the extension that shares that number.
      :::

   3. Under **Caller ID Pattern**, set any caller ID matching you need. For this example, leave the defaults in place.
   4. Under **Trunk**, move the trunk you created for the headquarters Cloud Voice system from the **Available** box to the **Selected** box.

      ![The Trunk section of the inbound route with the headquarters trunk in the Selected box](/images/pbx/pce-select-trunk-in-inbound-route-on-branch-pbx.png)

   5. Under **Default Destination**, choose where matched calls land:

      ![Default Destination set to Match Extension Range for the branch extension range](/images/pbx/inbound-destination-on-branch-pbx.png)

   1. In the **Default Destination** drop-down, select **Match Extension Range**.
   2. In the extension range field, enter the branch extension range. In this example, enter `2000-2050`.

      :::caution
      The range you enter here must match the branch's real extension numbers, and it must match the **DID Range** you set in the DID Pattern step. If the two ranges disagree, or either one misses an extension, calls to those numbers will not reach the intended phone.
      :::

4. Click **Save**, then **Apply**.

## Test the connection

Place a call between the two sites to confirm the routes work. For example, when extension 1000 at headquarters dials 2000, extension 2000 in the branch office should ring.

:::note
These two routes enable calling in one direction only: headquarters to branch. To let branch extensions call headquarters as well, build the mirror image of this setup: an outbound route on the branch PBX and an inbound route on the headquarters Cloud Voice system.
:::
