Schedule For Later Activity
Overviewβ
The Schedule for Later (schedule_for_later) Activity is a feature that allows you schedule any automation in Pia. With the Schedule for Later Activity, you can choose a specific date and time when Pia will automatically perform the action for you. Once the action is performed on scheduled date and time, you are notified via an email on the success or failure of the action.
This feature is highly beneficial for Service Desk Engineers because they no longer need to set a reminder to process a ticket at a specific time and date, as Pia will take care of this for them. One of the common scenarios for this activity to be used is when a client has a staff member leaving at the end the of the week and they have put through a request via service desk at the start of the week. Service Desk Engineers can then run the package when the request comes through and schedule the package to run on the Scheduled Date and Time.
The Schedule for Later activity is available in the Package Editor Screen under Activities Section as displayed below:
The package below is a working sample of the schedule for later activity where the Date and Time input received from the user is being converted to UTC time format before the value gets passed into the activity:
# 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
inputs:
text: 'Hello later!'
Activity Behaviourβ
The primary behaviour of the Schedule for Later activity is to schedule an automation to run on specified date and time. The schedule Date and Time can either be specified in the Package by the engineer themselves or the user can be provided with a form field to select date and time values in the chatbot which will then be passed as an input to this activity.
The scheduled package execution will be a copy of the original package execution. When the scheduled package execution starts, it will start at the point of the scheduled for later activity. This means that the scheduled package execution is a continuation (or fork) of the original package execution. The scheduled package execution will have access to all of the activity outputs from activities which have executed prior to the scheduled for later activity from the original package execution.
When your package is scheduled, a new ticket will also be created in your ticketing system by Pia on the scheduled date and time to run the scheduled package. This can be viewed and cancelled in the Scheduled Packages Screen.
For more information on Scheduled Packages screen, refer to Scheduled Packages Screen.
The Schedule for Later Activity can only be used in package executions which have been initiated via the Pia Chatbot (i.e., this activity will not work in cases where the package was initiated via Ticketing System Event).
Note: The Schedule for Later Activity is not to be confused with Schedule Condition. The Schedule Condition allows you to create recurring schedules which will run outside the chatbot whereas the Schedule for Later Activity is ONLY used inside packages that are initiated via Pia Chatbot enabling the users to control the scheduling behaviour.
Features of the Schedule for Later Activity Apart from Scheduling a package to run on specific date and time, the Schedule for Later activity has the following features to cover some use cases:
- At the time when the schedule is executed, a new ticket is created in the ticketing system for the scheduled package execution 1.1 You can set Pia to bundle the child ticket to the original ticket by changing input properties which is defined further below in this article. 1.2 The child ticket will inherit the same properties as the parent ticket i.e. the child ticket will have the same ticket board, ticket classification, client name and contact details 1.3 The child ticket will be automatically closed when Pia performs the scheduled action.
- After the scheduled package execution, Pia will send an email to the engineer who scheduled the package informing if the scheduled package has completed successfully or failed or didn't run at all 2.1 For this feature to work, partner must have a connected service for emailing configured correctly.
- The schedule for later activity takes a UTC date/time input. Since Pia allows users to input Date/Time in their local time, you will need to add an inline powershell to convert the Date/Time into UTC format for this activity.
An example of each feature above is available at the bottom of this article.
Input Propertiesβ
Use properties to modify the behaviour of the activity.
Property Name: schedule_date
Property Required: Yes
Property Description: Date (UTC) to schedule continuation of this package for later. Date Format: MM/dd/yyyy hh:mm AM/PM
Property Name: ticket_option_bundle
Property Required: Yes
Property Options: 'true' or 'false'
Default Value: 'true'
Property Description: If set to true, the scheduled ticket which is created will be bundled as a child ticket of the parent in the Ticketing System.
Note: Not all ticketing systems support bundling tickets so this behaviour may be affected by ticketing system limitations.
Output Propertiesβ
Property Name: running_schedule
Property Description: If this is true, the current execution of this package is running on scheduled date and time
Property Name: not_running_schedule
Property Description: If this is true, the current execution of this package is not running on schedule and has been initiated by user in Pia chatbot
Examplesβ
Schedule for Later with 'Skip' and 'Stop' conditions
Here is an example of Schedule for Later activity with 'skip' and 'stop' conditions where Pia performs distinct set of actions depending on whether it is running on a schedule or not.
# 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!'
Ticket Bundling
The package above automatically bundles the child ticket to parent when the child ticket is created. You can modify this behaviour with the following code change:
- task: schedule_for_later
inputs:
schedule_date: =inline_powershell.timeToRun
ticket_option_bundle: 'false'
This will create a separate (child) ticket to execute the scheduled task but will not link the child to the original ticket.
Email Format
Once the scheduled package runs on the scheduled Date and Time, you will get the following email:
For successful package run: