Skip to main content

Stop Activity

Overview​

The Stop Activity or Stop Execution Activity is one of the default activities in Pia that allows you to divide your package into multiple workflows. With this activity, you can define conditions where a package needs to stop executing further actions.

When the package with stop activity is being executed in Pia Chatbot, user will not see any actions being performed by Pia after the stop condition has been met. Pia will instead complete package execution for the user and present them with "See what you can ask me here" prompt.

The stop activity is a helpful feature for you to elegantly structure your automation in cases where you need execution before the package reaches to the final task. This is a good alternative to the skip feature in some scenarios.

One example scenario where this activity may be used is while running New User Package, Pia checks whether the required license is available for the new user being created or not. If the license is available, user will be able to continue with the package. If not, Pia will complete package execution informing the user that it cannot continue if the required license is not available.

Another example can be when the Package has schedule for later option. The package flow might be different when the package is running on schedule vs when the package is not running on schedule. In this example, you may wish to stop execution after you have scheduled the package.

The Stop activity can be located by searching for "Stop" in the list of activities in the package editor: stop_activity.png

Here is a working sample of the activity in a basic package:

# Orchestrator package
conditions:
- name: 'client_filter'
optMode: 'OptOut'
category: 'Testing'

- name: 'chat'
option_button: 'Test'
option_text: 'This is a Test Package'
option_category: 'Test'

steps:
- task: chat_interaction
inputs:
text: 'Select Yes to stop the package'
form_name: 'yes_no_form'
form_display_mode: 'Embed'

- task: stop
inputs:
condition: =chat_interaction.form.Option

- task: chat_interaction
inputs:
text: 'Hello'

In the above example, user is presented with Yes or No options in chatbot. Selecting Yes will stop the package from executing any further actions whereas selecting No will continue with the rest of the package execution.

The values of 'Yes' or 'No' have been defined in the form editor as below: formeditor_yes_no.png

Activity Behaviour​

The Stop activity is mainly used to stop executing further actions that have been defined in the package after certain conditions have been met. The stop condition can be defined using Form variables and inline powershell commands.

The Stop Activity can be used in all package executions (i.e. packages that are initiated via Schedule or Ticketing System Event or the Chatbot).

More examples on how the activity can be used in multiple scenarios are listed at the bottom of this article:

Input Properties​

The activity contains a single input property that can be used to modify its behaviour:

Property Name: condition
Default Value: None
Property Options: 'true' or 'false'
Property Required: Yes
Property Description: If the condition is 'true', Pia will stop package execution. Anything else will continue package execution. stop_activity_condition.png

Output Properties​

The Stop Activity does not have an Output property.

Examples​

Form Input in Stop Activity
Here, the package mentioned in the first example above has been modified so that the package continues if the user selects 'Yes' and stops if the user selects 'No'

# Orchestrator package
conditions:
- name: 'client_filter'
optMode: 'OptOut'
category: 'Testing'

- name: 'chat'
option_button: 'Test'
option_text: 'This is a Test Package'
option_category: 'Test Category'

steps:
- task: chat_interaction
inputs:
text: 'Hello'
form_name: 'yes_no_form'
form_display_mode: 'Embed'

# Additional logic
- task: inline_powershell
inputs:
user_choice: =chat_interaction.form.Option
script: |
$stop = $false
if($user_choice -eq 'false')
{
$stop = $true
}
return @{StopExecution = $stop}

- task: stop
inputs:
condition: =inline_powershell.StopExecution

- task: chat_interaction
inputs:
text: 'Hello again'

Stop Activity in a Scheduled Package

# Orchestrator package
conditions:
- name: 'client_filter'
optMode: 'OptOut'
category: 'Testing'

- name: 'chat'
option_button: 'Schedule Test'
option_text: 'This is a schedule test package'
option_category: 'Test Category'

steps:

- task: chat_interaction
inputs:
text: 'Hello'
form_name: 'schedule_for_later'
form_display_mode: 'Embed'

#This is added to convert the local Date and Time to UTC format
- task: inline_powershell
inputs:
date: =chat_interaction.form.schedule_date
script: |
[DateTime]$timeToRun = [System.DateTime]::Parse($date, [cultureinfo]::GetCultureInfo('UTC'))
#return @{ timeToRun = $timeToRun.ToString('dd/MM/yyyy hh:mm tt') }
Write-Host $($timeToRun.ToString('yyyy-MM-ddTHH:mm:ss.000Z'))
return @{
timeToRun = $timeToRun.ToString('MM/dd/yyyy hh:mm tt');
time_string = "$($timeToRun.ToString('yyyy-MM-ddTHH:mm:ss.000Z'))";
}

- task: schedule_for_later
inputs:
schedule_date: =inline_powershell.timeToRun

- task: chat_interaction
skip: =schedule_for_later.running_schedule
inputs:
text: 'Hello again!'

- task: stop
inputs:
condition: =schedule_for_later.not_running_schedule

- task: chat_interaction
inputs:
text: 'Hello later!'