Usage guide

Comments on tasks, records, and portals

One widget instance is one resource. A resource can hold many threads. The host record stays in your database. Comments stores the discussion, not the record itself.

Pick a stable tuple

  • Task in a workspace: tenantKey is the workspace id, resourceType is task, resourceId is the task id. The example uses tenant acme and task_1842.
  • CRM opportunity: resourceType opportunity and the opportunity's opaque id.
  • Purchase order or inventory row: use the order id or SKU record id you already authorize.
  • Client portal: tenantKey is the client account. Do not reuse another client's key. The example's second tenant is other with the same task_1842 string, and those discussions stay separate.

Single-tenant products still send a constant tenantKey. A page URL is not a resource id. Changing the record resets the widget: in-flight requests cancel, the stream closes, and the composer draft for the previous record stays isolated.

<Comments
  user={{ id: session.user.id, name: session.user.name }}
  scope={{
    tenantKey: account.id,
    resourceType: "purchase_order",
    resourceId: order.id,
  }}
  adapter={adapter}
/>

Your server must confirm this session may open order.id inside account.id before it lists or writes. The ids in the widget props are coordinates, not a grant. See resource authorization.

Related: Identity and tokens · Persisted BYO · Threads and updates