N
Novu4w ago
LUCKY

Echo Workflow Variants

Hi all I would like to try out Echo and was looking for a way how to specify variants in the docs, but didn’t find anything. Is this supported?
14 Replies
Ask Inkeep
Ask Inkeep4w ago
Hi @LUCKY, I'm an AI assistant for Novu. While a team member reviews this question, I'll see if I can find relevant sources for your question.
Novu_Bot
Novu_Bot4w ago
@LUCKY, you just advanced to level 3!
Ask Inkeep
Ask Inkeep4w ago
----------------------------- While I generate an answer, here are some sources that might be helpful: * Variants * Roadmap * Workflows * Quick Start -----------------------------
Ask Inkeep
Ask Inkeep4w ago
Answer Echo, as part of Novu's infrastructure, focuses on code-first notification workflow engines that allow for complex notification workflows to be crafted within your codebase. Echo provides a robust framework for defining and managing notification workflows but does not specifically mention or support "variants" as you've described within the context of Echo's documentation or functionalities (1) . For managing variants within workflows, Novu provides a feature called "Variants" in another part of its platform. This feature allows users to create multiple versions of a given workflow step, linked to specific conditions, which is essential for sending tailored notifications based on subscriber attributes or other contextual information (2) . However, this is explicitly mentioned in the context of Novu's general notification infrastructure rather than the Echo code-first engine. Given this, if you're looking to implement variants in the context of Echo, the current documentation does not explicitly cover this feature. Echo focuses more on the code-first approach to defining workflows and steps within your application, leveraging the power of Novu for notifications (1) . For detailed functionalities and the latest updates, it would be beneficial to check the official Novu documentation or reach out to the Novu community for more specific queries or feature requests (3) .
Ask Inkeep
Ask Inkeep4w ago
Got it. Tagging @Support for additional help.
Dima Grossman
Dima Grossman4w ago
Hi @LUCKY variants can actually just be an if statement in your workflow definition. Both for content and for configuration. Do you have a particular usecase in mind you are trying to achieve?
LUCKY
LUCKY4w ago
Hey @Dima Grossman Many thanks for your reply Ah I see, I could use the payload and based on it write a different logic, makes sense. I am just trying out echo, as I like the code-first approach, attached a screenshots Quick question: - Will the end-result of Novu Framework always be the Cloud Configuration. It's basically, like terraform, but for Novu? - In my example, will it create 2 variants and for each email + push? Can users still modify and say that they want to disable email? - How can I define that I want to send it over OneSignal for push and SendGrid for Email? Many thanks!
No description
Dima Grossman
Dima Grossman4w ago
You will need to add your if statements inside of your step functions and not outse, the workflow engine hydrates state so the workflow definition function should always have the same step structures The framework sdk will use your provider configurations from the cloud integrations page. So if you have email defined with sendgrid, it will use sendgrid User preferences work exactly like they work today, so if a user disabled email for a specific workflow in his preference it will be appleid to your workflow definition
LUCKY
LUCKY4w ago
@Dima Grossman sorry, I don't fully understand the first point, do you mean like this?
/* eslint-disable max-len */
import { workflow } from "@novu/framework";

const isAbsenceLimitExceeded: boolean = false;

export const requestAbsence = workflow(
"request-absence",
async ({ step, payload }) => {
await step.push("request-absence", async () => {
if (isAbsenceLimitExceeded) {
// variant 1
return {
subject: "Absence Limit Exceeded",
body: `Absence limit exceeded for ${payload.name}.`,
};
} else {
// variant 2
return {
subject: "Request Absence",
body: `${payload.name} has requested absence from ${payload.startDate} to ${payload.endDate}.`,
};
}
});

await step.email("send-email", async () => {
if (isAbsenceLimitExceeded) {
// variant 1
return {
subject: "Absence Limit Exceeded",
body: `Absence limit exceeded for ${payload.name}.`,
};
} else {
// variant 2
return {
subject: "Request Absence",
body: `${payload.name} has requested absence from ${payload.startDate} to ${payload.endDate}.`,
};
}
});
},
{
payloadSchema: {
type: "object",
properties: {
name: { type: "string" },
startDate: { type: "string" },
endDate: { type: "string" },
},
required: ["name", "startDate", "endDate"],
},
} as const
);
/* eslint-disable max-len */
import { workflow } from "@novu/framework";

const isAbsenceLimitExceeded: boolean = false;

export const requestAbsence = workflow(
"request-absence",
async ({ step, payload }) => {
await step.push("request-absence", async () => {
if (isAbsenceLimitExceeded) {
// variant 1
return {
subject: "Absence Limit Exceeded",
body: `Absence limit exceeded for ${payload.name}.`,
};
} else {
// variant 2
return {
subject: "Request Absence",
body: `${payload.name} has requested absence from ${payload.startDate} to ${payload.endDate}.`,
};
}
});

await step.email("send-email", async () => {
if (isAbsenceLimitExceeded) {
// variant 1
return {
subject: "Absence Limit Exceeded",
body: `Absence limit exceeded for ${payload.name}.`,
};
} else {
// variant 2
return {
subject: "Request Absence",
body: `${payload.name} has requested absence from ${payload.startDate} to ${payload.endDate}.`,
};
}
});
},
{
payloadSchema: {
type: "object",
properties: {
name: { type: "string" },
startDate: { type: "string" },
endDate: { type: "string" },
},
required: ["name", "startDate", "endDate"],
},
} as const
);
LUCKY
LUCKY4w ago
No description
Dima Grossman
Dima Grossman4w ago
Yes! Another option if you still want to keep them seaparate to easily preview content in the UI, each step has a skip method. If you will use it, you will be seeing them as separate steps in the web editor
LUCKY
LUCKY3w ago
@Dima Grossman thanks for helping me with the first workflow, I like the overall code-first concept. Can we use it with our self hosted Novu? Which Echo URL should we use? Many thanks
Dima Grossman
Dima Grossman3w ago
Hi @LUCKY the OSS Community Edition will rollout around mid-or and July, we are doing a big release next week on cloud and OSS will come next
LUCKY
LUCKY3w ago
@Dima Grossman many thanks for the update, great!
Want results from more Discord servers?
Add your server
More Posts
Does novu support sending messages to slack in markdownI want to send the message in table form in a slack channel via novu. How can this be achieved?Cannot open 'Layouts' tabWhen I click on Layouts on the novu dashboard, my page just blinks and go back to Workflows. I triedDoes the notification widget for React support WS service on a path?I'm deploying the self-hosted version to my infrastructure and have put API and WS services on a patNovu Headless - notifications not showing for custom subscriber IDsI have an app that accepts user's first name, last name, and first name. Then, it generates an ID siNot able to see the WEB UI on 4200I have been trying to setup the novu on my local machine after too many tries. i was able to run apiHow can I integrate in-app notifications in React Native?The Novu documentation contains integration guides for 'React' and other web apps. I need to integraGetting error "POST https://mydomain.com/api/v1/widgets/session/initialize 404 (Not Found)my .env example # Root URL REACT_APP_WS_URL=$HOST_NAME/ws API_ROOT_URL=$HOST_NAME/api DISABLE_USER_Firebase is forcing users to migrate from FCM to HTTP v1 (Does Novu supports HTTP v1)??Hi everyone I've got an email from firebase (check the attached email on the bottom) And I was wondWhere to report a broken Novu Cloud API?Looking at the support channel seeing little action, where should I report a broken API endpoint? hCannot get global preference for a subscriber (status: 400)If I try to use the endpoint `https://api.novu.co/v1/subscribers/{subscriberId}/preferences/global`