Lifehack: connecting your own delivery service
Published 21.01.2025 16:30 in Cases
Is your delivery service not on the AlterCPA Moe list? Connect it yourself: the built-in service can send orders, track parcels and print documents through three links to your own handler. There is no need to touch the code of the CRM itself.
What’s the point?
The “Generic” delivery service type was conceived as a stub for couriers you serve manually. But its settings have three fields for links. If your own handler lives behind those links, the stub works as a real integration: orders go to the service, statuses come back, documents get printed. There are no delivery hacks in the free AlterCPA Moe, but three links are quite enough.
Handlers can be written in any language and placed on your own hosting. True, you will have to set them up yourself: you need someone who can accept a request and reply in JSON format.
Three links
Open the delivery settings in the company management and add a service with the “Generic” type. It has three fields:
- Tracking URL — receives the parcel’s tracking code and returns its status history;
- Sending URL — receives the order data, creates a parcel and replies with a tracking code;
- Labels URL — returns a link to the finished file with labels and documents.
Macros work in the links: {track} or {code} inserts the tracking code, {order} — the order ID in the CRM, {track:xxx} — the tracking parameter xxx received on sending. For example, a tracking link may look like this: https://your-logistics.example/track?code={track}.
What to enable
- “Delivery service is active” — without this checkbox the service is unavailable when working with orders;
- “Use this delivery service as default for incoming leads” — the service will be assigned to all new leads;
- “Change order status automatically depending on delivery tracking” — the
transfer,delivered,paidandreturnstatuses from your handler’s reply will move the order to “Transfer”, “Arrived”, “Completed” and “Return” on their own; - Enable automatic dispatch of orders to the delivery service — set the “To send”, “Success” and “Error” statuses.
The CRM polls parcel statuses by itself, twice a day, and an operator can refresh the history manually from the order page; the order is sent to the service by a button from there as well. Documents are printed for a single order or in bulk. Parcels stuck in one status can be put on the call list with the “Automatic calls planning” block, and the time in it is set in hours.
Important!
- The automatic dispatch can be configured only after the sending link is specified. While the service is not active, you can put any placeholder there, save, go back and configure the rest.
- The price and cost of delivery are fixed: the built-in service has no dynamic price calculation. The settlement and cash services percentage in the cost is calculated from the order price for the buyer, not from the cost price.
- The reply to sending must contain a tracking code: the CRM uses it to follow the parcel and print documents.
- The error status must not be the same as the sending status. It is handy to create a separate nested status for errors: dragging them straight to a return is questionable.
The full reply schema and PHP handler examples are in the article “Creating simple logistics service”. Three links on a third-party hosting, and the humble stub suddenly becomes full-fledged logistics.