# Route Inbound Calls based on Employee Hours

When staff members each keep their own hours, a single inbound route can hand each caller to whoever is actually on shift. This example uses time-based routing on the system's default time zone to point calls at individual extensions during their scheduled windows, and to fall back to an IVR (Interactive Voice Response: the automated menu that answers a call and sends the caller onward based on the keys they press) at every other hour and on holidays.

## Example scenario

A hospital keeps duty doctors on call to handle urgent patient needs and to book appointments by phone. Each doctor works a different rotation, and patients should reach the doctor who is currently on duty. Whenever no one is scheduled, and on any holiday, the call should instead land on an IVR that directs the patient to the right service.

The rotation looks like this:

| Doctor | Hours |
|--------|-------|
| Dr. Tommy Tse | Monday 07:00 to 12:00, Friday 12:00 to 18:00 |
| Dr. Eric Chan | Monday 00:00 to 07:00, Thursday 07:00 to 12:00 |

## Before you start

- A trunk for receiving inbound calls is in place and ready to use.
- The destinations you plan to route to already exist. This example relies on an IVR to catch patients when no doctor is on duty, so build that first, see [Set up an IVR](/pbx/administrator-guide/set-up-an-ivr/).
- If you need several inbound routes for different schedules, give each route its own trunk, or a trunk with distinct DID numbers (DID stands for Direct Inward Dialing: the specific phone number the outside caller dials to reach you). That keeps calls landing on the destination you intend. See [Route Inbound Calls based on DID Numbers](/pbx/administrator-guide/route-inbound-calls-based-on-did-numbers/).

## Create the inbound route

1. Sign in to the PBX (Private Branch Exchange) web portal and go to **Call Control > Inbound Route**, then click **Add**.
2. In **Name**, enter a label that will help you recognize the route later.
3. Under **Trunk**, move the trunks that carry these calls from the **Available** box to the **Selected** box.

   For this scenario, select the **sip_routein_EH** trunk.

   ![Trunk sip_routein_EH moved into the Selected box for the inbound route](/images/pbx/inbound-route-based-on-employee-hours-trunk-ce.png)
4. In the **Default Destination** section, set up time-based routing.

   This one section holds three routing choices that work together: the custom time periods you define next, a **Holidays Destination**, and a **Default Destination** field that catches any time you did not schedule. Steps d and e set those last two.

   ![Default Destination section with Time Condition enabled and custom time periods configured](/images/pbx/inbound-route-based-on-custom-time-periods-destination.png)

   a. Select the **Time Condition** checkbox.

   b. Set **Time-based Routing Mode** to **Based on Custom Time Periods**.

   c. Add a time schedule for each doctor, using the system's default time zone:
   1. Click **Add Custom Time Periods**.
   2. In the window that opens, click **Add** to define a time period, choose its destination, and pick the days of the week it applies to.
   3. Click **Confirm**.
   4. Repeat these steps for the next schedule.

      For this scenario, add the following four schedules:

      | Start Time | End Time | Days of Week | Destination |
      |------------|----------|--------------|-------------|
      | 07:00 | 12:00 | Monday | Tommy's extension |
      | 12:00 | 18:00 | Friday | Tommy's extension |
      | 00:00 | 07:00 | Monday | Eric's extension |
      | 07:00 | 12:00 | Thursday | Eric's extension |

      :::caution
      Every start and end time here is read in the system's default time zone, not the caller's local time and not each doctor's location. Confirm that default time zone is correct before you save, and remember that changing it later shifts all of these windows. If the time zone is wrong, calls route to the wrong extension at the wrong hours.
      :::

   d. Set the **Holidays Destination**. Here, choose **IVR** and pick the IVR that guides patients.

   e. Set the **Default Destination**. Here, choose **IVR** and pick the IVR that guides patients.
5. Click **Save**, then **Apply**.

## Result

Calls that come in on the **sip_routein_EH** trunk now branch by the time they arrive:

- During a defined time period, the call goes to that period's destination, the extension of the doctor on duty.
- At any hour you did not define, the call goes to the **Default Destination**.
- On a holiday, the call goes to the **Holidays Destination**.

Cloud Voice also generates a set of feature codes for the route:

- One feature code for each time period.
- A **Switch to the Holidays Destination** code that forces calls to the holidays destination.
- A **Switch to the Default Destination** code that forces calls to the default destination.
- A **Reset** code that clears any override currently in effect.

:::tip
Authorized users can dial one of these feature codes to override the time condition on demand and send inbound calls to a specific destination, handy when you need to open or close service outside the normal schedule. See [Override Time Condition for Inbound Calls](/pbx/administrator-guide/override-time-condition-for-inbound-calls/).
:::
