SDK output types
Explore various SDK output types, including Component, Enum, String, Number, JSON, and Transformation, to define outcomes displayed on your site.
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 is displayed. To define the string to display complete the following steps:
- Enter the string as you want it to display in the Output text box.
- Click Save 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. 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 is displayed. To define the number to display complete the following steps:
Enter the number as you want it to display in the Output text box.
Click Save to save the number and return to the rules canvas. Selecting Cancel 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. The following table lists 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" } } }
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.
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 Outcome.
When an SDK feature rule is triggered, the following information about the returned components will be available in the response body:
transformationType: Type of the component
resourceId: Unique Id of the component
contentPath: The URL of the component
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 } ]