# Email Notification Stage

### **Email Notification Stage**

The **Notification Email stage** in AiFlo allows you to automatically send emails to one or more recipients during a workflow.\
It’s typically used for:

* **Status updates** (e.g., application received, request approved).
* **Alerts** (e.g., policy changes, error notifications).
* **Information sharing** (e.g., task assignment, reminders).

Once triggered, the stage sends an email with your specified subject, body, and recipient details — either static or dynamic.

<figure><img src="https://160083056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmK2RCoJJtarg5gUVoIgX%2Fuploads%2FFqnDwBD8vrVgPq6Eo4xk%2Fimage.png?alt=media&#x26;token=e7b79737-8457-4d8a-a9d6-9da7dbcca996" alt="" width="563"><figcaption></figcaption></figure>

**When to Use:**

Use the Notification Email stage when:

* You need **instant communication** triggered by workflow actions.
* You want to send **customized emails** using workflow data (variables).
* You need **automatic updates** without manual intervention.

**Configuration Steps:**

**Step 1 – Add the Stage**

1. Open your workflow in AiFlo.
2. Click **+ Add Stage**.
3. Select **Notification Email** from the list.

**Step 2 – Define Recipients (To and CC)**

You can choose who will receive the notification in several ways:

**Select from predefined options** in AiFlo:

* * **Employee** – Send to a specific employee in your organization.
  * **Team** – Send to all members of a selected team.
  * **Reporting Manager** – Send to the manager of the employee involved in the workflow.
  * **Department Head** – Send to the head of a particular department.

**Step 3 – Set Subject**

* Keep it short and meaningful.
* You can use variables to make it dynamic.

Example:

Application Status – ${Variable:ApplicantInfo:Name}

**Step 4 – Write Email Body**

You can write the email body in **plain text** or use **variables** to make the content personalized.

**Using Variables**

* Variables allow you to insert data collected in earlier workflow stages, such as the applicant’s name or job title.
* This makes each email unique and relevant to the recipient.

**Using AI Output**

* You can generate the email body dynamically by using the **AI Output** stage before the Notification Email stage.
* The AI Output stage can create the complete message text, and you can then reference that variable in your email body.

**Example (with variables):**

Hi ${Variable:ApplicantInfo:Name},

Your application for the position of ${Variable:JobInfo:Title} has been received successfully.

We will review your profile and get back to you shortly.

Regards,

HR Team

**Example (using AI-generated content):**

${Variable:AIMessage:Body}

*(Here, AIMessage:Body is the variable holding the text created in the AI Output stage.)*

**Step 5 – Save and Connect**

* Connect this stage to the relevant preceding stage (e.g., after Approval stage).
* Save your workflow.

### **Email Notification Stage Under For Each Stage**

**Purpose of "For Each" Stage**

The **For Each** stage in AiFlo is used to repeat actions for every item in a list or collection.\
It loops through all records, items, or values and executes the stages inside it **for each entry**.

**Common Uses:**

* Send an email to each candidate in a shortlist.
* Update records for all tasks in a project.
* Create notifications for each member of a team.

**Adding Email Notification Stage Inside “For Each”**

When you place an **Email Notification** stage inside a **For Each** stage:

* A separate email is sent for **each** item in the list.
* Variables from the current loop item can be used dynamically in the email.

**Example Scenario**

You want to email all shortlisted candidates.

1. **For Each Stage** → Loops through the list of shortlisted candidates
   * Select **Candidate Repository** as the source.
   * Add condition: **Status = Shortlisted**.
2. **Email Notification Stage** → Sends a personalized email to each candidate.

**Example Email Body:**

Hi ${Variable:CandidateInfo:Name},

Congratulations! You have been shortlisted for the position of ${Variable:JobInfo:Title}.

Our team will contact you soon for the next steps.

Regards,

HR Team

**Result:** Each shortlisted candidate receives their own personalized email.

### **Email Notification Stage Under Condition Stage**

**Purpose of "Condition" Stage**

The **Condition** stage in AiFlo is used when you want to execute specific actions only if a given logical condition is **true**.\
It evaluates a boolean expression (e.g., "Status = Approved") and runs the nested stages inside it **only if** the condition is met.

**Example Uses:**

* Send an approval confirmation email only if the request is approved.
* Notify a customer if their payment is overdue.
* Alert a recruiter only when a candidate’s score is above a certain threshold.

**Adding Email Notification Stage Inside “Condition”**

When you place an **Email Notification** stage inside a **Condition** stage:

* The system will send the email **only when the condition evaluates to true**.
* You can use variables from the workflow and the condition’s context to personalize the email.

**Example Scenario**

You have a workflow to process leave requests.

**Workflow Logic:**

1. **Condition Stage** → Check if **Leave Request Status = Approved**.
2. **Email Notification Stage** (inside Condition) → Send approval email to the employee.

**Example Email Body:**

Hi ${Variable:EmployeeInfo:Name},

Your leave request from ${Variable:LeaveInfo:StartDate} to ${Variable:LeaveInfo:EndDate} has been approved.

Please ensure all pending work is handed over before your leave.

Regards,

HR Team

**How it works:**

* If the status is **Approved**, the employee receives the approval email.
* If the status is **Rejected** or **Pending**, no email is sent.
