workflow('comment-on-post', async ({ step, payload }) => {
await step.email(
'send-email',
async () => {
return {
subject: `You have a new comment from: ${payload.author_name}.`,
body: render(<ReactEmailContent comment={payload.comment} />),
}
});
},
{
payloadSchema: {
// Always `object`
type: 'object',
// Specify the properties to validate. Supports deep nesting.
properties: {
post_id: { type: 'number' },
author_name: { type: 'string' },
comment: { type: 'string', maxLength: 200 },
},
// Specify the array of which properties are required.
required: ['post_id', 'comment'],
// 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,
},
);