Fleet writes a reminder when a service comes due, a document nears its expiry or a meter has gone quiet. You will be able to read the reminders, receive them by email, send one by WhatsApp and run the job on demand.
Before you start #
- Add maintenance schedules and documents so the job has something to watch. See how-due-is-worked-out and documents-and-expiry.
- For email, Pop Dispatch uses your own mail settings.
- Fleet runs under the
dispatch_fleetlicense flag. The job writes nothing without it, or while the license is read-only.
What the nightly job covers #
The job runs on a schedule and checks every hour. It records only what is new, so repeated runs never produce repeats. It looks at three things:
- Maintenance schedules: a reminder at
due_soonand another atoverdue. - Documents: the current document of each type, with a reminder at
expiringand another atexpired. - Meters: a
stalereminder for an asset whose meter has had no reading for 30 days.
Each reminder is written once for each level. A service that is due soon gets one reminder. If it later becomes overdue, that is a new level and gets its own reminder.
Steps #
- Read the reminders with
GET /fleet/alerts. The newest 200 come first. Each shows its subject (pm_schedule,documentormeter),kind,level,channelandsent_at. The in-app list is the record of every reminder. - Add an email address with
PATCH /settings/fleetand a body such as{"alert_email": "fleet@example.com"}. Each new reminder after that also queues an email to that address. - Check it with
GET /settings/fleet. The answer showsalert_email. - Turn email off by sending an empty
alert_email. - Run the job now with
POST /fleet/alerts/run. The owner or manager role is needed. The answer gives the count ofnewreminders and lists them. A second run straight after the first finds nothing new, because each level is written once.
The WhatsApp link #
Each reminder in the answer of POST /fleet/alerts/run carries a message and a whatsapp_link in the form https://wa.me/?text= followed by the message. The person taps the link and WhatsApp opens with the message ready. They pick the chat and press send themselves. Pop Dispatch sends nothing by WhatsApp.
The message names the asset or person, the item and the state, for example "Unit 12: oil service is coming due." The states read "is coming due", "is overdue", "expires soon", "has expired" and "needs a new reading".
Technical details
- Reminders are remembered in
fleet_alert_logby subject type, subject id, kind and level. A reminder in the log never sends again. - The email goes to the notification queue with the subject "Fleet reminder" and the reminder text as the body.
alert_emailaccepts one address of up to 200 characters with no spaces.- Document reminders cover the current document of each type only. A renewal or a void changes which one counts. See documents-and-expiry.
- The in-app channel is always on. Email adds to it.
If something goes wrong #
validation_failed(422) withfields: ["alert_email"]: send a single email address, or empty to turn emails off.feature_not_licensed(403): the license has nodispatch_fleetflag, so the job writes nothing andPOST /fleet/alerts/runis refused.licence_read_only(403): the license is in read-only mode and the job pauses.- No reminders appear: check that schedules or documents exist and that a threshold has been reached. A run with
new: 0found nothing new to write.