# How to send a transactional email with Batch?

## A bit of context first <a href="#h_2f1b117f03" id="h_2f1b117f03"></a>

### Transactional what? <a href="#h_bac4fb9e0b" id="h_bac4fb9e0b"></a>

Transactional emails contain information about **an action a recipient has taken**, unlike marketing e-mails that intend to drive the recipient towards an action you want them to take.

They take the form of **1-to-1 automated** and **personalized** scenarios, usually linked to account activity or a commercial transaction, like a password reset request or an order validation.

### What about delivrability? <a href="#h_d49a11ab98" id="h_d49a11ab98"></a>

Some specific rules apply to transactional emails:

* They **do not require** a marketing opt-in status;
* They are sent in **real time**;
* They have a **higher criticality** than other scenarios, and tend to generate **higher engagement rates** as well.

With Batch, each email sending purpose is **isolated** for deliverability reasons.

Transactional emails are sent from a dedicated subdomain (e.g. *service.domain.com*) and a specialized IP / IP pool with an excellent reputation.

This protects the deliverability of transactional emails from other types of scenarios sent with Batch (newsletters, marketing automation, etc.).

### Management on the Batch dashboard <a href="#h_42fc03ee3d" id="h_42fc03ee3d"></a>

To satisfy the need of brands and media to no longer have silos between marketing and transactional emails, we have chosen to handle them in a coordinated manner on the Batch platform.

This has several advantages:

* **Technical simplicity:** you have a single endpoint for all server-side data operations: our [Profile API](https://doc.batch.com/developer/api/cep/profiles/update). In the case of a transactional scenario, it allows you to track an event enriched with additional data for message personalization purposes. This single event can be used across different types of scenarios and different channels, streamlining API calls and data flows and considerably simplifying technical implementations.
* **Integrated tracking:** delivery and engagement indicators are tracked in a centralized way on the Batch dashboard. You can consolidate information related to a recipient, such as scenarios received, opened and clicked.
* **Operational team autonomy:** business teams can modify templates or carry out A/B testing independently. This frees up the bandwidth of technical teams to concentrate on other tasks.

## Technical implementation <a href="#h_1211845164" id="h_1211845164"></a>

When a transactional trigger is detected in your back-end, call the [Profile API](https://doc.batch.com/developer/api/cep/profiles/update) to **track a user event** for the given recipient, via its Custom user ID.

Attach to the event any data you need to **personalize** the email as event attributes.

In case of highly personalized emails such as order confirmations, you can use attributes objects to structure your data.

For example, in case of an order tracking email, track a *`parcel_sent`* event when the order has just left the warehouse.

Here is an example of how the payload could look like:

```
[
  {
    "identifiers": {
        "custom_id": "johndoe123"
    },
    "events": [
        {
           "name": "parcel_sent",
           "attributes": {
                   "carrier_name": "DHL Express France",
                   "collection_point": "E-mobile Paris 3",
                   "date(delivery_date)": "2024-02-12T10:10:10",
                   "url(tracking_link)": "www.dhl.com/suivi/456",
                   "order_id": 456
                   }
        }
    ]
  }
]
```

And that's it! The rest is done on the dashboard.

{% hint style="info" %}
💡 In addition to email, the trigger event can be used to trigger a message on **any channel** operated by Batch, thanks to our centralized data model.
{% endhint %}

## How to setup the email from the Batch dashboard? <a href="#h_7bc5e29a83" id="h_7bc5e29a83"></a>

Go to the Batch dashboard, **Automations → Email → New automation → Email Trigger**.

### Set up entrance <a href="#h_74a7aaea3d" id="h_74a7aaea3d"></a>

Click on *'**Select trigger**'* and choose the event that will trigger the email:

<figure><img src="https://1464139620-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUIK868wiiK9XOVyETGZS%2Fuploads%2FANUANx6B91WZwbJYB0n9%2Fimplementation_guides_automation_select_trigger_160625.gif?alt=media&#x26;token=eac6ff09-c8e8-4e74-8970-b7cc51a2d7a1" alt=""><figcaption><p>Select trigger in automation</p></figcaption></figure>

### Target opt-out users <a href="#h_33bfa85e45" id="h_33bfa85e45"></a>

Click on '**Add targeting**' and uncheck the toggle ***Only send to opted in users***.

Transactional emails do not need a marketing opt-in status.

<figure><img src="https://1464139620-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUIK868wiiK9XOVyETGZS%2Fuploads%2Fr6ZhZ05ZYqW5mjBXW4ZW%2Fuides_automation_target_all_users_160625.gif?alt=media&#x26;token=82e1a97c-a952-41bd-8f44-c1df1d57d162" alt=""><figcaption><p>Disable marketing opt-in in targeting conditions</p></figcaption></figure>

### Compose your email <a href="#h_41e9f52995" id="h_41e9f52995"></a>

1. **Add your sender**

   Click on the message block and select a sender attached to your transactional sending subdomain.
2. **Define the subject of your email**

   You can add dynamic personalization by clicking on the brackets {...} if needed.
3. **Compose your email**

   Last but not least, there are 2 ways to create the body of your email:

   1. **Design your message with our Email Composer.**

      <figure><img src="https://1464139620-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUIK868wiiK9XOVyETGZS%2Fuploads%2F9ilib07M4UXFdeh6ouK7%2Fuides_email_composer_new_template_160625.png?alt=media&#x26;token=c0eaf553-295a-4c93-87f0-dd80bfcfa54f" alt=""><figcaption><p>Design an email template with the email composer</p></figcaption></figure>

      Batch allows you to create an email from scratch via our Email Composer.&#x20;
   2. **Upload your HTML template.**

      <figure><img src="https://1464139620-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUIK868wiiK9XOVyETGZS%2Fuploads%2Fwc0MqaDMOEPCGKH1LNgJ%2Fuides_email_composer_upload_html_160625.png?alt=media&#x26;token=e532f093-7e9a-4937-a05b-ca622696328a" alt=""><figcaption><p>Upload an HTML template</p></figcaption></figure>

   If you have a template ready to be used, you can upload it here!&#x20;

Do not forget to add your dynamic variables coming from the event!

<figure><img src="https://1464139620-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUIK868wiiK9XOVyETGZS%2Fuploads%2FLSeuljIGmuls5QP58zSI%2Fuides_emai_set_email_sender_object_160625.gif?alt=media&#x26;token=f615b86c-2961-4484-9207-16af6e9d9732" alt=""><figcaption><p>Set an email sender and an object</p></figcaption></figure>

### Saving your automation <a href="#h_2b557f3d25" id="h_2b557f3d25"></a>

Click on the '**Save and run**' button at the bottom of the form to activate it or save it as a draft and come back later.

Your email is now ready to be sent! 🎉 (in real-time as soon as the trigger event is captured by Batch, from your sending subdomain dedicated to transactional emails). <br>
