RAIA™ Specification

2.38 ADR-330/331: Intercom Channel Map

Status: Accepted — 2026-08-28  Decider: Eugin Song · Author: Scribe

← Back to Developer Hub TEXTBOOK SPECIFICATION

Status: Accepted — 2026-08-28  Decider: Eugin Song · Author: Scribe

Related: ADR-133 (Intercom ETL → BQ → tbl_conversations) · ADR-330 (Tags OS) · ADR-096 (org isolation) · ADR-252 (conversation_type retirement)

LOW
Risk tier — docs + additive DDL only
9,499
Sovereign Node rows classified as intercom_notes
~1,559
Sovereign Node rows classified as intercom
9,172
Empty shells skipped — untouched, never stamped

A ELI5 — Why This Matters

Two axis — never conflate conversation_type Audience — who is in the thread internal = staff ↔ RAIA (Chat / Telegram) external = tenant / landlord (who wrote) channel Pipe — how the message arrived new: intercom (with user/admin comment) new: intercom_notes (notes-only, staff feed) Untouched conversation_type on every Intercom row
Plain English

When we copied 20,230 old Intercom conversations into RAIA, every single one landed on channel = 'internal' — the slot meant for "staff talking to the RAIA (Real estate Artificial Intelligence Agent) assistant". That was wrong in two directions: it hid external tenant / landlord threads among internal chats, and it made the channel field meaningless for Intercom history.

ADR-331 fixes the map. It splits the Intercom corpus into two honest buckets — channel = 'intercom' (a real messenger or email thread, because at least one user or admin comment exists) and channel = 'intercom_notes' (staff notes inside Intercom that never left the internal feed). Empty "shell" rows — assign / close / state-change events with no content — get left alone and are skipped by the tag-stamper. Instagram origin (~123 rows) is untouched: it never was Intercom to begin with. conversation_type is not touched; it is a different axis.

The DDL change is additive only (extend the CHECK constraint list). Sovereign Node is the first tenant to connect Intercom — the rules are written org-agnostic, so the next org connecting will get the same mapping for free.


B User Guide — How the Rules Map

Five rules drive the Intercom channel classifier. All are mechanical; none is probabilistic. Parts of an Intercom export are inspected in BigQuery (intercom_analytics.conversation_parts) together with the conversations master record.

  • 1
    At least one comment part → channel = 'intercom'

    A user or admin reply exists — this is a real messenger / email thread. ~818 widget-origin + ~741 mixed in Sovereign Node history.

  • 2
    Notes-only → channel = 'intercom_notes'

    Only staff-side notes exist, never a customer-visible reply. 9,499 rows in Sovereign Node history. Still surfaces on the person snapshot.

  • 3
    Empty shell → left as-is, skipped by tag-stamping

    Assign / close / state-change events with no note or comment text. 9,172 rows. The tag-stamper (ADR-330 §D3) skips these — stamping structural metadata only would inflate counts with zero-content rows.

  • 4
    Widget origin with comments → 'intercom'

    A subset of rule 1 — source_type = 'conversation' on a widget thread still maps to 'intercom'.

  • 5
    Instagram origin → untouched

    ~123 rows from Instagram dumped into the Intercom export. Re-classifying them as notes would be a lie, so they are left alone.

Reading the Map in the Inbox

The Inbox treats channel = 'intercom' as an ordinary incoming conversation to answer. channel = 'intercom_notes' is a staff-only feed — it surfaces on the person snapshot but is not a reply pipeline. Do not conflate conversation_type = 'internal' with Intercom origin: after this ADR, 'internal' means only staff ↔ RAIA (Real estate Artificial Intelligence Agent) (Chat / Telegram) and should sit at ~1 live row, not ~20,000.


C Decision Rules — D1 (org-agnostic)

Rulechannel valueRationale
Parts contain ≥1 comment (user or admin reply)intercomBi-directional thread; widget or email via Intercom
Parts are notes only — no commentintercom_notesOne-sided staff note; never left the internal Intercom feed
No note and no comment — assign / close / state-changeleave as-is ('internal'); skip tag-stampShells have no content; stamping them is noise
Widget source_type = 'conversation' with commentsintercomSubset of rule 1; widget origin maps to 'intercom'
Instagram originLeave untouchedOrigin is Instagram, not Intercom

