# Creating a dispatch rule

Dispatch rules determine which drivers are getting assigned to an order once they are ready for delivery. Multiple conditions can be set in one rule.\
\
One example is to assign orders to a driver based on the delivery location. Let's do just that!

## Step 1 - Navigate to dispatch rules setup

The dispatch rules setup page is enabled in both **Sales** and **Inventory**. Once you are on either pages, click on **"Configuration"**.

<figure><img src="https://1434748814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8jzt5nEhAzb1K8eIfu48%2Fuploads%2F8wpP628ZKtxhxcWCaAmQ%2Fimage.png?alt=media&#x26;token=3e168059-e552-4960-b7c9-fc878fcca334" alt=""><figcaption></figcaption></figure>

Click **"Dispatch rules".**

<figure><img src="https://1434748814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8jzt5nEhAzb1K8eIfu48%2Fuploads%2FITzO6aiOpmRKR7sKbq0g%2Fimage.png?alt=media&#x26;token=7bc68b56-e3aa-407e-a737-baec4cb34030" alt=""><figcaption></figcaption></figure>

## Step 2 - Creating a rule

Click **"Create"**. We are going to create a rule for assigning orders by matching delivery destination to the driver's city.

<figure><img src="https://1434748814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8jzt5nEhAzb1K8eIfu48%2Fuploads%2FIy2QqaALOfYeRmWTlgfI%2Fimage.png?alt=media&#x26;token=076cda2c-d286-435a-9747-7702f5997913" alt=""><figcaption></figcaption></figure>

Type in the name **"Talisay Orders"** and in conditions click **"Add a line".**

<figure><img src="https://1434748814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8jzt5nEhAzb1K8eIfu48%2Fuploads%2Fl1PiFIhpiSvZA4DbdlvE%2Fimage.png?alt=media&#x26;token=bc280e47-c53c-4575-bbe4-5b877c86e91a" alt=""><figcaption></figcaption></figure>

Check "**Order city from Talisay"** and click **"Select"**.

<figure><img src="https://1434748814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8jzt5nEhAzb1K8eIfu48%2Fuploads%2FdBbojry6KFl9x3ckIHfH%2Fimage.png?alt=media&#x26;token=0eee65ff-7d0e-4e86-b035-5ea69246d46b" alt=""><figcaption></figcaption></figure>

## Step 3 - Selecting a driver

Now, we are going to select the preferred drivers. For now, let's just select one.

On the **"Preferred Drivers"** click **"Add a line"**

<figure><img src="https://1434748814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8jzt5nEhAzb1K8eIfu48%2Fuploads%2FDUn8KUofXCwHE84CbxSX%2Fimage.png?alt=media&#x26;token=38a7b7d5-2405-48a3-a510-cd0a466f2984" alt=""><figcaption></figcaption></figure>

From here, you will see a list of users. Let's click on **"Filters".**

<figure><img src="https://1434748814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8jzt5nEhAzb1K8eIfu48%2Fuploads%2FnHWVVdSwL4M1oFGFeHk3%2Fimage.png?alt=media&#x26;token=3a805b8a-1ffa-44aa-acdd-dcbfd7a1ff06" alt=""><figcaption></figcaption></figure>

At the bottom part, selec&#x74;**"Add Custom Filter"** and **"Has Vehicle" : "Is Yes"**. And click **"Apply"**.

<figure><img src="https://1434748814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8jzt5nEhAzb1K8eIfu48%2Fuploads%2FPxyaVlrtsW5hJL32HDoa%2Fimage.png?alt=media&#x26;token=78a6e856-dfa9-4624-89a6-3c6199e9c705" alt=""><figcaption></figcaption></figure>

Select one.

<figure><img src="https://1434748814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8jzt5nEhAzb1K8eIfu48%2Fuploads%2FdQJkM8JckLspj8Ze6YWa%2Fimage.png?alt=media&#x26;token=378b593c-e95a-49ef-a185-c2b70ee188da" alt=""><figcaption></figcaption></figure>

Then finally, click **"Create"** or **"Save manually"** button.

<figure><img src="https://1434748814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8jzt5nEhAzb1K8eIfu48%2Fuploads%2Fg6WvByaNOEvYBJl76e4a%2Fimage.png?alt=media&#x26;token=c2e837ec-111b-4848-8557-71d908dbc522" alt=""><figcaption></figcaption></figure>

Now we have a dispatch rule for Talisay Orders to be matched with Delfin Nav for delivery.

## Further improvements

At present there are two conditions for this proof-of-concept — the delivery city, and the packaging size of the order. More conditions to be added soon!

The selection of preferred drivers is easy if there is only one matching driver. Currently, when there are multiple drivers preferred, a random selection is done. In the future, other features will be considered for the selection.
