# Call History Enrichment

> How contacts appear in your call history

Source: https://edesy.in/docs/voice-agent/contacts/call-history

When you upload contacts with names, those names automatically appear in your call history, making it easy to identify who was called.

> **View enriched call history:** [Open Call History](https://voice-agent.edesy.in/insights/conversations) to see contact names displayed alongside call records.

## How It Works

```
┌─────────────────────────────────────────────────────────┐
│                  Call History Flow                       │
├─────────────────────────────────────────────────────────┤
│                                                          │
│   1. Call made to +919876543210                         │
│                  │                                       │
│                  ▼                                       │
│   2. Call completes, record saved                       │
│                  │                                       │
│                  ▼                                       │
│   3. User views Call History                            │
│                  │                                       │
│                  ▼                                       │
│   4. System looks up phone in Contacts                  │
│                  │                                       │
│                  ▼                                       │
│   5. Contact name "Rahul Kumar" found                   │
│                  │                                       │
│                  ▼                                       │
│   6. Call History shows:                                │
│      ┌────────────────────────┐                         │
│      │  Rahul Kumar           │  ← Contact name         │
│      │  +919876543210         │  ← Phone number         │
│      └────────────────────────┘                         │
│                                                          │
└─────────────────────────────────────────────────────────┘
```

## Before and After

### Without Contacts

| Contact | Type | Status |
|---------|------|--------|
| +919876543210 | Campaign | Completed |
| +919876543211 | Campaign | Completed |
| +919876543212 | Inbound | Completed |

### With Contacts Uploaded

| Contact | Type | Status |
|---------|------|--------|
| **Rahul Kumar**<br/>+919876543210 | Campaign | Completed |
| **Priya Singh**<br/>+919876543211 | Campaign | Completed |
| +919876543212 | Inbound | Completed |

Notice how calls to known contacts show the name prominently, while unknown numbers still show just the phone number.

## Matching Logic

### Phone Number Lookup

The system matches calls to contacts using normalized phone numbers:

1. Call record has `recipient_phone`: `+919876543210`
2. System searches contacts in the workspace
3. Match found by `phoneNumber`: `+919876543210`
4. Contact name returned: `Rahul Kumar`

### Normalization

Both call records and contacts use E.164 format, ensuring consistent matching:

| Source | Original | Normalized |
|--------|----------|------------|
| Call Record | `+919876543210` | `+919876543210` |
| Contact CSV | `9876543210` | `+919876543210` |

**Result**: Match found!

## Priority Order

When displaying a contact in call history, the system uses this priority:

1. **Contact Name** (from Contacts table) - highest priority
2. **Recipient Name** (from call record, if provided)
3. **Phone Number** (always shown as secondary info)

### Example Display

```
┌──────────────────────────────────────┐
│  👤 Rahul Kumar           ← Primary  │
│     +919876543210       ← Secondary  │
│                                      │
│  Type: Campaign    Status: Completed │
└──────────────────────────────────────┘
```

## Viewing Call History

### Navigate to Call History

Go to **Insights → Call History** in the sidebar.

### Contact Column

The first column now shows:
- **Contact name** (with user icon) when available
- **Phone number** (with phone icon) when no contact found

### Filtering

You can still filter by phone number in the search box. Contact names are enriched for display only.

## Multiple Contacts Same Phone

If the same phone number exists in multiple contact lists:

- The **most recently added** contact is used
- Only one name is displayed
- All contacts with that phone are still searchable

## Retroactive Enrichment

When you upload contacts:
- **New calls**: Immediately show contact names
- **Past calls**: Also show contact names when viewing history

The system looks up contacts when you view call history, so even historical calls are enriched with newly uploaded contact names.

## Use Cases

### Campaign Tracking

Upload leads before a campaign, then easily see which leads were called and their outcomes:

| Contact | Outcome | Duration |
|---------|---------|----------|
| Rahul Kumar | Success | 2:45 |
| Priya Singh | Callback | 1:30 |
| Amit Patel | No Answer | 0:00 |

### Customer Support

Upload customer database to identify inbound callers:

| Contact | Type | Agent |
|---------|------|-------|
| Premium Customer A | Inbound | Support Bot |
| Unknown Caller | Inbound | Support Bot |

### Sales Follow-up

Track which prospects have been contacted:

| Contact | Status | Notes |
|---------|--------|-------|
| Hot Lead 1 | Completed | Interested |
| Hot Lead 2 | Voicemail | Retry tomorrow |

## Best Practices

### Upload Contacts Before Campaigns

For best results:
1. Upload contacts with names
2. Wait for upload to complete
3. Start your campaign
4. Call history shows names immediately

### Keep Contacts Updated

- Add new leads as they come in
- Update names if they change
- Remove invalid contacts

### Use Consistent Naming

For easy searching:
- `First Last` format
- Include company name if relevant
- Avoid abbreviations

## Troubleshooting

### Contact name not showing

1. **Check phone format**: Ensure contact phone matches call record
2. **Check workspace**: Contact must be in same workspace
3. **Refresh page**: Try refreshing call history

### Wrong name showing

1. **Multiple contacts**: Most recent contact is used
2. **Different workspace**: Check you're in correct workspace
3. **Phone number mismatch**: Verify both are same format

### Name shows for some calls only

- Contacts only match exact phone numbers
- Numbers without contacts show phone only
- Upload more contacts to improve coverage

## API Access

For programmatic access to contact-enriched call history:

```bash
GET /api/conversations?workspaceId=xxx&include_contact=true
```

Response includes `contactName` field when available.

## Next Steps

- [Call History Features](https://edesy.in/docs/voice-agent/contacts/call-history) - Full call history guide
- [Campaign Analytics](https://edesy.in/docs/voice-agent/campaigns/analytics) - Track campaign performance
