Start a trial
Color

Reminders, email and WhatsApp

See how the nightly job writes Fleet reminders, find them in the alerts list, add an email address and send one by WhatsApp.

For
OwnerFleet manager
Hosting
Any hosting
Devices
All devices
Business
Fleet

Checked against Pop Dispatch 0.1.0

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_fleet license 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_soon and another at overdue.
  • Documents: the current document of each type, with a reminder at expiring and another at expired.
  • Meters: a stale reminder 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 #

  1. Read the reminders with GET /fleet/alerts. The newest 200 come first. Each shows its subject (pm_schedule, document or meter), kind, level, channel and sent_at. The in-app list is the record of every reminder.
  2. Add an email address with PATCH /settings/fleet and a body such as {"alert_email": "fleet@example.com"}. Each new reminder after that also queues an email to that address.
  3. Check it with GET /settings/fleet. The answer shows alert_email.
  4. Turn email off by sending an empty alert_email.
  5. Run the job now with POST /fleet/alerts/run. The owner or manager role is needed. The answer gives the count of new reminders and lists them. A second run straight after the first finds nothing new, because each level is written once.

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_log by 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_email accepts 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) with fields: ["alert_email"]: send a single email address, or empty to turn emails off.
  • feature_not_licensed (403): the license has no dispatch_fleet flag, so the job writes nothing and POST /fleet/alerts/run is 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: 0 found nothing new to write.