Inputs are defined using JSON Schema, providing a strong run-time validation system for your workflows.

This ensures that you as the developer, and your non-technical peers are speaking the same language. Those responsible for styling and copy can edit with confidence, knowing their changes are tested in code.

Inputs vs Payload

Inputs - For Non-Technical Peers and Developers. Managed in the Novu Web UI, defined by developers and used by non-technical peers.

Examples - Color of a button, text of a button, should a section be shown, digest duration, static text content, the order of the email sections, and etc…

Payload Schema - For Developers. Passed during the novu.trigger method, and controlled by the developer.

Examples - User ID, Post ID, Comment, Order ID, 2FA token and etc…

Step Inputs

Step input schema is defining the input passed during the step method. Those inputs can be modified and persisted in the Novu Web UI.

The snippet below shows configuration for the Workflow payload schema and the Step input schema. If you don’t provide a schema, Typescript will infer the data type to unknown, reminding you of the best practice to specify your schema.

echo.workflow('new-signup', async ({ step, payload }) => {
    await step.email(
      'send-email',
      async (inputs) => {
          return {
            subject: inputs.subjectTitle,
            body: render(<ReactEmailContent hideBanner={inputs.hideBanner} components={inputs.components} />),
        }
      }, {
	      // Learn about JSON Schema here: https://json-schema.org/specification
        inputSchema: {
	        // Always `object`
          type: 'object',
          // Specify the properties to validate. Supports deep nesting.
          properties: {
            hideBanner: { type: 'boolean', default: false },
            subjectTitle: { type: 'string' },
            // Allowing no code control over the component in the Web UI
            components: {
                type: "array",
                items: {
                    type: "string"
                },
                default: ["header", "cta-row", "footer"]
            }
          },
          // Specify the array of which properties are required.
          required: ['complianceFooter'],
          // Used to enforce full type strictness, with no rogue properties.
          additionalProperties: false,
		      // The `as const` is important to let Typescript know that this
		      // type won't change, enabling strong typing on `inputs` via type
		      // inference of the provided JSON Schema.
        } as const,
      });
});

Learn more about JSON Schema here, including the powerful validation features to ensure your Content renders perfectly, every time.

Other validators, including Zod and more, coming soon. Any validator that supports transformation to JSON Schema can be added.

JSON Schema Examples

To Learn more about advanced examples, visit our JSON Schema page.