# HaulHub

{% hint style="info" %}
For assistance in building the Haul Hub Integration, contact us at 865-219-2980 or [support@tacinsight.com](mailto:mailto:support@tacinsight.com)
{% endhint %}

{% hint style="info" %}
Note: You will need access to the [API Module](https://tacinsight.zohodesk.com/portal/en/kb/articles/149-api-overview) in order to build this integration!
{% endhint %}

## Enabling the Haul Hub Integration

* Navigate to Admin Settings (Gear Icon) > API Info
* Click on the "Show" button to access the Webhooks Dashboard.
* Click the "+ Add Endpoint" button to build the webhook.
* In the Message Filtering options, select `ticket.created`, `ticket.updated`, and `ticket.voided`.
* Build the Endpoint URL following this layout:

{% code overflow="wrap" %}

```
https://haulhub.fastweigh.workers.dev/send?FW_GRAPHQL_SERVER=FWT&FW_API_KEY=<insert_fast-weigh_api_key_here>&HH_API_KEY=<insert_haulhub_api_key_here>
```

{% endcode %}

* You can find your API Key and GraphQL server (the first part of the GraphQL Endpoint URL) on the API Info Page.
* It should look something  like this when you are finished:

{% code overflow="wrap" %}

```
https://haulhub.fastweigh.workers.dev/send?FW_GRAPHQL_SERVER=FWT&FW_API_KEY=11111-11111-1111-11111&HH_API_KEY=2222222-22222-22222-22222
```

{% endcode %}

* Hit the Create button to create the new webhook.
* Check the "Certified" checkbox on any order that you want tickets to flow to HaulHub.

{% hint style="warning" %}

#### Customizing Payload

The following query parameters can optionally be appended to the webhook URL to modify the payload sent to HaulHub (e.g. `<webhook URL>&DOT_CODE=OrderUDF1`):

* `&DOT_CODE=`: Can be given the value of one of the following *(e.g. `&DOT_CODE=OrderUDF2`)*
  * `OrderUDF1` | `OrderUDF2` | `OrderUDF3`
  * `DOT_CODE` can also be hard coded into the webhook URL `<webhook URL>&DOT_CODE=01023436C3A3FABCD`
  * If set, the `dot_code` of the payload will use the assigned Order UDF field. If NOT set, the `dot_code` will be blank
* `&MAX_GVW=`: Can be given the value of one of the following *(e.g. `MAX_GVW=TicketUDF2`)*
  * `TicketUDF1` | `TicketUDF2` | `TicketUDF3`
  * If set, the `max_gvw` of the payload will use the assigned Ticket UDF field. If NOT set, the `max_gvw` will use the Truck's `WeightCapacity` if it exists, else it will be blank
* `&JOB=`: Can be given the value of `OrderDeliveryLocation`
  * If set, the `job` of the payload will use the Delivery Location of the Order. If NOT set, the `job` will use the Order's `Description` field
* `&JOB_NUMBER=`: Can be given the value of one of the following *(e.g. `JOB_NUMBER=OrderUDF3`)*
  * `OrderUDF1` | `OrderUDF2` | `OrderUDF3`
  * If set, the `job_number` of the payload will use the assigned Order UDF field. If NOT set, the `job_number` will use the Ticket's `Job` field, or if that is blank, the Order's `DefaultJob` field
* `&MATERIAL_NUMBER=`: Can be given the value of one of the following *(e.g. `MATERIAL_NUMBER=OrderUDF1`)*
  * `OrderUDF1` | `OrderUDF2` | `OrderUDF3` | `DOTName` | `PricingDescription`
  * If set to an OrderUDF, the `material_number` of the payload will use the assigned Order UDF field. If set to DOTName, the `material_number` of the payload will use the Product's `DOTName` field. If set to PricingDescription, the `material_number` of the payload will use the OrderProduct's `Description` field (the Product Pricing Description in Fast-Weigh). If NOT set, the `material_number` will use the Product's `ProductID` field
* `&PRODUCT_CODE=`: Can be given the value of one of the follow *(e.g. `PRODUCT_CODE=DOTName`)*
  * `DOTName` | `PricingDescription`
  * If set to DOTName, the `product_code` of the payload will use the Product's `DOTName` field. If set to PricingDescription, the `product_code` of the payload will use the OrderProduct's `Description` field (the Product Pricing Description in Fast-Weigh). If NOT set, the `product_code` will use the Product's `ProductID` field

It may look something like this when you are finished:

<https://haulhub.fastweigh.workers.dev/send?FW\\_GRAPHQL\\_SERVER=FWT\\&FW\\_API\\_KEY=11111-11111-1111-11111\\&HH\\_API\\_KEY=2222222-22222-22222-22222\\&DOT\\_CODE=0123436C3A3FABCD\\&PRODUCT\\_CODE=DOTName>
{% endhint %}

{% hint style="danger" %}
Some DOTs require a **Agency Code**.  This value will be provided by Haul Hub if applicable and is typically mapped to the DOT\_CODE field.
{% endhint %}

## Haulhub Javascript Payload

{% code overflow="wrap" lineNumbers="true" %}

```javascript
slip_number: ticket.TicketNumber,
dot_code: DOT_CODE ?? '',
dispatched_at: formattedDateTime,
last_updated: formattedDateTime,
timestamp: formattedDateTime,
gross_amount: ticket.GrossWeight,
tare_amount: ticket.TareWeight,
net_amount: ticket.NetWeight,
quantity_uom_code: 'ton',
gross2_amount: ticket.GrossWeight! * 2000,
tare2_amount: ticket.TareWeight! * 2000,
net2_amount: ticket.NetWeight * 2000,
uom2: 'lbs',
client_id: ticket.Order.Customer.CustomerID,
client_name: ticket.Order.Customer.CustomerName,
comments: ticket.Note,
contract_number: ticket.Order.PONumber,
customer_name: ticket.Order.Customer.CustomerName,
deputy: ticket.Operator,
dispatch_number: ticket.TicketNumber,
job: ticket.Order.Description,
job_number: ticket.Job ? ticket.Job : ticket.Order.DefaultJob,
line_item_description: ticket.OrderProduct?.Product.ProductDescription,
line_item_quantity: ticket.NetWeight,
loads_today: totalTickets,
material_number: ticket.OrderProduct?.Product.ProductID,
phase_code: ticket.Phase,
plant_id: ticket.OrderProduct?.Yard.YardName,
plant_name: ticket.OrderProduct?.Yard.YardDescription,
product_code: ticket.OrderProduct?.Product.ProductID,
purchase_order_number: ticket.Order.PONumber,
quantity_shipped_today: totalNetWeight,
supplier: ticket.OrderProduct?.Yard.Location.Region.RemitName,
supplier_code: ticket.OrderProduct?.Yard.WarehouseCode ?? ticket.OrderProduct?.Yard.Location.Region.RegionName,
tonnage: ticket.NetWeight,
void: ticket.Void,
weighmaster: ticket.Operator,
fleet_id: ticket.Truck.Hauler.HaulerID,
fleet_name: ticket.Truck.Hauler.HaulerName,
truck_id: ticket.Truck.TruckID,
license_1: ticket.Truck.LicenseNum,
audit_log: [],
```

{% endcode %}
