Make HTML button run custom node JS code

So the problem is quite simple. I have made a custom node that continually saves it's state into the node context. What I want to do is have a button in the edit dialog box that will run a function I have created in the JS for the node, the goal here being resetting these context variables. In essence I would have to create the button in the HTML file and define it's functionality somewhere in the javascript.

Is there a way to do this?

You create a HTTP Endpoint in the JS file and call to it from the HTML file. Take a look at the serial node in the Node red github repository for an example.