# How Agenvoy Uses go-bot

[Agenvoy](https://agenvoy.com/) is a local AI agent harness in Go that runs 24/7 on your own machine; its Telegram and Discord channels run on go-bot. This page maps each part of those channels to the go-bot calls it makes, based on the Agenvoy source.

## Channel Map

Agenvoy depends on `github.com/pardnchiu/go-bot v0.5.1` and imports `core/telegram` and `core/discord` in 15 files under `internal/runtime/chatbot` and the TUI. Setup on the Agenvoy side is described in [Telegram and Discord Setup](https://agenvoy.com/config-integrations-channels).

| Agenvoy feature | Source | go-bot calls | go-bot docs |
| --- | --- | --- | --- |
| Bot startup | `chatbot/telegram/new.go`, `chatbot/discord/new.go` | `New`, `Reply`, `Start`, `Status`, `Close` | [Bot Lifecycle](/core-concepts), [Reply Handler](/reply-handler) |
| Telegram command menu | `chatbot/telegram/new.go` | `SetCommands` | [Telegram Setup](/telegram) |
| Token check in TUI `/telegram`, `/discord` | `tui/commandTelegram.go`, `tui/commandDiscord.go` | `New`, `Start`, `Status`, `Close` | [Bot Lifecycle](/core-concepts) |
| Thinking status | `chatbot/telegram/reply.go`, `chatbot/discord/reply.go` | `SendStatus`, `FinishStatus` | [Status Messages](/status-messages) |
| Replies | `chatbot/telegram/reply.go`, `chatbot/discord/reply.go` | `Send` | [Telegram Messages](/telegram-messages), [Discord Messages](/discord-messages) |
| Confirmations and questions | `chatbot/telegram/pending.go`, `chatbot/discord/pending.go` | `SendSelect`, `SendMultiSelect`, `SendInput` | [Telegram Interactions](/telegram-interactions), [Discord Interactions](/discord-interactions) |
| Incoming attachments | `chatbot/telegram/attachments.go`, `chatbot/discord/attachments.go` | `Save` | [Saving Media](/media-save) |
| Outgoing files | `chatbot/telegram/attachments.go`, `chatbot/discord/attachments.go` | Telegram `SendPhoto`, `SendVoice`, `SendFile`; Discord `SendFiles` | [Telegram API](/api-reference-telegram), [Discord API](/api-reference-discord) |
| Background task results | `chatbot/telegram/push.go`, `chatbot/discord/push.go` | `New`, `Send` | [Telegram Messages](/telegram-messages) |
| `send_to_chatbot` tool | `chatbot/tool/send.go` | `New`, `Send` | [Telegram Messages](/telegram-messages), [Discord Messages](/discord-messages) |

## Startup and Incoming Messages

When Telegram or Discord is enabled and its token is in the keychain (`TELEGRAM_TOKEN`, `DISCORD_TOKEN`), Agenvoy builds the bot with `New` (Telegram with a 5-minute `WithHTTPClient`), registers one `Reply` handler, and calls `Start`. The handler always returns an empty string: Agenvoy answers through its own task runner instead of the handler's return value, so long agent runs never block the handler. The bot username from `Status` is saved to Agenvoy's config.

On Telegram, Agenvoy registers six commands with `SetCommands`: `/new`, `/model`, `/reasoning`, `/pending`, `/stop`, `/compact`. Photos or documents sent as one album are buffered by their media group and handed to the agent together.

The TUI `/telegram` and `/discord` commands check a pasted token by calling `New`, `Start` with a 10-second timeout, and `Status` for the username, then `Close`.

## Status and Replies

While a task runs, each progress line goes through `SendStatus`, so the chat shows one status message that keeps updating instead of a stream of new messages; on Telegram the line is wrapped in an expandable `<blockquote>` and sent with `WithStatusSendType(TypeHTML)`. `FinishStatus` clears it when the task ends. The final answer is sent with `Send`, as HTML on Telegram (`WithSendType(TypeHTML)`) and Markdown on Discord.

## Confirmations and Questions

When a tool needs approval or the agent asks the user something, Agenvoy sends:

- `SendSelect` for a confirmation or a single choice, also used by `/model`, `/reasoning`, `/pending` and `/stop`
- `SendMultiSelect` for several choices
- `SendInput` for free text, including secret values, and for the 6-digit code printed in the daemon log that authorizes a new chat or channel

The answer comes back to the same `Reply` handler as `Input.CallbackData` (one pick) or `Input.CallbackPicks` (several picks), and Agenvoy matches it to the waiting task.

## Attachments

- Incoming: photos, documents, voice and video are downloaded with `Save`; voice messages are then transcribed by Agenvoy's speech model before the text reaches the agent
- Outgoing on Telegram: images go out with `SendPhoto` in groups of up to 10, `.ogg`/`.oga`/`.opus` files with `SendVoice`, everything else with `SendFile(TypeDocument)`, on a separate client with a 10-minute timeout; a failed upload is reported to the chat
- Outgoing on Discord: files go out with `SendFiles`

## Messages Outside a Conversation

Results of background and scheduled tasks are pushed to the chat that started them: Agenvoy creates a short-lived client with `New` and sends the text with `Send`, split into chunks that fit the platform limit. The `send_to_chatbot` tool does the same for any session (TUI, CLI, cron), but only to a chat or channel that has already been authorized.
