N
Novu5mo ago
Mati OS

Override providers from nodejs code

Hola! I have a few email and sms providers configured in the Novu dashboard. Also I have 2 different workflows, one for email and one for sms. I want to pick the provider used in the workflow from my nodejs code.
await novu.trigger('email-workflow', {
to: {
subscriberId,
},
overrides: {
email: {
integrationIdentifier: "brevo-abcdef" // Is this line used to change the email provider?
},
},
payload: {},
});
await novu.trigger('email-workflow', {
to: {
subscriberId,
},
overrides: {
email: {
integrationIdentifier: "brevo-abcdef" // Is this line used to change the email provider?
},
},
payload: {},
});
I want to know if can use integrationIdentifier to pick different channel providers. I want to use for example
await novu.trigger('sms-workflow', {
to: {
subscriberId,
phone: '+13603963366',
},
overrides: {
sms: {
integrationIdentifier: "ntrbp-abcdef" // Can I use this to change sms provider?
},
},
payload: {},
});
await novu.trigger('sms-workflow', {
to: {
subscriberId,
phone: '+13603963366',
},
overrides: {
sms: {
integrationIdentifier: "ntrbp-abcdef" // Can I use this to change sms provider?
},
},
payload: {},
});
5 Replies
Mati OS
Mati OSOP5mo ago
Yes! The type deffined in events.interface.d.ts(10, 5) for overrides key are:
export interface IBroadcastPayloadOptions {
payload: ITriggerPayload;
overrides?: ITriggerOverrides; // this line
tenant?: ITriggerTenant;
transactionId?: string;
}

ITriggerOverrides = {
[key in 'mailgun' | 'nodemailer' | 'plivo' | 'postmark' | 'sendgrid' | 'twilio']?: object;
} & {
[key in 'fcm']?: ITriggerOverrideFCM;
} & {
[key in 'apns']?: ITriggerOverrideAPNS;
} & {
[key in 'expo']?: ITriggerOverrideExpo;
} & {
[key in 'delay']?: ITriggerOverrideDelayAction;
} & {
[key in 'layoutIdentifier']?: string;
} & {
[key in 'email']?: IEmailOverrides; // this line
} & {
[key in 'sms']?: ITriggerOverrideSMS; // this line
} & {
[key in SmsProviderIdEnum]?: ITriggerOverrideSMS;
} & {
[key in 'whatsapp']?: IWhatsappOverrides;
};
export interface IBroadcastPayloadOptions {
payload: ITriggerPayload;
overrides?: ITriggerOverrides; // this line
tenant?: ITriggerTenant;
transactionId?: string;
}

ITriggerOverrides = {
[key in 'mailgun' | 'nodemailer' | 'plivo' | 'postmark' | 'sendgrid' | 'twilio']?: object;
} & {
[key in 'fcm']?: ITriggerOverrideFCM;
} & {
[key in 'apns']?: ITriggerOverrideAPNS;
} & {
[key in 'expo']?: ITriggerOverrideExpo;
} & {
[key in 'delay']?: ITriggerOverrideDelayAction;
} & {
[key in 'layoutIdentifier']?: string;
} & {
[key in 'email']?: IEmailOverrides; // this line
} & {
[key in 'sms']?: ITriggerOverrideSMS; // this line
} & {
[key in SmsProviderIdEnum]?: ITriggerOverrideSMS;
} & {
[key in 'whatsapp']?: IWhatsappOverrides;
};
for email are
export interface IIntegrationOverride {
integrationIdentifier?: string;
}
export interface IEmailOverrides extends IIntegrationOverride {
to?: string[];
from?: string;
text?: string;
replyTo?: string;
cc?: string[];
bcc?: string[];
senderName?: string;
customData?: Record<string, any>;
headers?: Record<string, string>;
}
export interface IIntegrationOverride {
integrationIdentifier?: string;
}
export interface IEmailOverrides extends IIntegrationOverride {
to?: string[];
from?: string;
text?: string;
replyTo?: string;
cc?: string[];
bcc?: string[];
senderName?: string;
customData?: Record<string, any>;
headers?: Record<string, string>;
}
but for sms are
export type ITriggerOverrideSMS = {
to?: string;
content?: string;
from?: string;
customData?: Record<string, any>;
};
export type ITriggerOverrideSMS = {
to?: string;
content?: string;
from?: string;
customData?: Record<string, any>;
};
sms is missing integrationIdentifier. Not sure if this is a type error or a missing functionality
Shubham
Shubham2w ago
@Pawan Jain whatsapp is also missing integrationIdentifier. Can you check and confirm, integrationIdentifier use in whatsapp override?
Pawan Jain
Pawan Jain2w ago
@Shubham Whatsapp is a chat provider, chat provider don't support integration override currently
Want results from more Discord servers?
Add your server