Customize payload for different steps in workflow

Is there any way I can handle the payload for different steps in a workflow? Like for first push i want to set "title" different from second push. I'm using nodejs sdk.
Solution:
Thats not the issue im able to get the redirect url. im using custom url field in the payload. But when i have configured more than 1 push steps in one workflow all the push steps are getting same url. Is there any way to control the individual payload of a particular step when triggering the workflow?
Jump to solution
13 Replies
Ask Inkeep
Ask Inkeep7mo ago
Hi @Rahul-evolvier, 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. ----------------------------- While I generate an answer, here are some sources that might be helpful: * NodeJS SDK * Custom Action Step * Onesignal * Feature: Add Nodejs SDK methods for Workflow Overrides API -----------------------------
Ask Inkeep
Ask Inkeep7mo ago
Answer Yes, you can customize the payload for different steps in a workflow using Novu's Node.js SDK. This can be achieved using the custom action step feature, where you can define custom logic that can modify or set different payload properties for each step in your workflow. Here's a detailed example to show how you can execute custom logic and use its result in subsequent steps, which could include setting a different "title" for each push:
const stepResult = await step.custom('custom-step', async () => {
return {
title: 'A custom title',
// Additional custom properties
};
}, {
outputSchema: {
type: 'object',
properties: {
title: { type: 'string' },
// Define additional properties here
},
required: ['title'],
}
});
const stepResult = await step.custom('custom-step', async () => {
return {
title: 'A custom title',
// Additional custom properties
};
}, {
outputSchema: {
type: 'object',
properties: {
title: { type: 'string' },
// Define additional properties here
},
required: ['title'],
}
});
(1) This custom step allows you to execute any custom logic, including modifying the payload to suit your needs for each step within the workflow. You can then use the result of this custom step in the resolver functions of subsequent steps or actions. Keep in mind, this is a generic example to illustrate the approach. You'll need to adapt it based on your specific workflow and the kind of payload adjustments you wish to accomplish for each step.
Ask Inkeep
Ask Inkeep7mo ago
Got it. Tagging @Support for additional help. Got it. Tagging @Support for additional help.
Rahul-evolvier
Rahul-evolvierOP7mo ago
I have self hosted the app in docker
Pawan Jain
Pawan Jain7mo ago
@Rahul-evolvier Yes you can use different variables in those steps
Rahul-evolvier
Rahul-evolvierOP7mo ago
My app uses a url field in push notifications to navigate to the relevant page. Is there any way to control the value of this field in different steps of a workflow?
Pawan Jain
Pawan Jain7mo ago
currently we support title and message field imn push step redirect url is provider specific and should be sent while triggering the workflow https://docs.novu.co/channels-and-providers/push/fcm#sdk-trigger-example
Solution
Rahul-evolvier
Rahul-evolvier7mo ago
Thats not the issue im able to get the redirect url. im using custom url field in the payload. But when i have configured more than 1 push steps in one workflow all the push steps are getting same url. Is there any way to control the individual payload of a particular step when triggering the workflow?
Novu_Bot
Novu_Bot7mo ago
@Rahul-evolvier, you just advanced to level 2!
Pawan Jain
Pawan Jain7mo ago
@Rahul-evolvier Checkout this docs about variants https://docs.novu.co/workflows/variants In my opinion, this use case can be achieved using variants I see in variants, step content will change
Rahul-evolvier
Rahul-evolvierOP7mo ago
Sorry im not getting it. How can i change the payload content using variant? There's only provision to add condition to execute that step or a variant of it right?
Pawan Jain
Pawan Jain7mo ago
I see, variants allows you to create different versions of step havign different content based on some condtions, but it will not solve your usecase. could you help us by adding this in our roadmap?
Pawan Jain
Pawan Jain7mo ago
Novu roadmap | Productlane
Find out what the Novu team is working on and leave your feedback - powered by Productlane
Want results from more Discord servers?
Add your server