ADSL modem reset script, help

Hello people how are you,
I need if you can guide me a bit, I have a VPN and every so often as it hangs over the internet that I have Mikrotik, so I remotely enter the Mikrotik and restart the modem by console and the VPN reconnects, the question is, could I ask this for Script ?.
I have done some basic scripting, but I don’t know how to deal with the telnet modem access issue.
to put the username and password and give Reboot.
Greetings