N
Novu8mo ago
Nao Ohira

Override "to" use cases behavior

Hi, I'm having some issues when using overrides.[channel].to for mail and sms. The first one (email) seems to add recipient instead of overriding which seems to be a weird behavior It seems that it does not work for sms (I will test again because I checked the code and seems to be correct. I would like to know what would be the correct behavior. I can make a PR.
send-message-email.usecase.ts
send-message-sms.usescase.ts
9 Replies
Ask Inkeep
Ask Inkeep8mo ago
Hi @Nao Ohira, I'm an AI assistant for Novu. While a team member reviews this question, I'll look through relevant sources and see if I can provide suggestions. Please tag @Ask Inkeep with any follow-up questions. ----------------------------- While I generate an answer, here are some sources that might be helpful: * SMS Channel Overview * Layouts * How to send push notifications in an Android app (react native) with FCM and Novu * Broadcast event to all -----------------------------
Ask Inkeep
Ask Inkeep8mo ago
Answer For SMS, the correct behavior regarding overrides is that you can indeed specify different to, from, and content values to override the defaults. This allows sending messages to a different recipient, from a different sender, or with different content for SMS notifications. Here's a code snippet illustrating how to use overrides for SMS:
import { Novu } from '@novu/node';
const novu = new Novu('<NOVU_API_KEY>');
novu.trigger('<WORKFLOW_TRIGGER_IDENTIFIER>', {
to: {
subscriberId: '<SUBSCRIBER_ID>',
},
overrides: {
sms: {
to: '+123012345678',
from: 'Novu Team',
content: 'This SMS message is from overrides'
},
},
});
import { Novu } from '@novu/node';
const novu = new Novu('<NOVU_API_KEY>');
novu.trigger('<WORKFLOW_TRIGGER_IDENTIFIER>', {
to: {
subscriberId: '<SUBSCRIBER_ID>',
},
overrides: {
sms: {
to: '+123012345678',
from: 'Novu Team',
content: 'This SMS message is from overrides'
},
},
});
(1) For email, overrides should also allow changing specific fields like to, but based on community discussions, there might be an inconsistency where the to override adds recipients instead of overriding. This behavior seems to be acknowledged by the community and might be subject to future improvements or clarification in the documentation or codebase. Discussion from community forums indicates that there might've been similar confusion or issues with overrides, especially with email, where overrides behave differently than expected. While exact details on resolving this for email weren't directly available, understanding from related discussions suggests an acknowledgment of the issue and consideration for updates or fixes. If you're considering making a PR, it would be beneficial to review the latest discussions in the community forums or GitHub issues for any recent updates or ongoing discussions on this topic. Your contribution could be valuable to the Novu community, addressing these inconsistencies. (2)
Nao Ohira
Nao OhiraOP8mo ago
I've just tested the sms override and it seems working well. There is just the mail issue that seems to have a wrong behavior
Ask Inkeep
Ask Inkeep8mo ago
Got it. Tagging @Support for additional help.
Pawan Jain
Pawan Jain8mo ago
@Nao Ohira You are correct. email to overrides field merges (add) the email We have this info in our docs
No description
Pawan Jain
Pawan Jain8mo ago
What issue you are facing with sms to field?
Nao Ohira
Nao OhiraOP8mo ago
Hmm ok. So there is not possibility to override by replacing (I have a certain use case where we want to send a mail to validate that it's valid before changing the mail in our database)
Pawan Jain
Pawan Jain8mo ago
>> I have a certain use case where we want to send a mail to validate that it's valid before changing the mail in our database Would you like to share more about this? How you are using email overrides to field for this?
Nao Ohira
Nao OhiraOP8mo ago
We have an registered user with a mail [email protected] This user want to change its mail, so we are sending a mail with a deeplink the the new mail [email protected] to validate but we don't want to send it to a it's seems kinda weird that for email it adds, and for sms, it replaces and not send to the two phone number. As it's managed upstream it's also not possible to manage inside the provider. It would mean that we would need to have a second temporary subscriber to achieve this kind of process
Want results from more Discord servers?
Add your server