User Invites
Tutorials
Using User Invite API with Locales

How to Use User Invites API with Locales

The User Invites UI Components support locales so is the User Invites API version.

To use locales other than en-US and de-DE make sure you add the locale in the ROQ Console. Please look into this tutorial how to create locales.

The locales property is used to send emails in the language preferred by the targeted user, resulting in better engagement. For example, to send email in Korean language ko-KO, you need to add locales="ko-KO" in the code:

import 'dotenv/config';
import { Platform } from '@roq/nodejs';
 
/**
 * Connect to the ROQ Platform
 * Credentials in .env file
 */
const roqClient = new Platform({
	apiKey: process.env.ROQ_API_KEY,
	environmentId: process.env.ROQ_ENVIRONMENT_ID,
	host: process.env.ROQ_PLATFORM_URL
})
 
const status = await roqClient.asUser('530c9a92-71c5-4dce-a6e3-c638c2d0b1bc').sendUserInvites({
	userInvites: {
		tenantId: 'ee764883-f2c3-4486-9de6-070345e350af',
		userInvites: [{
			createdByUserId: '530c9a92-71c5-4dce-a6e3-c638c2d0b1bc',
			email: "baegyu.ri@gmail.com",
			locale: "ko-KR",
			roles: ["content-creator"]
		}]
	}
})

The invitation in the email sent to the invitee will be written in Korean language.

user invitation for Korean language

Before sending an email invite, it's important to check if the recipient has already been invited. Additionally, ensure that the email template for their specific location is available in the ROQ Console.

To check the existing email, you can utilize the userInvites() API with the filter option.

const search = await roqClient.asSuperAdmin().userInvites({
		filter: {
			email: {
				equalTo: "baegyu.ri@gmail.com"
			}
		}
	}
)