Feedback and reviews are the lifeblood of any business. Setting up an automated workflow to do so however, is unnecessarily complicated by the need to implement notification logic like delayed send.
import { workflow } from '@novu/framework';
import { renderFeedbackEmail } from '../emails/feedback';
import { zodControlSchema, zodDelayControlSchema, zodPayloadSchema } from './schemas';
export const AirbnbReview = workflow(
"Airbnb Review",
async ({ step, payload }) => {
* Delay Step
*/
await step.delay(
'delay-1-week',
async (controls) => {
return {
type: "regular",
unit: controls.unit,
amount: controls.amount,
};
},
{
controlSchema: zodDelayControlSchema
}
);
* Email Step
*/
await step.email(
"send-email",
async (controls) => {
return {
subject: controls.emailSubject,
body: renderFeedbackEmail(controls, payload),
};
},
{
controlSchema: zodControlSchema
}
);
},
{
payloadSchema: zodPayloadSchema
},
);