# Intercom conversation api payload reduce size

> Map conversation id state and latest snippet for list UIs. For "intercom conversation api payload reduce size", 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/reduce-intercom-conversation-payload with an rc_live_ client token.

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

## Problem: Intercom JSON bloat on React

Oversized Intercom payloads inflate parse time and mobile data charges for React users.

- Main-thread JSON parse stalls on low-end phones
- Accidentally exposing PII fields to the client
- Downstream components re-render on unused keys

## Solution steps

1. **Add vault secrets for this pipeline**: Create INTERCOM_ACCESS_TOKEN vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.

2. **Target the real upstream URL**: Use GET against https://api.intercom.io/contacts. Allowed origins on the client token should match leave cache ttl at 0 when each response is user-specific (include userid or record id in query params before enabling cache).

3. **Call from React**: Allowed origins on the token should list every React host that calls this URL.

```
const res = await fetch('https://realcomposer.com/v1/workspace/reduce-intercom-conversation-payload', {
  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 conversation api payload reduce size",
  "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/reduce-intercom-conversation-payload" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_reduce-i",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "reduce-intercom-conversation-payload"
  },
  "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

### What should React store instead of Intercom secrets?

Yes for reduce-intercom-conversation-payload. Ship only an rc_live_ client token in React; RealComposer injects INTERCOM_ACCESS_TOKEN on https://api.intercom.io/contacts.

### Will Anthropic or Linear prompt bodies be rewritten?

Cache key for reduce-intercom-conversation-payload: internal edge-cache path plus sorted query. Identical params hit; vary userId per user.

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

Rotate vault secrets for reduce-intercom-conversation-payload anytime; clients keep the same rc_live_ token.
