# Why bots run in the host

> How Zaun bots work, and why they run as sandboxed WebAssembly inside the community's own host.

On most chat platforms, a bot is somebody else's service. You invite it, and from then on your community's
messages are sent to wherever it runs. In Zaun, a bot is a **package** that whoever runs the host
installs, and it runs **inside the host**.

## What that gives you

- **No new reader.** The host already holds the community's channels. A bot inside it sees only what
  it was granted, and no third party receives your messages unless you also grant the bot internet
  access *and* it chooses to send them out.
- **No extra network hops.** A bot talks to the community in-process. Only members' own messages
  cross SimpleX, so bots answer as fast as the host can.
- **A real sandbox.** A bot is WebAssembly with no files, no environment and no sockets. Memory and
  CPU time per call are capped, and its internet access is off unless granted, host by host.
- **Transparency.** Every member sees a BOT badge and can open the bot's **card**: its permissions,
  whether it can read messages, which internet hosts it may reach, its storage. Every change is
  announced to everyone.
- **Only the owner decides.** Only whoever controls the host installs, updates, grants or removes
  bots, and the operator's configuration is a ceiling even the owner can't exceed.

## A familiar interaction model

Bots use a familiar interaction model: slash, user and message commands with options and autocomplete; buttons,
selects and Components V2 layouts; modals; ephemeral replies; deferred responses and follow-ups.
If you have written an interactions-based bot before, see
[Porting an existing bot](/docs/guide/bots/porting-a-bot/).

## How it works

1. The host verifies the package's signature and hashes.
2. It creates a **member** for the bot, with a BOT marker, and a **managed role** holding exactly the
   granted permission bits.
3. It starts the component in the sandbox and connects it to the community **in-process**.
4. From then on the bot acts through ordinary commands, checked by the same permission engine as a
   human member's. There is no bot shortcut.

## External bots

A program using [`zaun-client`](/docs/guide/client/installation/) that joined like any member can also
act as a bot: it's slower (every exchange crosses SimpleX) and not sandboxed by the host, but the
protocol is the same. See [External bots](/docs/guide/bots/external-bots/).
