Build a hello world bot with a Python function

Build a bot that calls a Python function to say hello world.

Prerequisites

To run Python script from Automation 360, you must already have the latest version of Python 3.x installed on your device.

Here is a Python script with one simple function. This script is used in this task.


# Function definition is here
def printme( str ):
   print(str)
   return str

Procedure

  1. Create a new bot:
    1. On the left panel, click Automation.
    2. Click Create new > Bot.
    3. In the Create Task Bot window, enter the bot name.
    4. Accept the default folder location: \Bots\
      To change the default bot storage location, click Choose and follow the prompts.
    5. Click Create and edit.
  2. Create a variable.
    1. Click Variables.
      The Variables accordion menu is located below the Actions menu.
    2. Click the Create variable icon.
    3. Enter sArguement in the name field.
      Note: It is recommended to prefix the variable name with a lowercase character to indicate the variable data type. See Variable naming.
    4. Type Hello world! in the Default value field.
    5. Click Create.
  3. Provide the script with a Python Script > Open action.
    1. Double-click or drag the Python Script > Open.
    2. Select the Manual input option.
    3. Copy and paste the following text into the Enter script here field.
      def printme( str ):
         print(str)
         return str
  4. Use a Python Script > Execute function action to tell the bot to run the script.
    1. Double-click or drag Python Script > Execute function.
    2. Type printme in the Enter name of function to be executed field.
    3. Select the sArgument variable from the Arguments to the function drop-down list.
    4. Create the variable sPythonHello for the Assign the output to variable field.
  5. Insert a Message box action to hold the Python function output.
    1. Double-click or drag the Message box > Message box action.
    2. In the Enter the message to display field, select and insert the variable sPythonHello.
    3. Select the Close message box after check box. Leave the default of 5 seconds in the field.
  6. Close the script execution session with a Python Script > Close action.
    1. Double-click or drag Python Script > Close.
    2. Click Save.
  7. Click the Run icon.
    The bot generates a pop-up Message box with the text Hello world!. After five seconds, the Message box disappears.

Next steps

After you have successfully run your bot, progress to Example of using Python script to join a list.