# Channels

The ways customers reach a brand. Every channel files into the same ticket
workspace: the same statuses, SLAs, rules, assignment and agent replies,
whichever way the customer wrote
([REQUIREMENTS §4.4](https://github.com/Docker-Hunterpedia/Helpdock/blob/main/docs/planning/REQUIREMENTS.md#44-channels)).

Each channel is configured per brand under **Settings › Channels**, which only an
Admin of the brand can open (`brand:manage`).

| Channel | Customer writes by | Agent's reply reaches them by | Set up on | Guide |
|---|---|---|---|---|
| Email | Mail to a mailbox address, fetched over IMAP or posted by the provider's inbound-parse webhook | Email from the brand's sender | Channels › Email, Channels › Outgoing email | [Receiving mail](https://helpdock.oday-bakkour.com/docs/email/), [Outbound email](https://helpdock.oday-bakkour.com/docs/outbound-email/) |
| Telegram | A message to the brand's bot | The same chat | Channels › Telegram | [Telegram](https://helpdock.oday-bakkour.com/docs/telegram/) |
| WhatsApp, Messenger, Instagram | A message to the brand's WhatsApp number, Facebook Page or Instagram professional account | The same platform and conversation, inside Meta's reply window | Channels › Meta | [Meta channels](https://helpdock.oday-bakkour.com/docs/meta-channels/) |
| Chat widget | The widget on the brand's site, or a native app speaking its protocol | The widget, live | Channels › Chat widget | [Widget protocol](https://helpdock.oday-bakkour.com/docs/widget-protocol/) |
| Web form | The hosted contact page, `/contact` on the help center domain | Email | Channels › Web form | [Web form](https://helpdock.oday-bakkour.com/docs/web-form/) |
| REST API | `POST /api/v1/tickets` with an API key | Your integration, which reads the thread with `GET /api/v1/tickets/{ticketId}/messages` | Developers › API keys | [API](https://helpdock.oday-bakkour.com/docs/api/) |

Agents can also open a ticket by hand from the ticket list
([tickets](https://helpdock.oday-bakkour.com/docs/tickets/)).

## What every channel shares

- **One contact per person.** An address or chat id seen before finds its
  contact; one never seen makes a new one. An address a customer typed is a
  claim, not proof, so it never joins someone else's history on its own
  ([contacts](https://helpdock.oday-bakkour.com/docs/contacts/), [DOMAIN-RULES §4](https://github.com/Docker-Hunterpedia/Helpdock/blob/main/docs/planning/DOMAIN-RULES.md#4-identity-and-conversation-ownership)).
- **No duplicates.** An inbound message carries its channel's own id, which is
  unique per channel, so a redelivered email, Telegram update or webhook files
  nothing twice ([DOMAIN-RULES §6](https://github.com/Docker-Hunterpedia/Helpdock/blob/main/docs/planning/DOMAIN-RULES.md#6-transactional-outbox)).
- **Replies go through the outbox.** An agent's reply is committed with an
  outbox row in the same transaction, and the worker sends it
  ([DOMAIN-RULES §6](https://github.com/Docker-Hunterpedia/Helpdock/blob/main/docs/planning/DOMAIN-RULES.md#6-transactional-outbox),
  [operations](https://helpdock.oday-bakkour.com/docs/operations/#scaling-the-worker)).
- **Attachments** pass the brand's content policy and the media pipeline
  whichever channel brought them ([attachments](https://helpdock.oday-bakkour.com/docs/attachments/)).
- **Reply windows.** WhatsApp, Messenger and Instagram accept a business's
  reply only for a time after the customer's last message. Helpdock refuses a
  reply outside that time when the agent writes it, and checks again when it
  sends ([reply windows](https://helpdock.oday-bakkour.com/docs/tickets/#reply-windows)).
- **Bot check.** The widget's first message and the web form can ask a visitor
  to pass a check first, chosen once per brand on Channels › Chat widget: the
  built-in proof-of-work check (`pow`, nothing sent to a third party),
  Cloudflare Turnstile or hCaptcha. See [Bot check](https://helpdock.oday-bakkour.com/docs/channels/#bot-check).
- **Outbound connections** to a host a brand configured (an IMAP server, a
  webhook endpoint) go through the SSRF-safe client
  ([security](https://helpdock.oday-bakkour.com/docs/security/#outbound-requests)).

## Bot check

A brand can ask visitors to pass a check before the widget accepts a first
message or the web form accepts a submission. It is off by default, and
the one setting serves both surfaces. An Admin of the brand sets it on
**Channels › Chat widget** under "Where the widget may run": switch on **Check for
bots before the first message**, then pick a **Provider**
([configuration](https://helpdock.oday-bakkour.com/docs/configuration/): `captcha.provider`).

| Provider | What it is | Keys |
|---|---|---|
| **Built-in (no third party)**, `pow` | A signed proof-of-work challenge the visitor's browser solves, using ALTCHA's wire protocol ([ADR 0052](https://github.com/Docker-Hunterpedia/Helpdock/blob/main/docs/decisions/0052-built-in-proof-of-work-captcha.md)). It slows simple floods; it does not stop a determined attacker. | None. **Difficulty**: Low (about half a second on a mid-range phone) or Medium (about two seconds), `captcha.difficulty`. |
| **Cloudflare Turnstile** | Stronger bot detection, at the cost of sending visitor signals to Cloudflare. | Site key and secret key. |
| **hCaptcha** | The same trade, with hCaptcha. | Site key and secret key. |

- The check is per conversation in the widget and per submission on the form.
- A Turnstile or hCaptcha pass must report one of the surface's own hosts, and
  Turnstile is rendered with the `widget-first-message` or `web-form` action
  and the brand id, so a pass earned on another surface or brand fails.
  Details: [widget protocol](https://helpdock.oday-bakkour.com/docs/widget-protocol/#the-built-in-check),
  [web form](https://helpdock.oday-bakkour.com/docs/web-form/#what-a-submission-does).
- A built-in solution is good once, for one brand and one surface, for
  15 minutes.
- There is no check on the staff sign-in link and reset forms, which email only
  an existing account and are limited per address and per IP
  ([authentication](https://helpdock.oday-bakkour.com/docs/authentication/#rate-limits)), nor on the help center's
  "Was this helpful?" card ([help center](https://helpdock.oday-bakkour.com/docs/help-center/)).

## Not in v1

Slack and Discord are on the v1.1 backlog
([REQUIREMENTS §6](https://github.com/Docker-Hunterpedia/Helpdock/blob/main/docs/planning/REQUIREMENTS.md#6-add-on-features-v11-backlog)).

## The widget's live preview

**Channels › Chat widget** shows a live preview beside Appearance from a 1200 px window and keeps it in view while you scroll the form (below that it sits under the card). It draws the widget as a visitor would see it with the changes you have not saved yet:

- the selected **Mode**: Chat (greeting and a composer), Chat and suggested articles (the articles above the composer), Help center (a search, articles and **Contact us**) or Contact form (an email and a message box with **Send**);
- the **Light or dark** choice: Light and Dark fix the preview and hide its theme toggle, and Auto keeps the toggle so you can look at both;
- the visitor's language, with its own English and Arabic toggle, whatever language the admin is in.

The caption says whether the pre-chat form is on only for the two chat modes, which are the ones that show it. Save and Discard on every card of the page stay disabled until the card has a change.
