> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# One customer, every channel

> Omnichannel in Devic: one assistant behind the API, the embedded widget, email, Slack, Teams and WhatsApp, and how every message is attributed to the same customer and the same person.

The same assistant can answer through your product's API, a chat embedded with `@devicai/ui`, an inbox, Slack, Microsoft Teams and WhatsApp. It keeps the same instructions, tools, knowledge and memory on every one. You do not build a conversation engine per channel, and you do not host an adapter for any of them: the four messaging [channels](https://docs.devic.ai/devic/administration/channels.md) are native.

What makes it one assistant *for one customer* rather than six disconnected bots is attribution. Every message, whichever way it arrived, is attributed to the same three identifiers.

***

## The three identifiers

| Identifier | What it names | Partitions |
| - | - | - |
| `tenantId` | Your customer: a company, an account | Costs, usage limits, the tenants list |
| `subtenantId` | A person or team inside that customer | Memory (by default), per-user costs and limits |
| `chatUid` | One conversation | History and context sent to the model |

`tenantId` and `subtenantId` describe **who**. `chatUid` describes **which conversation**. Keep them apart: the who is what carries across channels; the conversation usually does not.

***

## Who sets them

On the **API and the widget**, you do. Your backend sends them with each message, and in a browser a [tenant session](https://docs.devic.ai/devic/multi-tenant/tenant-sessions.md) proves them instead of trusting what the page says.

On a **channel**, nobody sends them: the message comes from Slack, Meta or a mail server. Devic works them out from who wrote, in this order:

1. **The directory.** If the workspace, organisation, number or address was mapped to one of your tenants, through a [link](https://docs.devic.ai/devic/administration/channels.md#connecting-a-customer) or by hand, that mapping wins.
2. **The platform's own ids**, when nothing has been mapped yet.

| Channel | One conversation per… | `tenantId` when unmapped | `subtenantId` when not mapped to a person |
| - | - | - | - |
| Email | mail thread | none | the sender's address |
| Slack | bot + workspace + channel + thread | the Slack workspace id | the Slack user id |
| Teams | bot + organisation + conversation | the Microsoft tenant id | the person's Entra object id |
| WhatsApp | number + contact (the chat never ends; long ones are compacted) | the contact itself | none |

Once a channel is mapped to a tenant, the person writing is attributed like this:

* **WhatsApp and email** links can name the person (`subtenantId`) directly.
* **Slack and Teams** links map a whole workspace or organisation. Each person in it is then matched to one of that tenant's existing subtenants **by email**, when their profile email equals one Devic already has for that tenant. The match never looks outside the tenant.

> [!NOTE]
>
> The tenant never comes from the model or from the text of a message. It comes from a link you issued, a mapping you made, or the API key and tenant session of the call.

***

## What carries across channels, and what does not

> [card] Shared, through tenantId and subtenantId
>
> **Memory**: with the default scope, one memory per tenant and subtenant, whichever channel wrote it.
>
> **Costs, usage and limits**: one tenant's consumption, wherever it came from.
>
> **Conversations**: every channel's chats are listed and filtered by the same tenant and subtenant.

> [card] Kept per channel
>
> **The conversation itself.** A WhatsApp chat and a widget chat are two conversations, each with its own history. The assistant knows on which channel each message arrived.
>
> **Delivery rules**, such as WhatsApp's 24-hour window or replying in a Slack thread.

So when somebody tells your assistant something in the widget and later writes on WhatsApp, the assistant does not see the widget conversation. It **does** recall what it learned there, provided both channels carry the same `tenantId` and `subtenantId`.

> [!WARNING]
>
> To Devic, `user-42` in the widget and `34600111222` on WhatsApp are two different people, even if they are the same human. Memory and per-user limits only follow a person across channels if every channel resolves them to **the same `subtenantId` string**. The next section shows how.

> [!NOTE]
>
> Use the `subtenant` or `tenant` [memory scope](https://docs.devic.ai/devic/memory/buckets.md) for cross-channel memory. The `user` owner relies on a signed-in Devic user; runs started by an inbound channel fall back to the assistant's own bucket.

***

## Making one person the same person everywhere

The rule is simple: choose the id your own product already uses for each user, use it as `subtenantId` in the API and the widget, and attach each channel to it.

| Channel | How the person gets your `subtenantId` |
| - | - |
| API / widget | You send it, proven by a tenant session in the browser. |
| WhatsApp | A link issued with `tenantId` **and** `subtenantId`. The person sends the pre-written code from their phone; from then on that contact is that user. |
| Email | A link issued with `subtenantId`, accepted from the exact address. Without one, the subtenant is the address, which already matches if your product uses emails as `subtenantId`. |
| Slack / Teams | A link maps the workspace or organisation to the tenant; people are matched to subtenants by email. |

### Verified link between a phone number and your user

This is the question every WhatsApp integration has to solve: *how do I know this phone belongs to user 42 of my SaaS?* Devic solves it without SMS codes or your own verification flow.

**1. Your product issues the link, for the signed-in user**

From your backend, with the user's ids. The link is shown only inside your authenticated product, so only that user sees it.

```bash theme={null}
curl -X POST https://api.devic.ai/api/v1/channels/invites \
  -H "Authorization: Bearer $DEVIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "whatsapp",
    "channelAppId": "<your WhatsApp app id>",
    "accountId": "<the number they will write to>",
    "tenantId": "acme",
    "subtenantId": "user-42",
    "expiresInHours": 24
  }'
```

The response contains a `url` (a hosted page with a QR code), a `waUrl` (a click-to-chat link with the code already written), the `joinCode` on its own, and the invite `id`. The link and the code are returned **once**: only their hashes are stored.

**2. The user sends the message from their phone**

Show the page, or `waUrl` as a button on mobile. Sending the message is the proof: only the phone that sends the code gets bound. The code is single-use, works only on that number, and expires. It is removed from the text before the assistant reads it.

**3. Every later message is attributed**

That contact now resolves to `acme` / `user-42`: the same tenant, person and memory as in your widget.

You can also let the assistant offer it. An assistant that also answers on a WhatsApp number, with the WhatsApp built-in tools enabled, can generate this same link during a widget or API conversation (for example when the user asks to continue on WhatsApp). The link is bound to the tenant and subtenant of **that conversation**; the model cannot choose them.

To tighten it further:

* `maxBindings` (1 by default) caps how many phones one link may bind.
* `requireApproval` holds each new binding until someone approves it in the console.
* A WhatsApp binding can **refuse unknown contacts**: anyone not mapped gets one fixed sentence and no run starts.

***

## Overriding the defaults

Each channel binding exposes the templates that compute these values (`chatUidTemplate`, `tenantIdTemplate`, `subtenantIdTemplate`, `userNameTemplate` and `messageTemplate`) under its receiving settings. A template written by hand takes precedence over the directory, so only override when you need something other than the mapping. An empty template means *use the default*, not *none*.

> [!WARNING]
>
> Setting `subtenantIdTemplate` to the raw contact (for example `{{whatsapp.contact_id}}`) ignores every mapping made through links, so people will no longer match their `subtenantId` in your product.

***

## Related

> [card] [Channels](https://docs.devic.ai/devic/administration/channels.md)
>
> Setting up email, Slack, Teams and WhatsApp, and issuing links.

> [card] [Channels API](https://docs.devic.ai/api-reference/endpoint/post-api-v1-channels-invites.md)
>
> Issue links and list mapped identities from your backend.

> [card] [Tenant sessions](https://docs.devic.ai/devic/multi-tenant/tenant-sessions.md)
>
> Proving the tenant and subtenant in the browser.

> [card] [Memory buckets](https://docs.devic.ai/devic/memory/buckets.md)
>
> How memory is partitioned by tenant and subtenant.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.