Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

3. Modify its content in the window and click Save.

Sample

Note that by default Workflow Utility files provide you with the tips on how to create functions.

...

What’s next?

Once you have created a function, you can use it with the help of the Call function node in workflows.

An example is described on the Web service node and APIs page:

  • The Call function node is used for obtaining the authorization details.

  • It uses the wf.itsm.ticket.get_authorization_header function, which returns Session Auth Token.

To use your custom function in a workflow:

...

Creating a function

Here is a sample demonstrating a function that asks a user whether they are satisfied with the support and stores the reply in a keyword key.

Code Block
def ask_support_feedback(key=''):
    """ Ask user for his satisfaction with a support and store the response 
    into keyword key"""
    dialog = Bot.Bot().GetDialog()
    response = dialog.UserAsk("Tell us how you are satisfied with out JSM support?")
    if key:
        dialog.AddKeyword(key, response.text)
    return "Success"

You can copy this code and paste it into one of Workflow Utility files. Make sure to click Save and Apply.

...

Using the function in a workflow

1. Open your workflow in Content > Workflows and add the Call function node.

2. In the Function name field, specify the function. Our ask_support_feedback function is created in my1 file, so it is referred to as wf.my1.ask_support_feedback.

3. Save the result in a variable, so you can use it in other nodes later on. The variable is defined in the Keep result in variable field.

...

...

Testing a workflow

To test your workflow, go to chat and enter the #workflow <your-workflow-name> command.

...

Debug

To view the debug information, type the #debug on command in a chat. It turns on the debug mode, so you can view processing and messaging details right in the chat.

...