Run Python Scripts in Playbooks

You can use Python scripts as automation steps in a playbook, for example, to manipulate events of interest.

Add a Python Script to Logichub

To add a Python script to LogicHub, open the Automations > Scripts page and click New Script.

The new script page includes a boilerplate script on the left and the details about the script on the right.

3356

The following actions are supported on this page.

To name the script, click the Edit icon for the default title in the header bar, enter the name without space to include underscores, and click the checkbox icon.

To show the Details panel, click Details. To hide the panel, click X in the upper right corner. By default, the details page will be shown.

To modify the script, click to edit the boilerplate code.

To test the script with data, click Test Data. A window opens to show boilerplate test data. Replace the boilerplate test data with your own data or use the boilerplate test data by removing the comment symbol (#) from the data lines in the boilerplate, and then clicking Save and Exit. The script runs with the test data. If successful, a checkbox is added to the Test Data button.

361

To configure the script and test it with data:

📘

Note

The Configure button will be enabled after you test the data and save it.

  • Click Configure.

  • Enter the number of rows to test, and choose one of the actions specified in the Python script.

  • Select one or more values, as prompted, based on the test data.

  • Click Submit and Test to save the changes and run a test or Submit and Exit to save the values but not run a test.

2242

When you run the test, the results are shown on the right and any console messages are presented below the code area.

1303

Use a Script in a Playbook

You can select an existing python script as the integration when adding a playbook step. See Create Playbooks with Easy Mode.

Export and Import Scripts

You can export and import scripts from the Scripts page. To export, click the More icon (...) for the script and select Download. Or select multiple scripts and click the Download button.

To import a script, click Import on the Script page. If a script with the same name already exists in the system, you can rename it to keep both or use the existing script in the system.

562

Create a Python Script within a Playbook

  1. In the Easy Mode playbook editor, start creating a new step by clicking + on the parent step.
  2. In the 'What do you want to automate?' field, enter ‘Python’. Select the Python Script automation and click Search & Add Automation.
  3. For the input table, the parent step is selected by default. To change the parent step, select from the dropdown list.
  4. For the script, select an existing script from the dropdown list or select Create New. For instructions on creating a new script, see ‘Add a Python script to Logichub’ in this topic.
  5. Choose the script action and specify column values as prompted.
898
  1. Select true for Explode Fields to display all the result details. To display only summary results, select false.
  2. Click Submit to add the script to the playbook.

Additional Notes

  • Changes that you make to the code for an existing script might affect other steps or playbooks that call that function, so be careful when making such changes. To prevent unintended impacts when you modify a script, LogicHub provides the opportunity to save the modified script under a different name.
  • If you change the entry function that is populated on the runScript operator form, any existing parameters are prefilled for the new function. Options are also included to select any additional parameters.

© Devo Technology Inc. All Rights Reserved.