Trigger Machine Learning Script
Introduction
Leveraging the results of the Machine Learning tool in Action Flows can be pretty helpful. That's why we provide that automation solution that shows you how to trigger an ML script from a Slack message in a channel of your choice, including a Script snippet for the connection to the Action Flow. If you want to know more about how to build useful Machine Learning Scripts, have a look here.
Follow the step-by-step guide below to implement this solution for your Celonis Action Flows use case.
Sample Action Flow
The image below shows two working Action Flows:
Watch a Slack Channel for a trigger phrase.
Trigger a Machine Learning script
Use Case Enhancements
If you want to pass parameters to the ML script, please check out this template:Forward Parameters to Machine Learning Script
If you want to return data to an Action Flow, please check out this template: Trigger an Action Flow from ML Workbench.
![]() |
Configuring Action Flow
Below you will find the step-by-step guide for configuring each module of the above Action Flow.
1. Wait for Trigger phrase
To be able to trigger the ML script and Action Flows via Slack we use this module to keep track of all the messages in one specific private channel.
![]() |
Configuration:
Action Flows Module: Slack
Action: Watch Private Channel Messages
Connection: connect to your Slack account
Channel: choose the channel from where you want to trigger the ML Script
![]() |
2. Filter for Trigger phrase
We filter on the defined Trigger phrase to not trigger the ML script when sending random messages in the Channel.
Condition: {{Text}} from previous Slack module
Filter:Equal to (case insensitive) - Text operators
String variable:Enter text that is only used to trigger this AF (here: %%forecast)
String variable
In this context, %% or similar structures help to differentiate from other slack messages.
![]() |
3. 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 correct 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.: GjV6ODBvghgv6r76r0YzkyLTkxZwjbflqjwhebfljwhebfqjhebfwlV5TEVCcjMzAHBFK0F8TXdGBTlqBWFlsVPNk (create Application Key → Navigate to Permissions → Select Machine Learning Permissions → Enable Use all Machine Learning Apps for your AppKey)
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
![]() |
4. Trigger ML Script
This module sends a Post Request to our ML API and triggers a defined 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}}" }
![]() |
Configure ML Script
Import the script into a new or existing ML App. The ML script will run your pre-defined Python logic.
Triggering & Response Script
Creating your own Logic
The script includes further documentation on how to ensure successful execution. Please make sure to follow these steps as well.
If you apply your own logic, please code robustly and test the script thoroughly. If an error occurs, the backend does not indicate 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 two Scripts provided above
![]() |
4. Make sure both are 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
![]() |
![]() |
Trigger a Response to be handled by Action Flow
If you want to return data to an Action Flow, please check out this template: Trigger an Action Flow from ML Workbench
Download Action Flows Blueprint
You can download the blueprints of the Action Flows defined in this Help Page.
These blueprints can be imported into your Celonis EMS Team so that you can quickly make the required changes without needing to build the Action Flows from scratch.
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