Passing Parameters via Action Commands commands

I am using the Action Commands plugin to send emails from Octoprint

1/ When the print starts heating up the bed and head.
2/ when printing actually starts.
3/ when the print finishes.

I installed the smtp client script onto the Octoprint Raspeberry pi ( is a pure Perl smtp client for sending email) it just needed a couple of extra perl modules adding (for SSL support) then it can be configured to send email via any smtp server you are using such as Gmail, etc.

I found it much easier to install and configure than any of the standard raspberry packages available for sending emails and as Octoprint already has Perl installed it was a natural fit.

I put three perl scripts on the raspberry pi which send the appropriate emails using the script. I configured the Action Commands plugin to call my scripts when certain action commands are encountered in the Gcode then added the M118 //action;dosomething; commands in the appropriate Slic3R (my slicer software) custom gcode sections.This works nicely and generates Gcode files that will send these emails.

At the moment I just get emails saying essentially prepared, started, completed.

What I would like to do is have the action commands pass a parameter, probably the gcode filename to the script being called so it can use it in the the email messages, so the email can tell me what script is being prepared, started and completed. Is there a way of

1/ Obtaining the gcode filename at runtime in the the gcode program,
2/ Passing the value obtained as a parameter in the action command

Looking at that plugin's code it doesn't seem to support any form of parameters to pass on. But, I believe you could achieve what you want with the default events in config.yaml. The reason I say that is because you have access to a payload that will have the data your after I think.

There's an old cookbook that was on the wiki that got migrated over here that also has an example of this email sending technique. Look for Send an email incl. a snapshot of the printed object upon print completion. It might be tricky in the situation of distinguishing the "2/ when printing actually starts." but you might be able to adapt to using Alert maybe from this event.

Thank you very much for that, I will have a look and see what I can come up it does look promising and I see what you mean about using Alert.
The reason I have the second event 'started' is so I can see the actual printing time between the time that email was sent and the 'ended' email was sent, not including homing and heating up time.