Identity anchor: tbl_conversations.source_ref = 'intercom_<conversation_id>'. Sovereign Node live counts (2026-08-28 snapshot): 9,499 intercom_notes · ~1,559 intercom · 9,172 shells · 123 Instagram (untouched).

First tenant, not the only tenant

Sovereign Node is the first organisation to connect Intercom. Because the rules are org-agnostic, the same mapping will apply to any future org that connects — no per-org fork of intercom_shell_promote.cjs is needed.

DDL — Check Extension (D2)

The migration extends the CHECK list on tbl_conversations.channel (and, in the same migration, tbl_conversation_messages.channel) to include the two new values. The backfill remap script must run only after this DDL guard is applied — it is the boundary that prevents the script from inserting illegal values.

-- V434/01_intercom_channel_values.sql (additive — no rows altered here)
ALTER TABLE public.tbl_conversations
  DROP CONSTRAINT IF EXISTS tbl_conversations_channel_check;

ALTER TABLE public.tbl_conversations
  ADD CONSTRAINT tbl_conversations_channel_check CHECK (
    channel = ANY (ARRAY[
      'whatsapp','phone','email','sms','website_chat','line',
      'in_person','airbnb','internal','aigent_desktop',
      'aigent_telegram','a2a','intercom','intercom_notes'
    ])
  );
!
Constraint name caveat

Verify with \d+ tbl_conversations before applying — never invent constraint names. V434 (already merged into data/intercom-channel-and-tags) handles both tables and raises on missing values.

Backfill Sequence (D3)

  • 1
    Apply migration V434 first

    DDL guard must be live before any reclassification runs.

  • 2
    Run intercom_shell_promote.cjs with the updated CHANNEL_MAP

    Reclassifies intercom / intercom_notes rows; skips shells and Instagram.

  • 3
    Easy-win tag-stamp pass (ADR-330 §D3) on reclassified rows

    Stamps intercom and intercom_notes (only if text is non-empty) with from-domain → org tag. Runs idempotently with before / after counts in the report.

  • 4
    Skip shells

    Never stamp PERSONS / TENANTS folder parents — freemail goes to a person record, not a tag.

CHANNEL_MAP Update — D4

The remap script exports its channel map. Future ingests will use this map directly, so new Intercom rows land on the correct channel at ingest time and never default to 'internal' for Intercom source refs.

// CHANNEL_MAP — org-agnostic; applies to any source_ref matching /^intercom_/
const CHANNEL_MAP = {
  // Has at least one comment part (user or admin)
  has_comment: 'intercom',
  // Parts exist but are notes only (no comment)
  notes_only:  'intercom_notes',
  // No parts with content (assign / close / state shells) — leave channel as-is, skip stamp
  empty_shell: null,
};

Open Questions

  • tbl_conversation_messages.channel — does that constraint also need the two new values? Programmer to check live DDL (\d+ tbl_conversation_messages) and extend in the same migration if required. (V434 already ships both; verify before running the remap script.)
  • Nightly delta — once intercom_shell_promote.cjs is updated, does the nightly Intercom→BQ→tbl_conversations sync honour the new CHANNEL_MAP for incremental rows, or does the import job need a separate patch?

D References & Related ADRs

Related ADRs & Sources

SourceTypeNotes
ADR-331 — Intercom Channel Classification (commit ee083e24 on docs/intercom-channel-map) ADR The full decision document this page summarises
ADR-330 — Tags OS SSOT ADR The tag-stamp doctrine this channel map feeds; see §D3 for the stamp-and-skip rules
ADR-133 — Intercom ETL → BQ → tbl_conversations ADR Amended: the original "everything is internal" posture is superseded by ADR-331
ADR-096 — Multi-tenant org isolation ADR Why the map is org-agnostic; isolation lives in organisation_id, not the mapping
ADR-252 — conversation_type retirement ADR Clarifies the audience-vs-pipe axis this ADR depends on
V434 — add intercom channel values (data/intercom-channel-and-tags) Migration Extends the CHECK list on tbl_conversations.channel and tbl_conversation_messages.channel
programs/jobs/intercom_shell_promote.cjs Script The remap script that applies CHANNEL_MAP after V434 is applied
GitHub #782 Issue Closes the docs portion; data remap is the data worktree branch