Skip to main content

Creating an external treatment to share action details in a file or database

Outbound emails are sent either directly by Pega Customer Decision Hub or by a third-party email service provider. Use external email treatments to send the necessary customer data to email service providers in the form of a file or a database table. When you use external email treatments, Pega Customer Decision Hub™ does not store email content. In this case, Customer Decision Hub does not have direct integration with an SMTP server, but a third-party email service provider handles the service. These providers rely on file or database integrations and have a defined format of the data that they expect.

In such cases, create the file or database integrations in Customer Decision Hub with all the information you want to share with the third-party email service provider. Then, associate the file or database template with an external treatment. With external email treatments, Customer Decision Hub generates the data that the third-party email service provider requires to send the emails.

Business scenario

U+ Bank, a retail bank, sends credit card offers to eligible customers by email. However, to comply with the security and spamming regulations, the bank wants to use a third-party email delivery service instead of using the in-house email server. As a result, the offer details need to be written to a file that can be shared with a third-party email service provider and mapped to an external email treatment.

Creating a file template

Pega Customer Decision Hub™ enables you to write action details to a file that can be sent to a third-party vendor or application for distribution.

To implement this business requirement, you need to configure a file template. The file template landing page can be accessed from the navigation pane, Content > Treatments.

Treatments option

You can create a new file template from this page.

Create a new File template

Provide a short description for the new file template, and the identifier is automatically populated when you tab out.

Create file output template

Creating a repository

When configuring a file template, provide details on an existing repository or create a new repository where the file needs to be stored.

In this case, you create a new repository.

repository name of the file output template

Provide a short description and a name for the repository to create one.

Create and open action of the repository

Select a Repository Type where you want to store the file.

Repository type

Pega Customer Decision Hub supports various cloud-based destinations as repository types, such as JFrog Artifactory, Amazon S3, and Microsoft Azure, in addition to the local file system.

the list of repository types

When you select the File system repository type, in the Resource Path, provide a directory path in the file system to where you want to store the file.

directory path of the repository

Configuring a file template

In the Edit file output template page, continue configuring the file template.

Select the repository and provide a path where the file needs to be stored. The location is a sub-directory under the directory specified in the file system repository. The format for the file path and name is folder/filename.

For example, if the repository path is /opt/tomcat/fileoutput and the file path is actions/output/mailing-list.csv, then the file will be created under /opt/tomcat/fileoutput/actions/output.

Example repository and directory

Finalizing the output template

Finalization is the technical process of writing data from an internal staging area to the final file. Finalized data is ready to be consumed by a different system. The system can trigger finalization manually or automatically based on a schedule. Select the Finalize template after Action Initiation option to trigger the finalization after each run.

By finalizing a template at the end of each run, you ensure that all data in the file is the result of a single run. That is, the final output includes all data related to the run that triggered the finalization. If you want the data from multiple outbound runs to be written to the same file, leave this option unselected. When you leave this option unselected, you must configure a separate finalization schedule in the Finalize tab or finalize the file manually in the Treatments > File landing page.

If you choose to finalize at the end of each run, select Include run ID in file name to include the run ID for easier identification of the files generated in each run.

finalize output template

In the Fields tab, you can configure the information elements that you want to output.

You can configure the customer and action details that you want to share with the third-party email service provider. In the Name field, you enter a name for the field. In the Content field, you select the corresponding property. Use the .Customer. construct to access customer properties and .OfferData. construct to access action properties. As shown in the example, adding the treatment name as an information element helps to map the actions with the corresponding external treatments.

configuration of fields in an output template

On the Finalize tab, you can configure further finalization options. 

The Finalize tab of the output template

The Advanced section can be used for additional processing during the finalization process. For example, you can use it to initiate the file transfer to a particular location.

Using the file template in an action flow

You need to configure one of the Send* shapes, that is, Send Email, Send SMS, Send Generic or Send Multi shapes, in the action flow to reference the file template so that the action details are written to the output file during an outbound run.

The workflow of the send email action

To write action details to a file template, select the Use associated Treatment option. This option ensures that the treatment is associated with the action.

associate a treatment to the send email action

Creating an external email treatment

Once you integrate the customer and action details into the file template, create an external email treatment. With external email treatments, Customer Decision Hub generates the data that the third-party email service provider requires to send the emails.

For this scenario, you create a new external email treatment, Standard card email. Add a short description and an appropriate Keycode for the email treatment. Then, select the file template to write the action details. You use the file template that you created earlier, which the system uses to write the action details that you want to share with the third-party email service provider. Next, add an email subject. You can specify a specific email subject that you want the third-party email service provider to use while sending the outbound emails. You add the .OfferData.pyEmailSubject property to the file or database template to include the subject as part of the details of the shared actions.

Details and Content sections of an external email treatment

Running an outbound schedule

To write the action details to a file, run an outbound schedule. The file with action details is stored in the specified repository.

The action details file

The file contains the fields as configured in the file template.

Writing action details to a database

Like a file template, you can map an external email treatment to a database template and make the outbound run write details to the database table. The process of creating a database template is similar to creating a file template. Instead of the repository, file path, and file name configurations, you must provide the Database name and Table name.

Definition tab of the email treatment

Bypassing action flow processing

In the always-on outbound scenario, you can bypass the action flow processing and write action details to a database table directly with a database template. Use this feature when you do not need to perform multiple steps in the life cycle of an action (such as send an action message, wait for a response, or take appropriate action upon response).

To use this feature, go to Next-Best-Action Designer, Channel. In the Primary schedule section, click the Gear icon next to Recurrence to access the outbound schedule configuration. Enable the Write results using a database template option to add a database template.

Note: Here, you can configure only database templates that have the Writing option set to Append to existing data.
The Configure outbound schedule section

Capturing responses

When you use an internal email treatment and send the email content directly to the SMTP server, Customer Decision Hub captures the customer response (clicks and impressions). Because Customer Decision Hub does not have direct integration with the SMTP server in the case of external email treatments, the third-party email service provider receives the responses to all emails. In this case, an integration is necessary to send the captured responses to Customer Decision Hub to ensure that the system updates the interaction history and trains the AI models with the received responses. External systems can send the responses using a REST integration, calling the Capture Response API, or creating a data flow to process the responses from a file, stream, or database table.


This Topic is available in the following Modules:

If you are having problems with your training, please review the Pega Academy Support FAQs.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice