Skip to main content

Extension Automations Activity

Overview​

The Extension Automation (extension_automation) Activity in the Pia Package Editor screen is used to define extension points in a package. With the extension automation activity, you can link your custom automations to a Pia package so that the package performs additional tasks as per your requirement.

The extension points created by Extension Automation activity can be accessed in the package configuration screen. You can configure a single package to have one or more extension based on how many Extension Automation activities you have defined in your package.

The extension automation activity may be used in a scenarios where you need a package to perform actions that are specific to your business requirement. For example, sending an email to the HR after a new user has been created. Another example is automatically forwarding all the emails to the manager while setting up out of office for a staff member.

The Extension Automation activity can be located by searching for "Extension Automation" in the list of activities in the package editor: extension_automations_activity.png

Here is an example of a basica package that uses Extension Automation Activity:

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

- name: 'chat'
option_button: 'Extension Automation Test'
option_text: 'This is an extension test package'
option_category: 'Test Category'

steps:
- task: chat_interaction
inputs:
text: 'Start of the original Package'

- task: extension_automation
inputs:
description: 'Extension Point 1'
data: '{}'
data_schema: '{}'
extension_unique_id: 'point_1'

- task: chat_interaction
inputs:
text: 'End of original package'

In the above package, an extension point has been defined using the extension automation activity. Another package has been created as below that will be linked as an extension to the above package.

conditions: 
- name: 'client_filter'
optMode: 'OptOut'
category: 'Testing'

- name: 'extension_automation'

steps:
- task: chat_interaction
inputs:
text: 'This is the start of extension 1'

- task: chat_interaction
inputs:
text: 'This is the end of extension 1'

Once the extension automation is linked to original package, it will run within the original package in Pia chatbot:

example_2212.png

Activity Behaviour​

The primary purpose of the Extension Automation activity is to create extension points for a package that can be accessed through the package procedure screen. For each extension point, you can link one or multiple extension automations that will run within the original package.

When the extension automation activity is added to a package, it will check if there is an extension automation configured in the package configuration screen. If there is, the activity will use the same behavior as inline package execution property the Start Package (start_package) activity to start the package excution i.e. When a package with an extension automation runs, Pia will pause execution of the first package when the extension automation activity runs, start executing the second package, complete execution of the second package and resume execution of the first package.

The Extension Automation Activity can be used in all package executions (i.e. for packages that were initiated via Schedule or Ticketing System Event or chatbot).

Features of the Extension Automation Activity
The Extension Automation activity is primarily used to create extension points, but there are also some additional features which make a couple of common scenarios easier:

  1. When the extension package is started, it will have the same context as the parent package i.e. it will inherit the data provided in the parent package by the user

  2. By its very nature, extension automations would allow any activity to be executed and allow chat messages to be sent and received with further information collected from the user.

  3. If the extension automation fails, an output will displayed stating that β€œAn extension automation has failed to execute; Pia will continue with this action but cannot ensure that all desired actions for this package will be completed. Please contact your Pia support team for more information” and continue execution of the parent package.

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: description
Property Required: Yes
Property Description: This is the decsription of where this extension automation is placed in the package flow. decsription.png

Property Name: data
Property Required: Yes
Property Description: This is the data to be passed into the extension automation so that it can perform some actions from the information provided. data.png

Property Name: data_schema
Property Required: Yes
Property Description: Provide a JSON schema of the data so that the user understands what data they can expect to be passed via the input parameter. data_schema.png

Property Name: extension_unique_id
Property Required: Yes
Property Description: Enter an ID that is unique within this package and is used to determine the location of the external extension execution. extension_unique_ids.png

Output Properties​

The activity has no output property.

Examples​

Below is a working sample of a package that uses extension automations:

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

- name: 'chat'
option_button: 'Extension Automation Test 1'
option_text: 'Extension Automation Test'

steps:
- task: chat_interaction
inputs:
text: 'Start of the original package'

- task: chat_interaction
alias: 'tchat'
inputs:
text: 'Test Input Form'
form_name: 'variable_test_form'
#This form contains four text input fields to collect First Name, Last Name, Phone and Email

- task: inline_powershell
alias: 'form_converter'
inputs:
form_data: =tchat.form
script: |
#Write-Host $(ConvertTo-Json -Depth 5 $form_data);
return @{ formData = $(ConvertTo-Json -Depth 5 $form_data); }

- task: extension_automation
inputs:
description: 'Execute Point 1'
data: =form_converter.formData
data_schema: '{"firstName": "<First Name>", "lastName": "<Last Name>", "email": "<Email>", "phone": "<Phone Number>"}'
extension_unique_id: 'point_1'

- task: chat_interaction
inputs:
text: 'End of the original package'

Here, another package has been created that will be linked as an extension to the above package:

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

- name: 'extension_automation'

steps:
- task: chat_interaction
inputs:
text: 'This is start of Extension Point 1'

# Test context variable
- task: inline_powershell
inputs:
ticketid: $Ctx_Ticket_Id
script: |
Write-Host $ticketid

# Test context variable
- task: inline_powershell
inputs:
data: =extension_automation.parent_data
script: |
Write-Host Test
$UserInfo = $(ConvertFrom-Json $data)
Write-Host Hi ($UserInfo.firstName), there is a kind info for testing would send to your email address ($UserInfo.email).

- task: chat_interaction
inputs:
text: 'This is end of Extension Point 1'

You can link the extension package to the original package as an extension through the Package Configuration Screen. The configuration process has been defined further below in this article. Once the extension package has been linked, the package will run in the chatbot as below:

extension_example.png