Channels

Telegram free

Telegram is the simplest channel to connect. Create a bot with @BotFather, copy the token, and pass it to connect_telegram(). Caspian registers the webhook and routes every message to the same on_message handler you already have. No other setup, no cost.

1. Create a bot with @BotFather

A bot token is the one thing only a human can make. Open Telegram and message @BotFather:

That token is the bot's password, so keep it out of source control.

2. Connect it

Pass the token to connect_telegram(). Caspian registers the webhook with Telegram for you, so inbound messages start flowing immediately.

agent.py
from caspian_sdk import CommClient

client = CommClient()                        # reads COMM_API_KEY / COMM_BASE_URL

tg = client.connect_telegram(bot_token="7123456789:AAE-xxxxxxxx")
print("Telegram bot:", tg["address"])        # @acme_support_bot

@client.on_message
def handle(message):
    # same handler as every other channel
    message.reply(f"You said: {message.text}")

client.listen()                              # blocks, dispatching messages forever
agent.ts
import { CommClient } from "caspian-sdk";

const client = new CommClient();                   // reads COMM_API_KEY / COMM_BASE_URL

const tg = await client.connectTelegram({ botToken: "7123456789:AAE-xxxxxxxx" });
console.log("Telegram bot:", tg.address);          // @acme_support_bot

client.onMessage(async (message) => {
  // same handler as every other channel
  await message.reply(`You said: ${message.text}`);
});

await client.listen();                             // runs forever; pass an AbortSignal to stop

One bot equals one connection. To run more than one Telegram bot, create another token with @BotFather and call connect_telegram() again with it.

3. Send it a message

With your program running, open Telegram, search for the bot's @username, and send it anything. Your handler fires and the reply lands back in the same chat within a few seconds. That is the whole loop: inbound message to your handler to reply.

Telegram supports a typing indicator. Caspian shows one automatically before your handler runs; call message.typing() (Python) / message.typing() (JS) again during long work to keep it alive.

Message fields

Telegram messages arrive with the same shape as every other channel:

FieldDescription
message.textThe text the user sent.
message.senderThe sender's Telegram identity.
message.conversation_id / conversationIdStable id for the chat; key your agent's memory on it.

Reply with message.reply(text); Caspian routes it back to the same Telegram chat automatically.

Troubleshooting

ErrorMeaning
409 ConflictThat bot token is already connected elsewhere. Create a different bot with @BotFather.
422 Unprocessable naming bot_tokenThe token was missing or malformed. Copy it again from BotFather, including the part after the colon.
!

A Telegram bot cannot read normal group messages unless you disable privacy mode. If you want the bot to see every message in a group, send /setprivacy to @BotFather, pick your bot, and choose Disable. In one-to-one chats it always sees everything.

Next steps

WhatsApp →
Twilio or Meta Cloud API.
All channels →
What each one needs to connect.
Behavior guides →
Reply the right way on each platform.