Custom Expressions for Email Address Format

This guide provides instructions on how to use custom expressions for email generation within our system. Users can define their email templates using various placeholders and transformation functions.

Syntax

Custom email templates use the following syntax:

  • {attribute}: Refers to a user attribute.

  • {attribute.function(arguments)}: Applies a function to the user attribute.

Supported Functions

  • toLowerCase(): Converts the attribute to lowercase.

  • toUpperCase(): Converts the attribute to uppercase.

  • substring(start, end): Extracts a substring from the attribute.

  • trim(): Removes whitespace from both ends of the attribute.

  • padStart(targetLength, padString): Pads the current string with another string until the resulting string reaches the given length.

  • charAt(index): Returns the character at the specified index.

Examples

Here are some examples of how you can use these functions in your templates:

Basic Usage

  • Template: {first_name}.{last_name}@{domain}

  • Generated Email: john.doe@company.com

Using Transformations

  • Template: {first_name.toLowerCase()}.{last_name.toUpperCase()}@{domain}

  • Generated Email: john.DOE@company.com

Indexing and Substrings

  • Template: {first_name[0].toLowerCase()}.{last_name.substring(0, 3)}@{domain}

  • Generated Email: j.doe@company.com

Trimming and Padding

  • Template: {department.trim()}_{level.padStart(2, '0')}@{domain}

  • Generated Email: engineering_04@company.com

Attribute Placeholders

The following placeholders can be used within templates:

  • {id}: User ID

  • {company_id}: Company ID

  • {manager_id}: Manager ID

  • {employee_id}: Employee ID

  • {first_name}: First Name

  • {last_name}: Last Name

  • {email_verified_at}: Email Verified At

  • {created_at}: Created At

  • {updated_at}: Updated At

  • {personal_email}: Personal Email

  • {unique_id}: Unique ID

  • {user_types}: User Types

  • {address}: Address

  • {phone}: Phone

  • {domain_id}: Domain ID

  • {level}: Level

  • {title}: Title

  • {department}: Department

  • {office_location}: Office Location

  • {payment_frequency}: Payment Frequency

  • {start_date}: Start Date

  • {manager}: Manager

  • {is_active}: Is Active

  • {deleted_at}: Deleted At

Sample Templates

Simple Email

  • Template: {first_name}.{last_name}@{domain}

  • Example: john.doe@company.com

Email with Transformations

  • Template: {first_name.charAt(0).toLowerCase()}.{last_name.toUpperCase()}@{domain}

  • Example: j.DOE@company.com

Complex Email Format

  • Template: {first_name[0].toLowerCase()}{last_name.substring(0, 3).toUpperCase()}@{domain}

  • Example: jDOE@company.com

By following this guide, users can create custom email templates that match their specific needs. For any additional assistance, please refer to our detailed documentation or contact support.

Last updated