N
Novu•2mo ago
sultansaeed.

Subject Undefined from a new workflow

Hello everyone, I am using novu for in-app notification I follow the official docs and created a new workflow inside payload I am sending content and subject while when I am getting notification in app through useNotification I am getting content data inside body but subject is undefined is there any solution? #💬│support
No description
5 Replies
Pawan Jain
Pawan Jain•2mo ago
@sultansaeed. Are you using @novu/framework to build workflows?
sultansaeed.
sultansaeed.OP•2mo ago
@Pawan Jain yes bro This is how I created my workflow { "subscriberId": "6760297481105a45d22ec004", "workflowIdentifier": "salman-test-workflow", "payload": { "fullName": "Sharjeel Qadeer" } } API : app.post('/send-notification', async (req, res) => { const { subscriberId, workflowIdentifier, payload } = req.body; // Correct field names console.log('Request Body:', req.body); // Validate input if (!subscriberId !workflowIdentifier !payload) { return res.status(400).json({ error: 'Missing required fields: subscriberId, workflowIdentifier, or payload.', }); } try { // Trigger the workflow await novu.trigger(workflowIdentifier, { to: { subscriberId, }, payload, }); console.log("Notification sent successfully!"); res.status(200).json({ message: 'Notification sent successfully!' }); } catch (error) { console.error('Error sending notification:', error.response?.data error.message); res.status(500).json({ error: 'Failed to send notification.', details: error.response?.data error.message, }); } });
Pawan Jain
Pawan Jain•2mo ago
@sultansaeed. Above code is to trigger the workflow Could you please share the workflow code using @novu/framework
sultansaeed.
sultansaeed.OP•2mo ago
Yes @Pawan Jain
Pawan Jain
Pawan Jain•2mo ago
@sultansaeed. This above code is for rest api read more about @novu/framework in this doc https://docs.novu.co/framework/typescript/overview It is different. Since you are using workflows created using API, I would recommend you use old @novu/notification-center

Did you find this page helpful?