Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Email AI Agent Template (Node.js)

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.

Quickstart

1. Install dependencies

npm install
cp .env.example .env

2. 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 start

It prints your agent's inbox address. Send an email to that address and the agent replies.

How it works

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 messagemessage.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.

Add more channels

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.

Links

  • 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.

License

MIT

About

Give your AI agent its own email inbox in under 5 minutes — no domain, no DNS, no server. Node.js/TypeScript template: one message handler, instant inbox, powered by the open-source Caspian SDK.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages