await step.chat(
// The Step name, must be unique across the Workflow
'onboarding-follow-up',
// The Step resolver, returns the basic requirements for the channel.
// For `chat`, only the `body` field is required.
async (
// The inputs for the Step, provided statically via Novu Web.
inputs
) => {
return {
body: `Hey ${inputs.name}! How do you like the product?`,
}
}, {
// JSON Schema for validation and type-safety. Zod, and others coming soon.
// https://json-schema.org/draft-07/json-schema-release-notes
//
// The schema for the Step inputs passed statically via Novu Web.
// Defaults to an empty schema.
inputSchema: { properties: { feedbackUrl: { type: 'string', format: 'uri' }}},
// An optional callback allowing you to define if the Step should be skipped.
// The Step will not run if this returns true.
// Defaults to false.
skip: () => false, // true | false
// The provider overrides for the Channel.
// Enables you to construct a specific payload to pass to the provider.
providers: {
// The provider resolver. The provider `outputs` in the function
// arguments are dependent on the Channel, whilst the function result
// is dependent on the provider.
//
// [providerName: string]: (step: {
// inputs: ChannelInput;
// outputs: ChannelOutput;
// }) => Promise<ProviderOutput>
//
// An example is shown below for Slack on the Chat channel.
// Intellisense will help you to fill out the required options.
slack: async ({
// The inputs for the Step, provided statically via Novu Web.
inputs, // For the custom schema defined: { feedbackUrl: string }
// The outputs from the Step resolver.
outputs, // For inApp: { body: string }
}) => ({
// The specific requirements of the Slack provider.
text: outputs.body,
blocks: [{ type: 'section', text: { type: 'mrkdwn', text: outputs.body } }],
webhookUrl: 'https://hooks.slack.com/onboarding-follow-up',
}),
}
});
});