Skip to main content

SDK output types

Zuora

SDK output types

In your SDK feature, you can use an output type to define the outcome that is displayed on your site. Once created in the Developer Interface, a related Outcome decision node is available from the Outcomes segment title in the decision bar above the rules canvas.

Note: Each SDK feature can use only one output type.

You can create the following output types:

  • Component

A Component output type uses HTML to define the outcome that is displayed on your site.

You can add multiple Component output types in the Developer Interface.

  • Enum

An Enum output type uses a constant value to define the outcome that is displayed on your site.

You can add multiple Enum output types in the Developer Interface.

  • String

A String output type uses a string that is displayed on your site.

You can add a single String output type in the Developer Interface.

When you add the String Output decision node to your rules canvas, the Output String dialog box displays, as illustrated below:

Output_String.jpg

To define the string to display complete the following steps:

You can use the String decision node multiple times in your rule. Each time you add it to the rules canvas, you can define a different string as described above.

  1. Enter the string as you want it to display in the Output text box
  2. Select the Save button to save the string and return to the rules canvas. Selecting the Cancel button closes the Output String dialog box and returns you to the rules canvas; the String Output decision node is not included on the rules canvas
  • Number

A Number output type uses a number that is displayed on your site.

You can add a single Number output type in the Developer Interface.

When you add the Number Output decision node to your rules canvas, the Output Number dialog box displays, as illustrated below:

Output_Number.jpg

To define the number to display complete the following steps:

You can use the Number Output decision node multiple times in your rule. Each time you add it to the rules canvas, you can define a different number as described above.

  1. Enter the number as you want it to display in the Output text box
  2. Select the Save button to save the number and return to the rules canvas. Selecting the Cancel button closes the Output Number dialog box and returns you to the rules canvas; the Number Output decision node is not included on the rules canvas
  • JSON

A JSON output is defined by a JSON schema. It could contain different types of data, including string, number, enum, and component.

Technical users can create and add a JSON schema in the Developer Interface. Non-technical users can then create JSON outputs using a form that is dynamically generated from the JSON schema.

The JSON output options will be validated to ensure they are valid JSON and that they conform to the schema if specified. 

Below is an example JSON Schema and the visual form generated for editing JSON output options:

Example JSON Schema

Visual form for editing JSON outputs

 {
    "type": "object",
    "properties": {
        "showRegForm": {
            "type": "boolean",
            "title": "If a registration form is required"
        },
        "recommendedBookIds": {
            "type": "array",
            "format": "table",
            "title": "Recommended books",
            "uniqueItems": true,
            "items": {
                "$ref": "#/$defs/Book"
              }
        },
        "recommendedTitle": {
            "title": "The title of the recommended books section",
            "type": "string"
        },
        "recommendedSubTitle": {
            "title": "The subtitle of the recommended books section",
            "type": "string"
        },
        "secondaryBookIds": {
            "type": "array",
            "format": "table",
            "title": "Secondary books",
            "uniqueItems": true,
            "items": {
                "$ref": "#/$defs/Book"
              }
        },
        "secondaryTitle": {
            "title": "The title of the second books section",
            "type": "string"
        },
        "secondarySubTitle": {
            "title": "The subtitle of the second books section",
            "type": "string"
        },
        "primaryColor": {
            "type": "string",
            "format": "color",
            "title": "The primary design color",
            "default": "#ffa500"
          }
    },
    "required": [
        "showRegForm",
        "recommendedBookIds",
        "recommendedTitle",
        "recommendedSubTitle",
        "secondaryBookIds",
        "secondaryTitle",
        "secondarySubTitle",
        "primaryColor"
    ],
    "$defs": {
        "Book":{
            "description": "Book",
            "enum": [
              "alice-in-wonderland",
              "romeo-and-juilet",
              "pride-and-prejudice",
              "code-of-harambe",
              "beyond-good-and-evil",
              "the-prince"  
            ],
            "type": "string"
          }
    }
}

