If we look at the Gcode for Duets (https://duet3d.dozuki.com/Wiki/Gcode), this can easily be implemented:
Comments are after the ";" and can be removed, they are explaining what is expected to happen at this line. Gcode are simple plain text and human readable instructions.
Lines with square brackets [] means you should figure out what you need there.
G60 S1 ; Save the current print head coordinates into slot 1 (same one used during standard pausing; alternatively use slot 0 or 2).
G1 E-1 F1200 ; G1 is a move command, here used to retract 1mm of filament at the a feedrate of 1200mm/min
G91 ; G91 simple sets the Duet into Relative Positioning, since you want to lift the head, absolute coordinates are not useful at all (unless you have a park position for the head).
G0 Z5 F900 ; G0 is a move command where we lift the head, in this case by 5mm (at a speed [or Feedrate] of 900mm/min or 15mm/s - you can change this to your liking).
G90 ; G90 undo the G91 by setting X, Y and Z into Absolute Positioning (now a X, Y, Z parameter of G1 or G0 will move to that position).
G0 X0 Y0 F2000 ; Here we move the head towards the front left (on a typical Cartesian coordinate system)
G1 E-2 F1200 ; Retract the other 2mm of your total 3mm retraction
M144 S0 ; bed to standby temperatures
[use the first part of the gcode from your preferred method below here]
M291 R"Title" P"Message" S2 X1 Y1 Z1 ; The command displays a prompt/message with an OK button, S3 also gives a Cancel button; S2 and S3 are blocking and will wait until OK; this also gives movement buttons for X Y and Z.
[use the second part from your preferred method here]
M116 P1; wait for the tool to reach it target temperature
M144 S1 ; set bed to active temperature (we dont currently have to wait for it, since we are loading filament).
[typically here you would handle full unloading and loading of filament as well as priming the nozzle, also might be a good idea to Home X and Y at this time, ensures coordinates are perfect]
G1 E-3 ; since we have the nozzle primed, we retract it again to not ooze it out again.
M116 ; Allows the bed to fully heat to its temperature (optional)
G90 ; ensure we are at absolute coordinates
G0 R1 X0 Y0 Z5 F2000 ; move to 5mm above the saved position
G91 ; once again to relative mode, to lower the head
G1 Y-5 F900 ; slowly lower the head to the print, coming from above ensures we do not accidentally crash into the print, knocking it over
G1 E3 ; unretract the 3mm - nozzle should now be primed and ready
G90 ; final absolute coordinates; after this line, the M600 is over and the print will simply continue
Here I break the code into 2 options:
1] manually set the temperatures that will always be used (tool remains active, so movements are allowed).
2] set the current tool to Idle temperatures (tool is idle and thus cant be moved, but we keep our previously set temperatures).
Option 1:
[first part]
G10 P1 S0 R0 ; set the active and standby temperatures for Tool 1 (typically first extruder) to 0; initiating a cooldown
[last part]
G10 P1 S210 R0 ; set the active temperature for Tool 1 to 210C and keep the standby on 0 - modify as needed.
Option 2:
[first part]
T-1 ; deselect current tool; will automatically cooldown to Standby temperature. Note no movement is allowed.
[last part]
T1 ; select the first tool; automatically start heating to its Active temperature
Note that by the time you might see the message, the printer might be cooled completely, so moving the extruder at that time is not safe (and if it is below its threshold simply will not move).
The M144 commands are optional, is simple lets the bed cool (some coatings might release the print if the bed cools too far).
While this may look like a lot of code, learning Gcode by doing something like this is effective. Understanding Gcode (or at least having slight background and searching) with a Duet printer will unleash its power - the ability to make it do anything you want (within the realms of 3D manufacturing).