# Dispatch Optimized Routes to Motive

After generating the optimized routes with NextBillion.ai's API, the next step is to dispatch these routes to the Motive Driver App. Here's how to do it:

## Step 1: Construct and Dispatch Routes

**Construct the POST Request Body**: Use the optimized routes data to create a request body suitable for the Motive API.

Refer to [Motive API documentation](https://developer.gomotive.com/reference/getting-started-with-your-api) for more information.

Dispatch Routes: Use the following JavaScript code to construct and dispatch routes.

```javascript
// Initialize an array to store all routes

let allRoutes = [];

// Iterate over the routes and construct route objects
nbaiOptimizationStatus.data.result.routes.forEach(rte => {
    let route = {
      "vendor_id": `AMZN-${uuid.v4().split('-')[0]}`,
        "vehicle_id": 1535464,
    "shipper_dispatch_location_id": 1554007,
        "consignee_dispatch_location_id": 1554007,
        "consignee_status": "available",
        "shipper_status": "available",
        "status": "planned",
        "consignee_form_ids": [
            "058785d7-4971-4092-80eb-9bed523570fb",
            "d8e107be-6333-4b10-9ad8-633ec5192c39"
        ],
        "shipper_form_ids": [
            "3ed8c5f8-4877-41e1-804f-fed1666a68ae",
            "b6b76538-2001-4a34-9f27-427a16965c59"
        ],
        "shipper_type": "pickup",
        "consignee_type": "dropoff",
        "dispatch_stops": []
    };

    // Assign driver id based on vehicle id
    let driverId = null;
    if (rte.vehicle === 1535461) {
        driverId = 4700955;
    } else if (rte.vehicle === 1535463 || rte.vehicle === 1535464) {
        driverId = 4764848;
    }
    route.driver_id = 4764848; //driverId;

  console.log(route);
    let form_ids = [
        "3ed8c5f8-4877-41e1-804f-fed1666a68ae",
        "b6b76538-2001-4a34-9f27-427a16965c59"
    ];
    let stopNumber = 1;
    rte.steps.forEach(stop => {
        let theStop = {};
        theStop.vendor_id = `AMZN-${uuid.v4().split('-')[0]}`;
        //theStop.vendor_id = `${stopNumber} ${stop.type === 'start' || stop.type === 'end' ? 'V6' : stop.description}`;
        theStop.dispatch_location_id = stop.type === 'start' || stop.type === 'end' ? 1554007: stop.id;
        theStop.early_date = dtShiftStart2.value;
        theStop.late_date = dtShiftEnd2.value;
        theStop.driver_load = false;
        theStop.form_ids = form_ids;
        theStop.number = stopNumber++;
        theStop.status = "available";
        theStop.type = stop.type === 'start' ? "PU" : "UL"; // Assuming 'start' type is pickup and all others correspond to dropoff
        route.dispatch_stops.push(theStop);
    });

    allRoutes.push(route);
});

// Convert allRoutes array to JSON string
let body = JSON.stringify(allRoutes);

// Print the body in the console
console.log("Request Body:", body);
tmpRouteObject.setValue(allRoutes);

// Make a single POST request with the constructed body
// Jim comment: we need to do this Post Dispatch call for every entry in the array no the full response
allRoutes.forEach(d => {
localStorage.setValue('tmpRouteMotive', d);
  Post_DispatchApiKey.trigger({
    onSuccess: function (data) {
        console.log(`Routes processed successfully ${data}`);
    },
    onFailure: function (error) {
        console.error("Error processing routes:", error);
    },
  });
});
```

### Code Explanation

This code initializes an array to store routes, iterates over the optimized routes to construct route objects, assigns driver IDs, constructs stop objects for each route, adds the routes to the array, converts the array to a JSON string, and finally makes POST requests to the Motive API for each route.

A detailed description of the code is as follows:

-   An empty array called `allRoutes` is initialized which will store all the constructed route objects.
    
-   For each route in the `nbaiOptimizationStatus.data.result.routes` array, a new route object is created with various attributes like `vendor_id, vehicle_id`, `shipper_dispatch_location_id`, etc.
    
-   The driver ID is assigned based on the vehicle ID from the route object. This ensures that each vehicle is assigned the correct driver.
    
-   For each stop in the route’s steps, a stop object is created and added to the `dispatch_stops` array in the route object. The stop object includes attributes like `vendor_id`, `dispatch_location_id`, `early_date`, `late_date`, `driver_load`, `form_ids`, `number`, `status`, and `type`.
    
-   The constructed route object is added to the `allRoutes` array.
    
-   The `allRoutes` array is converted to a JSON string for the API request. It is also logged to the console for debugging purposes and stored in `tmpRouteObject`.
    
-   For each route in the `allRoutes` array, a POST request is made to the Motive API. The success and failure callbacks log the response to the console.
    

## Step 2: POST Dispatches to Motive

Use the following cURL command to dispatch the routes to the Motive API.

### API Request

```bash
curl --location 'https://api.keeptruckin.com/v1/dispatches' \
--header 'Authorization: Bearer <Access token>' \
--data '<body>'
```

Replace <Access token> with your Motive API access token and <body> with the constructed JSON body from the previous step.

### API Response

```javascript
{
  "dispatch": {
    "id": 6640255,
    "driver_id": 4764848,
    "vehicle_id": 1535464,
    "consignee_dispatch_location_id": 1554007,
    "shipper_dispatch_location_id": 1554007,
    "additional_drops": null,
    "additional_pickups": null,
    "consignee_bill_of_lading": null,
    "consignee_comments": null,
    "consignee_driver_load": null,
    "consignee_form_ids": [
      "058785d7-4971-4092-80eb-9bed523570fb",
      "d8e107be-6333-4b10-9ad8-633ec5192c39"
    ],
    "consignee_pallets": null,
    "consignee_pieces": null,
    "consignee_refno": null,
    "consignee_status": "available",
    "consignee_type": "dropoff",
    "consignee_volume": null,
    "consignee_weight": null,
    "delivery_early_date": null,
    "delivery_late_date": null,
    "loaded_miles": null,
    "order_pieces": null,
    "order_volume": null,
    "order_weight": null,
    "pickup_early_date": null,
    "pickup_late_date": null,
    "pickup_number": "1",
    "product": null,
    "shipper_bill_of_lading": null,
    "shipper_comments": null,
    "shipper_driver_load": null,
    "shipper_form_ids": [
      "3ed8c5f8-4877-41e1-804f-fed1666a68ae",
      "b6b76538-2001-4a34-9f27-427a16965c59"
    ],
    "shipper_pallets": null,
    "shipper_pieces": null,
    "shipper_status": "available",
    "shipper_type": "pickup",
    "shipper_volume": null,
    "shipper_weight": null,
    "status": "planned",
    "status_updated_at": "2024-05-14T06:24:10Z",
    "temperature_max": null,
    "temperature_min": null,
    "trailer": null,
    "consignee_form_entry_ids": {},
    "shipper_form_entry_ids": {},
    "auto_complete_forms": true,
    "custom_sort_time": null,
    "custom_field1": null,
    "shipper_custom_field1": null,
    "consignee_custom_field1": null,
    "custom_field2": null,
    "shipper_custom_field2": null,
    "consignee_custom_field2": null,
    "custom_field3": null,
    "shipper_custom_field3": null,
    "consignee_custom_field3": null,
    "custom_field4": null,
    "shipper_custom_field4": null,
    "consignee_custom_field4": null,
    "custom_field5": null,
    "shipper_custom_field5": null,
    "consignee_custom_field5": null,
    "custom_field6": null,
    "shipper_custom_field6": null,
    "consignee_custom_field6": null,
    "custom_field7": null,
    "shipper_custom_field7": null,
    "consignee_custom_field7": null,
    "custom_field8": null,
    "shipper_custom_field8": null,
    "consignee_custom_field8": null,
    "custom_field9": null,
    "shipper_custom_field9": null,
    "consignee_custom_field9": null,
    "custom_field10": null,
    "shipper_custom_field10": null,
    "consignee_custom_field10": null,
    "custom_field11": null,
    "shipper_custom_field11": null,
    "consignee_custom_field11": null,
    "custom_field12": null,
    "shipper_custom_field12": null,
    "consignee_custom_field12": null,
    "custom_field13": null,
    "shipper_custom_field13": null,
    "consignee_custom_field13": null,
    "custom_field14": null,
    "shipper_custom_field14": null,
    "consignee_custom_field14": null,
    "custom_field15": null,
    "shipper_custom_field15": null,
    "consignee_custom_field15": null,
    "custom_field16": null,
    "shipper_custom_field16": null,
    "consignee_custom_field16": null,
    "custom_field17": null,
    "shipper_custom_field17": null,
    "consignee_custom_field17": null,
    "custom_field18": null,
    "shipper_custom_field18": null,
    "consignee_custom_field18": null,
    "custom_field19": null,
    "shipper_custom_field19": null,
    "consignee_custom_field19": null,
    "custom_field20": null,
    "shipper_custom_field20": null,
    "consignee_custom_field20": null,
    "custom_field21": null,
    "shipper_custom_field21": null,
    "consignee_custom_field21": null,
    "custom_field22": null,
    "shipper_custom_field22": null,
    "consignee_custom_field22": null,
    "custom_field23": null,
    "shipper_custom_field23": null,
    "consignee_custom_field23": null,
    "custom_field24": null,
    "shipper_custom_field24": null,
    "consignee_custom_field24": null,
    "custom_field25": null,
    "shipper_custom_field25": null,
    "consignee_custom_field25": null,
    "custom_field26": null,
    "shipper_custom_field26": null,
    "consignee_custom_field26": null,
    "custom_field27": null,
    "shipper_custom_field27": null,
    "consignee_custom_field27": null,
    "custom_field28": null,
    "shipper_custom_field28": null,
    "consignee_custom_field28": null,
    "custom_field29": null,
    "shipper_custom_field29": null,
    "consignee_custom_field29": null,
    "custom_field30": null,
    "shipper_custom_field30": null,
    "consignee_custom_field30": null,
    "custom_field31": null,
    "shipper_custom_field31": null,
    "consignee_custom_field31": null,
    "custom_field32": null,
    "shipper_custom_field32": null,
    "consignee_custom_field32": null,
    "custom_field33": null,
    "shipper_custom_field33": null,
    "consignee_custom_field33": null,
    "custom_field34": null,
    "shipper_custom_field34": null,
    "consignee_custom_field34": null,
    "custom_field35": null,
    "shipper_custom_field35": null,
    "consignee_custom_field35": null,
    "custom_field36": null,
    "shipper_custom_field36": null,
    "consignee_custom_field36": null,
    "custom_field37": null,
    "shipper_custom_field37": null,
    "consignee_custom_field37": null,
    "custom_field38": null,
    "shipper_custom_field38": null,
    "consignee_custom_field38": null,
    "custom_field39": null,
    "shipper_custom_field39": null,
    "consignee_custom_field39": null,
    "custom_field40": null,
    "shipper_custom_field40": null,
    "consignee_custom_field40": null,
    "custom_field41": null,
    "shipper_custom_field41": null,
    "consignee_custom_field41": null,
    "custom_field42": null,
    "shipper_custom_field42": null,
    "consignee_custom_field42": null,
    "custom_field43": null,
    "shipper_custom_field43": null,
    "consignee_custom_field43": null,
    "custom_field44": null,
    "shipper_custom_field44": null,
    "consignee_custom_field44": null,
    "custom_field45": null,
    "shipper_custom_field45": null,
    "consignee_custom_field45": null,
    "custom_field46": null,
    "shipper_custom_field46": null,
    "consignee_custom_field46": null,
    "custom_field47": null,
    "shipper_custom_field47": null,
    "consignee_custom_field47": null,
    "custom_field48": null,
    "shipper_custom_field48": null,
    "consignee_custom_field48": null,
    "custom_field49": null,
    "shipper_custom_field49": null,
    "consignee_custom_field49": null,
    "custom_field50": null,
    "shipper_custom_field50": null,
    "consignee_custom_field50": null,
    "custom_field51": null,
    "shipper_custom_field51": null,
    "consignee_custom_field51": null,
    "custom_field52": null,
    "shipper_custom_field52": null,
    "consignee_custom_field52": null,
    "custom_field53": null,
    "shipper_custom_field53": null,
    "consignee_custom_field53": null,
    "custom_field54": null,
    "shipper_custom_field54": null,
    "consignee_custom_field54": null,
    "custom_field55": null,
    "shipper_custom_field55": null,
    "consignee_custom_field55": null,
    "custom_field56": null,
    "shipper_custom_field56": null,
    "consignee_custom_field56": null,
    "custom_field57": null,
    "shipper_custom_field57": null,
    "consignee_custom_field57": null,
    "custom_field58": null,
    "shipper_custom_field58": null,
    "consignee_custom_field58": null,
    "custom_field59": null,
    "shipper_custom_field59": null,
    "consignee_custom_field59": null,
    "custom_field60": null,
    "shipper_custom_field60": null,
    "consignee_custom_field60": null,
    "custom_field61": null,
    "shipper_custom_field61": null,
    "consignee_custom_field61": null,
    "custom_field62": null,
    "shipper_custom_field62": null,
    "consignee_custom_field62": null,
    "custom_field63": null,
    "shipper_custom_field63": null,
    "consignee_custom_field63": null,
    "custom_field64": null,
    "shipper_custom_field64": null,
    "consignee_custom_field64": null,
    "custom_field65": null,
    "shipper_custom_field65": null,
    "consignee_custom_field65": null,
    "custom_field66": null,
    "shipper_custom_field66": null,
    "consignee_custom_field66": null,
    "custom_field67": null,
    "shipper_custom_field67": null,
    "consignee_custom_field67": null,
    "custom_field68": null,
    "shipper_custom_field68": null,
    "consignee_custom_field68": null,
    "custom_field69": null,
    "shipper_custom_field69": null,
    "consignee_custom_field69": null,
    "custom_field70": null,
    "shipper_custom_field70": null,
    "consignee_custom_field70": null,
    "custom_field71": null,
    "shipper_custom_field71": null,
    "consignee_custom_field71": null,
    "custom_field72": null,
    "shipper_custom_field72": null,
    "consignee_custom_field72": null,
    "custom_field73": null,
    "shipper_custom_field73": null,
    "consignee_custom_field73": null,
    "custom_field74": null,
    "shipper_custom_field74": null,
    "consignee_custom_field74": null,
    "custom_field75": null,
    "shipper_custom_field75": null,
    "consignee_custom_field75": null,
    "custom_field76": null,
    "shipper_custom_field76": null,
    "consignee_custom_field76": null,
    "custom_field77": null,
    "shipper_custom_field77": null,
    "consignee_custom_field77": null,
    "custom_field78": null,
    "shipper_custom_field78": null,
    "consignee_custom_field78": null,
    "custom_field79": null,
    "shipper_custom_field79": null,
    "consignee_custom_field79": null,
    "custom_field80": null,
    "shipper_custom_field80": null,
    "consignee_custom_field80": null,
    "custom_field81": null,
    "shipper_custom_field81": null,
    "consignee_custom_field81": null,
    "custom_field82": null,
    "shipper_custom_field82": null,
    "consignee_custom_field82": null,
    "custom_field83": null,
    "shipper_custom_field83": null,
    "consignee_custom_field83": null,
    "custom_field84": null,
    "shipper_custom_field84": null,
    "consignee_custom_field84": null,
    "custom_field85": null,
    "shipper_custom_field85": null,
    "consignee_custom_field85": null,
    "custom_field86": null,
    "shipper_custom_field86": null,
    "consignee_custom_field86": null,
    "custom_field87": null,
    "shipper_custom_field87": null,
    "consignee_custom_field87": null,
    "custom_field88": null,
    "shipper_custom_field88": null,
    "consignee_custom_field88": null,
    "custom_field89": null,
    "shipper_custom_field89": null,
    "consignee_custom_field89": null,
    "custom_field90": null,
    "shipper_custom_field90": null,
    "consignee_custom_field90": null,
    "custom_field91": null,
    "shipper_custom_field91": null,
    "consignee_custom_field91": null,
    "custom_field92": null,
    "shipper_custom_field92": null,
    "consignee_custom_field92": null,
    "custom_field93": null,
    "shipper_custom_field93": null,
    "consignee_custom_field93": null,
    "custom_field94": null,
    "shipper_custom_field94": null,
    "consignee_custom_field94": null,
    "custom_field95": null,
    "shipper_custom_field95": null,
    "consignee_custom_field95": null,
    "custom_field96": null,
    "shipper_custom_field96": null,
    "consignee_custom_field96": null,
    "custom_field97": null,
    "shipper_custom_field97": null,
    "consignee_custom_field97": null,
    "custom_field98": null,
    "shipper_custom_field98": null,
    "consignee_custom_field98": null,
    "custom_field99": null,
    "shipper_custom_field99": null,
    "consignee_custom_field99": null,
    "custom_field100": null,
    "shipper_custom_field100": null,
    "consignee_custom_field100": null,
    "vendor_id": "AMZN-5ff2d94b",
    "vendor_shipper_id": "shipper",
    "vendor_consignee_id": "consignee",
    "dispatch_stops": [
      {
        "dispatch_stop": {
          "id": 5251061,
          "bill_of_lading": null,
          "comments": null,
          "dispatch_location_id": 1554007,
          "driver_load": false,
          "early_date": "2024-05-15T08:00:00+05:30",
          "form_ids": [
            "3ed8c5f8-4877-41e1-804f-fed1666a68ae",
            "b6b76538-2001-4a34-9f27-427a16965c59"
          ],
          "late_date": "2024-05-15T20:00:00+05:30",
          "number": 1,
          "pallets_in": null,
          "pallets_out": null,
          "pieces": null,
          "status": "available",
          "type": "PU",
          "volume": null,
          "weight": null,
          "form_entry_ids": {},
          "custom_field1": null,
          "custom_field2": null,
          "custom_field3": null,
          "custom_field4": null,
          "custom_field5": null,
          "custom_field6": null,
          "custom_field7": null,
          "custom_field8": null,
          "custom_field9": null,
          "custom_field10": null,
          "custom_field11": null,
          "custom_field12": null,
          "custom_field13": null,
          "custom_field14": null,
          "custom_field15": null,
          "custom_field16": null,
          "custom_field17": null,
          "custom_field18": null,
          "custom_field19": null,
          "custom_field20": null,
          "custom_field21": null,
          "custom_field22": null,
          "custom_field23": null,
          "custom_field24": null,
          "custom_field25": null,
          "custom_field26": null,
          "custom_field27": null,
          "custom_field28": null,
          "custom_field29": null,
          "custom_field30": null,
          "custom_field31": null,
          "custom_field32": null,
          "custom_field33": null,
          "custom_field34": null,
          "custom_field35": null,
          "custom_field36": null,
          "custom_field37": null,
          "custom_field38": null,
          "custom_field39": null,
          "custom_field40": null,
          "custom_field41": null,
          "custom_field42": null,
          "custom_field43": null,
          "custom_field44": null,
          "custom_field45": null,
          "custom_field46": null,
          "custom_field47": null,
          "custom_field48": null,
          "custom_field49": null,
          "custom_field50": null,
          "custom_field51": null,
          "custom_field52": null,
          "custom_field53": null,
          "custom_field54": null,
          "custom_field55": null,
          "custom_field56": null,
          "custom_field57": null,
          "custom_field58": null,
          "custom_field59": null,
          "custom_field60": null,
          "custom_field61": null,
          "custom_field62": null,
          "custom_field63": null,
          "custom_field64": null,
          "custom_field65": null,
          "custom_field66": null,
          "custom_field67": null,
          "custom_field68": null,
          "custom_field69": null,
          "custom_field70": null,
          "custom_field71": null,
          "custom_field72": null,
          "custom_field73": null,
          "custom_field74": null,
          "custom_field75": null,
          "custom_field76": null,
          "custom_field77": null,
          "custom_field78": null,
          "custom_field79": null,
          "custom_field80": null,
          "custom_field81": null,
          "custom_field82": null,
          "custom_field83": null,
          "custom_field84": null,
          "custom_field85": null,
          "custom_field86": null,
          "custom_field87": null,
          "custom_field88": null,
          "custom_field89": null,
          "custom_field90": null,
          "custom_field91": null,
          "custom_field92": null,
          "custom_field93": null,
          "custom_field94": null,
          "custom_field95": null,
          "custom_field96": null,
          "custom_field97": null,
          "custom_field98": null,
          "custom_field99": null,
          "custom_field100": null,
          "vendor_id": "AMZN-a7894d05",
          "vendor_dispatch_location_id": "AMAZON_HUB-DC"
        }
      },
      {
        "dispatch_stop": {
          "id": 5251064,
          "bill_of_lading": null,
          "comments": null,
          "dispatch_location_id": 1517226,
          "driver_load": false,
          "early_date": "2024-05-15T08:00:00+05:30",
          "form_ids": [
            "3ed8c5f8-4877-41e1-804f-fed1666a68ae",
            "b6b76538-2001-4a34-9f27-427a16965c59"
          ],
          "late_date": "2024-05-15T20:00:00+05:30",
          "number": 2,
          "pallets_in": null,
          "pallets_out": null,
          "pieces": null,
          "status": "available",
          "type": "UL",
          "volume": null,
          "weight": null,
          "form_entry_ids": {},
          "custom_field1": null,
          "custom_field2": null,
          "custom_field3": null,
          "custom_field4": null,
          "custom_field5": null,
          "custom_field6": null,
          "custom_field7": null,
          "custom_field8": null,
          "custom_field9": null,
          "custom_field10": null,
          "custom_field11": null,
          "custom_field12": null,
          "custom_field13": null,
          "custom_field14": null,
          "custom_field15": null,
          "custom_field16": null,
          "custom_field17": null,
          "custom_field18": null,
          "custom_field19": null,
          "custom_field20": null,
          "custom_field21": null,
          "custom_field22": null,
          "custom_field23": null,
          "custom_field24": null,
          "custom_field25": null,
          "custom_field26": null,
          "custom_field27": null,
          "custom_field28": null,
          "custom_field29": null,
          "custom_field30": null,
          "custom_field31": null,
          "custom_field32": null,
          "custom_field33": null,
          "custom_field34": null,
          "custom_field35": null,
          "custom_field36": null,
          "custom_field37": null,
          "custom_field38": null,
          "custom_field39": null,
          "custom_field40": null,
          "custom_field41": null,
          "custom_field42": null,
          "custom_field43": null,
          "custom_field44": null,
          "custom_field45": null,
          "custom_field46": null,
          "custom_field47": null,
          "custom_field48": null,
          "custom_field49": null,
          "custom_field50": null,
          "custom_field51": null,
          "custom_field52": null,
          "custom_field53": null,
          "custom_field54": null,
          "custom_field55": null,
          "custom_field56": null,
          "custom_field57": null,
          "custom_field58": null,
          "custom_field59": null,
          "custom_field60": null,
          "custom_field61": null,
          "custom_field62": null,
          "custom_field63": null,
          "custom_field64": null,
          "custom_field65": null,
          "custom_field66": null,
          "custom_field67": null,
          "custom_field68": null,
          "custom_field69": null,
          "custom_field70": null,
          "custom_field71": null,
          "custom_field72": null,
          "custom_field73": null,
          "custom_field74": null,
          "custom_field75": null,
          "custom_field76": null,
          "custom_field77": null,
          "custom_field78": null,
          "custom_field79": null,
          "custom_field80": null,
          "custom_field81": null,
          "custom_field82": null,
          "custom_field83": null,
          "custom_field84": null,
          "custom_field85": null,
          "custom_field86": null,
          "custom_field87": null,
          "custom_field88": null,
          "custom_field89": null,
          "custom_field90": null,
          "custom_field91": null,
          "custom_field92": null,
          "custom_field93": null,
          "custom_field94": null,
          "custom_field95": null,
          "custom_field96": null,
          "custom_field97": null,
          "custom_field98": null,
          "custom_field99": null,
          "custom_field100": null,
          "vendor_id": "AMZN-9cec5f92",
          "vendor_dispatch_location_id": "C7"
        }
      },
      {
        "dispatch_stop": {
          "id": 5251067,
          "bill_of_lading": null,
          "comments": null,
          "dispatch_location_id": 1554007,
          "driver_load": false,
          "early_date": "2024-05-15T08:00:00+05:30",
          "form_ids": [
            "3ed8c5f8-4877-41e1-804f-fed1666a68ae",
            "b6b76538-2001-4a34-9f27-427a16965c59"
          ],
          "late_date": "2024-05-15T20:00:00+05:30",
          "number": 3,
          "pallets_in": null,
          "pallets_out": null,
          "pieces": null,
          "status": "available",
          "type": "UL",
          "volume": null,
          "weight": null,
          "form_entry_ids": {},
          "custom_field1": null,
          "custom_field2": null,
          "custom_field3": null,
          "custom_field4": null,
          "custom_field5": null,
          "custom_field6": null,
          "custom_field7": null,
          "custom_field8": null,
          "custom_field9": null,
          "custom_field10": null,
          "custom_field11": null,
          "custom_field12": null,
          "custom_field13": null,
          "custom_field14": null,
          "custom_field15": null,
          "custom_field16": null,
          "custom_field17": null,
          "custom_field18": null,
          "custom_field19": null,
          "custom_field20": null,
          "custom_field21": null,
          "custom_field22": null,
          "custom_field23": null,
          "custom_field24": null,
          "custom_field25": null,
          "custom_field26": null,
          "custom_field27": null,
          "custom_field28": null,
          "custom_field29": null,
          "custom_field30": null,
          "custom_field31": null,
          "custom_field32": null,
          "custom_field33": null,
          "custom_field34": null,
          "custom_field35": null,
          "custom_field36": null,
          "custom_field37": null,
          "custom_field38": null,
          "custom_field39": null,
          "custom_field40": null,
          "custom_field41": null,
          "custom_field42": null,
          "custom_field43": null,
          "custom_field44": null,
          "custom_field45": null,
          "custom_field46": null,
          "custom_field47": null,
          "custom_field48": null,
          "custom_field49": null,
          "custom_field50": null,
          "custom_field51": null,
          "custom_field52": null,
          "custom_field53": null,
          "custom_field54": null,
          "custom_field55": null,
          "custom_field56": null,
          "custom_field57": null,
          "custom_field58": null,
          "custom_field59": null,
          "custom_field60": null,
          "custom_field61": null,
          "custom_field62": null,
          "custom_field63": null,
          "custom_field64": null,
          "custom_field65": null,
          "custom_field66": null,
          "custom_field67": null,
          "custom_field68": null,
          "custom_field69": null,
          "custom_field70": null,
          "custom_field71": null,
          "custom_field72": null,
          "custom_field73": null,
          "custom_field74": null,
          "custom_field75": null,
          "custom_field76": null,
          "custom_field77": null,
          "custom_field78": null,
          "custom_field79": null,
          "custom_field80": null,
          "custom_field81": null,
          "custom_field82": null,
          "custom_field83": null,
          "custom_field84": null,
          "custom_field85": null,
          "custom_field86": null,
          "custom_field87": null,
          "custom_field88": null,
          "custom_field89": null,
          "custom_field90": null,
          "custom_field91": null,
          "custom_field92": null,
          "custom_field93": null,
          "custom_field94": null,
          "custom_field95": null,
          "custom_field96": null,
          "custom_field97": null,
          "custom_field98": null,
          "custom_field99": null,
          "custom_field100": null,
          "vendor_id": "AMZN-d5521680",
          "vendor_dispatch_location_id": "AMAZON_HUB-DC"
        }
      }
    ],
    "vendor_shipper_dispatch_location_id": "AMAZON_HUB-DC",
    "vendor_consignee_dispatch_location_id": "AMAZON_HUB-DC"
  }
}
```

### Step 3: Track and Manage Dispatches

**Driver App Updates:** The generated routes will be dispatched to the respective drivers' apps. Drivers must update arrival and departure information in the app, which will be used for tracking.

![documentation image](https://static.nextbillion.io/docs-next/integrations/motive/image-5.webp)

**Motive Dashboard:** Track the dispatch details in the Motive Dashboard to monitor the status and progress of each route.

![documentation image](https://static.nextbillion.io/docs-next/integrations/motive/image-6.webp)

The status can be tracked on both mobile app and web app interface.

![documentation image](https://static.nextbillion.io/docs-next/integrations/motive/image-7.webp)

**Completion Summary:** Upon dispatch completion, Motive will generate a short summary, providing an overview of the completed tasks and any issues encountered.

![documentation image](https://static.nextbillion.io/docs-next/integrations/motive/image-8.webp)

This integration streamlines the process of route planning and management, reducing operational costs, improving service times, and maximizing resource utilization.

For any further assistance or advanced customization, refer to the respective API documentation of Motive and NextBillion.ai, or reach out to the support team.
