Give your AI agent its own email inbox in under 5 minutes — no domain, no DNS, no server. This template uses Caspian to provision a real inbox instantly, then routes every incoming email into a single respond() function. Drop in your LLM or agent framework and reply.
connectEmail() is instant: call it and you have a working address. That's the whole setup.
1. Install dependencies
npm install
cp .env.example .env2. Add your Caspian API key
Set CASPIAN_API_KEY in .env (and CASPIAN_BASE_URL, which defaults to https://api.trycaspianai.com). Email needs no platform credentials — no Google Workspace, no domain verification.
3. Run it
npm startIt prints your agent's inbox address. Send an email to that address and the agent replies.
import { CommClient } from "caspian-sdk";
const client = new CommClient();
const connection = await client.connectEmail({ displayName: "My Agent" });
console.log(connection.address); // e.g. my-agent@agents.trycaspianai.com
client.onMessage(async (message) => {
await message.reply(respond(message.text));
});
await client.listen();connectEmail() provisions the inbox instantly and returns a connection whose address is your agent's email. Incoming mail arrives at your onMessage handler as a message — message.text is the body, message.reply() answers in the same thread, and message.conversationId is stable per thread. client.listen() runs the loop and dedupes within a run.
Put your agent's logic in respond(). It's provider-neutral — call OpenAI, Anthropic, a local model, or a full agent framework and return a string.
The same handler answers every channel. Add another connect*() call — no new handler code:
await client.connectTelegram({ botToken: "..." }); // token from @BotFather
await client.connectDiscord({ botToken: "..." }); // or installDiscord() for one-click
await client.connectSlack({ slackClientId: "...", slackClientSecret: "...", slackSigningSecret: "..." });Email, Telegram, Discord, and Slack are free and connect instantly. See the Caspian SDK for the full channel list, including WhatsApp, SMS/voice, iMessage, and X.
- Caspian SDK on GitHub — the open-source client powering this template. If it's useful, star it.
- Caspian — one communication identity for your AI agent across every channel.
MIT