# Intercom contact json slim for crm sidebar

> Contact id email and company for quick context. For "intercom contact json slim for crm sidebar", store INTERCOM_ACCESS_TOKEN in Secret Vault, call https://api.intercom.io/contacts from a Worker, and let React hit only https://realcomposer.com/v1/workspace/slim-intercom-contact-json-sidebar with an rc_live_ client token.

- Canonical page: https://realcomposer.com/recipes/slim-intercom-contact-json-sidebar
- Client platform: React
- Upstream services: Intercom
- Category: Payload Slimmer
- JSON version: https://realcomposer.com/recipes/slim-intercom-contact-json-sidebar.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=slim-intercom-contact-json-sidebar&via=agent

## Problem: Unmapped Intercom fields waste bandwidth

Intercom returns nested CRM, audit, and configuration objects. React parses them on the main thread even when the UI binds three fields.

- Large arrays kept in memory after navigation
- Analytics showing poor LCP on API-heavy screens
- Developers shipping defensive null checks for unused paths

## Solution steps

1. **Add vault secrets for this pipeline**: Add INTERCOM_ACCESS_TOKEN to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream.

2. **Target the real upstream URL**: Configure headersTemplate to inject vault secrets, target https://api.intercom.io/contacts, and Map only the UI fields in output mapping so clients never download audit or nested blobs.

3. **Call from React**: Call https://realcomposer.com/v1/workspace/slim-intercom-contact-json-sidebar with a restricted rc_live_ client token. React never sends upstream secrets.

```
const res = await fetch('https://realcomposer.com/v1/workspace/slim-intercom-contact-json-sidebar', {
  headers: { Authorization: 'Bearer rc_live_your_token' }
});
const data = await res.json();
```

## Pipeline config

Import this config into a RealComposer pipeline. `{{secrets.NAME}}` values are read from the encrypted Secret Vault at request time, so the client never sees them.

```json
{
  "name": "Intercom contact json slim for crm sidebar",
  "method": "GET",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "intercom",
      "upstreamUrlTemplate": "https://api.intercom.io/contacts",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.INTERCOM_ACCESS_TOKEN}}",
        "Accept": "application/json"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "contactId",
        "sourcePath": "data.0.id",
        "type": "string",
        "sourceStep": "intercom"
      },
      {
        "targetPath": "email",
        "sourcePath": "data.0.email",
        "type": "string",
        "sourceStep": "intercom"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/workspace/slim-intercom-contact-json-sidebar" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_slim-int",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "slim-intercom-contact-json-sidebar"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "contactId": "sample",
  "email": "sample"
}
```

## FAQ

### Does React need CORS changes after adding RealComposer?

Yes for slim-intercom-contact-json-sidebar. Ship only an rc_live_ client token in React; RealComposer injects INTERCOM_ACCESS_TOKEN on https://api.intercom.io/contacts.

### What cache key does RealComposer use?

slim-intercom-contact-json-sidebar forwards client JSON to POST upstreams unchanged; secrets interpolate only in URLs and header templates.

### What happens if an upstream step times out?

Upstream steps in slim-intercom-contact-json-sidebar honor timeoutMs and optional fallback JSON without leaking secrets.
