# Emarsys (beta)

{% hint style="warning" %}
The Emarsys integration is still in beta
{% endhint %}

Connect your Emarsys account to Chatlayer to manage contact data, trigger automated campaigns, and synchronize customer information across your marketing channels.

## Setting Up API Credential in Emarsys

You need the `Account Owner` role inside of emarsys to be able to provision one. You can find it under `Management -> Security Settings -> Api Credentials`, create one of type `WSSE`.

### Api permissions

Before connecting Emarsys to Chatlayer, you need to ensure your API credentials has the appropriate permissions in Emarsys.

<figure><img src="/files/FwHH6iN1RDk4DJYlP2Bz" alt="" width="375"><figcaption><p>Configure API user permissions in Emarsys (part 1)</p></figcaption></figure>

<figure><img src="/files/ahftYuMflnP4g3zSJ24H" alt="" width="375"><figcaption><p>Configure API user permissions in Emarsys (part 2)</p></figcaption></figure>

Make sure your API user has permissions to access contacts, external events, and field information. Refer to the [Emarsys API documentation](https://dev.emarsys.com/docs/emarsys-core-api-guides/branches/main/84e0ffaf961f9-overview) for detailed information on creating API users.

## Connecting Emarsys to Chatlayer

Once you have your API credentials (Username(ID) and Secret(Client Secret)) from your Emarsys account, you can connect to Chatlayer.

In an Action block, the Emarsys app will be available from the App options menu.

An App integration section will appear. You'll see any accounts already connected to Chatlayer and a button to connect a new account. If the account you need is already connected, you can select it from the list and skip the connection steps.

Click "Connect new account" and enter your Emarsys API credentials (Username and Secret from the API user you created).

<figure><img src="/files/gjUxScFkzZCp3i8tZkep" alt="" width="375"><figcaption><p>Enter Emarsys Username and Secret</p></figcaption></figure>

After successful authentication, your Emarsys account will appear in the connected accounts list.

## Available Actions

The Emarsys integration provides several actions for managing contacts and triggering events:

Most actions use `field IDs`. See [this reference](https://dev.emarsys.com/docs/core-api-reference/7f3e853b57d26-contact-system-fields) for built-in fields. You can also use the "List Available Fields" action to view all available fields.

### Get Contact Data with Enumeration Values

Retrieves field values for a specified contact and returns human-readable values for choice fields instead of numeric codes.

<figure><img src="/files/Gy6OmE4kQb3nI0yCz4Xo" alt="" width="375"><figcaption><p>Get Contact Data with Enumeration Values action</p></figcaption></figure>

**Required fields:**

* **Key ID**: The field ID to use as the contact identifier (e.g., "3" for email)
* **Contact ID**: The value of the identifier (e.g., the email address)
* **Fields**: Comma-separated list of field IDs to retrieve (e.g., "1,2,3")

### Update Contact Data

Updates data for an existing contact or creates a new contact if they don't exist.

<figure><img src="/files/tBTej6WuxWZqo5gTCrnC" alt="" width="375"><figcaption><p>Update Contact Data action</p></figcaption></figure>

**Required fields:**

* **Key ID**: The field ID to use as the contact identifier
* **Contact ID**: The value of the identifier
* **Contact Data Fields**: Key-value pairs of field IDs and their new values

Example use case: Update a contact's preferences or subscription status based on bot interactions.

### List Available Fields

Retrieves all available contact fields in your Emarsys account. Useful for discovering field IDs when configuring other actions.

<figure><img src="/files/qozt0PP5WbncU5GyuGNc" alt="" width="375"><figcaption><p>List Available Fields action</p></figcaption></figure>

### List Available Choices (Multi)

Returns the available options for multi-choice fields, helping you understand valid values for updates.

<figure><img src="/files/iuwjnL1lP9Fm6ZH8MTKc" alt="" width="375"><figcaption><p>List Available Choices for multi-choice fields</p></figcaption></figure>

### List Available Choices (Single)

Returns the available options for single-choice fields.

<figure><img src="/files/hYUWvxWTDVhymNNTqt5m" alt="" width="375"><figcaption><p>List Available Choices for single-choice fields</p></figcaption></figure>

### Get Contact Data

Retrieves field values for a specified contact. Use this to pull customer information into your bot flow.

<figure><img src="/files/XSipK5F3CWaLjVakSpMf" alt="" width="375"><figcaption><p>Get Contact Data action</p></figcaption></figure>

**Required fields:**

* **Key ID**: The field ID to use as the contact identifier (e.g., "3" for email)
* **Contact ID**: The value of the identifier (e.g., the email address)
* **Fields**: Comma-separated list of field IDs to retrieve (e.g., "1,2,3")

### Trigger External Event

Triggers an external event in Emarsys for a specific contact, which can initiate automated campaigns.

**Required fields:**

* **Contact ID**: The unique identifier of the contact
* **Event ID**: The ID of the external event to trigger

Example use case: Trigger a welcome email campaign when a user completes onboarding in your bot.

## Developer Notes

### Authentication

The Emarsys integration uses WSSE authentication (Web Services Security), which generates a secure token for each API request based on:

* Username and Secret from your API credentials
* A unique nonce (random value)
* Current timestamp
* SHA1 hash for security

This ensures secure communication without exposing your credentials in plain text.

### Field IDs

Emarsys uses numeric field IDs rather than field names. Common system fields include:

* **1**: First Name
* **2**: Last Name
* **3**: Email
* **31**: Phone

Use the "List Available Fields" action to discover field IDs specific to your account, including custom fields.

### Error Handling

API responses include status codes and error messages. Common issues:

* **400**: Invalid request format or missing required fields
* **401**: Authentication failed - verify your credentials
* **404**: Contact or resource not found
* **429**: Rate limit exceeded - reduce request frequency


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.chatlayer.ai/integrateandcode/app-integrations/emarsys.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
