sartography / SpiffWorkflow

A powerful workflow engine implemented in pure Python
GNU Lesser General Public License v3.0
1.67k stars 312 forks source link

How do integrate a webhook into a task? #210

Closed adamhub closed 2 years ago

adamhub commented 2 years ago

I have a Twillio webhook that is ready to send a webhook POST call. How can I best do that?

I saw issue #131 and it seems that there is no implementation for Event Listener. Can I just do it in the code easy enough without breaking the engine?

essweine commented 2 years ago

The easiest way to do this is probably to use a script task.

By default Spiff uses a very basic python environment to execute scripts. You can extend the existing PythonScriptEngine or simply create an instance of the default one with any data or functions you might need to call pre-loaded in it. You can call you additions from a script, which will be executed when the task is reached.

There is a simple example here: https://github.com/sartography/spiff-example-cli. The BPMN that uses the custom engine is in this diagram: https://github.com/sartography/spiff-example-cli

There is some additional information here: https://spiffworkflow.readthedocs.io/en/latest/bpmn/advanced.html#custom-script-engines