> For the complete documentation index, see [llms.txt](https://alhena.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alhena.gitbook.io/docs/integrations/marketing/integrating-mparticle-with-alhena-ai.md).

# mParticle

Capture customer data from AI conversations and sync it to mParticle CDP.

Automatically extract customer information from conversations and send it to mParticle as user profiles and events. Optionally fetch existing mParticle user data to personalize AI responses.

## Prerequisites

* An mParticle account
* mParticle OAuth credentials (Client ID and Client Secret)

## Getting Your Credentials

**OAuth Credentials (required):**

1. In mParticle, go to **Settings > Credential Management**
2. Create OAuth credentials and copy the **Client ID** and **Client Secret**

**Platform API Credentials (for lead syncing):**

1. In mParticle, go to **Setup > Inputs**
2. Create or select a Custom Feed input
3. Copy the **API Key** and **API Secret**

See [mParticle's documentation](https://docs.mparticle.com/developers/credential-management/) for detailed instructions.

## Setup

### Step 1: Connect mParticle

1. In Alhena, go to **Settings > Integrations**
2. Find **mParticle** and click **Enable**
3. Enter your **Client ID** and **Client Secret**
4. Click **Connect**

### Step 2: Add Platform API Credentials (for lead syncing)

To sync extracted leads to mParticle, add your Platform API credentials:

1. Click **Show advanced options**
2. Enter your **API Key** and **API Secret**
3. Set your **Region** if needed (this is a free-text field that defaults to `us2`; enter another value such as `us1` or `eu1` to match your mParticle data region)
4. Click **Connect** again to save

Without these credentials, Alhena can extract lead attributes from conversations but won't sync them to mParticle.

#### Advanced options fields

The **Show advanced options** panel exposes six optional fields, all of which are used by the Profile API and Events API:

| Field            | Purpose                                                              |
| ---------------- | -------------------------------------------------------------------- |
| **API Key**      | Lead syncing via the Events API                                      |
| **API Secret**   | Lead syncing via the Events API                                      |
| **Org ID**       | Fetching user profiles for personalization                           |
| **Account ID**   | Fetching user profiles for personalization                           |
| **Workspace ID** | Fetching user profiles for personalization                           |
| **Region**       | Free-text data region, defaults to `us2` (e.g., `us1`, `us2`, `eu1`) |

These fields are only editable while mParticle is disconnected.

### Step 3: Configure Attributes to Extract

Define what information to extract from conversations and send to mParticle:

1. Click **Add attribute**
2. Enter the **Attribute name** (the mParticle user attribute key, e.g., `email`, `$FirstName`, `company_size`)
3. Add a **Description** to help the AI identify this information in conversations
4. Optionally add **Examples** of values (up to 4)

Default attributes (pre-configured):

* `email` - User's email address
* `$FirstName` - User's first name
* `$LastName` - User's last name

{% hint style="info" %}
These attributes tell Alhena what to extract and sync; they do not make the AI proactively request the information. Add a matching [lead-capture guideline](/docs/integrations/marketing.md#set-up-proactive-lead-capture), or ask [AI Help](/docs/features/ai-help.md) to draft one. Configure an mParticle attribute for every value the guideline collects.
{% endhint %}

When a conversation ends, Alhena uses AI to extract these attributes from the chat and sends them to mParticle as a `lead_generated` event.

***

## User Profile Personalization (Optional)

Fetch existing user data from mParticle to personalize AI responses.

### Requirements

To enable personalization, you need:

1. **Org ID**, **Account ID**, and **Workspace ID** from mParticle
2. The user's **MPID** passed via the Alhena SDK

### Setup

1. In the mParticle settings, click **Show advanced options**
2. Enter your **Org ID**, **Account ID**, and **Workspace ID**
3. In the separate **User attributes to fetch from mParticle** section (its own card further down the settings page), add the mParticle attributes you want to use for personalization (e.g., `$FirstName`, `loyalty_tier`, `favorite_category`)

### Passing MPID via SDK

Include the user's mParticle ID in your widget configuration:

```html
<script>
document.gleenConfig = {
    company: 'your-company-key',
    apiBaseUrl: 'https://app.alhena.ai',
    userMetadata: {
        mpid: '1234567890'  // User's mParticle ID
    }
};
</script>
```

When an MPID is provided, Alhena fetches the configured user attributes from mParticle and includes them in the AI's context for personalized responses.

***

## Enabled Agents

When you connect mParticle, lead capture is enabled for the lead generation agent:

| Agent                     | Description                                                                   |
| ------------------------- | ----------------------------------------------------------------------------- |
| **Lead generation agent** | Extracts configured attributes from conversations and syncs them to mParticle |

You can configure this agent in **AI Settings > Agents**.

***

## Credential Reference

| Credential                       | Purpose                                             |
| -------------------------------- | --------------------------------------------------- |
| **Client ID / Secret**           | OAuth authentication (required to connect)          |
| **API Key / Secret**             | Lead syncing via Events API and user identification |
| **Org / Account / Workspace ID** | Fetching user profiles for personalization          |
| **Region**                       | Your mParticle data region for Events API           |

***

## Disconnecting

To disconnect mParticle:

1. Go to **Settings > Integrations > mParticle**
2. Click **Disconnect**
3. Confirm the disconnection
