N
Novu2y ago
sgrzelak

Add member to organization

This is your code when we want to add some new member to organization:
if (process.env.NOVU_API_KEY && (process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'production')) {
const novu = new Novu(process.env.NOVU_API_KEY);

// cspell:disable-next
await novu.trigger(process.env.NOVU_TEMPLATEID_INVITE_TO_ORGANISATION || 'invite-to-organization-wBnO8NpDn', {
to: {
subscriberId: command.email,
email: command.email,
},
payload: {
email: command.email,
inviteeName: capitalize(command.email.split('@')[0]),
organizationName: capitalize(organization.name),
inviterName: capitalize(inviterUser.firstName ?? ''),
acceptInviteUrl: `${process.env.FRONT_BASE_URL}/auth/invitation/${token}`,
},
});
}
if (process.env.NOVU_API_KEY && (process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'production')) {
const novu = new Novu(process.env.NOVU_API_KEY);

// cspell:disable-next
await novu.trigger(process.env.NOVU_TEMPLATEID_INVITE_TO_ORGANISATION || 'invite-to-organization-wBnO8NpDn', {
to: {
subscriberId: command.email,
email: command.email,
},
payload: {
email: command.email,
inviteeName: capitalize(command.email.split('@')[0]),
organizationName: capitalize(organization.name),
inviterName: capitalize(inviterUser.firstName ?? ''),
acceptInviteUrl: `${process.env.FRONT_BASE_URL}/auth/invitation/${token}`,
},
});
}
As you can see you assign command.email to subscriberId but how it is possible to send invitation to new user to join organization when subscriberId is generate in random way? I have create custom template and it works but the problem is subscriberId which is not an email in this situation. Is it another way to add someone to same organization? Thanks for answer
4 Replies
Pawan Jain
Pawan Jain2y ago
Hi @sgrzelak As far as I know, if you invite a new user in your org, user first creates novu account and then joins the org Are you self hosting Novu?
sgrzelak
sgrzelakOP2y ago
yup, self hosting ok user first creates novu account for some email but the subsriberId is generate in some random way so how to invite such a user to ogranization/ ?
george.d
george.d2y ago
Hey there @sgrzelak, this feature is not supported in the self-hosted meaning that the new user won't get the email.
I know this flow can be confusing here, in this flow Novu using Novu in order to send the mail invite. The command.email is the email that you are providing in the WEB dashboard in Team Members. Instead what you could do in the self-hosted: Make sure that you have configured the environment variable: REACT_APP_DOCKER_HOSTED_ENV=true, after the invite click a popup will pop you can choose one of the provided options or click the three dots in order to recopy and send the invite link. @Pawan Jain Do you know if we have any section to this part in the docs? (if it is missing probably my fault) if we don't have it maybe it will be a good idea to create an issue for it.
Pawan Jain
Pawan Jain2y ago
This part is missing in docs
Want results from more Discord servers?
Add your server