I'm guessing you mean on OEM firmware?
There's a few threads about how to run a script when a task is completed.
These may be helpful:
- How to detect DHCP assignment to send an email on OpenWrt
- Mwan3 notifcation script
- Router having an E-Mail address to receive emails and act upon it
Also, others may read and offer some more ideas.