# Route Calls from a Branch PBX to Cloud Voice

Once a branch office PBX (Private Branch Exchange, the on-site phone system) is interconnected with your headquarters Cloud Voice system, you still need to tell each side how to move calls across the link. This page walks through the route settings that let anyone on the branch PBX dial a headquarters extension on Cloud Voice.

:::note
This procedure assumes the trunk between the branch PBX and your Cloud Voice system is already in place. A trunk is the connection that carries calls between the two systems. The routes below only decide which calls travel over that existing trunk; they do not create it.
:::

## How the call flows

Two pieces of configuration work together for a branch-to-headquarters call:

| Where | What to do |
|-------|------------|
| Branch PBX | Add an **outbound route** that sends the call out over the trunk to Cloud Voice. |
| Cloud Voice (headquarters) | Add an **inbound route** that accepts the call and delivers it to the matching headquarters extension. |

Both routes must be in place. The branch side alone will send the call out, but without the inbound route on Cloud Voice there is nothing to answer it.

:::note
These routes cover one direction only: branch extensions calling headquarters. To let headquarters extensions dial the branch as well, set up the mirror image: an outbound route on Cloud Voice and a matching inbound route on the branch PBX.
:::

The diagram below shows the path a call takes from a branch extension to a headquarters extension.

![Cloud Voice, call routing from a branch extension across the trunk to a headquarters extension](/images/pbx/pce-inbound-from-pbx.png)

## Step 1. Add an outbound route on the branch PBX

An outbound route decides which calls leave the branch PBX and over which trunk. This one hands calls from branch extensions to the trunk that reaches Cloud Voice.

1. Sign in to the branch PBX web portal 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.

      :::tip
      Name the route after the system it reaches, for example `To-Cloud-Voice-HQ`. On a busy PBX with many routes, a descriptive name saves time when you need to find or edit it.
      :::
   2. Under **Dial Pattern**, set the dial rules that decide which dialed numbers use this route. For this example, leave the defaults as they are.
   3. Under **Trunk**, move the trunk you created for Cloud Voice from the **Available** box to the **Selected** box.

      ![Cloud Voice trunk moved into the Selected box of the branch outbound route](/images/pbx/pce-select-trunk-in-inbound-route-on-branch-pbx.png)
   4. Under **Extension/Extension Group**, move every extension from **Available** to **Selected** so that all branch users are allowed to call Cloud Voice.

      :::caution
      Selecting every extension lets all branch users place these calls. If only certain people should be able to reach headquarters, move only those specific extensions into the **Selected** box instead of all of them.
      :::
4. Click **Save**, then **Apply**.

:::caution
Changes stay pending until you click **Apply**. If you click **Save** but skip **Apply**, the route will not take effect and test calls will fail.
:::

## Step 2. Add an inbound route on Cloud Voice

An inbound route decides what happens to calls arriving over a trunk. This one receives the branch call and points it at the right headquarters extension.

1. Sign in to your Cloud Voice web portal 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 the dialed number is matched. DID stands for Direct Inward Dialing: it is the number the branch caller dials, which Cloud Voice uses to pick the destination extension.

      ![DID range mapped to the headquarters extension range on a Cloud Voice inbound route](/images/pbx/match-did-to-headquarters-extensions.png)

      - **DID Matching Mode**: Select **Match DID Range to Extension Range**.
      - **DID Range**: Enter the headquarters extension range. In this example, enter `1000-1200`.

      When a dialed number falls inside the DID range, the call is sent to the extension it maps to.
   3. Under **Caller ID Pattern**, set any caller ID matching you need. For this example, leave the defaults as they are.
   4. Under **Trunk**, move the trunk you created for the branch PBX from the **Available** box to the **Selected** box.

      ![Branch PBX trunk moved into the Selected box of the Cloud Voice inbound route](/images/pbx/pce-select-trunk-in-outbound-route.png)
   5. Under **Default Destination**, choose where matched calls land:

      ![Default destination set to match the headquarters extension range on the Cloud Voice inbound route](/images/pbx/select-inbound-route-destination-on-headquarters-pbx.png)

   1. In the **Default Destination** drop-down list, select **Match Extension Range**.
   2. In the extension range field, enter the headquarters extension range. In this example, enter `1000-1200`.
4. Click **Save**, then **Apply**.

:::caution
The **DID Range** and the **Default Destination** extension range must be the same, and both must cover extensions that actually exist on the headquarters Cloud Voice system. If a dialed number matches the DID range but has no real extension behind it, the call has nowhere to land and will fail.
:::

## Test the connection

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

:::note
If the test call does not connect, check three things first: both routes were saved and applied, the same extension range was entered in the DID Range and Default Destination fields, and the correct trunk is selected on each side.
:::
