# Smart Router Functionality

In this example, we will create a Smart Router instance that utilizes the [Transaction Size Strategy](#transaction-size-strategy-multi-selection). The following steps will demonstrate how to configure the Smart Router and define the criteria for selected MIDs, specifically `MPGS` and  `Knet` MIDs.

### **Step 1: Create a Smart Router Instance**

Navigate to the **PGSR** (Smart Router section) in the **Administration Panel** and click on the **Add Smart Router** button. Fill in the required details as shown in the figure below:

**Smart Router Configuration:**

* **Name:** Smart Router Example
* **Is Active:** Yes
* **Code Identifier:** smart\_router\_example
* **Strategies:** Transaction Size Strategy

<figure><img src="/files/4wDzRzszwEkEdmxfCvDM" alt=""><figcaption></figcaption></figure>

### **Step 2: Define Criteria for Selected MIDs**

Since we are using the [Transaction Size Strategy](#transaction-size-strategy-multi-selection), the criteria for this strategy must be defined for each selected MID. The figure below shows the criteria defined for `MPGS` and `Knet` MIDs:

**Knet MID Criteria:**

* **Minimum Amount:** 1
* **Maximum Amount:** 50

**MPGS MID Criteria:**

* **Minimum Amount:** 51
* **Maximum Amount:** 100

<figure><img src="/files/QVrbnDpZwjdFisWnyXig" alt=""><figcaption></figcaption></figure>

### **Step 3: Create a Checkout Link Using Checkout API**

Using the [Checkout API](broken://pages/w6x1vl3nTj166uTuqUyg), we will create a checkout link. Below is the payload request for creating the checkout link:

```json
{
    "type": "payment_request",
    "pg_codes": ["smart-router-example"],
    "amount": "55",
    "currency_code": "KWD"
}
```

The generated checkout link will redirect to the **Checkout Page** where the customer will click on the **Pay** button.

<figure><img src="/files/48WQEQCV7rBPvoH0XXPT" alt=""><figcaption></figcaption></figure>

### **Step 4: Payment Processing with Smart Router**

Once the pay button is clicked, the Smart Router starts functioning to choose the best path between the two chosen MIDs (**MPGS** and **Knet**). The path selection is based on the defined criteria.

As shown in the figure below, the chosen MID is **MPGS** since the transaction amount is 55, which falls within the range of the defined **MPGS** criteria.

<figure><img src="/files/XxZuG01xllUgk8O4Dq8z" alt=""><figcaption></figcaption></figure>

If we change the amount in the request payload to be 50.

```json
{
    "type": "payment_request",
    "pg_codes": ["smart-router-example"],
    "amount": "50",
    "currency_code": "KWD"
}
```

The Smart Router will choose Knet since the defined range covers the amount, as shown in the figure below:

<figure><img src="/files/7vPOYiVguQq8tGG1uFN8" alt=""><figcaption></figcaption></figure>

**Conclusion**

By following these steps, we demonstrated how to create a Smart Router instance using the [Transaction Size Strategy](/ottu-team-sandbox-doc/user-guide-proposal/features/smart-router-engine/transaction-size-strategy-scenario.md) and defined criteria for `MPGS` and `Knet` MIDs. This example illustrates how the Smart Router dynamically selects the most appropriate payment gateway based on the transaction amount, optimizing the payment processing workflow and enhancing overall efficiency.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/user-guide-proposal/features/smart-router-engine/smart-router-functionality.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
