Two different events with different email addresses are sent to the first email address

Hello, I have been using novu for a short time in my work. I have been using it regularly to send emails . I am working with nestjs framework. My previous tasks were only related to sending one email at a time, however, I am on a task where I need to send two consecutive emails, to two different events: one to notify the user and one to notify an administrator. My problem is that, although I send both events with the specific subscriber information to each one, both emails always arrive only to one of the emails. I have a method in my communication service to send any type of event and content:
typescript
async sendEmail(
trigger: string,
subscriber: { subscriberId: string; email: string },
payload: any,
): Promise<any> {
const result = await this.novu.trigger(trigger, {
to: subscriber,
payload: payload,
});

return result.data;
}
typescript
async sendEmail(
trigger: string,
subscriber: { subscriberId: string; email: string },
payload: any,
): Promise<any> {
const result = await this.novu.trigger(trigger, {
to: subscriber,
payload: payload,
});

return result.data;
}
When I use it, I call runs with waiting for each step to be executed, inside a try/catch
typescript
try {
// Notify user
await this.notificationService.sendEmail(
'lockers-reservation-user',
{
subscriberId: `${result.subscriber_id}`,
email: result.email,
},
{
...result,
},
);

// Notify admin
await this.notificationService.sendEmail(
'lockers-reservation-admin',
{
subscriberId: '0',
email: process.env.LOCKERS_ADMIN_EMAIL,
},
{
admin: process.env.LOCKERS_ADMIN_NAME,
...result,
},
);
} catch (error) {
console.error(error);
}
typescript
try {
// Notify user
await this.notificationService.sendEmail(
'lockers-reservation-user',
{
subscriberId: `${result.subscriber_id}`,
email: result.email,
},
{
...result,
},
);

// Notify admin
await this.notificationService.sendEmail(
'lockers-reservation-admin',
{
subscriberId: '0',
email: process.env.LOCKERS_ADMIN_EMAIL,
},
{
admin: process.env.LOCKERS_ADMIN_NAME,
...result,
},
);
} catch (error) {
console.error(error);
}
When calling each execution of the method to send the email I have checked that each email is the correct one, and it is always the one I have indicated, however both still arrive only to the user's notification email. Any idea what might be going on?
No description
No description
No description
5 Replies
Zac Clifton
Zac Clifton7mo ago
@George
Pawan Jain
Pawan Jain7mo ago
@Esteban Alvarado By any chance, admin email and subscriber email could be same? Could you please share transactionId ? I will check the root cause
Esteban Alvarado
Hey, Thanks! I print first the to object of each event trigger, and as you can see each email and subscriber id is different. Also, I'm showing the result data with the transactions id.
{ subscriberId: '42', email: 'estalvgs1999@gmail.com' }
{ subscriberId: '0', email: 'dev.ealvarado@gmail.com' }
{
data: {
acknowledged: true,
status: 'processed',
transactionId: '524abcf0-91e9-4146-a1e3-75b5f59679a4'
}
} {
data: {
acknowledged: true,
status: 'processed',
transactionId: '9c7e11c4-aaf2-4f54-a375-73d1c59fff08'
}
}
{ subscriberId: '42', email: 'estalvgs1999@gmail.com' }
{ subscriberId: '0', email: 'dev.ealvarado@gmail.com' }
{
data: {
acknowledged: true,
status: 'processed',
transactionId: '524abcf0-91e9-4146-a1e3-75b5f59679a4'
}
} {
data: {
acknowledged: true,
status: 'processed',
transactionId: '9c7e11c4-aaf2-4f54-a375-73d1c59fff08'
}
}
I also attach a screenshot of the subscribers table in the novu dashboard.
No description
Esteban Alvarado
@Pawan Jain I have also tried to use a direct email address in the code, instead of the environment variable and it still skips sending to this address and still sends both emails to the user. @Pawan Jain Hello, I have managed to solve the problem, I was sending in the payload a property called email, which overwrote the email to which it should be sent. Thanks anyway!
Pawan Jain
Pawan Jain7mo ago
Thanks for the update @Esteban Alvarado As email is system variable, it should not be used as payload dynamic variable
Want results from more Discord servers?
Add your server
More Posts
If I use topic subscription, is there a group selector in the digest?Hi I am using topic subscription, Is it possible inside the digest to get a "groupBy" topic for the Selecting one of many MSteamsI'm trying to add a new step in a workflow(chat-MSTeams). But I have couple of providers added for MUpdating Message CTA Button status using TransactionIdI am sending notifications which contains CTA buttons (Approve and Reject) to multiple subscribers uNot able to send subscriber email, first name and last name when using iFrameShould I include the first name, email, and last name in the API request for this issue?https://githAWS s3 self-hosted errorhello i have deployed novu self-hosted with an s3 bucket and i can't upload brand logo ,i get the erGot error after trying to use novu.broadcastI planned to use this method (https://docs.novu.co/api-reference/events/broadcast-event-to-all) to schanging trigger identifier throws workflow_not_found ErrorHello guys, I changed the Trigger Identifier on one of my notifications. When I try to run a testNew notifications not being received by the socket connectionI am using the listenNotificationReceive method from the @novu/headless package with react to listenAvoid subsequent initializations of notification centerHi! We have integrated the notification center in our vue 3 project. The problem we have is that in What do the job statuses mean in practice?Could someone please explain what the various job status mean in practice? E.g. pending, queued, del