Screen Shot 2023-08-11 at 16.22.26.pngScreen Shot 2023-08-11 at 16.22.38.png

In addition to using the visual editor to create JSON outputs, you can also use the raw-text editor to do so.

Note: You can create JSON output options without adding a schema in advance. In this case, the JSON output editor will only validate if the input is a valid JSON. 

You can use variables in the JSON output option to store user-specific data in the following format: blaize.user.<ua-slug> (with double curly brackets). For example, blaize.user.first-name (with double curly brackets).

After a JSON output option is saved, you can edit it by double-clicking it in the rules canvas.

When saving or publishing a feature version, validation is present to check that all the paths in the canvas lead to an output, it is not possible to save a rule with some of the decision paths leading to nothing.

Note the following limitations when using the JSON output type:

  • Some newer JSON Schema features may not be supported by the Visual editor. If this is the case, the form won’t be shown.
  • We only check if the JSON schema is a valid JSON, but not check if it is a schema that makes sense (e.g. it contains invalid references or unknown types). You should ensure the schema doesn't have such issues.

 

  • Transformation

The Transformation output type allows you to use Zephr's highly customisable feature outcomes in your SDK rules.

After selecting Transformation as the output type, you can create outcomes with customised components, such as a payment or subscription change form, custom component block, or a template form that is defined in the Component Library. For detailed instructions on how to create outcomes and forms, see Feature Outcomes.

When an SDK feature rule is triggered, the following information about the returned components will be available in the response body: 

Components can be accessed through the returned contentPath.

Below is an example of the returned transformations data:

          \"transformations\":[
            {
              \"transformType\":\"CUSTOM_COMPONENT\",
              \"resourceId\":\"7fb6c2d1-a894-4450-a791-34e6eab1ea13\",
              \"contentPath\":\"/zephr/public/ui-components/v1/ui-components/7fb6c2d1-a894-4450-a791-34e6eab1ea13\"
            },{
              \"transformType\":\"FORM\",
              \"resourceId\":\"M-2EZg3K\",
              \"contentPath\":\"/zephr/public/ui-components/v1/ui-components/M-2EZg3K\"
            },{
              \"transformType\":\"FORM\",
              \"resourceId\":\"F-lEWwDb\",
              \"contentPath\":\"/zephr/public/ui-components/v1/ui-components/F-lEWwDb\"
            }]

If you turn on the Content Enabled toggle, the following data will be returned in the response body:

            \"transformations\":[
              {
                \"transformType\":\"ENABLE_CONTENT\",
                \"resourceId\":null,
                \"contentPath\":null
              }
            ]

Output Type Comparison

The following table provides a summary of the application and limitations of each output type:

  Component Enum String Number JSON Transformation
Pros
  • Add custom HTML
  • Simplify reuse of code components
  • Use less processing time
  • Consistent responses
  • Ease of debugging
  • Avoid hardcoding of messages
  • Simple to define and update
  • Simple to define and update
  • One JSON output could contain a comprehensive data set, which can be used to build a more powerful page.
  • Technical and non-technical users can collaborate on creating the JSON schema and outputs. N
  • on-technical users will enjoy greater creative freedom in achieving desired outcomes, reducing their dependence on the technical team.
  • Allows for using out-of-box forms in SDK rules.
Cons
  • Knowledge of HTML required
  • If referencing an external UI component, you must know the source URL and it must be available
  • Can only use constant values
  • Your code must be able to understand and process the Enum value
  • No additional formatting can be applied
  • Your code must be able to understand and process the strings
  • Your code must be able to understand and process the numbers
  • Technical Knowledge of HTML, CSS and Javascript is required for creating JSON schemas.
 
Example Use
  • Customise fonts, colour, size and positioning using HTML
  • Including an external UI component in your page
  • Allow or deny access to the feature when using your own CDN
  • Specify the user experience
  • Return a value that is recognised by your code
  • Display a message in the appropriate language
  • Return a code that is recognised by your software
  • Return a numerical code that is recognised by your software