...
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 returnsSession 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. For example, if you have created a new function called check_status
Our ask_support_feedback
function is created in my1
file, you must refer to it in the Call function node so it is referred to as wf.my1.checkask_support_status
.
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.
...
feedback
.
...
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.
...