v0.5.1

How Agenvoy Uses go-bot

Last updated


Agenvoy 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.
Agenvoy featureSourcego-bot callsgo-bot docs
Bot startupchatbot/telegram/new.go, chatbot/discord/new.goNew, Reply, Start, Status, CloseBot Lifecycle, Reply Handler
Telegram command menuchatbot/telegram/new.goSetCommandsTelegram Setup
Token check in TUI /telegram, /discordtui/commandTelegram.go, tui/commandDiscord.goNew, Start, Status, CloseBot Lifecycle
Thinking statuschatbot/telegram/reply.go, chatbot/discord/reply.goSendStatus, FinishStatusStatus Messages
Replieschatbot/telegram/reply.go, chatbot/discord/reply.goSendTelegram Messages, Discord Messages
Confirmations and questionschatbot/telegram/pending.go, chatbot/discord/pending.goSendSelect, SendMultiSelect, SendInputTelegram Interactions, Discord Interactions
Incoming attachmentschatbot/telegram/attachments.go, chatbot/discord/attachments.goSaveSaving Media
Outgoing fileschatbot/telegram/attachments.go, chatbot/discord/attachments.goTelegram SendPhoto, SendVoice, SendFile; Discord SendFilesTelegram API, Discord API
Background task resultschatbot/telegram/push.go, chatbot/discord/push.goNew, SendTelegram Messages
send_to_chatbot toolchatbot/tool/send.goNew, SendTelegram 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.