memcode docs
Agents

Telegram

Run your memcode agent from a Telegram bot.

Memcode talks to Telegram directly over the Bot API, so there is nothing to install. You create a bot, drop its token in, and message it.

Step 1: Create a bot

Open @BotFather in Telegram, send /newbot, and follow the prompts. It gives you a token that looks like 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11.

Step 2: Find your user id

Message @userinfobot. It replies with your numeric user id. You will allow-list this so only you can drive the agent.

Step 3: Configure

memcode gateway setup

Choose telegram, paste the bot token, and when prompted for allowed users enter your numeric user id from Step 2. Authorization is on stable ids, not @handles, so a username change cannot grant or lose access. The token is written to your global .env as TELEGRAM_BOT_TOKEN; the allow-list is written to gateway.yaml.

The gateway is default-deny, so a bot with an empty allow-list answers no one. Add * to allow anyone who can reach the bot.

Step 4: Run

memcode gateway

from the project you want the agent to work in, then message your bot. Each message runs as an agent job and the reply comes back in the chat.

Groups

To use the bot in a group, add it to the group and disable BotFather's privacy mode (/setprivacy in BotFather) so it can see group messages. Add the group members' user ids to allow_from.

In a group the bot acts only when addressed: @mention it, use /command@yourbot, or reply to one of its messages. This keeps it from running a job on every message. To have it act on every group message instead, set respond_to_all: true under the channel in gateway.yaml.

On this page