Discussion

467
Views
Piotr Kulig Member since 2014 8 posts
PEGA
Posted: 1 year ago
Last activity: 1 year 9 months ago

How to create custom conversational channel action

Action is a primary component of command processing by MCP engine. List of actions is dynamically generated based on action class inheritance.

Action could be a very simple logic without any parameters or could be very complex.

Action is invoked with pyInteractionCase page context - developer is able to use his own properties from Work-Channel-Interaction-* class. Proper pyOutboundMessage structure is an expected output from each action and such outbound will be passed to application view’s endpoint.

There are two types of actions: common actions and channel-specific actions.

Common actions are stored in Embed-Channel-Action-Commons- class instances. By default, there are some common actions implemented:

  • Cancel - cancel current work,
  • Create case - create new case type,
  • Menu - display available response options in menu,
  • Restart - start current case from the beginning,
  • Text - simple text response.
  • Custom - data transform rule based response

Channel-specific actions need to be created in Embed-Channel-Action-<channel_name>-. For example, in FacebookChannel ruleset there is a channel-specific link account action, which gives the possibility to link Pega 7 operator's account.

Step by step guide

1. Create new abstract class rule:

    • for common action: derived from Embed-Channel-Action-Commons,
    • for channel-specific action: derived from Embed-Channel-Action-<channel_name>.

2. Save as pyCaption.ActionLabel (Embed-Channel-Action-) field value to your Embed-Channel-Action-*-* class and set proper action's label.

3. Save as pyPerformAction activity to your Embed-Channel-Action-*-* class and implement some logic:

    • Primary page for this activity is a page taken from configuration, so it contains all properties set within particular configuration of channel which currently is processed,
    • pyInteractionCase page is available to read the input and set the output.

Optional steps:

  1. Save as pyActionProperties section to create UI for action's specific properties:
    • At this place you are able to extend Embed-Channel-Action-*-* model and create action's specific configuration properties,
    • Default values could be placed in pyDefault DT - remember to call parent-class DT.
  2. Save as pyValidateAction activity when you need to add validation constraints on action configuration properties:
    • Add any number of error messages to action configuration properties. When at least one error message exists on configuration page it cannot be persisted.
  3. Save as pyActionSummary section to override default presentation of action in grid. By default pyCaption.ActionLabel field value is presented.
  4. Save as pyOnLoad if you want to add some logic which will be invoked when action is added/modified within configuration.
  • Field Value for property pyCaption with id ActionLabel which contains action's label:

  • Section pyActionProperties to customize action configuration UI:

  • Activity pyPerformAction to implement action logic:

ProcessingPage is only a parameter name, its value is always set to pyInteractionCase (Work-Channel-Interaction).

  • Activity pyOnLoad to implement logic when action is added to configuration.

Action could generate multiple outbound messages and depending on what channel it is, it will be handled in a different way (i.e. FB sends multiple requests to Messenger and multiple messages are displayed to end user).

There is a single page pyMetadata, which includes the information used for choosing the correct rendering.

Pega Intelligent Virtual Assistant Conversational Channels Developer Knowledge Share
Share this page LinkedIn