Trigger an Action Flow from ML Workbench
In order to use the results and insights of your Machine Learning Script automatically, we provide you with a receiving Action Flow that integrates the ML results into secondary actions. This template shows you the steps of a ML script snippet that pushes data to a receiving Action Flow and how the Action Flow can deal with this information. 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 snippet.
Sample Action Flow
The image below shows two working Action Flows which:
Use a Machine Learning script to send response data back to Action Flow
Receive and resends the answer from the ML script
Configure ML Script Snippet
Copy the following script snippet into a new or existing ML App.
import json import re import sys import requests ## you can choose any data to send to webhook, as long as it is in json format, for example json_transfer = {'email_to': email_to, 'info1': value_ABC, 'info2': value_BCD } data = json.dumps(json_transfer) webhook_url = '< paste your webhook url here >' byte_length = str(sys.getsizeof(data)) headers = {'Content-Type': "application/json", 'Content-Length': data} response = requests.post(webhook_url, data=data_df, headers=headers)
The ML script will run your pre-defined Python logic that you either trigger manually in the ML Workbench or by a different Action Flow (see here).
Response Script Snippet
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, 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. From your Celonis Platform team, click Data - Machine Learning.
2. Open an existing App or create a new one (click New App).
3. Import the script provided above
4. Make sure the script is uploaded successfully and displayed in the section on the left
1. Customize ML Script Response
Required:
url: paste here the URL of the Webhook of the module from the Action Flow below (do not delete the quotation marks ' ')
Optional:
message: you can adjust the message of the response
title: you can adjust the title of the response
Additional data fields
Add new fields (e.g. results of your ML Script) by copying the structure of the fields before and adding it additionally to the JSON called "fields" in the same way title and value are defined
Configuring Action Flow
Below you will find the step-by-step guide for configuring each module of the above Action Flow.
1. Receive ML Script Response
In this module we define a Webhook where we receive data from the ML Script.
Configuration:
Action Flows Module: Webhooks
Action: Custom webhook
Copy the address to clipboard and proceed in the next step where you add the URL to the ML Script
2. Re-determine Data Structure of the Webhook
1. Click on the blue button called 'Re- determine data structure'
2. As soon as you see it is trying to redetermine, send the triggering phrase in the Slack channel and run the triggering Flow. When the HTTP module shows the 200 code as a response it can take a few seconds
Note
Please run the script manually, the response will connect to the webhook and re-determine the data structure.
3. The webhook determined the data structure when showing you the green success statement. Click 'Ok' to save the structure and be able to continue.
3. Send Response in Slack
In this module we'll send the received data to Slack to controle if everything worked out.
Configuration:
Action Flows Module: Slack
Action: Create a Message
Enter a channel ID or name: Select from the list
Channel type: Private channel
Private channel: select the channel where you want to get the results of the ML script
Text:
title: {{fields[].title}} value: {{fields[].value}}
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 Alternatives
You could 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