Skip to main content

Celonis Product Documentation

Trigger Machine Learning Script
Introduction

Leveraging the results of the Machine Learning tool in Action Flows can be quite helpful. That's the reason we provide you with 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 on 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 which:

  1. Watch a Slack Channel for a trigger phrase

  2. 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

60361483.png
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.

60361484.png

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

60361486.png
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:entertext 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.

60361489.png
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 right permissions

60361485.png

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

60361487.png
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!

60361490.png

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}}"
}
60361488.png
Configure ML Script

Import the script in 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 make sure to code robustly and test the script thoroughly. If an error occurs, the backend does not give an indicator of what the error was.

1. Navigate to Machine Learning Tab

60361493.png

2. Open existing App or create a new one

60361491.png

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

60361492.png

4. Make sure both are uploaded successfully and displayed in the section on the left

60361499.png

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

60361513.png
60361487.png

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.

55707554.png
55706522.png
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