{
  "slug": "combine-intercom-with-posthog-events",
  "title": "Combine intercom with posthog user events",
  "metaDescription": "Combine intercom with posthog user events. Intercom conversation list plus PostHog person properti. Merge Intercom and PostHog in one React call with.",
  "headline": "Support tool with product analytics context",
  "category": "aggregation",
  "categoryLabel": "Multi-API Aggregation",
  "urgency": 8,
  "clientPlatform": "React",
  "upstreamServices": [
    "Intercom",
    "PostHog"
  ],
  "searchIntentQuery": "combine intercom with posthog user events",
  "directAnswerSummary": "Intercom conversation list plus PostHog person properties in one payload. For \"combine intercom with posthog user events\", store INTERCOM_ACCESS_TOKEN, POSTHOG_PERSONAL_API_KEY in Secret Vault, call https://api.intercom.io/contacts from a Worker, and let React hit only https://realcomposer.com/v1/workspace/combine-intercom-with-posthog-events with an rc_live_ client token.",
  "problem": {
    "title": "Serial Intercom and PostHog calls slow React pages",
    "explanation": "Each extra Intercom and PostHog hop adds hundreds of milliseconds and another OAuth refresh path your UI must manage.",
    "risks": [
      "One slow upstream blocking an entire page",
      "Partial failures leaving UI in inconsistent states",
      "Duplicate auth refresh logic per service"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Add vault secrets for this pipeline",
      "description": "Add INTERCOM_ACCESS_TOKEN, POSTHOG_PERSONAL_API_KEY to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream."
    },
    {
      "stepNumber": 2,
      "title": "Configure upstream steps and output mapping",
      "description": "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)."
    },
    {
      "stepNumber": 3,
      "title": "Call from React",
      "description": "Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.",
      "codeSnippet": "const res = await fetch('https://realcomposer.com/v1/workspace/combine-intercom-with-posthog-events', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});\nconst data = await res.json();"
    }
  ],
  "pipelineConfig": {
    "name": "Combine intercom with posthog user events",
    "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
      },
      {
        "stepKey": "posthog",
        "upstreamUrlTemplate": "https://us.posthog.com/api/projects/{{query.projectId}}/feature_flags",
        "httpMethod": "GET",
        "headersTemplate": {
          "Authorization": "Bearer {{secrets.POSTHOG_PERSONAL_API_KEY}}"
        },
        "timeoutMs": 3000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "intercom.contactId",
          "sourcePath": "data.0.id",
          "type": "string",
          "sourceStep": "intercom"
        },
        {
          "targetPath": "intercom.email",
          "sourcePath": "data.0.email",
          "type": "string",
          "sourceStep": "intercom"
        },
        {
          "targetPath": "posthog.flagKey",
          "sourcePath": "results.0.key",
          "type": "string",
          "sourceStep": "posthog"
        },
        {
          "targetPath": "posthog.active",
          "sourcePath": "results.0.active",
          "type": "boolean",
          "sourceStep": "posthog"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_combine-",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "combine-intercom-with-posthog-events"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "intercom_contactId": "sample",
    "intercom_email": "sample",
    "posthog_flagKey": "sample",
    "posthog_active": "sample"
  },
  "curlSnippet": "curl -X GET \"https://realcomposer.com/v1/workspace/combine-intercom-with-posthog-events\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "What should React store instead of Intercom secrets?",
      "answer": "Use scoped tokens where the vendor allows them on combine-intercom-with-posthog-events. Admin keys stay {{secrets.*}} references only."
    },
    {
      "question": "How do I forward JSON bodies to POST upstreams?",
      "answer": "Cache key for combine-intercom-with-posthog-events: internal edge-cache path plus sorted query. Identical params hit; vary userId per user."
    },
    {
      "question": "Can I restrict which domains call this pipeline?",
      "answer": "Rotate vault secrets for combine-intercom-with-posthog-events anytime; clients keep the same rc_live_ token."
    }
  ],
  "relatedRecipeSlugs": [
    "merge-clerk-and-posthog-feature-flags",
    "posthog-mobile-proxy"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/combine-intercom-with-posthog-events",
    "markdown": "https://realcomposer.com/recipes/combine-intercom-with-posthog-events.md",
    "json": "https://realcomposer.com/recipes/combine-intercom-with-posthog-events.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=combine-intercom-with-posthog-events&via=agent"
  }
}