# Customer Memory

Customer Memory is a feature that allows an AI Assistant to become customer-aware. By integrating with Twilio Segment, the Assistant can access and store relevant customer data, enabling it to personalize interactions based on previous engagements and customer profiles. Two key engines power this capability:

* [**AI Personalization Engine**](https://twilioalpha.com/personalization-engine): This engine pulls relevant customer data from Segment, allowing the Assistant to tailor its responses.
* [**AI Perception Engine**](https://twilioalpha.com/perception-engine): This engine captures relevant data from ongoing conversations and updates the customer profile in Segment, evolving the Assistant's understanding of the customer over time.

## Configure Customer Memory

In the Twilio Console, navigate to the **Segment Workspace** section of [**AI Assistants Settings**](https://console.twilio.com/us1/develop/ai-assistants/settings).

1. Name your workspace for reference from within AI Assistants.

#### Find your Space ID in Segment

2. From Segment, visit **Unify** -> **Unify Settings** -> **API access** and copy your "space ID" (begins with `spa_`) to the Segment Workspace Space ID field in **AI Assistants Settings**.

#### Get your Profile Access token

3. From the same **API access screen**, click the **Generate Token** button to generate a new Profile access token for your AI Assistants. Store the token value securely, and copy it to the **Segment Workspace Profile Access Token settings** in AI Assistants.

#### Copy your Write Key from a Source in Segment

4. Write Key: Required to write data back to Segment. You can either use an existing source or create a new Segment source:

* Create a new source:
  1. From Segment, view your **Connections** -> **Sources** create a new Node.js source.
  2. Click into the new source -> **Settings** -> **API Keys** and copy the 'Write Key' into the **Segment Workspace Write Key setting** in AI Assistants.
  3. Connect your new source to your Unify space: Visit **Unify** -> **Unify Settings** -> **Profile sources** and click **Connect source** to add your newly created Node.js source.
* Use an existing source:
  1. In Segment, go to an existing source -> **Settings** -> **API Keys** and copy the **Write Key** from your new source into the **Segment Workspace Write Key setting** in AI Assistants.

## Use Customer Memory

Once you've configured your Segment settings, you can enable the AI Personalization Engine and AI Perception Engine for each Assistant you create in your Assistant's [base configuration](/docs/alpha/ai-assistants#base-configuration), (Assistant -> Settings).

When your Assistant uses either customer engine, it passes the identity associated with that session to Segment. If you're using the API, the `identity` parameter of the `POST` request defines the identity. In the Simulator, you define the identity from the UI.

The user identity must match the form: `type:value`, and the `type` field must correlate with an identifier on the profile within Segment. Learn more about identity resolution in the [Segment Unify documentation](/docs/segment/unify/identity-resolution/identity-resolution-onboarding/).
For example:

```javascript
"email:example@example.com"
// or
"phone:15554455"
```

You can debug responses from each engine in the Simulator to understand what data your Assistant is receiving from or sending to Segment.

## Manage Segment profile data via API

You can manage your Segment profile data using the [Segment Profile API](/docs/segment/unify/profile-api/).
