Forward Parameters to Machine Learning Script
In order to use the full power of Machine Learning Scripts in combination with Action Flows, the forwarding of parameters is essential. That's the reason we provide you with an Action Flow Snippet that integrates desired parameter of the Action Flow into the ML tool automatically.
Follow the step-by-step guide below to implement this solution for your Celonis Action Flows snippet.
Sample Action Flow
The image below shows an Action Flow snippet which:
Creates JSON data structure to forward parameters
Trigger ML script with parameters
Configuring Action Flow
Below you will find the step-by-step guide for configuring each module of the above Action Flow.
0. Trigger the Action Flow
Note
You can integrate any trigger sequence, e.g. Slack, Email, Celonis, etc.
An example for a Slack trigger sequence can be found at Trigger Machine Learning Script.
1. Customize Variables
This is the most important module in this Action Flow where we have to adjust all the data specific to your team and account like the team domain or an Application Key with the right permissions
Configuration:
Action Flows Module: Tools
Action: Set multiple variables
teamDomain: enter your teamdomain, e.g. demo-action-flows
env: enter your cluster, e.g. try, eu-1...
AppKey: e.g.:
GjV6ODBvghgv6r76r0YzkyLTkxZwjbflqjwhebfljwhebfqjhebfwlV5TEVCcjMzAHBFK0F8TXdGBTlqBWFlsVPN
notebookId: we will add this one at a later point in this Template when creating a ML App / adding Scripts to an existing ML App
executionFileName: the name of the ML Script to be triggered, e.g. trigger_MLScript.ipynb
2. Pass Parameters as JSON
This module creates a JSON that is sent as a variable in the HTML request body to be used in our ML script.
Configuration:
Action Flows Module: JSON
Action: Create JSON
Parameters, e.g.:
JSON file for Generator
{ "parameter1": "test1", "parameter2": "test2", "parameter3": "test3" }
Possible Data Types
You can pass any parameters of any type that can be handled by standard python or libraries, e.g. HTML, JSON, str, int, csv-files, txt-files etc.
3. Trigger ML Script
This module sends a POST Request to our ML API and triggers the previously defined ML script.
You do not have to change anything in this module!
Configuration:
Action Flows Module: HTTP
Action: Make a Request
URL: https://{{teamDomain}}.{{env}}.celonis.cloud/machine-learning/api/executions
Method: POST
Headers:
Name: Authorization
Value: AppKey {{AppKey}}
Body type: Raw
Content type: JSON (application/json)
Request content:
{ "notebookId": "{{notebookId}}", "executionFileName":"{{executionFileName}}", "params": {{json}} }
ML Script: Adding a ML Script to Trigger
Import the script in a new or existing ML App. The ML script will run your pre-defined Python logic and can make use of the parameters that you have forwarded.
Creating your own Logic
The script includes further documentation on how to ensure the successful execution. Please make sure to follow these steps as well.
If you apply your own logic and parameters, please make sure to code robustly and test the script thoroughly. If an error occurs, the backend does not give an indicator what the error was.
1. Navigate to Machine Learning Tab
2. Open existing App or create a new one
Delay
When creating a new ML App it can take a while (minutes to one hour) until you can open it.
3. Import the Script provided above
4. Make sure it is uploaded successfully and displayed in the section on the left
5. Copy the notebookId to the clipboard and add it to the variables as value for the notebookId in the module 'Customize Variables' in the Triggering Action Flow
Mandatory Step for Parameters
When developing your Python code, you can define default values for the parameters to run the script by itself and test your logic.
IMPORTANT Tag the cell of your Notebook with the Tag "parameters" where you set your default values with the same data type that you will pass from the Action Flow. While developing and running the code from Jupyter, these values will be used. When you are calling the Notebook from the Action Flow, the default values will be overwritten by the ones passed by the Action Flow.
Download Action Flows Blueprint
Downloading Action Flow blueprints
To download blueprints for Action Flows, go to Marketplace. In the Marketplace page for your Action Flow, click the Download button to get the blueprint.
Blueprints can be imported into your Celonis Platform Team so that you can quickly make the required changes without needing to build the Action Flow from scratch.
Potential Enhancements
You could integrate other apps into the Action Flow Snippet to forward parameters with data from Celonis, Google Sheets, SAP etc.
Potential Alternatives
You could replace the triggering Slack module with a Scheduling to just run the ML Script frequently.
You could also replace the Slack module at the end with a messaging module of your choice e.g. Email or Microsoft Teams.
Possible Use Cases
Run complex Python scripts in Action Flows and use the results for different use cases
Integrate ML capabilities in your Action Flows